pqPropertyWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqPropertyWidget.h
5 
6  Copyright (c) 2005-2012 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 _pqPropertyWidget_h
33 #define _pqPropertyWidget_h
34 
35 #include "pqComponentsModule.h"
36 #include "vtkSetGet.h" // for VTK_LEGACY_REMOVE.
37 
38 #include "pqPropertyLinks.h"
39 #include <QPointer>
40 #include <QScopedPointer>
41 #include <QWidget>
42 
44 class pqTimer;
45 class pqView;
46 class vtkPVXMLElement;
47 class vtkSMDomain;
48 class vtkSMProperty;
49 class vtkSMProxy;
54 class PQCOMPONENTS_EXPORT pqPropertyWidget : public QWidget
55 {
56  Q_OBJECT
57  typedef QWidget Superclass;
58 
59 public:
60  pqPropertyWidget(vtkSMProxy* proxy, QWidget* parent = 0);
61  ~pqPropertyWidget() override;
62 
63  virtual void apply();
64  virtual void reset();
65 
73  virtual void select() { this->Selected = true; }
74  virtual void deselect() { this->Selected = false; }
75  bool isSelected() const { return this->Selected; }
76 
77  // This method is called on pqPropertyWidget instances that pqProxyWidget
78  // deems that should be shown in current configuration. Subclasses can
79  // override this method to change the appearance of the widget based on
80  // whether advanced properties are currently being shown by the pqProxyWidget
81  // or not.
82  virtual void updateWidget(bool showing_advanced_properties)
83  {
84  Q_UNUSED(showing_advanced_properties);
85  }
86 
87  pqView* view() const;
88  vtkSMProxy* proxy() const;
89  vtkSMProperty* property() const;
90  using Superclass::property; // Don't hide superclass method
91 
96  virtual char* panelVisibility() const;
97  virtual void setPanelVisibility(const char* vis);
98 
109  virtual bool isSingleRowItem() const;
110 
111  bool showLabel() const;
112 
126  template <class T>
127  static QString getXMLName(T* object)
128  {
129  return QString(object->GetXMLName());
130  }
131 
135  const QList<QPointer<pqPropertyWidgetDecorator> >& decorators() const { return this->Decorators; }
136 
141  using Superclass::setProperty;
142 
146  static QString getTooltip(vtkSMProperty* property);
147 
152  static int hintsWidgetHeightNumberOfRows(vtkPVXMLElement* hints, int defaultValue = 10);
153 
154 Q_SIGNALS:
158  void viewChanged(pqView* view);
159 
164  void changeAvailable();
165 
170  void changeFinished();
171 
176  void restartRequired();
177 
178 public Q_SLOTS:
182  virtual void setView(pqView*);
183 
184 protected:
185  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
186  vtkSMProperty* smproperty, int smindex = -1);
187  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
188  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
189  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
190  vtkSMProperty* smproperty, int smindex = -1);
191  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
192  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
193  void setShowLabel(bool show);
194 
204  {
205  this->ChangeAvailableAsChangeFinished = status;
206  }
207 
213  void addDecorator(pqPropertyWidgetDecorator*);
214 
218  void removeDecorator(pqPropertyWidgetDecorator*);
219 
223  pqPropertyLinks& links() { return this->Links; }
224 
225 public:
226  void setProperty(vtkSMProperty* property);
227 
228 private:
231  friend class pqProxyWidget;
232 
233 private Q_SLOTS:
237  void onChangeAvailable();
238 
239 private:
240  vtkSMProxy* Proxy;
241  vtkSMProperty* Property;
242  QPointer<pqView> View;
243  QList<QPointer<pqPropertyWidgetDecorator> > Decorators;
244 
245  pqPropertyLinks Links;
246  bool ShowLabel;
247  bool ChangeAvailableAsChangeFinished;
248  bool Selected;
249 
250  const QScopedPointer<pqTimer> Timer;
251 
256  void modified();
257  void editingFinished();
258 };
259 
260 #if !defined(VTK_LEGACY_REMOVE)
261 #include "pqDebug.h"
262 #define PV_DEBUG_PANELS() pqDebug("PV_DEBUG_PANELS")
263 #endif
264 
265 #endif // _pqPropertyWidget_h
pqPropertyWidget represents a widget created for each property of a proxy on the pqPropertiesPanel (f...
virtual void updateWidget(bool showing_advanced_properties)
pqPropertyWidgetDecorator subclass that can combine multiple decorators using boolean operations...
const QList< QPointer< pqPropertyWidgetDecorator > > & decorators() const
Provides access to the decorators for this widget.
void setChangeAvailableAsChangeFinished(bool status)
For most pqPropertyWidget subclasses a changeAvailable() signal, corresponds to a changeFinished() si...
#define PQCOMPONENTS_EXPORT
virtual void deselect()
superclass for all SM properties
virtual void select()
These methods are called by pqPropertiesPanel when the panel for proxy becomes active/deactive.
bool isSelected() const
This is a PQ abstraction of a generic view module.
Definition: pqView.h:54
pqPropertyLinks & links()
Provides access to the pqPropertyLinks instance.
represents the possible values a property can have
Definition: vtkSMDomain.h:49
static QString getXMLName(T *object)
Description: This static utility method returns the XML name for an object as a QString.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
pqProxyWidget represents a panel for a vtkSMProxy.
Definition: pqProxyWidget.h:57
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
pqPropertyWidgetDecorator provides a mechanism to decorate pqPropertyWidget instances to add logic to...