ParaView/Properties Panel: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 41: Line 41:
The XML for the proxy and property definitions allow for developers to control how the controls for their proxy are shown to the user.
The XML for the proxy and property definitions allow for developers to control how the controls for their proxy are shown to the user.


==== Panel Visibility ====
The <tt>panel_visibility</tt> attribute allows for the visibility of the widget on the panel to be modified.
The <tt>panel_visibility</tt> attribute allows for the visibility of the widget on the panel to be modified.


Line 54: Line 55:
   <IntVectorProperty name="PhiResolution" panel_visibility="advanced">
   <IntVectorProperty name="PhiResolution" panel_visibility="advanced">
   </IntVectorProperty>
   </IntVectorProperty>
</source>
==== Custom Panel Widgets ====
A custom panel widget for a property can be specified with the <tt>panel_widget</tt> property.
Some builtin custom widgets are:
* <tt>color_selector</tt>: a color-swatch button for changing a single color
* <tt>display_representation_selector</tt>: for selecting representations
* <tt>texture_selector</tt>: for loading textures from files
For example:
<source lang="xml">
<DoubleVectorProperty command="SetEdgeColor"
                      default_values="0 0 0.5"
                      name="EdgeColor"
                      panel_widget="color_selector"
                      panel_visibility="advanced">
</DoubleVectorProperty>
</source>
</source>



Revision as of 16:59, 24 September 2012

ParaView 4.0 comes with an revamped properties panel. This page documents the new features and capabilities of the panel.

Changes since 3.x

The major GUI change between ParaView 3.x and 4.x is that the "Properties" and "Display" tabs in the object inspector have now been combined into a single "Properties" tab with a new interface. The new interface also features a search bar to allow users to easily find the controls for a certain property.

Wavelet Properties Panel.png

Implementation Details

The pqPropertiesPanel class

The central class in the new properties panel framework is pqPropertiesPanel. It inherits QWidget and by default is placed in a QDockWidget in the lower-left of the ParaView window. The two main API methods are setProxy(pqProxy *proxy) and setRepresentation(pqRepresentation *repr). The setProxy() method is called each time the current proxy is changed (e.g. the user creates a new sphere source or clicks a different object in the pipeline inspector) and will populate the top-half of the panel with the controls for the proxy. The setRepresentation() method is called each time the current representation changes (e.g. a different representation is select in the representation combo-box) and will populate the bottom-half of the panel with controls for the representation.

When the current proxy or representation changes the properties panel will read the XML object for each property in the proxy and create the appropriate subclass of pqPropertyWidget for it. This is done through the static pqPropertiesPanel::createWidgetForProperty(vtkSMProperty *property, vtkSMProxy *proxy, QWidget *parent = 0) method. This method is static so that other parts of ParaView can use it to provide a GUI widget for controlling a specific property on a proxy. The pqPropertyWidget class has a number of subclasses which implement a wide range of controls for each type of ParaView property (e.g. IntVectorProperty, StringVectorProperty, etc.).

The pqPropertyWidget class

The pqPropertyWidget class is the base class for all widgets controlling the value of a vtkSMProperty. A few generic implementations are provided for ParaView's property types:

  • pqIntVectorPropertyWidget for vtkSMIntVectorProperty
  • pqDoubleVectorPropertyWidget for vtkSMDoubleVectorProperty
  • pqStringVectorPropertyWidget for vtkSMStringVectorProperty
  • pqProxyVectorPropertyWidget for vtkSMProxyVectorProperty

Furthermore each of the basic property widget types will specialize and display themseleves based on the domain(s) of the property. For example, a vtkSMIntVectorProperty with a vtkSMBooleanRangeDomain will display a QCheckBox.

The pqPropertyWidget class has a fairly simple API:

<source lang="cpp"> class pqPropertyWidget { public:

 virtual void apply(); // apply settings (copy value from widget to property on the server)
 virtual void reset(); // reset settings (copy value from the property on the server to the widget)

signals:

 void modified(); // emitted when the widget's value changes

}; </source>

And, as mentioned before, the easiest way to create a property widget for a given property is with the static pqPropertiesPanel::createWidgetForProperty(vtkSMProperty *property, vtkSMProxy *proxy, QWidget *parent = 0) method.

XML Attributes

The XML for the proxy and property definitions allow for developers to control how the controls for their proxy are shown to the user.

Panel Visibility

The panel_visibility attribute allows for the visibility of the widget on the panel to be modified.

Valid values for panel_visibility are:

  • "default" - always shown on the panel
  • "advanced" - only shown when the advanced button is clicked
  • "never" - never shown on the panel

For example, the following property will only be shown when the user clicks the advanced button in the properties panel:

<source lang="xml">

 <IntVectorProperty name="PhiResolution" panel_visibility="advanced">
 </IntVectorProperty>

</source>

Custom Panel Widgets

A custom panel widget for a property can be specified with the panel_widget property.

Some builtin custom widgets are:

  • color_selector: a color-swatch button for changing a single color
  • display_representation_selector: for selecting representations
  • texture_selector: for loading textures from files

For example:

<source lang="xml"> <DoubleVectorProperty command="SetEdgeColor"

                     default_values="0 0 0.5"
                     name="EdgeColor"
                     panel_widget="color_selector"
                     panel_visibility="advanced">

</DoubleVectorProperty> </source>

Debuging

Setting the PV_DEBUG_PANELS enviornmental variable will cause the pqPropertiesPanel class to print out the reason for creating each property widget.

For example, after doing export PV_DEBUG_PANELS, running ParaView, and creating a Sphere source the following will be printed:

Creating panel widgets for the Sphere proxy: 
  - Center ( Center ) gets a pqDoubleVectorPropertyWidget containing a "List of QLineEdit's for an DoubleVectorProperty with an DoubleRangeDomain (range) and more than one element" 
  - Radius ( Radius ) gets a pqDoubleVectorPropertyWidget containing a "List of QLineEdit's for an DoubleVectorProperty with an DoubleRangeDomain (range) and more than one element" 
  - ThetaResolution ( Theta Resolution ) gets a pqIntVectorPropertyWidget containing a "List of QLineEdit's for an IntVectorProperty with an IntRangeDomain (range) and more than one element" 
  - StartTheta ( Start Theta ) gets a pqDoubleVectorPropertyWidget containing a "pqDoubleRangeWidget for an DoubleVectorProperty with a single element and a DoubleRangeDomain (range) with a minimum and a maximum" 
  - EndTheta ( End Theta ) gets a pqDoubleVectorPropertyWidget containing a "pqDoubleRangeWidget for an DoubleVectorProperty with a single element and a DoubleRangeDomain (range) with a minimum and a maximum" 
  - PhiResolution ( Phi Resolution ) gets a pqIntVectorPropertyWidget containing a "List of QLineEdit's for an IntVectorProperty with an IntRangeDomain (range) and more than one element" 
  - StartPhi ( Start Phi ) gets a pqDoubleVectorPropertyWidget containing a "pqDoubleRangeWidget for an DoubleVectorProperty with a single element and a DoubleRangeDomain (range) with a minimum and a maximum" 
  - EndPhi ( End Phi ) gets a pqDoubleVectorPropertyWidget containing a "pqDoubleRangeWidget for an DoubleVectorProperty with a single element and a DoubleRangeDomain (range) with a minimum and a maximum" 

Auto-Apply

The new properties panel retains the "auto-apply" functionality of the previous properties panel. This is implemented by automatically calling pqPropertiesPanel::apply() whenever a property widget is modified. The auto-apply function can be set by the user in the Edit->Settings menu or progromatically with the pqPropertiesPanel::setAutoApply(bool enabled) method. Additionally, a time delay may be introduced with the pqPropertiesPanel::setAutoApplyDelay(int msec) method.