mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Remove default constructor for ColorTable
The problem is that there is no good "default" constructor for ColorTable. The previous default constructor created an empty color table, but that would be confusing if someone actually tried to use it. We could set ot to the default preset, but the default preset uses the diverging color map, which could foul people up if they actually want to edit or create their own color map. Instead, force the declaration of ColorTable to indicate what you plan to do with it.
This commit is contained in:
parent
cb8a05c71b
commit
a3b2c3931d
@ -166,7 +166,7 @@ public:
|
||||
///
|
||||
/// Note: The color table will have 0 entries
|
||||
/// Note: The alpha table will have 0 entries
|
||||
ColorTable(ColorSpace space = ColorSpace::LAB);
|
||||
explicit ColorTable(ColorSpace space);
|
||||
|
||||
/// Construct a color table with a 2 positions
|
||||
///
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
|
||||
//verify that we can get the presets
|
||||
std::set<std::string> names = table.GetPresets();
|
||||
VTKM_TEST_ASSERT(names.size() == 14, "incorrect number of names in preset set");
|
||||
VTKM_TEST_ASSERT(names.size() == 15, "incorrect number of names in preset set");
|
||||
|
||||
VTKM_TEST_ASSERT(names.count("inferno") == 1, "names should contain inferno");
|
||||
VTKM_TEST_ASSERT(names.count("black-body radiation") == 1,
|
||||
@ -288,8 +288,7 @@ public:
|
||||
vtkm::Range range{ 0.0, 50.0 };
|
||||
auto diverging = vtkm::cont::ColorSpace::DIVERGING;
|
||||
|
||||
vtkm::cont::ColorTable table;
|
||||
table.LoadPreset("Cool to Warm");
|
||||
vtkm::cont::ColorTable table(vtkm::cont::ColorTable::Preset::COOL_TO_WARM);
|
||||
VTKM_TEST_ASSERT(table.GetColorSpace() == diverging,
|
||||
"color space not switched when loading preset");
|
||||
|
||||
@ -426,8 +425,7 @@ public:
|
||||
static void TestSampling()
|
||||
{
|
||||
|
||||
vtkm::cont::ColorTable table;
|
||||
table.LoadPreset("Linear green");
|
||||
vtkm::cont::ColorTable table(vtkm::cont::ColorTable::Preset::LINEAR_GREEN);
|
||||
VTKM_TEST_ASSERT((table.GetRange() == vtkm::Range{ 0.0, 1.0 }),
|
||||
"loading linear green table failed with wrong range");
|
||||
VTKM_TEST_ASSERT((table.GetNumberOfPoints() == 21),
|
||||
@ -453,8 +451,7 @@ public:
|
||||
{
|
||||
//build a color table with clamping off and verify that sampling works
|
||||
vtkm::Range range{ 0.0, 50.0 };
|
||||
vtkm::cont::ColorTable table;
|
||||
table.LoadPreset("Cool to Warm");
|
||||
vtkm::cont::ColorTable table(vtkm::cont::ColorTable::Preset::COOL_TO_WARM);
|
||||
table.RescaleToRange(range);
|
||||
table.SetClampingOff();
|
||||
table.SetAboveRangeColor(vtkm::Vec<float, 3>{ 1.0f, 0.0f, 0.0f }); //red
|
||||
|
@ -32,8 +32,7 @@ void TestFieldToColors()
|
||||
|
||||
//build a color table with clamping off and verify that sampling works
|
||||
vtkm::Range range{ 0.0, 50.0 };
|
||||
vtkm::cont::ColorTable table;
|
||||
table.LoadPreset(vtkm::cont::ColorTable::Preset::COOL_TO_WARM);
|
||||
vtkm::cont::ColorTable table(vtkm::cont::ColorTable::Preset::COOL_TO_WARM);
|
||||
table.RescaleToRange(range);
|
||||
table.SetClampingOff();
|
||||
table.SetAboveRangeColor(vtkm::Vec<float, 3>{ 1.0f, 0.0f, 0.0f }); //red
|
||||
|
@ -38,17 +38,6 @@ struct Actor::InternalsType
|
||||
vtkm::Range ScalarRange;
|
||||
vtkm::Bounds SpatialBounds;
|
||||
|
||||
VTKM_CONT
|
||||
InternalsType(const vtkm::cont::DynamicCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField)
|
||||
: Cells(cells)
|
||||
, Coordinates(coordinates)
|
||||
, ScalarField(scalarField)
|
||||
{
|
||||
this->ColorTable.LoadPreset("Cool to Warm");
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
InternalsType(const vtkm::cont::DynamicCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
@ -65,7 +54,7 @@ struct Actor::InternalsType
|
||||
InternalsType(const vtkm::cont::DynamicCellSet& cells,
|
||||
const vtkm::cont::CoordinateSystem& coordinates,
|
||||
const vtkm::cont::Field& scalarField,
|
||||
const vtkm::cont::ColorTable& colorTable)
|
||||
const vtkm::cont::ColorTable& colorTable = vtkm::cont::ColorTable::Preset::DEFAULT)
|
||||
: Cells(cells)
|
||||
, Coordinates(coordinates)
|
||||
, ScalarField(scalarField)
|
||||
|
@ -27,11 +27,11 @@ namespace rendering
|
||||
{
|
||||
|
||||
ColorBarAnnotation::ColorBarAnnotation()
|
||||
: ColorTable(vtkm::cont::ColorSpace::LAB)
|
||||
, Position(vtkm::Range(-0.88, +0.88), vtkm::Range(+0.87, +0.92), vtkm::Range(0, 0))
|
||||
, Horizontal(true)
|
||||
, FieldName("")
|
||||
{
|
||||
vtkm::Bounds bounds(vtkm::Range(-0.88, +0.88), vtkm::Range(+0.87, +0.92), vtkm::Range(0, 0));
|
||||
Position = bounds;
|
||||
Horizontal = true;
|
||||
FieldName = "";
|
||||
}
|
||||
|
||||
ColorBarAnnotation::~ColorBarAnnotation()
|
||||
|
Loading…
Reference in New Issue
Block a user