pqPropertyWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqPropertyWidget_h
5 #define pqPropertyWidget_h
6 
7 #include "pqComponentsModule.h"
8 
9 #include "pqPropertyLinks.h"
10 #include <QFrame>
11 #include <QPointer>
12 #include <QScopedPointer>
13 
15 class pqTimer;
16 class pqView;
17 class vtkPVXMLElement;
18 class vtkSMDomain;
19 class vtkSMProperty;
20 class vtkSMProxy;
26 {
27  Q_OBJECT
28  typedef QWidget Superclass;
29 
30 public:
31  pqPropertyWidget(vtkSMProxy* proxy, QWidget* parent = nullptr);
32  ~pqPropertyWidget() override;
33 
34  virtual void apply();
35  virtual void reset();
36 
38 
48  virtual void select() { this->Selected = true; }
49  virtual void selectPort(int portIndex) { Q_UNUSED(portIndex); }
50  virtual void deselect() { this->Selected = false; }
51  bool isSelected() const { return this->Selected; }
53 
54  // This method is called on pqPropertyWidget instances that pqProxyWidget
55  // deems that should be shown in current configuration. Subclasses can
56  // override this method to change the appearance of the widget based on
57  // whether advanced properties are currently being shown by the pqProxyWidget
58  // or not.
59  virtual void updateWidget(bool showing_advanced_properties)
60  {
61  Q_UNUSED(showing_advanced_properties);
62  }
63 
64  pqView* view() const;
65  vtkSMProxy* proxy() const;
66  vtkSMProperty* property() const;
67  using Superclass::property; // Don't hide superclass method
68 
73  virtual char* panelVisibility() const;
74  virtual void setPanelVisibility(const char* vis);
75 
86  virtual bool isSingleRowItem() const;
87 
88  bool showLabel() const;
89 
103  template <class T>
104  static QString getXMLName(T* object)
105  {
106  return QString(object->GetXMLName());
107  }
108 
112  const QList<QPointer<pqPropertyWidgetDecorator>>& decorators() const { return this->Decorators; }
113 
118  using Superclass::setProperty;
119 
123  static QString getTooltip(vtkSMProperty* property);
124 
129  static int hintsWidgetHeightNumberOfRows(vtkPVXMLElement* hints, int defaultValue = 10);
130 
137  static std::vector<std::string> parseComponentLabels(
138  vtkPVXMLElement* hints, unsigned int elemCount = 0);
139 
140 Q_SIGNALS:
144  void viewChanged(pqView* view);
145 
150  void changeAvailable();
151 
156  void changeFinished();
157 
162  void restartRequired();
163 
164 public Q_SLOTS:
168  virtual void setView(pqView*);
169 
170 protected:
171  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
172  vtkSMProperty* smproperty, int smindex = -1);
173  void addPropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
174  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
175  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
176  vtkSMProperty* smproperty, int smindex = -1);
177  void removePropertyLink(QObject* qobject, const char* qproperty, const char* qsignal,
178  vtkSMProxy* smproxy, vtkSMProperty* smproperty, int smindex = -1);
179  void setShowLabel(bool show);
180 
190  {
191  this->ChangeAvailableAsChangeFinished = status;
192  }
193 
199  void addDecorator(pqPropertyWidgetDecorator*);
200 
204  void removeDecorator(pqPropertyWidgetDecorator*);
205 
209  pqPropertyLinks& links() { return this->Links; }
210 
211 public:
212  void setProperty(vtkSMProperty* property);
213 
214 private:
217  friend class pqProxyWidget;
218 
219 private Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
223  void onChangeAvailable();
224 
225 private: // NOLINT(readability-redundant-access-specifiers)
226  vtkSMProxy* Proxy;
227  vtkSMProperty* Property;
228  QPointer<pqView> View;
229  QList<QPointer<pqPropertyWidgetDecorator>> Decorators;
230 
231  pqPropertyLinks Links;
232  bool ShowLabel;
233  bool ChangeAvailableAsChangeFinished;
234  bool Selected;
235 
236  const QScopedPointer<pqTimer> Timer;
237 
242  void modified();
243  void editingFinished();
244 };
245 
246 #endif // pqPropertyWidget_h
virtual void selectPort(int portIndex)
These methods are called by pqPropertiesPanel when the panel for proxy becomes active/deactive.
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()
These methods are called by pqPropertiesPanel when the panel for proxy becomes active/deactive.
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
These methods are called by pqPropertiesPanel when the panel for proxy becomes active/deactive.
This is a PQ abstraction of a generic view module.
Definition: pqView.h:26
pqPropertyLinks & links()
Provides access to the pqPropertyLinks instance.
represents the possible values a property can have
Definition: vtkSMDomain.h:37
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:140
pqProxyWidget represents a panel for a vtkSMProxy.
Definition: pqProxyWidget.h:31
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...