Commit 8e5d3969 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'categorical-colors'

a9cdca16 Add the code used to create XML color maps ...
a2dd2fc2 Fix color test regression.
d4633551 Eliminate compiler warning.
a11132d4 Fix "traffic light" colormaps, add one more.
d2aa0960 Add missing button signal for annotations.
6fcf33cb Add "Traffic Light" color palettes.
f4aef178 Fix uninitialized variable usage.
d3e406d1 Use `ToDouble` instead of `ToNumeric`.
dedfc89f `ToDouble` instead of `ToNumeric`: fix link error?
08b485c0 Eliminate warnings.
9b22042d Fix color editor button presses in tests.
fc7fcf19 Handle NULL pointer.
045831be Add explicit lib. dependency; make Windows happy?
15a87ccf Fix Linux/Windows build error (missing <typeinfo>).
5d21e6dd Fix client-server categorical color test.
a1db41d2 Provide a way to stream vtkVariant objects.
...
parents 52faa087 a9cdca16
......@@ -69,6 +69,7 @@ SET (TESTS_WITH_BASELINES
${CMAKE_CURRENT_SOURCE_DIR}/ColorEditor2.xml
${CMAKE_CURRENT_SOURCE_DIR}/NewColorEditor3.xml
${CMAKE_CURRENT_SOURCE_DIR}/ColorEditor4.xml
${CMAKE_CURRENT_SOURCE_DIR}/CategoricalColorScalarBar1.xml
${CMAKE_CURRENT_SOURCE_DIR}/ComparativeVisPanel.xml
${CMAKE_CURRENT_SOURCE_DIR}/CompositeSurfaceSelection.xml
${CMAKE_CURRENT_SOURCE_DIR}/Contour.xml
......
......@@ -13,7 +13,7 @@
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqRescaleRangeDialog/MinimumScalar" command="set_string" arguments="8" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqRescaleRangeDialog/MaximumScalar" command="set_string" arguments="8.2" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqRescaleRangeDialog/RescaleButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="setCurrent" arguments="6.0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/CloseButton" command="activate" arguments="" />
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources" command="activate" arguments="ImageMandelbrotSource" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/MaximumNumberOfIterations/LineEdit" command="set_string" arguments="10" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/SubsampleRate" command="key" arguments="16777217" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/pqProxyGroupMenuManager0/Calculator" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/Function" command="set_string" arguments="floor(Iterations)" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/ScrollArea/qt_scrollarea_viewport/PanelArea/Editor/Function" command="key" arguments="16777248" />
<pqevent object="pqClientMainWindow/objectInspectorDock/objectInspector/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/representationToolbar/displayRepresentation/comboBox" command="set_string" arguments="Surface" />
<pqevent object="pqClientMainWindow/cameraToolbar/actionResetCamera" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/actionScalarBarVisibility" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/variableToolbar/actionEditColorMap" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/SwitchToAdvanced" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="setCurrent" arguments="127.0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/AnnotationsPage/AddActiveValues" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/AnnotationsPage/AnnotationTree" command="setCurrent" arguments="0.1" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/AnnotationsPage/AnnotationSwatch" command="setChosenColor" arguments="54,127,37" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/CloseButton" command="activate" arguments="" />
</pqevents>
......@@ -4,7 +4,7 @@
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="set_string" arguments="FractalIterations" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ColorEditor/1QGroupBox0/1pqGenericSummaryDisplayPanel0/1QPushButton1" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="currentChanged" arguments="/2|0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/CloseButton" command="activate" arguments="" />
......
......@@ -8,7 +8,7 @@
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ColorEditor/1QGroupBox0/1pqGenericSummaryDisplayPanel0/1QPushButton1" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/SwitchToAdvanced" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/CancelButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/TableSize" command="set_int" arguments="5" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/TableSizeText" command="set_string" arguments="7" />
......
......@@ -21,7 +21,7 @@
Choose a preset color map and make sure the corresponding NaN color is loaded.
-->
<pqevent object="pqClientMainWindow/variableToolbar/actionEditColorMap" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="setCurrent" arguments="1.0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/CloseButton" command="activate" arguments="" />
......
......@@ -6,7 +6,7 @@
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="set_string" arguments="RTData" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ColorEditor/1QGroupBox0/1pqGenericSummaryDisplayPanel0/1QPushButton1" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/SwitchToAdvanced" command="set_boolean" arguments="true" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mousePress" arguments="1,1,0,125,7,/5:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mouseRelease" arguments="1,0,0,125,7,/5:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
......@@ -22,13 +22,13 @@
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mousePress" arguments="(0.0936709,0.5,1,1,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mouseMove" arguments="(0.144304,0.52,1,0,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mouseRelease" arguments="(0.144304,0.52,1,0,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/SaveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/SaveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/RemoveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mousePress" arguments="1,1,0,100,5,/6:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mouseMove" arguments="1,0,0,99,5,/6:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mouseRelease" arguments="1,0,0,99,5,/6:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mousePress" arguments="1,1,0,177,12,/6:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mouseRelease" arguments="1,0,0,177,12,/6:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
......@@ -38,16 +38,16 @@
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mousePress" arguments="(0.721519,0.5,1,1,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mouseMove" arguments="(0.194937,0.54,1,0,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/frameColorTF/1pqTransferFunctionChartViewWidget0/1QVTKWidget0" command="mouseRelease" arguments="(0.194937,0.54,1,0,0)" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/SaveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/SaveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/ExportButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/FileExportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/mycolormap.xml" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/RemoveButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mousePress" arguments="1,1,0,131,11,/1:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/Gradients" command="mouseRelease" arguments="1,0,0,131,11,/1:0" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/ColorTabs/qt_tabwidget_stackedwidget/ScalePage/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/PresetButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/ImportButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/FileImportDialog" command="filesSelected" arguments="$PARAVIEW_TEST_ROOT/mycolormap.xml" />
<pqevent object="pqClientMainWindow/pqColorScaleDialog/pqColorPresetDialog/OkButton" command="activate" arguments="" />
......
......@@ -3,7 +3,6 @@
# to ensure all ParaView needed modules are turned on when building the complete
# application.
set(_vtk_mpi_modules
vtkParallelMPI
vtkFiltersParallelImaging
......@@ -26,6 +25,7 @@ set(_vtk_modules
# time dependency on
vtkRenderingVolume
vtkRenderingLabel
vtkRenderingMathText
vtkRenderingFreeType
vtkRenderingFreeTypeOpenGL
vtkRenderingVolumeOpenGL
......@@ -345,6 +345,15 @@ if (PARAVIEW_USE_VISITBRIDGE)
list (APPEND _vtk_modules vtkIOVisItBridge)
endif()
# See if matplotlib is present.
# If so, add vtkRenderingMatplotlib for math text rendering.
if (PYTHON_EXECUTABLE)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import matplotlib"
RESULT_VARIABLE IMPORT_MATPLOTLIB_EXITCODE)
if (${IMPORT_MATPLOTLIB_EXITCODE} EQUAL 0)
list (APPEND _vtk_modules vtkRenderingMatplotlib)
endif()
endif()
# Any module can import this file and add DEPENDS or COMPILE_DEPENDS on this
# list of modules to ensure that these are enabled when the corresponding module
......
......@@ -410,6 +410,7 @@ else()
ThirdParty/protobuf
ThirdParty/QtTesting
Utilities/ProcessXML
Utilities/ColorSeriesToXML
Utilities/VisItBridge/databases
Utilities/VisItBridge/Library
Utilities/WrapClientServer
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkPVArrayInformation.h"
#include "vtkAbstractArray.h"
#include "vtkClientServerStream.h"
#include "vtkDataArray.h"
#include "vtkObjectFactory.h"
......@@ -23,10 +24,16 @@
#include "vtkStringArray.h"
#include "vtkStdString.h"
#include "vtkPVPostFilter.h"
#include "vtkVariant.h"
#include "vtkVariantArray.h"
#include <map>
#include <set>
#include <vector>
#include <vtksys/ios/sstream>
#define VTK_MAX_CATEGORICAL_VALS (32)
namespace
{
typedef std::vector<vtkStdString*> vtkInternalComponentNameBase;
......@@ -38,6 +45,8 @@ namespace
};
typedef std::vector<vtkPVArrayInformationInformationKey> vtkInternalInformationKeysBase;
typedef std::map<int,std::set<vtkVariant> > vtkInternalUniqueValuesBase;
}
class vtkPVArrayInformation::vtkInternalComponentNames:
......@@ -50,7 +59,12 @@ class vtkPVArrayInformation::vtkInternalInformationKeys:
{
};
vtkStandardNewMacro( vtkPVArrayInformation);
class vtkPVArrayInformation::vtkInternalUniqueValues:
public vtkInternalUniqueValuesBase
{
};
vtkStandardNewMacro(vtkPVArrayInformation);
//----------------------------------------------------------------------------
vtkPVArrayInformation::vtkPVArrayInformation()
......@@ -60,6 +74,7 @@ vtkPVArrayInformation::vtkPVArrayInformation()
this->ComponentNames = 0;
this->DefaultComponentName = 0;
this->InformationKeys = 0;
this->UniqueValues = 0;
this->Initialize();
}
......@@ -110,6 +125,12 @@ void vtkPVArrayInformation::Initialize()
delete this->InformationKeys;
this->InformationKeys = 0;
}
if ( this->UniqueValues )
{
delete this->UniqueValues;
this->UniqueValues = 0;
}
}
//----------------------------------------------------------------------------
......@@ -117,6 +138,7 @@ void vtkPVArrayInformation::PrintSelf(ostream& os, vtkIndent indent)
{
int num, idx;
vtkIndent i2 = indent.GetNextIndent();
vtkIndent i3 = i2.GetNextIndent();
this->Superclass::PrintSelf(os, indent);
if (this->Name)
......@@ -162,6 +184,23 @@ void vtkPVArrayInformation::PrintSelf(ostream& os, vtkIndent indent)
{
os << i2 << "None" << endl;
}
os << indent << "UniqueValues :" << endl;
if(this->UniqueValues)
{
for ( vtkInternalUniqueValues::iterator cit = this->UniqueValues->begin(); cit != this->UniqueValues->end(); ++ cit )
{
os << i2 << "Component " << cit->first << " (" << cit->second.size() << " values )" << endl;
for ( vtkInternalUniqueValues::mapped_type::iterator vit = cit->second.begin(); vit != cit->second.end(); ++ vit )
{
os << i3 << vit->ToString() << endl;
}
}
}
else
{
os << i2 << "None" << endl;
}
}
//----------------------------------------------------------------------------
......@@ -194,6 +233,9 @@ void vtkPVArrayInformation::SetNumberOfComponents(int numComps)
this->Ranges[2 * idx] = VTK_DOUBLE_MAX;
this->Ranges[2 * idx + 1] = -VTK_DOUBLE_MAX;
}
if ( this->UniqueValues )
this->UniqueValues->clear();
}
//----------------------------------------------------------------------------
......@@ -423,7 +465,7 @@ void vtkPVArrayInformation::AddRanges(vtkPVArrayInformation *info)
}
//----------------------------------------------------------------------------
void vtkPVArrayInformation::DeepCopy(vtkPVArrayInformation *info)
void vtkPVArrayInformation::DeepCopy( vtkPVArrayInformation* info )
{
int num, idx;
......@@ -491,6 +533,19 @@ void vtkPVArrayInformation::DeepCopy(vtkPVArrayInformation *info)
this->InformationKeys->push_back(info->InformationKeys->at(i));
}
}
// Copy the list of unique values for each component.
if ( this->UniqueValues && ! info->UniqueValues )
{
delete this->UniqueValues;
this->UniqueValues = 0;
}
else if ( info->UniqueValues )
{
if ( ! this->UniqueValues )
this->UniqueValues = new vtkInternalUniqueValues;
*this->UniqueValues = *info->UniqueValues;
}
}
//----------------------------------------------------------------------------
......@@ -587,6 +642,71 @@ void vtkPVArrayInformation::CopyFromObject(vtkObject* obj)
}
it->Delete();
}
// Check whether the array has a small number of unique values
// (i.e, test whether the array represents samples from a discrete
// set or a continuum).
if ( this->UniqueValues )
{
this->UniqueValues->clear();
}
else
{
this->UniqueValues = new vtkInternalUniqueValues;
}
int nc = this->GetNumberOfComponents();
std::vector<int> componentCount( nc + 1 );
int ndc = nc; // number of discrete components remaining (tracked during iteration)
std::pair<vtkInternalUniqueValues::mapped_type::iterator,bool> result;
std::set<std::vector<vtkVariant> > uniqueVectors;
std::vector<vtkVariant> uv( nc );
vtkVariantArray* tuple;
// Here we iterate over the components and add to their respective lists of previously encountered
// values -- as long as there are not too many values already in the list. We also accumulate each
// component's value into a vtkVariantArray named tuple, which is added to the list of unique vectors
// -- again assuming it is not already too long.
for ( vtkIdType i = 0; i < this->GetNumberOfTuples() && ndc; ++ i )
{
// First, do per-component insert.
for ( int j = 0; j < nc; ++ j )
{
if ( componentCount[j] > VTK_MAX_CATEGORICAL_VALS )
continue;
uv[j] = array->GetVariantValue( i * nc + j );
result = (*this->UniqueValues)[j].insert( uv[j] );
if ( result.second )
{
if ( ++ componentCount[j] > VTK_MAX_CATEGORICAL_VALS )
{
-- ndc;
}
}
}
// Now, as long as no component has exceeded VTK_MAX_CATEGORICAL_VALS unique values, it is
// worth seeing whether the vector as a whole is unique:
if ( ndc == nc )
{
std::pair<std::set<std::vector<vtkVariant> >::iterator,bool> vres = uniqueVectors.insert( uv );
if ( vres.second )
{
if ( ++ componentCount[nc] <= VTK_MAX_CATEGORICAL_VALS )
{
tuple = vtkVariantArray::New();
tuple->SetNumberOfComponents( nc );
tuple->SetNumberOfTuples( 1 );
for ( int j = 0; j < nc; ++ j )
tuple->SetVariantValue( j, uv[j] );
result = (*this->UniqueValues)[nc].insert( tuple );
tuple->Delete(); // now only owned by vtkVariant in UniqueValues
}
}
}
}
for ( int i = 0; i <= nc; ++ i )
{
if ( (*this->UniqueValues)[i].size() >= VTK_MAX_CATEGORICAL_VALS )
this->UniqueValues->erase( i );
}
}
//----------------------------------------------------------------------------
......@@ -612,9 +732,10 @@ void vtkPVArrayInformation::AddInformation(vtkPVInformation* info)
}
else
{
// Leave everything but ranges as original, add ranges.
// Leave everything but ranges and unique values as original, add ranges and unique values.
this->AddRanges(aInfo);
this->AddInformationKeys(aInfo);
this->AddUniqueValues(aInfo);
}
}
}
......@@ -663,6 +784,25 @@ void vtkPVArrayInformation::CopyToStream(vtkClientServerStream* css)
*css << location << name;
}
int numberOfUniqueValueComponents = static_cast<int>(
this->UniqueValues ? this->UniqueValues->size() : 0);
*css << numberOfUniqueValueComponents;
if (numberOfUniqueValueComponents)
{
// Iterate over component numbers:
vtkInternalUniqueValues::iterator cit;
for (cit = this->UniqueValues->begin(); cit != this->UniqueValues->end(); ++cit)
{
unsigned nuv = static_cast<unsigned>(cit->second.size());
*css << cit->first << nuv;
vtkInternalUniqueValues::mapped_type::iterator vit;
for (vit = cit->second.begin(); vit != cit->second.end(); ++ vit)
{
*css << *vit;
}
}
}
*css << vtkClientServerStream::End;
}
......@@ -789,6 +929,54 @@ void vtkPVArrayInformation::CopyFromStream(const vtkClientServerStream* css)
vtkStdString key_name = name;
this->AddInformationKey(key_location, key_name);
}
int numberOfUniqueValueComponents;
if ( ! css->GetArgument( 0, pos++, &numberOfUniqueValueComponents ) )
{
vtkErrorMacro("Error parsing unique value existence from message.");
return;
}
if ( ! numberOfUniqueValueComponents && this->UniqueValues )
{
delete this->UniqueValues;
this->UniqueValues = 0;
}
else if ( numberOfUniqueValueComponents )
{
if ( ! this->UniqueValues )
{
this->UniqueValues = new vtkInternalUniqueValues;
}
else
{
this->UniqueValues->clear();
}
for ( int i = 0; i < numberOfUniqueValueComponents; ++ i )
{
int component;
if (!css->GetArgument(0, pos++, &component))
{
vtkErrorMacro( "Error decoding the " << i << "-th unique-value component ID." );
return;
}
unsigned nuv;
if ( ! css->GetArgument( 0, pos++, &nuv ) )
{
vtkErrorMacro( "Error decoding the number of unique values for component " << i );
return;
}
for (unsigned j = 0; j < nuv; ++j)
{
vtkVariant val;
if (!css->GetArgument(0, pos, &val))
{
vtkErrorMacro("Error decoding the " << j << "-th unique value for component " << i);
return;
}
(*this->UniqueValues)[component].insert(val);
}
}
}
}
//-----------------------------------------------------------------------------
......@@ -836,7 +1024,7 @@ void vtkPVArrayInformation::AddUniqueInformationKey(const char* location,
int vtkPVArrayInformation::GetNumberOfInformationKeys()
{
return (this->InformationKeys ? this->InformationKeys->size() : 0);
return static_cast<int>(this->InformationKeys ? this->InformationKeys->size() : 0);
}
const char* vtkPVArrayInformation::GetInformationKeyLocation(int index)
......@@ -869,3 +1057,61 @@ int vtkPVArrayInformation::HasInformationKey(const char* location,
}
return 0;
}
void vtkPVArrayInformation::AddUniqueValues( vtkPVArrayInformation* info )
{
if ( ! info->UniqueValues )
{ // Must have too many values, so erase our list.
delete this->UniqueValues;
this->UniqueValues = 0;
return;
}
vtkInternalUniqueValues::iterator cit; // component iterator
for ( int i = 0; i <= this->NumberOfComponents; ++ i )
{
cit = info->UniqueValues->find( i );
vtkInternalUniqueValues::mapped_type::iterator vit; // iterator over values of component cit->first.
bool tooManyValues = false;
if ( cit == info->UniqueValues->end() )
{ // info had too many values to be rendered as categorical data.
tooManyValues = true;
}
else
{ // Add info's values to our list of unique keys
for ( vit = cit->second.begin(); vit != cit->second.end(); ++ vit )
{
if ( (*this->UniqueValues)[i].insert( *vit ).second && this->UniqueValues->size() > VTK_MAX_CATEGORICAL_VALS - 1 )
break;
}
if ( this->UniqueValues->size() > VTK_MAX_CATEGORICAL_VALS - 1 )
tooManyValues = true;
}
// If the union of values is too large, delete the list of values
if ( tooManyValues )
{
this->UniqueValues->erase( i );
}
}
}
vtkAbstractArray* vtkPVArrayInformation::GetUniqueComponentValuesIfFDiscrete( int component )
{
vtkInternalUniqueValues::iterator compEntry;
unsigned nv;
if (
! this->UniqueValues ||
( compEntry = this->UniqueValues->find( component ) ) == this->UniqueValues->end() ||
( nv = static_cast<unsigned>(compEntry->second.size()) ) == 0
)
return 0;
vtkVariantArray* va = vtkVariantArray::New();
vtkInternalUniqueValues::mapped_type::iterator vit;
va->Allocate( nv );
for ( vit = compEntry->second.begin(); vit != compEntry->second.end(); ++ vit )
{
va->InsertNextValue( *vit );
}
return va;
}
......@@ -26,6 +26,7 @@
#include "vtkPVClientServerCoreCoreModule.h" //needed for exports
#include "vtkPVInformation.h"
class vtkAbstractArray;
class vtkClientServerStream;
class vtkStdString;
class vtkStringArray;
......@@ -54,9 +55,9 @@ public:
vtkGetMacro(NumberOfComponents, int);
// Description:
// Set the name for a component. Must be >= 1.
void SetComponentName( vtkIdType component, const char *name );
// Set the name for a component. Must be >= 1.
void SetComponentName( vtkIdType component, const char* name );
//Description:
// Get the component name for a given component.
// Note: the const char* that is returned is only valid
......@@ -73,36 +74,36 @@ public:
// Range for component -1 is the range of the vector magnitude.
// The number of components should be set before these ranges.
void SetComponentRange(int comp, double min, double max);
void SetComponentRange(int comp, double *range)
void SetComponentRange(int comp, double* range)
{ this->SetComponentRange(comp, range[0], range[1]);}
double *GetComponentRange(int component);
void GetComponentRange(int comp, double *range);
double* GetComponentRange(int component);
void GetComponentRange(int comp, double* range);
// Description:
// This method return the Min and Max possible range of the native
// data type. For example if a vtkScalars consists of unsigned char
// data these will return (0,255).
// data these will return (0,255).
// Nothing particular for 12bits data is done
void GetDataTypeRange(double range[2]);
// Description:
// Returns 1 if the array can be combined.
// It must have the same name and number of components.
int Compare(vtkPVArrayInformation *info);
int Compare(vtkPVArrayInformation* info);
// Description: