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 
37 #include "pqCoreModule.h"
38 #include <QAbstractItemModel>
39 
40 class vtkCollection;
42 class pqProxy;
43 class pqRenderView;
44 class pqServer;
46 class vtkSMLink;
47 class vtkSMProxy;
48 class vtkSMProxyListDomain;
49 class vtkSMProxyLocator;
50 class vtkPVXMLElement;
51 
55 class PQCORE_EXPORT pqLinksModel : public QAbstractTableModel
56 {
57  Q_OBJECT
58  typedef QAbstractTableModel Superclass;
59 
60 public:
62  enum ItemType
63  {
68  Selection
69  };
70 
71 public:
73  pqLinksModel(QObject *parent=0);
74 
76  ~pqLinksModel();
77 
78  // implementation to satisfy api
80  int rowCount(const QModelIndex &parent=QModelIndex()) const;
82  int columnCount(const QModelIndex &parent=QModelIndex()) const;
84  QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
86  QVariant headerData(int section, Qt::Orientation orient,
87  int role=Qt::DisplayRole) const;
88 
89  // subclass specific implementation
91  ItemType getLinkType(const QModelIndex& idx) const;
93  vtkSMLink* getLink(const QModelIndex& idx) const;
95  QModelIndex findLink(vtkSMLink* link) const;
96 
99  int FindLinksFromProxy(vtkSMProxy* inputProxy, int direction,
100  vtkCollection* links) const;
101 
103  vtkSMProxy* getProxy1(const QModelIndex& idx) const;
105  vtkSMProxy* getProxy2(const QModelIndex& idx) const;
106 
108  QString getProperty1(const QModelIndex& idx) const;
110  QString getProperty2(const QModelIndex& idx) const;
111 
113  QString getLinkName(const QModelIndex& idx) const;
115  vtkSMLink* getLink(const QString& name) const;
116 
118  void addProxyLink(const QString& name,
119  vtkSMProxy* proxy1, vtkSMProxy* proxy2);
120 
122  void addCameraLink(const QString& name,
123  vtkSMProxy* proxy1,
124  vtkSMProxy* proxy2,
125  bool interactiveViewLink = false);
126 
128  bool hasInteractiveViewLink(const QString& name);
129 
131  pqInteractiveViewLink* getInteractiveViewLink(const QString& name);
132 
134  void addPropertyLink(const QString& name,
135  vtkSMProxy* proxy1, const QString& prop1,
136  vtkSMProxy* proxy2, const QString& prop2);
137 
139  void addSelectionLink(const QString& name,
140  vtkSMProxy* proxy1, vtkSMProxy* proxy2);
141 
143  void removeLink(const QModelIndex& idx);
145  void removeLink(const QString& name);
146 
150  static pqProxy* representativeProxy(vtkSMProxy* proxy);
151 
154  static vtkSMProxyListDomain* proxyListDomain(vtkSMProxy* proxy);
155 
156 signals:
158  void linkAdded(int linkType);
159 
161  void linkRemoved(const QString& name);
162 
163 protected slots:
164  void onSessionCreated(pqServer*);
165  void onSessionRemoved(pqServer*);
166 
169  void onStateLoaded(vtkPVXMLElement* root, vtkSMProxyLocator* locator);
170 
173  void onStateSaved(vtkPVXMLElement* root);
174 
176  void createInteractiveViewLink(const QString& name, vtkSMProxy* displayView, vtkSMProxy* linkedView,
177  double xPos = 0.375, double yPos = 0.375, double xSize = 0.25, double ySize = 0.25);
178 
180  void emitLinkRemoved(const QString& name);
181 
182 private:
183  ItemType getLinkType(vtkSMLink* link) const;
184  vtkSMProxy* getProxyFromIndex(const QModelIndex& idx, int dir) const;
185  QString getPropertyFromIndex(const QModelIndex& idx, int dir) const;
186 
187  class pqInternal;
188  pqInternal* Internal;
189 };
190 
191 // internal class here for moc'ing reasons
192 class pqLinksModelObject : public QObject
193 {
194  Q_OBJECT
195 public:
196  pqLinksModelObject(QString name, pqLinksModel* p, pqServer*);
198 
199  QString name() const;
200  vtkSMLink* link() const;
201 
202 signals:
203  void linkRemoved();
204 
205 private slots:
206  void proxyModified(pqServerManagerModelItem*);
207  void refresh();
208  void remove();
209 
210 private:
211  class pqInternal;
212  pqInternal* Internal;
213 
214  void linkUndoStacks();
215  void unlinkUndoStacks(pqRenderView*);
216 };
217 
218 #endif
219 
A Qt based model to represent the vtkSMLinks in the server manager.
Definition: pqLinksModel.h:55
pqServerManagerModelItem is a element maintained by pqServerManagerModel.
ItemType
type of link (camera, proxy or property)
Definition: pqLinksModel.h:62
This class represents any registered Server Manager proxy.
Definition: pqProxy.h:52
pqServer (should be renamed to pqSession) is a pqServerManagerModelItem subclass that represents a vt...
Definition: pqServer.h:62