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 
52 class PQCOMPONENTS_EXPORT pqPropertyWidget : public QWidget
53 {
54  Q_OBJECT
55  typedef QWidget Superclass;
56 public:
57  pqPropertyWidget(vtkSMProxy *proxy, QWidget *parent = 0);
58  virtual ~pqPropertyWidget();
59 
60  virtual void apply();
61  virtual void reset();
62 
68  virtual void select() {this->Selected = true;}
69  virtual void deselect() {this->Selected = false;}
70  bool isSelected() const { return this->Selected; }
71 
72  // This method is called on pqPropertyWidget instances that pqProxyWidget
73  // deems that should be shown in current configuration. Subclasses can
74  // override this method to change the appearance of the widget based on
75  // whether advanced properties are currently being shown by the pqProxyWidget
76  // or not.
77  virtual void updateWidget(bool showing_advanced_properties)
78  {Q_UNUSED(showing_advanced_properties);}
79 
80  pqView* view() const;
81  vtkSMProxy* proxy() const;
82  vtkSMProperty* property() const;
83  using Superclass::property; // Don't hide superclass method
84 
87  virtual char* panelVisibility() const;
88  virtual void setPanelVisibility(const char* vis);
89 
90  bool showLabel() const;
91 
103  template<class T>
104  static QString getXMLName(T *object)
105  {
106  return QString(object->GetXMLName());
107  }
108 
110  const QList<QPointer<pqPropertyWidgetDecorator> >& decorators() const
111  {
112  return this->Decorators;
113  }
114 
117  using Superclass::setProperty;
118 
120  static QString getTooltip(vtkSMProperty* property);
121 
122 signals:
124  void viewChanged(pqView *view);
125 
128  void changeAvailable();
129 
132  void changeFinished();
133 
136  void restartRequired();
137 
138 public slots:
140  virtual void setView(pqView*);
141 
142 protected:
143  void addPropertyLink(QObject *qobject,
144  const char *qproperty,
145  const char *qsignal,
146  vtkSMProperty *smproperty,
147  int smindex = -1);
148  void addPropertyLink(QObject *qobject,
149  const char *qproperty,
150  const char *qsignal,
151  vtkSMProxy *smproxy,
152  vtkSMProperty *smproperty,
153  int smindex = -1);
154  void removePropertyLink(QObject *qobject,
155  const char *qproperty,
156  const char *qsignal,
157  vtkSMProperty *smproperty,
158  int smindex = -1);
159  void removePropertyLink(QObject *qobject,
160  const char *qproperty,
161  const char *qsignal,
162  vtkSMProxy *smproxy,
163  vtkSMProperty *smproperty,
164  int smindex = -1);
165  void setShowLabel(bool show);
166 
174  { this->ChangeAvailableAsChangeFinished = status; }
175 
179  void addDecorator(pqPropertyWidgetDecorator*);
180 
183  { return this->Links; }
184 
185 public:
186  void setProperty(vtkSMProperty *property);
187 
188 private:
189 
191  friend class pqProxyWidget;
192 
193 private slots:
195  void onChangeAvailable();
196 
197 private:
198  vtkSMProxy *Proxy;
199  vtkSMProperty *Property;
200  QPointer<pqView> View;
201  QList<QPointer<pqPropertyWidgetDecorator> > Decorators;
202 
203  pqPropertyLinks Links;
204  bool ShowLabel;
205  bool ChangeAvailableAsChangeFinished;
206  bool Selected;
207 
208  const QScopedPointer<pqTimer> Timer;
209 
212  void modified();
213  void editingFinished();
214 };
215 
216 #define PV_DEBUG_PANELS() pqDebug("PV_DEBUG_PANELS")
217 
218 #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()
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:55
pqPropertyLinks & links()
Provides access to the pqPropertyLinks instance.
static QString getXMLName(T *object)
Description: This static utility method returns the XML name for an object as a QString.
pqProxyWidget represents a panel for a vtkSMProxy.
Definition: pqProxyWidget.h:55
pqPropertyWidgetDecorator provides a mechanism to decorate pqPropertyWidget instances to add logic to...