Merge topic 'rendering_cpp_cleanup'

c8caecfef try to supress warning on windows
85b4b18fc properly call make_unique
10bcf618f non-virtual color table annotations

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland <morelandkd@ornl.gov>
Merge-request: !3077
This commit is contained in:
Li-Ta Lo 2023-06-07 21:59:46 +00:00 committed by Kitware Robot
commit 75d0dd9bf8
4 changed files with 13 additions and 22 deletions

@ -20,12 +20,9 @@ ColorBarAnnotation::ColorBarAnnotation()
: ColorTable(vtkm::ColorSpace::Lab)
, Position(vtkm::Range(-0.88, +0.88), vtkm::Range(+0.87, +0.92), vtkm::Range(0, 0))
, Horizontal(true)
, FieldName("")
{
}
ColorBarAnnotation::~ColorBarAnnotation() {}
void ColorBarAnnotation::SetFieldName(const std::string& fieldName)
{
FieldName = fieldName;
@ -83,7 +80,7 @@ void ColorBarAnnotation::Render(const vtkm::rendering::Camera& camera,
this->Axis.SetMinorTickSize(0, 0, 0); // no minor ticks
this->Axis.Render(camera, worldAnnotator, canvas);
if (FieldName != "")
if (!FieldName.empty())
{
vtkm::Vec2f_32 labelPos;
if (Horizontal)

@ -35,8 +35,6 @@ protected:
public:
ColorBarAnnotation();
virtual ~ColorBarAnnotation();
VTKM_CONT
void SetColorTable(const vtkm::cont::ColorTable& colorTable) { this->ColorTable = colorTable; }
@ -56,9 +54,9 @@ public:
VTKM_CONT
void SetPosition(const vtkm::Bounds& position);
virtual void Render(const vtkm::rendering::Camera& camera,
const vtkm::rendering::WorldAnnotator& worldAnnotator,
vtkm::rendering::Canvas& canvas);
void Render(const vtkm::rendering::Camera& camera,
const vtkm::rendering::WorldAnnotator& worldAnnotator,
vtkm::rendering::Canvas& canvas);
};
}
} //namespace vtkm::rendering

@ -21,8 +21,6 @@ ColorLegendAnnotation::ColorLegendAnnotation()
this->LabelColor = vtkm::rendering::Color::white;
}
ColorLegendAnnotation::~ColorLegendAnnotation() {}
void ColorLegendAnnotation::Clear()
{
this->Labels.clear();
@ -42,9 +40,9 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera,
vtkm::Float32 l = -0.95f, r = -0.90f;
vtkm::Float32 b = +0.90f, t = +0.95f;
for (unsigned int i = 0; i < this->ColorSwatchList.size(); ++i)
for (auto& color : this->ColorSwatchList)
{
canvas.AddColorSwatch(l, b, l, t, r, t, r, b, this->ColorSwatchList[i]);
canvas.AddColorSwatch(l, b, l, t, r, t, r, b, color);
b -= 0.07f;
t -= 0.07f;
}
@ -57,9 +55,8 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera,
while (this->Annot.size() < this->Labels.size())
{
this->Annot.push_back(
std::unique_ptr<TextAnnotationScreen>(new vtkm::rendering::TextAnnotationScreen(
"test", this->LabelColor, this->FontScale, vtkm::Vec2f_32(0, 0), 0)));
this->Annot.push_back(std::make_unique<TextAnnotationScreen>(
"test", this->LabelColor, this->FontScale, vtkm::Vec2f_32(0, 0)));
}
for (unsigned int i = 0; i < this->Annot.size(); ++i)

@ -34,7 +34,6 @@ private:
public:
ColorLegendAnnotation();
~ColorLegendAnnotation();
ColorLegendAnnotation(const ColorLegendAnnotation&) = delete;
ColorLegendAnnotation& operator=(const ColorLegendAnnotation&) = delete;
@ -46,13 +45,13 @@ public:
void SetLabelFontScale(vtkm::Float32 s)
{
this->FontScale = s;
for (unsigned int i = 0; i < this->Annot.size(); i++)
this->Annot[i]->SetScale(s);
for (auto& annot : this->Annot)
annot->SetScale(s);
}
virtual void Render(const vtkm::rendering::Camera&,
const vtkm::rendering::WorldAnnotator& annotator,
vtkm::rendering::Canvas& canvas);
void Render(const vtkm::rendering::Camera&,
const vtkm::rendering::WorldAnnotator& annotator,
vtkm::rendering::Canvas& canvas);
};
}
} //namespace vtkm::rendering