Commit 33dbcb11 authored by Cory Quammen's avatar Cory Quammen

Add restoration of default transfer function from site settings

Transfer function proxies need some special care when restoring from
site settings or application defaults. Implemented restoration of the
global transfer function default to site settings if available or to
application defaults if not.

Added a test for this new functionality.
parent b616cb71
Pipeline #27598 passed with stage
......@@ -451,10 +451,13 @@ if(PARAVIEW_ENABLE_PYTHON)
${CMAKE_CURRENT_SOURCE_DIR}/TraceSupplementalProxiesFully.xml
)
list(APPEND TESTS_WITH_INLINE_COMPARES
${CMAKE_CURRENT_SOURCE_DIR}/TraceMultiViews.xml)
${CMAKE_CURRENT_SOURCE_DIR}/RestoreDefaultTransferFunction.xml
${CMAKE_CURRENT_SOURCE_DIR}/TraceMultiViews.xml
)
list(APPEND TESTS_WITHOUT_BASELINES
${CMAKE_CURRENT_SOURCE_DIR}/PythonCalculator.xml
${CMAKE_CURRENT_SOURCE_DIR}/TraceIntegrateVariables.xml)
${CMAKE_CURRENT_SOURCE_DIR}/TraceIntegrateVariables.xml
)
# Check that matplotlib is available
include(FindPythonModules)
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuTools" />
<pqevent object="pqClientMainWindow/menubar/menuTools" command="activate" arguments="actionToolsPythonShell" />
<pqevent object="pqClientMainWindow/pythonDialog/splitter/verticalLayoutWidget/shellWidget/1pqConsoleWidget0" command="executeCommand" arguments="userRGBPoints = [0, 0, 0, 0, 1, 1, 1, 1]&#xA;userSettingsString = &quot;&quot;&quot;&#xA;{ &quot;lookup_tables&quot; : {&#xA; &quot;PVLookupTable&quot; : {&#xA; &quot;ColorSpace&quot; : 0,&#xA; &quot;NanColor&quot; : [ 1, 0, 0 ],&#xA; &quot;RGBPoints&quot; : %s&#xA; }&#xA; }&#xA;}&#xA;&quot;&quot;&quot; % userRGBPoints&#xA;&#xA;siteRGBPoints = [0, 1, 1, 1, 1, 0, 0, 0]&#xA;siteSettingsString = &quot;&quot;&quot;&#xA;{&#xA; &quot;lookup_tables&quot; : {&#xA; &quot;PVLookupTable&quot; : {&#xA; &quot;ColorSpace&quot; : 0,&#xA; &quot;NanColor&quot; : [ 1, 0, 0 ],&#xA; &quot;RGBPoints&quot; : %s&#xA; }&#xA; }&#xA;}&#xA;&quot;&quot;&quot; % siteRGBPoints&#xA;&#xA;session = paraview.servermanager.vtkSMSession()&#xA;pxm = session.GetSessionProxyManager()&#xA;settings = paraview.servermanager.vtkSMSettings.GetInstance()&#xA;settings.ClearAllSettings()&#xA;&#xA;# Add user and site settings in the way that ParaView does when starting up&#xA;settings.AddCollectionFromString(userSettingsString, paraview.vtk.VTK_DOUBLE_MAX)&#xA;settings.AddCollectionFromString(siteSettingsString, 1.0)&#xA;&#xA;tfManager = paraview.servermanager.vtkSMTransferFunctionManager()&#xA;tf = tfManager.GetColorTransferFunction(&quot;blah&quot;, pxm)&#xA;&#xA;rgbPoints = tf.GetProperty(&quot;RGBPoints&quot;)&#xA;&#xA;# The transfer function should have the values from the user settings string&#xA;# at this point.&#xA;try:&#xA; for i in range(len(userRGBPoints)):&#xA; assert(userRGBPoints[i] == rgbPoints.GetElement(i))&#xA;except:&#xA; print(&quot;Err&quot;&quot;or: RGBPoints mismatch in user settings!&quot;)&#xA;" />
<pqevent object="pqClientMainWindow/pythonDialog/splitter/verticalLayoutWidget/shellWidget/1pqConsoleWidget0" command="executeCommand" arguments="" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources" command="activate" arguments="SphereSource" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="Normals" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Components" command="activated" arguments="X" />
<pqevent object="pqClientMainWindow/variableToolbar/actionScalarBarVisibility" command="set_boolean" arguments="false" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/RestoreDefaultTransferFunctionA.png" width="300" height="300" />
<pqevent object="pqClientMainWindow/variableToolbar/actionEditColorMap" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/RestoreDefaults" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Components" command="activated" arguments="X" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/RestoreDefaultTransferFunctionB.png" width="300" height="300" />
<pqevent object="pqClientMainWindow/pythonDialog/splitter/verticalLayoutWidget/shellWidget/1pqConsoleWidget0" command="executeCommand" arguments="settings.ClearAllSettings()&#xA;" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/RestoreDefaults" command="activate" arguments="" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/RestoreDefaultTransferFunctionC.png" width="300" height="300" />
</pqevents>
......@@ -869,7 +869,7 @@ bool vtkSMTransferFunctionProxy::UpdateScalarBarsComponentTitle(
}
//----------------------------------------------------------------------------
void vtkSMTransferFunctionProxy::ResetPropertiesToXMLDefaults(
void vtkSMTransferFunctionProxy::ResetPropertiesToDefaults(
bool preserve_range)
{
try
......@@ -903,6 +903,19 @@ void vtkSMTransferFunctionProxy::ResetPropertiesToXMLDefaults(
double range[2] = {points.front().GetData()[0],
points.back().GetData()[0]};
this->ResetPropertiesToXMLDefaults();
// Restore to site setting if there is one. If there isn't, this does not
// change the property setting. NOTE: user settings have priority
// of VTK_DOUBLE_MAX, so we set the site settings priority to a
// number just below VTK_DOUBLE_MAX.
vtkSMSettings* settings = vtkSMSettings::GetInstance();
// First, check to see if there is an array-specific transfer function in
// the settings.
settings->GetProxySettings(this, nextafter(VTK_DOUBLE_MAX, 0));
this->RescaleTransferFunction(range[0], range[1], false);
}
catch (bool val)
......
......@@ -250,17 +250,17 @@ public:
}
// Description:
// Helper method to reset a transfer function proxy to its XML defaults. By
// Helper method to reset a transfer function proxy to its defaults. By
// passing in preserve_range, you can make this method preserve the current
// transfer function range.
virtual void ResetPropertiesToXMLDefaults(bool preserve_range);
static void ResetPropertiesToXMLDefaults(vtkSMProxy* proxy, bool preserve_range=false)
virtual void ResetPropertiesToDefaults(bool preserve_range);
static void ResetPropertiesToDefaults(vtkSMProxy* proxy, bool preserve_range=false)
{
vtkSMTransferFunctionProxy* self =
vtkSMTransferFunctionProxy::SafeDownCast(proxy);
if (self)
{
self->ResetPropertiesToXMLDefaults(preserve_range);
self->ResetPropertiesToDefaults(preserve_range);
}
}
using Superclass::ResetPropertiesToXMLDefaults;
......
......@@ -394,10 +394,10 @@ void pqColorMapEditor::restoreDefaults()
}
else
{
vtkSMTransferFunctionProxy::ResetPropertiesToXMLDefaults(lutProxy, true);
vtkSMTransferFunctionProxy::ResetPropertiesToDefaults(lutProxy, true);
if (vtkSMProxy* sofProxy = vtkSMPropertyHelper(lutProxy, "ScalarOpacityFunction").GetAsProxy())
{
vtkSMTransferFunctionProxy::ResetPropertiesToXMLDefaults(sofProxy, true);
vtkSMTransferFunctionProxy::ResetPropertiesToDefaults(sofProxy, true);
}
}
}
......
......@@ -84,6 +84,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QShowEvent>
#include <QVBoxLayout>
#include <cmath>
#include <vector>
//-----------------------------------------------------------------------------------
......@@ -1277,8 +1278,11 @@ bool pqProxyWidget::restoreDefaults()
}
smproperty->ResetToDefault();
// Restore to site settings if there is one.
settings->GetPropertySetting(smproperty, 1.0);
// Restore to site setting if there is one. If there isn't, this does
// not change the property setting. NOTE: user settings have priority
// of VTK_DOUBLE_MAX, so we set the site settings priority to a
// number just below VTK_DOUBLE_MAX.
settings->GetPropertySetting(smproperty, nextafter(VTK_DOUBLE_MAX, 0));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment