pqLinksModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef pqLinksModel_h
6 #define pqLinksModel_h
7 
8 #include "pqCoreModule.h"
9 #include <QAbstractItemModel>
10 
11 class vtkCollection;
14 class pqProxy;
15 class pqRenderView;
16 class pqServer;
18 class vtkSMLink;
19 class vtkSMProxy;
21 class vtkSMProxyLocator;
22 class vtkPVXMLElement;
23 
28 class PQCORE_EXPORT pqLinksModel : public QAbstractTableModel
29 {
30  Q_OBJECT
31  typedef QAbstractTableModel Superclass;
32 
33 public:
37  enum ItemType
38  {
44  Selection
45  };
46 
50  pqLinksModel(QObject* parent = nullptr);
51 
55  ~pqLinksModel() override;
56 
57  // implementation to satisfy api
61  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
65  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
69  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
73  QVariant headerData(
74  int section, Qt::Orientation orient, int role = Qt::DisplayRole) const override;
75 
76  // subclass specific implementation
80  ItemType getLinkType(const QModelIndex& idx) const;
84  vtkSMLink* getLink(const QModelIndex& idx) const;
88  QModelIndex findLink(vtkSMLink* link) const;
89 
94  int FindLinksFromProxy(vtkSMProxy* inputProxy, int direction, vtkCollection* links) const;
95 
99  vtkSMProxy* getProxy1(const QModelIndex& idx) const;
103  vtkSMProxy* getProxy2(const QModelIndex& idx) const;
104 
108  QString getProperty1(const QModelIndex& idx) const;
112  QString getProperty2(const QModelIndex& idx) const;
113 
117  QString getLinkName(const QModelIndex& idx) const;
121  vtkSMLink* getLink(const QString& name) const;
122 
126  void addProxyLink(const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2);
127 
131  void addCameraLink(
132  const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2, bool interactiveViewLink = false);
133 
137  void addCameraWidgetLink(const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2);
138 
142  bool hasInteractiveViewLink(const QString& name);
143 
147  pqInteractiveViewLink* getInteractiveViewLink(const QString& name);
148 
152  bool hasCameraWidgetViewLink(const QString& name);
153 
157  pqCameraWidgetViewLink* getCameraWidgetViewLink(const QString& name);
158 
162  void addPropertyLink(const QString& name, vtkSMProxy* proxy1, const QString& prop1,
163  vtkSMProxy* proxy2, const QString& prop2);
164 
168  void addSelectionLink(
169  const QString& name, vtkSMProxy* proxy1, vtkSMProxy* proxy2, bool convertToIndices = true);
170 
174  void removeLink(const QModelIndex& idx);
178  void removeLink(const QString& name);
179 
185  static pqProxy* representativeProxy(vtkSMProxy* proxy);
186 
191  static vtkSMProxyListDomain* proxyListDomain(vtkSMProxy* proxy);
192 
193 Q_SIGNALS:
197  void linkAdded(int linkType);
198 
202  void linkRemoved(const QString& name);
203 
204 protected Q_SLOTS:
205  void onSessionCreated(pqServer*);
206  void onSessionRemoved(pqServer*);
207 
212  void onStateLoaded(vtkPVXMLElement* root, vtkSMProxyLocator* locator);
213 
218  void onStateSaved(vtkPVXMLElement* root);
219 
223  void createInteractiveViewLink(const QString& name, vtkSMProxy* displayView,
224  vtkSMProxy* linkedView, double xPos = 0.375, double yPos = 0.375, double xSize = 0.25,
225  double ySize = 0.25);
226 
230  void createCameraWidgetViewLink(
231  const QString& name, vtkSMProxy* displayView, vtkSMProxy* linkedView);
232 
236  void emitLinkRemoved(const QString& name);
237 
238 private:
239  ItemType getLinkType(vtkSMLink* link) const;
240  vtkSMProxy* getProxyFromIndex(const QModelIndex& idx, int dir) const;
241  QString getPropertyFromIndex(const QModelIndex& idx, int dir) const;
242 
243  class pqInternal;
244  pqInternal* Internal;
245 };
246 
247 // internal class here for moc'ing reasons
248 class pqLinksModelObject : public QObject
249 {
250  Q_OBJECT
251 public:
253  ~pqLinksModelObject() override;
254 
255  QString name() const;
256  vtkSMLink* link() const;
257 
258 Q_SIGNALS:
259  void linkRemoved();
260 
261 private Q_SLOTS:
262  void proxyModified(pqServerManagerModelItem*);
263  void refresh();
264  void remove();
265 
266 private: // NOLINT(readability-redundant-access-specifiers)
267  class pqInternal;
268  pqInternal* Internal;
269 
270  void linkUndoStacks();
271  void unlinkUndoStacks(pqRenderView*);
272 };
273 
274 #endif
data
A Qt based model to represent the vtkSMLinks in the server manager.
Definition: pqLinksModel.h:28
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
ItemType
type of link (camera, proxy or property)
Definition: pqLinksModel.h:37
name
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
This class represents any registered Server Manager proxy.
Definition: pqProxy.h:28
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
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:35