Commit 2352686f authored by Michael Migliore's avatar Michael Migliore Committed by Joachim Pouderoux

Add a new checkbox in Volume representation to avoid confusion with MapScalars

When volume representation is selected and **Map Scalars** and selected data
array has 2 or 4 components, a new property called **Mutliple Components Mapping**
is available.

When this new feature is enabled:
* for a two-components array, the first component is mapped to the color, the
  second component is mapped to the opacity.
* for a four-components array, the first, second and third components are used
  as RGB values and the fourth component is mapped to the opacity.

Note that:
* this feature is only available when **MapScalars** is *ON* ;
* this feature forces **Use Separate Color Map** ;
* it scales the color and the opacity range with the correct component.
parent 78ad5a47
......@@ -81,6 +81,7 @@ paraview_test_load_data(""
tube.exo
vehicle_data.csv
viscoplastic-ring.h5
waveletElevation.vti
waveletMaterial.vti
)
......@@ -450,6 +451,7 @@ list(APPEND TESTS_WITH_BASELINES
${CMAKE_CURRENT_SOURCE_DIR}/UndoRedo8.xml
${CMAKE_CURRENT_SOURCE_DIR}/UnstructuredOutline.xml
${CMAKE_CURRENT_SOURCE_DIR}/VolumeRenderingWithContour.xml
${CMAKE_CURRENT_SOURCE_DIR}/VolumeReprTwoIndepComp.xml
${CMAKE_CURRENT_SOURCE_DIR}/VariableSelector.xml
${CMAKE_CURRENT_SOURCE_DIR}/VariableSelector1.xml
${CMAKE_CURRENT_SOURCE_DIR}/ViewSettingsDialog.xml
......@@ -723,6 +725,7 @@ set (LoadSaveStateVolume_FORCE_SERIAL TRUE)
# We don't support volume rendering of image data in data server & render server mode
set(LoadSaveStateVolume_DISABLE_CRS TRUE)
set(SeparatedColorMapOpacity_DISABLE_CRS TRUE)
set(VolumeReprTwoIndepComp_DISABLE_CRS TRUE)
# Set properties for CTH tests
set(CTHAMRContour_DISABLE_CS TRUE)
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/MainControlsToolbar/actionOpenData" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/waveletElevation.vti" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/outputWidgetDock/qt_dockwidget_closebutton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/SearchBox/AdvancedButton" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/representationToolbar/displayRepresentation/comboBox" command="activated" arguments="Volume" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/MultiComponentsMapping/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/cameraToolbar/actionPositiveX" command="activate" arguments="" />
</pqevents>
# Improve support of dependent components for volume representation
When volume representation is selected and **Map Scalars** and selected data
array has 2 or 4 components, a new property called **Mutliple Components Mapping**
is available.
When this new feature is enabled:
* for a two-components array, the first component is mapped to the color, the
second component is mapped to the opacity.
* for a four-components array, the first, second and third components are used
as RGB values and the fourth component is mapped to the opacity.
Note that:
* this feature is only available when **MapScalars** is *ON* ;
* this feature forces **Use Separate Color Map** ;
* it scales the color and the opacity range with the correct component.
......@@ -465,6 +465,12 @@ void vtkImageVolumeRepresentation::SetIndependentComponents(bool val)
this->Property->SetIndependentComponents(val);
}
//----------------------------------------------------------------------------
void vtkImageVolumeRepresentation::SetMultiComponentsMapping(bool val)
{
this->Property->SetIndependentComponents(!val);
}
//----------------------------------------------------------------------------
void vtkImageVolumeRepresentation::SetRequestedRenderMode(int mode)
{
......
......@@ -95,6 +95,7 @@ public:
void SetSpecularPower(double);
void SetShade(bool);
void SetIndependentComponents(bool);
void SetMultiComponentsMapping(bool);
//@{
/**
......
......@@ -351,31 +351,42 @@ bool vtkSMPVRepresentationProxy::RescaleTransferFunctionToDataRange(
}
else
{
double range[2];
info->GetComponentFiniteRange(component, range);
if (range[1] >= range[0])
double rangeColor[2];
double rangeOpacity[2];
if (this->GetVolumeIndependentRanges())
{
// the range must be large enough, compared to values order of magnitude
// If data range is too small then we tweak it a bit so scalar mapping
// produces valid/reproducible results.
vtkSMCoreUtilities::AdjustRange(range);
if (lut)
{
vtkSMTransferFunctionProxy::RescaleTransferFunction(lut, range, extend);
vtkSMProxy* sof_lut =
vtkSMPropertyHelper(lut, "ScalarOpacityFunction", true).GetAsProxy();
if (sof_lut && sof != sof_lut)
{
vtkSMTransferFunctionProxy::RescaleTransferFunction(sof_lut, range, extend);
}
}
if (sof)
info->GetComponentFiniteRange(0, rangeColor);
info->GetComponentFiniteRange(1, rangeOpacity);
}
else
{
info->GetComponentFiniteRange(component, rangeColor);
rangeOpacity[0] = rangeColor[0];
rangeOpacity[1] = rangeColor[1];
}
// the range must be large enough, compared to values order of magnitude
// If data range is too small then we tweak it a bit so scalar mapping
// produces valid/reproducible results.
vtkSMCoreUtilities::AdjustRange(rangeColor);
vtkSMCoreUtilities::AdjustRange(rangeOpacity);
if (lut && rangeColor[1] >= rangeColor[0])
{
vtkSMTransferFunctionProxy::RescaleTransferFunction(lut, rangeColor, extend);
vtkSMProxy* sof_lut = vtkSMPropertyHelper(lut, "ScalarOpacityFunction", true).GetAsProxy();
if (sof_lut && sof != sof_lut && rangeOpacity[1] >= rangeOpacity[0])
{
vtkSMTransferFunctionProxy::RescaleTransferFunction(sof, range, extend);
vtkSMTransferFunctionProxy::RescaleTransferFunction(sof_lut, rangeOpacity, extend);
}
}
return (lut || sof);
if (sof && rangeOpacity[1] >= rangeOpacity[0])
{
vtkSMTransferFunctionProxy::RescaleTransferFunction(sof, rangeOpacity, extend);
}
return (lut || sof);
}
}
return false;
......@@ -900,3 +911,20 @@ int vtkSMPVRepresentationProxy::GetEstimatedNumberOfAnnotationsOnScalarBar(vtkSM
sbProxy->UpdatePropertyInformation();
return vtkSMPropertyHelper(sbProxy, "EstimatedNumberOfAnnotations").GetAsInt();
}
//----------------------------------------------------------------------------
bool vtkSMPVRepresentationProxy::GetVolumeIndependentRanges()
{
// the representation is Volume
vtkSMProperty* repProperty = this->GetProperty("Representation");
if (strcmp(vtkSMPropertyHelper(repProperty).GetAsString(), "Volume") != 0)
{
return false;
}
// MapScalars and MultiComponentsMapping are checked
vtkSMProperty* msProperty = this->GetProperty("MapScalars");
vtkSMProperty* mcmProperty = this->GetProperty("MultiComponentsMapping");
return (vtkSMPropertyHelper(msProperty).GetAsInt() != 0 &&
vtkSMPropertyHelper(mcmProperty).GetAsInt() != 0);
}
......@@ -327,6 +327,12 @@ public:
*/
bool SetRepresentationType(const char* type) VTK_OVERRIDE;
/**
* True if ranges have to be computed independently on component 0 for the color
* and 1 for the opacity on the Volume representation.
*/
bool GetVolumeIndependentRanges();
protected:
vtkSMPVRepresentationProxy();
~vtkSMPVRepresentationProxy() override;
......
......@@ -3693,6 +3693,8 @@
<PropertyGroup label="Scalar Coloring">
<Property name="MapScalars"
panel_visibility="advanced" />
<Property name="MultiComponentsMapping"
panel_visibility="advanced" />
<Property name="InterpolateScalarsBeforeMapping"
panel_visibility="advanced" />
</PropertyGroup>
......@@ -4490,13 +4492,15 @@
<BooleanDomain name="bool" />
<Documentation>Enable/Disable shading.</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetIndependentComponents"
default_values="1"
name="MapScalars"
<IntVectorProperty command="SetMultiComponentsMapping"
default_values="0"
name="MultiComponentsMapping"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>Enable/Disable independent component usage such a
unsigned char RGBA data array.</Documentation>
<Hints>
<PropertyWidgetDecorator type="MultiComponentsDecorator"
components="2 4" />
</Hints>
</IntVectorProperty>
<ProxyProperty command="SetScalarOpacity"
name="ScalarOpacityFunction" >
......@@ -4664,6 +4668,7 @@
floating point type) and then directly used as
color.</Documentation>
</IntVectorProperty>
<ProxyProperty command="SetLookupTable"
name="LookupTable"
skip_dependency="1">
......@@ -5308,13 +5313,14 @@
name="MapScalars"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>When set to true, LookupTable will always be
<Documentation>When set to True, LookupTable will always be
used for scalar mapping. Otherwise, when up to 4 component
scalars are present, the components are clamped to a valid
color interval (0-255 for an integral type and 0.0-1.0 for a
floating point type) and then directly used as
color.</Documentation>
</IntVectorProperty>
<ProxyProperty command="SetLookupTable"
name="LookupTable" >
<Documentation>Set the lookup table to use for scalar
......@@ -11117,13 +11123,36 @@
name="MapScalars"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>When set to True, LookupTable will always be
<Documentation>When enabled, LookupTable will always be
used for scalar mapping. Otherwise, when up to 4 component
scalars are present, the components are clamped to a valid
color interval (0-255 for an integral type and 0.0-1.0 for a
floating point type) and then directly used as
color.</Documentation>
</IntVectorProperty>
<IntVectorProperty default_values="0"
name="MultiComponentsMapping"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>Enable multi components mapping. For a two-components array,
the first component is mapped to the color, the second component is mapped to the
opacity. For a four-components array, the first, second and third components are used as
RGB values and the fourth component is mapped to the opacity. Only available
when MapScalars is ON. This feature forces "Separate Color Map" and scales the color and
the opacity range with the correct component.</Documentation>
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="Representation"
value="Volume" />
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="MapScalars"
value="1" />
<PropertyWidgetDecorator type="MultiComponentsDecorator"
components="2 4" />
</Hints>
</IntVectorProperty>
<IntVectorProperty command="SetInterpolateScalarsBeforeMapping"
default_values="1"
name="InterpolateScalarsBeforeMapping"
......
......@@ -206,6 +206,8 @@ set (Module_SRCS
pqMasterOnlyReaction.h
pqModelTransformSupportBehavior.cxx
pqModelTransformSupportBehavior.h
pqMultiComponentsDecorator.cxx
pqMultiComponentsDecorator.h
pqObjectPickingBehavior.cxx
pqObjectPickingBehavior.h
pqOpacityTableModel.cxx
......@@ -423,6 +425,7 @@ set (Module_MOC_HDRS
pqManagePluginsReaction.h
pqMasterOnlyReaction.h
pqModelTransformSupportBehavior.h
pqMultiComponentsDecorator.h
pqObjectPickingBehavior.h
pqOpacityTableModel.h
pqOSPRayHidingDecorator.h
......
......@@ -123,7 +123,8 @@ public:
// We use this pqPropertyLinks instance to simply monitor smproperty changes.
pqPropertyLinks LinksForMonitoringChanges;
vtkNew<vtkEventQtSlotConnect> VTKConnector;
vtkNew<vtkEventQtSlotConnect> IndexedLookupConnector;
vtkNew<vtkEventQtSlotConnect> RangeConnector;
pqInternals(pqColorOpacityEditorWidget* self, vtkSMPropertyGroup* group)
: ColorTableModel(self)
......@@ -187,9 +188,9 @@ pqColorOpacityEditorWidget::pqColorOpacityEditorWidget(
SIGNAL(xvmsPointsChanged()));
}
QObject::connect(&pqActiveObjects::instance(), SIGNAL(representationChanged(pqRepresentation*)),
this, SLOT(updateButtonEnableState()));
this, SLOT(representationOrViewChanged()));
QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this,
SLOT(updateButtonEnableState()));
SLOT(representationOrViewChanged()));
QObject::connect(ui.OpacityEditor, SIGNAL(currentPointChanged(vtkIdType)), this,
SLOT(opacityCurrentChanged(vtkIdType)));
......@@ -278,7 +279,7 @@ pqColorOpacityEditorWidget::pqColorOpacityEditorWidget(
// we are not controlling the IndexedLookup property, we are merely
// observing it to ensure the UI is updated correctly. Hence we don't fire
// any signal to update the smproperty.
this->Internals->VTKConnector->Connect(smproxy->GetProperty("IndexedLookup"),
this->Internals->IndexedLookupConnector->Connect(smproxy->GetProperty("IndexedLookup"),
vtkCommand::ModifiedEvent, this, SLOT(updateIndexedLookupState()));
this->updateIndexedLookupState();
......@@ -342,9 +343,26 @@ void pqColorOpacityEditorWidget::setScalarOpacityFunctionProxy(pqSMProxy sofProx
internals.ScalarOpacityFunctionProxy = newSofProxy;
if (internals.ScalarOpacityFunctionProxy)
{
// FIXME: need to verify that repeated initializations are okay.
ui.OpacityEditor->initialize(
vtkScalarsToColors::SafeDownCast(this->proxy()->GetClientSideObject()), false, pwf, true);
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
vtkSMPVRepresentationProxy* proxy = static_cast<vtkSMPVRepresentationProxy*>(repr->getProxy());
// When representation changes, we have to initialize the opacity widget when
// "MultiComponentsMapping" is modified
this->Internals->RangeConnector->Disconnect();
vtkSMProperty* msProp = proxy->GetProperty("MapScalars");
vtkSMProperty* mcmProp = proxy->GetProperty("MultiComponentsMapping");
if (msProp && mcmProp)
{
this->Internals->RangeConnector->Connect(msProp, vtkCommand::ModifiedEvent, this,
SLOT(multiComponentsMappingChanged(vtkObject*, unsigned long, void*, void*)), pwf);
this->Internals->RangeConnector->Connect(mcmProp, vtkCommand::ModifiedEvent, this,
SLOT(multiComponentsMappingChanged(vtkObject*, unsigned long, void*, void*)), pwf);
// FIXME: need to verify that repeated initializations are okay.
this->initializeOpacityEditor(pwf);
}
// add new property links.
this->links().addPropertyLink(this, "xvmsPoints", SIGNAL(xvmsPointsChanged()),
internals.ScalarOpacityFunctionProxy,
......@@ -372,6 +390,48 @@ void pqColorOpacityEditorWidget::updateIndexedLookupState()
}
}
//-----------------------------------------------------------------------------
void pqColorOpacityEditorWidget::multiComponentsMappingChanged(vtkObject* vtkNotUsed(sender),
unsigned long vtkNotUsed(event), void* clientData, void* vtkNotUsed(callData))
{
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
vtkSMPVRepresentationProxy* proxy = static_cast<vtkSMPVRepresentationProxy*>(repr->getProxy());
if (proxy->GetVolumeIndependentRanges())
{
// force separate color map
vtkSMProperty* separateProperty = proxy->GetProperty("UseSeparateColorMap");
bool sepEnabled = vtkSMPropertyHelper(separateProperty).GetAsInt() != 0;
if (!sepEnabled)
{
vtkSMPropertyHelper(separateProperty).Set(1);
vtkSMPropertyHelper helper(proxy->GetProperty("ColorArrayName"));
proxy->SetScalarColoring(helper.GetAsString(4), vtkDataObject::POINT);
proxy->RescaleTransferFunctionToDataRange();
return;
}
}
this->initializeOpacityEditor(static_cast<vtkPiecewiseFunction*>(clientData));
proxy->RescaleTransferFunctionToDataRange();
}
//-----------------------------------------------------------------------------
void pqColorOpacityEditorWidget::initializeOpacityEditor(vtkPiecewiseFunction* pwf)
{
Ui::ColorOpacityEditorWidget& ui = this->Internals->Ui;
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
vtkSMPVRepresentationProxy* proxy = static_cast<vtkSMPVRepresentationProxy*>(repr->getProxy());
vtkScalarsToColors* stc = nullptr;
vtkSMProperty* separateProperty = proxy->GetProperty("UseSeparateColorMap");
bool sepEnabled = vtkSMPropertyHelper(separateProperty).GetAsInt() != 0;
if (!proxy->GetVolumeIndependentRanges() || !sepEnabled)
{
stc = vtkScalarsToColors::SafeDownCast(this->proxy()->GetClientSideObject());
}
ui.OpacityEditor->initialize(stc, false, pwf, true);
}
//-----------------------------------------------------------------------------
void pqColorOpacityEditorWidget::opacityCurrentChanged(vtkIdType index)
{
......@@ -594,7 +654,7 @@ void pqColorOpacityEditorWidget::currentDataEdited()
}
//-----------------------------------------------------------------------------
void pqColorOpacityEditorWidget::updateButtonEnableState()
void pqColorOpacityEditorWidget::representationOrViewChanged()
{
pqDataRepresentation* repr = pqActiveObjects::instance().activeRepresentation();
bool hasRepresentation = repr != NULL;
......@@ -605,6 +665,26 @@ void pqColorOpacityEditorWidget::updateButtonEnableState()
ui.ResetRangeToData->setEnabled(hasRepresentation);
ui.ResetRangeToDataOverTime->setEnabled(hasRepresentation);
ui.ResetRangeToVisibleData->setEnabled(hasRepresentation && hasView);
vtkSMProxy* pwfProxy = this->scalarOpacityFunctionProxy();
vtkPiecewiseFunction* pwf =
pwfProxy ? vtkPiecewiseFunction::SafeDownCast(pwfProxy->GetClientSideObject()) : nullptr;
// When representation changes, we have to initialize the opacity widget when
// "MultiComponentsMapping" is modified
this->Internals->RangeConnector->Disconnect();
vtkSMProperty* msProp = repr->getProxy()->GetProperty("MapScalars");
vtkSMProperty* mcmProp = repr->getProxy()->GetProperty("MultiComponentsMapping");
if (msProp && mcmProp)
{
this->Internals->RangeConnector->Connect(msProp, vtkCommand::ModifiedEvent, this,
SLOT(multiComponentsMappingChanged(vtkObject*, unsigned long, void*, void*)), pwf);
this->Internals->RangeConnector->Connect(mcmProp, vtkCommand::ModifiedEvent, this,
SLOT(multiComponentsMappingChanged(vtkObject*, unsigned long, void*, void*)), pwf);
this->initializeOpacityEditor(pwf);
}
}
//-----------------------------------------------------------------------------
......
......@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QList>
#include <QVariant>
class vtkPiecewiseFunction;
class vtkSMPropertyGroup;
class pqColorMapModel;
......@@ -234,6 +235,11 @@ protected slots:
*/
void updateIndexedLookupState();
/**
* called when "MultiComponentsMappingChanged" checkbox is modified.
*/
void multiComponentsMappingChanged(vtkObject*, unsigned long, void*, void*);
/**
* called when the use-log-scale checkbox is clicked by the user. We then add
* extra logic to valid ranges convert the color map to log/linear space.
......@@ -248,10 +254,11 @@ protected slots:
/**
* called when the active representation or view changes. We then change the
* enabled/disabled state of the buttons. Some actions require a valid
* enabled/disabled state of the buttons. Some actions require a valid
* representation or view, so disable them if there isn't one.
* We also update the opacity editor.
*/
void updateButtonEnableState();
void representationOrViewChanged();
protected:
/**
......@@ -259,6 +266,11 @@ protected:
*/
void prepareRangeForLogScaling();
/**
* Initialize the opacity editor.
*/
void initializeOpacityEditor(vtkPiecewiseFunction* pwf);
private:
Q_DISABLE_COPY(pqColorOpacityEditorWidget)
......
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqMultiComponentsDecorator.h"
#include "vtkPVArrayInformation.h"
#include "vtkPVXMLElement.h"
#include "vtkSMPVRepresentationProxy.h"
#include "vtkSMPropertyHelper.h"
#include <sstream>
//-----------------------------------------------------------------------------
pqMultiComponentsDecorator::pqMultiComponentsDecorator(
vtkPVXMLElement* config, pqPropertyWidget* parentObject)
: Superclass(config, parentObject)
{
std::stringstream ss(config->GetAttribute("components"));
int n;
while (ss >> n)
{
this->Components.push_back(n);
}
}
//-----------------------------------------------------------------------------
bool pqMultiComponentsDecorator::canShowWidget(bool show_advanced) const
{
vtkSMPVRepresentationProxy* proxy =
vtkSMPVRepresentationProxy::SafeDownCast(this->parentWidget()->proxy());
vtkPVArrayInformation* info = proxy->GetArrayInformationForColorArray();
if (info)
{
int nbComp = info->GetNumberOfComponents();
if (std::find(this->Components.begin(), this->Components.end(), nbComp) ==
this->Components.end())
{
return false;
}
}
return this->Superclass::canShowWidget(show_advanced);
}
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef pqMultiComponentsDecorator_h
#define pqMultiComponentsDecorator_h
#include "pqPropertyWidgetDecorator.h"
#include <vector>
/**
* pqMultiComponentsDecorator's purpose is to prevent the GUI from
* showing Multi Components Mapping checkbox when the representation is not Volume,
* the number of components is not valid or MapScalars is not checked.
*/
class pqMultiComponentsDecorator : public pqPropertyWidgetDecorator
{
Q_OBJECT
typedef pqPropertyWidgetDecorator Superclass;
public:
pqMultiComponentsDecorator(vtkPVXMLElement* config, pqPropertyWidget* parentObject);
~pqMultiComponentsDecorator() override = default;
/**
* Overridden to hide the widget
*/
bool canShowWidget(bool show_advanced) const override;
private:
Q_DISABLE_COPY(pqMultiComponentsDecorator)
std::vector<int> Components;
};
#endif
......@@ -63,6 +63,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqIntMaskPropertyWidget.h"
#include "pqLinePropertyWidget.h"
#include "pqListPropertyWidget.h"
#include "pqMultiComponentsDecorator.h"
#include "pqOSPRayHidingDecorator.h"
#include "pqPropertyGroupButton.h"
#include "pqProxyEditorPropertyWidget.h"
......@@ -318,6 +319,10 @@ pqPropertyWidgetDecorator* pqStandardPropertyWidgetInterface::createWidgetDecora
{
return new pqOSPRayHidingDecorator(config, widget);
}
if (type == "MultiComponentsDecorator")
{
return new pqMultiComponentsDecorator(config, widget);
}
// *** NOTE: When adding new types, please update the header documentation ***
return NULL;
......
......@@ -116,6 +116,7 @@ public:
* \li \c InputDataTypeDecorator : pqInputDataTypeDecorator
* \li \c GenericDecorator: pqGenericPropertyWidgetDecorator
* \li \c OSPRayHidingDecorator: pqOSPRayHidingDecorator
* \li \c MultiComponentsDecorator: pqMultiComponentsDecorator
*/
pqPropertyWidgetDecorator* createWidgetDecorator(
const QString& type, vtkPVXMLElement* config, pqPropertyWidget* widget) override;
......
......@@ -107,6 +107,19 @@ void pqUseSeparateColorMapReaction::setRepresentation(pqDataRepresentation* repr
//-----------------------------------------------------------------------------
void pqUseSeparateColorMapReaction::onTriggered()
{
// Disable Multi Components Mapping
pqDataRepresentation* repr = this->CachedRepresentation.data();
vtkSMPVRepresentationProxy* proxy = static_cast<vtkSMPVRepresentationProxy*>(repr->getProxy());
vtkSMProperty* mcmProperty = proxy->GetProperty("MultiComponentsMapping");
if (vtkSMPropertyHelper(mcmProperty).GetAsInt() == 1)
{
vtkSMProperty* sepProperty = proxy->GetProperty("UseSeparateColorMap");
if (vtkSMPropertyHelper(sepProperty).GetAsInt() == 0)
{
vtkSMPropertyHelper(mcmProperty).Set(0);
}
}
// Force color widget to update representation and color map
emit this->ColorWidget->arraySelectionChanged();
}
d329ae0fceff87a0edb7ed60acf46b79
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