ParaView
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 
37 #include "pqDebug.h"
38 #include "pqPropertyLinks.h"
39 #include <QPointer>
40 #include <QScopedPointer>
41 #include <QWidget>
42 
44 class pqTimer;
45 class pqView;
46 class vtkSMDomain;
47 class vtkSMProperty;
48 class vtkSMProxy;
49 
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  virtual ~pqPropertyWidget();
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 
136 signals:
140  void viewChanged(pqView* view);
141 
146  void changeAvailable();
147 
152  void changeFinished();
153 
158  void restartRequired();
159 
160 public slots:
164  virtual void setView(pqView*);
165 
166 protected:
167  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
168  vtkSMProperty* smproperty, int smindex = -1);
169  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
170  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
171  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
172  vtkSMProperty* smproperty, int smindex = -1);
173  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
174  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
175  void setShowLabel(bool show);
176 
186  {
187  this->ChangeAvailableAsChangeFinished = status;
188  }
189 
195  void addDecorator(pqPropertyWidgetDecorator*);
196 
200  pqPropertyLinks& links() { return this->Links; }
201 
202 public:
203  void setProperty(vtkSMProperty* property);
204 
205 private:
207  friend class pqProxyWidget;
208 
209 private slots:
213  void onChangeAvailable();
214 
215 private:
216  vtkSMProxy* Proxy;
217  vtkSMProperty* Property;
218  QPointer<pqView> View;
219  QList<QPointer<pqPropertyWidgetDecorator> > Decorators;
220 
221  pqPropertyLinks Links;
222  bool ShowLabel;
223  bool ChangeAvailableAsChangeFinished;
224  bool Selected;
225 
226  const QScopedPointer<pqTimer> Timer;
227 
232  void modified();
233  void editingFinished();
234 };
235 
236 #define PV_DEBUG_PANELS() pqDebug("PV_DEBUG_PANELS")
237 
238 #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)
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:56
pqPropertyLinks & links()
Provides access to the pqPropertyLinks instance.
represents the possible values a property can have
Definition: vtkSMDomain.h:48
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
pqPropertyWidgetDecorator provides a mechanism to decorate pqPropertyWidget instances to add logic to...