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() override;
84 
85  // implementation to satisfy api
89  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
93  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
97  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
101  QVariant headerData(
102  int section, Qt::Orientation orient, int role = Qt::DisplayRole) const override;
103 
104  // subclass specific implementation
108  ItemType getLinkType(const QModelIndex& idx) const;
112  vtkSMLink* getLink(const QModelIndex& idx) const;
116  QModelIndex findLink(vtkSMLink* link) const;
117 
122  int FindLinksFromProxy(vtkSMProxy* inputProxy, int direction, vtkCollection* links) const;
123 
127  vtkSMProxy* getProxy1(const QModelIndex& idx) const;
131  vtkSMProxy* getProxy2(const QModelIndex& idx) const;
132 
136  QString getProperty1(const QModelIndex& idx) const;
140  QString getProperty2(const QModelIndex& idx) const;
141 
145  QString getLinkName(const QModelIndex& idx) const;
149  vtkSMLink* getLink(const QString& name) const;
150 
154  void addProxyLink(const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2);
155 
159  void addCameraLink(
160  const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2, bool interactiveViewLink = false);
161 
165  bool hasInteractiveViewLink(const QString& name);
166 
170  pqInteractiveViewLink* getInteractiveViewLink(const QString& name);
171 
175  void addPropertyLink(const QString& name, vtkSMProxy* proxy1, const QString& prop1,
176  vtkSMProxy* proxy2, const QString& prop2);
177 
181  void addSelectionLink(
182  const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2, bool convertToIndices = true);
183 
187  void removeLink(const QModelIndex& idx);
191  void removeLink(const QString& name);
192 
198  static pqProxy* representativeProxy(vtkSMProxy* proxy);
199 
204  static vtkSMProxyListDomain* proxyListDomain(vtkSMProxy* proxy);
205 
206 Q_SIGNALS:
210  void linkAdded(int linkType);
211 
215  void linkRemoved(const QString& name);
216 
217 protected Q_SLOTS:
218  void onSessionCreated(pqServer*);
219  void onSessionRemoved(pqServer*);
220 
225  void onStateLoaded(vtkPVXMLElement* root, vtkSMProxyLocator* locator);
226 
231  void onStateSaved(vtkPVXMLElement* root);
232 
236  void createInteractiveViewLink(const QString& name, vtkSMProxy* displayView,
237  vtkSMProxy* linkedView, double xPos = 0.375, double yPos = 0.375, double xSize = 0.25,
238  double ySize = 0.25);
239 
243  void emitLinkRemoved(const QString& name);
244 
245 private:
246  ItemType getLinkType(vtkSMLink* link) const;
247  vtkSMProxy* getProxyFromIndex(const QModelIndex& idx, int dir) const;
248  QString getPropertyFromIndex(const QModelIndex& idx, int dir) const;
249 
250  class pqInternal;
251  pqInternal* Internal;
252 };
253 
254 // internal class here for moc'ing reasons
255 class pqLinksModelObject : public QObject
256 {
257  Q_OBJECT
258 public:
260  ~pqLinksModelObject() override;
261 
262  QString name() const;
263  vtkSMLink* link() const;
264 
265 Q_SIGNALS:
266  void linkRemoved();
267 
268 private Q_SLOTS:
269  void proxyModified(pqServerManagerModelItem*);
270  void refresh();
271  void remove();
272 
273 private:
274  class pqInternal;
275  pqInternal* Internal;
276 
277  void linkUndoStacks();
278  void unlinkUndoStacks(pqRenderView*);
279 };
280 
281 #endif
data
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
name
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
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