Commit f6188558 authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot

Merge topic 'FlipScalarBar'

26298cbe Adding a ReverseLegend property to the Scalar Bar Actor
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Nicolas Vuaille's avatarNicolas Vuaille <nicolas.vuaille@kitware.com>
Merge-request: !2571
parents 9afd422a 26298cbe
Pipeline #108902 canceled with stage
in 0 seconds
......@@ -426,6 +426,7 @@ list(APPEND TESTS_WITH_BASELINES
${CMAKE_CURRENT_SOURCE_DIR}/RepresentationSelector.xml
${CMAKE_CURRENT_SOURCE_DIR}/ResampleWithDataset.xml
${CMAKE_CURRENT_SOURCE_DIR}/RescaleToTemporal.xml
${CMAKE_CURRENT_SOURCE_DIR}/ReverseLegend.xml
${CMAKE_CURRENT_SOURCE_DIR}/RotateCamera90.xml
# ${CMAKE_CURRENT_SOURCE_DIR}/SaveAnimationGeometry.xml
${CMAKE_CURRENT_SOURCE_DIR}/SaveColorMap.xml
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar/menuSources" command="activate" arguments="RTAnalyticSource" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="RTData" />
<pqevent object="pqClientMainWindow/representationToolbar/displayRepresentation/comboBox" command="activated" arguments="Surface" />
<pqevent object="pqClientMainWindow/variableToolbar/actionEditColorMap" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/IndexedLookup/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/Add" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="0.0" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="0.2" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="edit" arguments="0.2" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable/qt_scrollarea_viewport/1QExpandingLineEdit0" command="set_string" arguments="100" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="0.3" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="edit" arguments="0.3" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable/qt_scrollarea_viewport/1QExpandingLineEdit0" command="set_string" arguments="100" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/Add" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="1.0" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="1.2" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="edit" arguments="1.2" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable/qt_scrollarea_viewport/1QExpandingLineEdit0" command="set_string" arguments="50" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="setCurrent" arguments="1.3" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable" command="edit" arguments="1.3" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/AnnotationsEditor/AnnotationsTable/qt_scrollarea_viewport/1QExpandingLineEdit0" command="set_string" arguments="50" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/IndexedLookup/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/EditScalarBar" command="activate" arguments="" />
<pqevent object="ColorLegendEditor/scrollArea/qt_scrollarea_viewport/Container/ProxyWidget/ReverseLegend/CheckBox" command="set_boolean" arguments="true" />
<pqevent object="ColorLegendEditor/widget/ApplyButton" command="activate" arguments="" />
<pqevent object="ColorLegendEditor/widget/OKButton" command="activate" arguments="" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/ReverseLegend_A.png" threshold="5" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/IndexedLookup/CheckBox" command="set_boolean" arguments="true" />
<pqcompareview object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Frame.0/CentralWidgetFrame/Viewport" baseline="$PARAVIEW_DATA_ROOT/Baseline/ReverseLegend_B.png" threshold="5" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/Properties/IndexedLookup/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="pqClientMainWindow/colorMapEditorDock/colorMapEditorPanel/EditScalarBar" command="activate" arguments="" />
<pqevent object="ColorLegendEditor/scrollArea/qt_scrollarea_viewport/Container/ProxyWidget/AutoOrient/CheckBox" command="set_boolean" arguments="false" />
<pqevent object="ColorLegendEditor/scrollArea/qt_scrollarea_viewport/Container/ProxyWidget/Orientation/ComboBox" command="activated" arguments="Horizontal" />
<pqevent object="ColorLegendEditor/widget/ApplyButton" command="activate" arguments="" />
<pqevent object="ColorLegendEditor/widget/OKButton" command="activate" arguments="" />
</pqevents>
......@@ -519,6 +519,7 @@
<Property name="DrawNanAnnotation" panel_visibility="advanced" />
<Property name="NanAnnotation" panel_visibility="advanced" />
<Property name="TextPosition" />
<Property name="ReverseLegend" />
<Property name="ScalarBarThickness" />
<Property name="ScalarBarLength" />
</PropertyGroup>
......
......@@ -1080,6 +1080,17 @@
horizontal or vertical, respectively.
</Documentation>
</DoubleVectorProperty>
<IntVectorProperty animateable="0"
command="SetReverseLegend"
default_values="0"
name="ReverseLegend"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>
When on, the color bar and all associated ticks and notations will be reversed,
from high to low instead of low to high.
</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetAutomaticLabelFormat"
default_values="1"
name="AutomaticLabelFormat"
......
......@@ -135,6 +135,8 @@ vtkContext2DScalarBarActor::vtkContext2DScalarBarActor()
this->UseCustomLabels = false;
this->CustomLabels = vtkSmartPointer<vtkDoubleArray>::New();
this->ReverseLegend = false;
this->ScalarBarItem = vtkScalarBarItem::New();
this->ScalarBarItem->Actor = this;
......@@ -286,7 +288,14 @@ void vtkContext2DScalarBarActor::UpdateScalarBarTexture(vtkImageData* image)
color[1] = colorTmp[1];
color[2] = colorTmp[2];
color[3] = static_cast<unsigned char>(255.0 * ctf->GetOpacity(originalValue) + 0.5);
colors->SetTypedTuple(i, color);
if (this->ReverseLegend)
{
colors->SetTypedTuple(numColors - i - 1, color);
}
else
{
colors->SetTypedTuple(i, color);
}
}
}
......@@ -422,26 +431,8 @@ vtkRectf vtkContext2DScalarBarActor::GetAboveRangeColorRect(double size[2])
if (ctf->GetUseAboveRangeColor())
{
if (this->Orientation == VTK_ORIENT_VERTICAL)
{
double width = size[0];
rect = vtkRectf(0, size[1] - width, width, width);
}
else
{
// Horizontal
double nanSpace = this->GetNaNColorRect(size).GetWidth();
if (nanSpace > 0)
{
nanSpace += this->Spacer;
}
double height = size[1];
// Move it all the way to the right, minus the NaN swatch
rect = vtkRectf(size[0] - nanSpace - height, 0, height, height);
}
rect = this->GetOutOfRangeColorRectInternal(vtkContext2DScalarBarActor::ABOVE_RANGE, size);
}
return rect;
}
......@@ -467,6 +458,40 @@ vtkRectf vtkContext2DScalarBarActor::GetBelowRangeColorRect(double size[2])
}
if (ctf->GetUseBelowRangeColor())
{
rect = this->GetOutOfRangeColorRectInternal(vtkContext2DScalarBarActor::BELOW_RANGE, size);
}
return rect;
}
//----------------------------------------------------------------------------
vtkRectf vtkContext2DScalarBarActor::GetOutOfRangeColorRectInternal(
vtkContext2DScalarBarActor::OutOfRangeType type, double size[2])
{
vtkRectf rect(0, 0, 0, 0);
bool graphicallyAbove = type == vtkContext2DScalarBarActor::ABOVE_RANGE && !this->ReverseLegend;
if (graphicallyAbove)
{
if (this->Orientation == VTK_ORIENT_VERTICAL)
{
double width = size[0];
rect = vtkRectf(0, size[1] - width, width, width);
}
else
{
// Horizontal
double nanSpace = this->GetNaNColorRect(size).GetWidth();
if (nanSpace > 0)
{
nanSpace += this->Spacer;
}
double height = size[1];
// Move it all the way to the right, minus the NaN swatch
rect = vtkRectf(size[0] - nanSpace - height, 0, height, height);
}
}
else
{
if (this->Orientation == VTK_ORIENT_VERTICAL)
{
......@@ -485,7 +510,6 @@ vtkRectf vtkContext2DScalarBarActor::GetBelowRangeColorRect(double size[2])
rect = vtkRectf(0, 0, width, width);
}
}
return rect;
}
......@@ -587,6 +611,7 @@ void vtkContext2DScalarBarActor::PaintColorBar(vtkContext2D* painter, double siz
}
// Now loop over indexed colors and draw swatches
double x, y;
for (int i = 0; i < numIndexedColors; ++i)
{
double shift = i * (indexedColorSwatchLength + this->Spacer);
......@@ -597,16 +622,30 @@ void vtkContext2DScalarBarActor::PaintColorBar(vtkContext2D* painter, double siz
brush->SetColorF(indexedColor);
if (this->Orientation == VTK_ORIENT_VERTICAL)
{
double x = barRect.GetX();
double y = barRect.GetY() + barRect.GetHeight() - shift - indexedColorSwatchLength;
x = barRect.GetX();
if (this->ReverseLegend)
{
y = barRect.GetY() + shift;
}
else
{
y = barRect.GetY() + barRect.GetHeight() - shift - indexedColorSwatchLength;
}
painter->DrawRect(x, y, barRect.GetWidth(), indexedColorSwatchLength);
annotationAnchors[y + 0.5 * indexedColorSwatchLength] = annotation;
}
else
{
// Horizontal
double x = barRect.GetX() + shift;
double y = barRect.GetY();
if (this->ReverseLegend)
{
x = barRect.GetX() + barRect.GetWidth() - shift - indexedColorSwatchLength;
}
else
{
x = barRect.GetX() + shift;
}
y = barRect.GetY();
painter->DrawRect(x, y, indexedColorSwatchLength, barRect.GetHeight());
annotationAnchors[x + 0.5 * indexedColorSwatchLength] = annotation;
}
......@@ -668,6 +707,10 @@ void vtkContext2DScalarBarActor::PaintColorBar(vtkContext2D* painter, double siz
low = barRect.GetY();
high = low + barRect.GetHeight();
}
if (this->ReverseLegend)
{
std::swap(high, low);
}
if (this->GetAutomaticAnnotations())
{
......@@ -848,6 +891,11 @@ void vtkContext2DScalarBarActor::PaintAxis(vtkContext2D* painter, double size[2]
range[0] = lutRange[0];
range[1] = lutRange[1];
if (this->ReverseLegend)
{
std::swap(range[0], range[1]);
}
vtkPen* axisPen = this->Axis->GetPen();
axisPen->SetColorF(this->LabelTextProperty->GetColor());
......
......@@ -80,6 +80,12 @@ public:
SucceedScalarBar
};
enum OutOfRangeType
{
BELOW_RANGE = 0,
ABOVE_RANGE = 1,
};
//@{
/**
* Set the scalar bar thickness. When the orientation is
......@@ -104,6 +110,16 @@ public:
vtkGetMacro(ScalarBarLength, double);
//@}
//@{
/**
* Set whether the scalar bar is reversed ie from high
* to low instead of from low to high. Default is false;
*/
vtkSetMacro(ReverseLegend, bool);
vtkGetMacro(ReverseLegend, bool);
vtkBooleanMacro(ReverseLegend, bool);
//@}
//@{
/**
* If true (the default), the printf format used for the labels will be
......@@ -270,6 +286,11 @@ private:
bool UseCustomLabels;
/**
* Flag that controls if the whole color legend should be reversed
*/
bool ReverseLegend;
/**
* Custom label values.
*/
......@@ -328,6 +349,9 @@ private:
*/
vtkRectf GetBelowRangeColorRect(double size[2]);
vtkRectf GetOutOfRangeColorRectInternal(
vtkContext2DScalarBarActor::OutOfRangeType type, double size[2]);
/**
* Get the rect for the NaN color swatch.
*/
......
4e766fadf5f263bb2409d108c0be93c69bb84955b3fe0aedc89f3bc7891896274ba620e0882ecc0acc300c2c99b8402fb82878fdaf784541487fb48489c08cc9
267a73c1341ea5a72832b9cd26990cca9191be0f69ae484302f01b4d71229a51f24f03075bb1470e7ec57cedc9cab2b61721619672d2c5d33b291bda6282e8d4
2c224e7ed78a7ce8c1b92ca7cf75f90f3a272abaa30c3a44d00fc4cb3b1a2d27045057a4e1f92624bc8ab74c579866c1fffed3f45847b6278217e32ee78b758b
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