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 
64 class PQCORE_EXPORT pqPropertyLinks : public QObject
65 {
66  Q_OBJECT
67  typedef QObject Superclass;
68 public:
69  pqPropertyLinks(QObject* parent=0);
70  virtual ~pqPropertyLinks();
71 
88  QObject* qobject, const char* qproperty, const char* qsignal,
89  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex=-1)
90  {
91  return this->addPropertyLink<pqPropertyLinksConnection>(
92  qobject, qproperty, qsignal, smproxy, smproperty, smindex);
93  }
94 
95  template <class ConnectionType>
96  bool addPropertyLink(
97  QObject* qobject, const char* qproperty, const char* qsignal,
98  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex=-1,
99  ConnectionType* notused=NULL);
100 
102  bool removePropertyLink(
103  QObject* qobject, const char* qproperty, const char* qsignal,
104  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex=-1);
105 
106  bool autoUpdateVTKObjects() const
107  { return this->AutoUpdateVTKObjects; }
109  { return this->UseUncheckedProperties; }
110 
111 public slots:
113  void removeAllPropertyLinks() { this->clear(); }
114  void clear();
115 
119  void accept();
120 
123  void reset();
124 
128  void setUseUncheckedProperties(bool val);
129 
131  void setAutoUpdateVTKObjects(bool val)
132  { this->AutoUpdateVTKObjects = val; }
133 
134 signals:
135  void qtWidgetChanged();
136  void smPropertyChanged();
137 
138 
139 private slots:
142  void onQtPropertyModified();
143  void onSMPropertyModified();
144 
145 private:
146  bool addNewConnection(pqPropertyLinksConnection*);
147 
148 private:
149  Q_DISABLE_COPY(pqPropertyLinks)
150 
151  class pqInternals;
152  pqInternals* Internals;
153  bool UseUncheckedProperties;
154  bool AutoUpdateVTKObjects;
155 };
156 
157 //-----------------------------------------------------------------------------
158 template <class ConnectionType>
160  QObject* qobject, const char* qproperty, const char* qsignal,
161  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex,
162  ConnectionType*)
163 {
164  if (!qobject || !qproperty || !qsignal || !smproxy || !smproperty)
165  {
166  qCritical() << "Invalid parameters to pqPropertyLinks::addPropertyLink";
167  qDebug() << "(" << qobject << ", " << qproperty << ", " << qsignal
168  << ") <==> ("
169  << (smproxy? smproxy->GetXMLName() : "(none)")
170  << "," << (smproperty? smproperty->GetXMLLabel() : "(none)")
171  << smindex << ")";
172  return false;
173  }
174  pqPropertyLinksConnection* connection = new ConnectionType(
175  qobject, qproperty, qsignal, smproxy, smproperty, smindex,
176  this->useUncheckedProperties(), this);
177  return this->addNewConnection(connection);
178 }
179 
180 
181 #endif
pqPropertyLinksConnection is used by pqPropertyLinks to keep a QObject and vtkSMProperty linked toget...