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 
99  bool showLabel() const;
100 
114  template <class T>
115  static QString getXMLName(T* object)
116  {
117  return QString(object->GetXMLName());
118  }
119 
123  const QList<QPointer<pqPropertyWidgetDecorator> >& decorators() const { return this->Decorators; }
124 
129  using Superclass::setProperty;
130 
134  static QString getTooltip(vtkSMProperty* property);
135 
140  static int hintsWidgetHeightNumberOfRows(vtkPVXMLElement* hints, int defaultValue = 10);
141 
142 signals:
146  void viewChanged(pqView* view);
147 
152  void changeAvailable();
153 
158  void changeFinished();
159 
164  void restartRequired();
165 
166 public slots:
170  virtual void setView(pqView*);
171 
172 protected:
173  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
174  vtkSMProperty* smproperty, int smindex = -1);
175  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
176  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
177  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
178  vtkSMProperty* smproperty, int smindex = -1);
179  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
180  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
181  void setShowLabel(bool show);
182 
192  {
193  this->ChangeAvailableAsChangeFinished = status;
194  }
195 
201  void addDecorator(pqPropertyWidgetDecorator*);
202 
206  void removeDecorator(pqPropertyWidgetDecorator*);
207 
211  pqPropertyLinks& links() { return this->Links; }
212 
213 public:
214  void setProperty(vtkSMProperty* property);
215 
216 private:
219  friend class pqProxyWidget;
220 
221 private slots:
225  void onChangeAvailable();
226 
227 private:
228  vtkSMProxy* Proxy;
229  vtkSMProperty* Property;
230  QPointer<pqView> View;
231  QList<QPointer<pqPropertyWidgetDecorator> > Decorators;
232 
233  pqPropertyLinks Links;
234  bool ShowLabel;
235  bool ChangeAvailableAsChangeFinished;
236  bool Selected;
237 
238  const QScopedPointer<pqTimer> Timer;
239 
244  void modified();
245  void editingFinished();
246 };
247 
248 #if !defined(VTK_LEGACY_REMOVE)
249 #include "pqDebug.h"
250 #define PV_DEBUG_PANELS() pqDebug("PV_DEBUG_PANELS")
251 #endif
252 
253 #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...
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...