ParaView
pqPropertyLinks.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
5 
6  Copyright (c) 2005,2006 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 #ifndef pqPropertyLinks_h
33 #define pqPropertyLinks_h
34 
35 #include <QObject>
36 #include <QtDebug>
37 
38 #include "pqCoreModule.h"
39 #include "pqPropertyLinksConnection.h" // needed for pqPropertyLinksConnection.
40 
41 class vtkSMProperty;
42 class vtkSMProxy;
43 
66 class PQCORE_EXPORT pqPropertyLinks : public QObject
67 {
68  Q_OBJECT
69  typedef QObject Superclass;
70 
71 public:
72  pqPropertyLinks(QObject* parent = 0);
73  virtual ~pqPropertyLinks();
74 
92  bool addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
93  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1)
94  {
95  return this->addPropertyLink<pqPropertyLinksConnection>(
96  qobject, qproperty, qsignal, smproxy, smproperty, smindex);
97  }
98 
99  template <class ConnectionType>
100  bool addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
101  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1,
102  ConnectionType* notused = NULL);
103 
107  bool removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
108  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
109 
110  bool autoUpdateVTKObjects() const { return this->AutoUpdateVTKObjects; }
111  bool useUncheckedProperties() const { return this->UseUncheckedProperties; }
112 
113 public slots:
117  void removeAllPropertyLinks() { this->clear(); }
118  void clear();
119 
125  void accept();
126 
131  void reset();
132 
138  void setUseUncheckedProperties(bool val);
139 
143  void setAutoUpdateVTKObjects(bool val) { this->AutoUpdateVTKObjects = val; }
144 
145 signals:
146  void qtWidgetChanged();
147  void smPropertyChanged();
148 
149 private slots:
154  void onQtPropertyModified();
155  void onSMPropertyModified();
156 
157 private:
158  bool addNewConnection(pqPropertyLinksConnection*);
159 
160 private:
161  Q_DISABLE_COPY(pqPropertyLinks)
162 
163  class pqInternals;
164  pqInternals* Internals;
165  bool UseUncheckedProperties;
166  bool AutoUpdateVTKObjects;
167 };
168 
169 //-----------------------------------------------------------------------------
170 template <class ConnectionType>
171 bool pqPropertyLinks::addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
172  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex, ConnectionType*)
173 {
174  if (!qobject || !qproperty || !qsignal || !smproxy || !smproperty)
175  {
176  qCritical() << "Invalid parameters to pqPropertyLinks::addPropertyLink";
177  qDebug() << "(" << qobject << ", " << qproperty << ", " << qsignal << ") <==> ("
178  << (smproxy ? smproxy->GetXMLName() : "(none)") << ","
179  << (smproperty ? smproperty->GetXMLLabel() : "(none)") << smindex << ")";
180  return false;
181  }
182  pqPropertyLinksConnection* connection = new ConnectionType(qobject, qproperty, qsignal, smproxy,
183  smproperty, smindex, this->useUncheckedProperties(), this);
184  return this->addNewConnection(connection);
185 }
186 
187 #endif
superclass for all SM properties
virtual char * GetXMLLabel()
The label assigned by the xml parser.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
pqPropertyLinksConnection is used by pqPropertyLinks to keep a QObject and vtkSMProperty linked toget...
virtual char * GetXMLName()
Assigned by the XML parser.