ParaView
pqLinksModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqLinksModel.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 
33 #ifndef _pqLinksModel_h
34 #define _pqLinksModel_h
35 
36 #include "pqCoreModule.h"
37 #include <QAbstractItemModel>
38 
39 class vtkCollection;
41 class pqProxy;
42 class pqRenderView;
43 class pqServer;
45 class vtkSMLink;
46 class vtkSMProxy;
48 class vtkSMProxyLocator;
49 class vtkPVXMLElement;
50 
56 class PQCORE_EXPORT pqLinksModel : public QAbstractTableModel
57 {
58  Q_OBJECT
59  typedef QAbstractTableModel Superclass;
60 
61 public:
65  enum ItemType
66  {
71  Selection
72  };
73 
74 public:
78  pqLinksModel(QObject* parent = 0);
79 
83  ~pqLinksModel();
84 
85  // implementation to satisfy api
89  int rowCount(const QModelIndex& parent = QModelIndex()) const;
93  int columnCount(const QModelIndex& parent = QModelIndex()) const;
97  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
101  QVariant headerData(int section, Qt::Orientation orient, int role = Qt::DisplayRole) const;
102 
103  // subclass specific implementation
107  ItemType getLinkType(const QModelIndex& idx) const;
111  vtkSMLink* getLink(const QModelIndex& idx) const;
115  QModelIndex findLink(vtkSMLink* link) const;
116 
121  int FindLinksFromProxy(vtkSMProxy* inputProxy, int direction, vtkCollection* links) const;
122 
126  vtkSMProxy* getProxy1(const QModelIndex& idx) const;
130  vtkSMProxy* getProxy2(const QModelIndex& idx) const;
131 
135  QString getProperty1(const QModelIndex& idx) const;
139  QString getProperty2(const QModelIndex& idx) const;
140 
144  QString getLinkName(const QModelIndex& idx) const;
148  vtkSMLink* getLink(const QString& name) const;
149 
153  void addProxyLink(const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2);
154 
158  void addCameraLink(
159  const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2, bool interactiveViewLink = false);
160 
164  bool hasInteractiveViewLink(const QString& name);
165 
169  pqInteractiveViewLink* getInteractiveViewLink(const QString& name);
170 
174  void addPropertyLink(const QString& name, vtkSMProxy* proxy1, const QString& prop1,
175  vtkSMProxy* proxy2, const QString& prop2);
176 
180  void addSelectionLink(const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2);
181 
185  void removeLink(const QModelIndex& idx);
189  void removeLink(const QString& name);
190 
196  static pqProxy* representativeProxy(vtkSMProxy* proxy);
197 
202  static vtkSMProxyListDomain* proxyListDomain(vtkSMProxy* proxy);
203 
204 signals:
208  void linkAdded(int linkType);
209 
213  void linkRemoved(const QString& name);
214 
215 protected slots:
216  void onSessionCreated(pqServer*);
217  void onSessionRemoved(pqServer*);
218 
223  void onStateLoaded(vtkPVXMLElement* root, vtkSMProxyLocator* locator);
224 
229  void onStateSaved(vtkPVXMLElement* root);
230 
234  void createInteractiveViewLink(const QString& name, vtkSMProxy* displayView,
235  vtkSMProxy* linkedView, double xPos = 0.375, double yPos = 0.375, double xSize = 0.25,
236  double ySize = 0.25);
237 
241  void emitLinkRemoved(const QString& name);
242 
243 private:
244  ItemType getLinkType(vtkSMLink* link) const;
245  vtkSMProxy* getProxyFromIndex(const QModelIndex& idx, int dir) const;
246  QString getPropertyFromIndex(const QModelIndex& idx, int dir) const;
247 
248  class pqInternal;
249  pqInternal* Internal;
250 };
251 
252 // internal class here for moc'ing reasons
253 class pqLinksModelObject : public QObject
254 {
255  Q_OBJECT
256 public:
257  pqLinksModelObject(QString name, pqLinksModel* p, pqServer*);
259 
260  QString name() const;
261  vtkSMLink* link() const;
262 
263 signals:
264  void linkRemoved();
265 
266 private slots:
267  void proxyModified(pqServerManagerModelItem*);
268  void refresh();
269  void remove();
270 
271 private:
272  class pqInternal;
273  pqInternal* Internal;
274 
275  void linkUndoStacks();
276  void unlinkUndoStacks(pqRenderView*);
277 };
278 
279 #endif
A Qt based model to represent the vtkSMLinks in the server manager.
Definition: pqLinksModel.h:56
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
ItemType
type of link (camera, proxy or property)
Definition: pqLinksModel.h:65
This class represents any registered Server Manager proxy.
Definition: pqProxy.h:56
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
is used to locate proxies referred to in state xmls while loading state files.
union of proxies.
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:64