mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'rendering_cpp_cleanup'
362efb637 try to surpress warning for window 3f680a5be Merge branch 'master' into rendering_cpp_cleanup 7bbda42fe clean up Annontations Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <morelandkd@ornl.gov> Merge-request: !3081
This commit is contained in:
commit
e5c6a39172
@ -10,8 +10,6 @@
|
||||
|
||||
#include <vtkm/rendering/AxisAnnotation.h>
|
||||
|
||||
#include <vtkm/cont/ErrorBadType.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
@ -37,7 +35,7 @@ void AxisAnnotation::CalculateTicks(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions,
|
||||
int modifyTickQuantity) const
|
||||
int modifyTickQuantity)
|
||||
{
|
||||
positions.clear();
|
||||
proportions.clear();
|
||||
@ -144,7 +142,7 @@ void AxisAnnotation::CalculateTicks(const vtkm::Range& range,
|
||||
void AxisAnnotation::CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions) const
|
||||
std::vector<vtkm::Float64>& proportions)
|
||||
{
|
||||
positions.clear();
|
||||
proportions.clear();
|
||||
@ -167,7 +165,7 @@ void AxisAnnotation::CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
last_log = first_log + 1;
|
||||
}
|
||||
vtkm::Float64 diff_log = last_log - first_log;
|
||||
vtkm::Int32 step = vtkm::Int32((diff_log + 9) / 10);
|
||||
auto step = vtkm::Int32((diff_log + 9) / 10);
|
||||
|
||||
if (minor)
|
||||
{
|
||||
@ -175,7 +173,7 @@ void AxisAnnotation::CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
last_log += step;
|
||||
}
|
||||
|
||||
for (vtkm::Int32 i = vtkm::Int32(first_log); i <= last_log; i += step)
|
||||
for (auto i = vtkm::Int32(first_log); i <= last_log; i += step)
|
||||
{
|
||||
vtkm::Float64 logpos = i;
|
||||
vtkm::Float64 pos = vtkm::Pow(10, logpos);
|
||||
@ -229,9 +227,5 @@ void AxisAnnotation::CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AxisAnnotation::AxisAnnotation() {}
|
||||
|
||||
AxisAnnotation::~AxisAnnotation() {}
|
||||
}
|
||||
} // namespace vtkm::rendering
|
||||
|
@ -24,20 +24,20 @@ namespace rendering
|
||||
class VTKM_RENDERING_EXPORT AxisAnnotation
|
||||
{
|
||||
protected:
|
||||
void CalculateTicks(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions,
|
||||
int modifyTickQuantity) const;
|
||||
void CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions) const;
|
||||
static void CalculateTicks(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions,
|
||||
int modifyTickQuantity);
|
||||
static void CalculateTicksLogarithmic(const vtkm::Range& range,
|
||||
bool minor,
|
||||
std::vector<vtkm::Float64>& positions,
|
||||
std::vector<vtkm::Float64>& proportions);
|
||||
|
||||
public:
|
||||
AxisAnnotation();
|
||||
AxisAnnotation() = default;
|
||||
|
||||
virtual ~AxisAnnotation();
|
||||
virtual ~AxisAnnotation() = default;
|
||||
|
||||
virtual void Render(const vtkm::rendering::Camera& camera,
|
||||
const vtkm::rendering::WorldAnnotator& worldAnnotator,
|
||||
|
@ -20,7 +20,6 @@ namespace rendering
|
||||
{
|
||||
|
||||
AxisAnnotation2D::AxisAnnotation2D()
|
||||
: AxisAnnotation()
|
||||
{
|
||||
this->AlignH = TextAnnotation::HCenter;
|
||||
this->AlignV = TextAnnotation::VCenter;
|
||||
@ -31,8 +30,6 @@ AxisAnnotation2D::AxisAnnotation2D()
|
||||
this->MoreOrLessTickAdjustment = 0;
|
||||
}
|
||||
|
||||
AxisAnnotation2D::~AxisAnnotation2D() {}
|
||||
|
||||
void AxisAnnotation2D::SetRangeForAutoTicks(const Range& range)
|
||||
{
|
||||
this->TickRange = range;
|
||||
@ -84,12 +81,11 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
|
||||
canvas.AddLine(this->PosX0, this->PosY0, this->PosX1, this->PosY1, this->LineWidth, this->Color);
|
||||
|
||||
// major ticks
|
||||
unsigned int nmajor = (unsigned int)this->ProportionsMajor.size();
|
||||
auto nmajor = (unsigned int)this->ProportionsMajor.size();
|
||||
while (this->Labels.size() < nmajor)
|
||||
{
|
||||
this->Labels.push_back(
|
||||
std::unique_ptr<TextAnnotation>(new vtkm::rendering::TextAnnotationScreen(
|
||||
"test", this->Color, this->FontScale, vtkm::Vec2f_32(0, 0), 0)));
|
||||
this->Labels.push_back(std::make_unique<TextAnnotationScreen>(
|
||||
"test", this->Color, this->FontScale, vtkm::Vec2f_32(0, 0)));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
@ -116,8 +112,7 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
|
||||
this->Labels[i]->SetText(numberToString.str());
|
||||
//if (fabs(this->PositionsMajor[i]) < 1e-10)
|
||||
// this->Labels[i]->SetText("0");
|
||||
TextAnnotation* tempBase = this->Labels[i].get();
|
||||
TextAnnotationScreen* tempDerived = static_cast<TextAnnotationScreen*>(tempBase);
|
||||
auto* tempDerived = dynamic_cast<TextAnnotationScreen*>(this->Labels[i].get());
|
||||
tempDerived->SetPosition(vtkm::Float32(xs), vtkm::Float32(ys));
|
||||
|
||||
this->Labels[i]->SetAlignment(this->AlignH, this->AlignV);
|
||||
@ -126,7 +121,7 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
|
||||
// minor ticks
|
||||
if (this->MinorTickSizeX != 0 || this->MinorTickSizeY != 0)
|
||||
{
|
||||
unsigned int nminor = (unsigned int)this->ProportionsMinor.size();
|
||||
auto nminor = (unsigned int)this->ProportionsMinor.size();
|
||||
for (unsigned int i = 0; i < nminor; ++i)
|
||||
{
|
||||
vtkm::Float64 xc = this->PosX0 + (this->PosX1 - this->PosX0) * this->ProportionsMinor[i];
|
||||
@ -140,9 +135,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nmajor; ++i)
|
||||
for (auto& label : this->Labels)
|
||||
{
|
||||
this->Labels[i]->Render(camera, worldAnnotator, canvas);
|
||||
label->Render(camera, worldAnnotator, canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ protected:
|
||||
TextAnnotation::HorizontalAlignment AlignH;
|
||||
TextAnnotation::VerticalAlignment AlignV;
|
||||
std::vector<std::unique_ptr<TextAnnotation>> Labels;
|
||||
// std::vector<TextAnnotation*> Labels;
|
||||
|
||||
std::vector<vtkm::Float64> PositionsMajor;
|
||||
std::vector<vtkm::Float64> ProportionsMajor;
|
||||
@ -54,8 +53,6 @@ protected:
|
||||
public:
|
||||
AxisAnnotation2D();
|
||||
|
||||
~AxisAnnotation2D();
|
||||
|
||||
AxisAnnotation2D(const AxisAnnotation2D&) = delete;
|
||||
|
||||
AxisAnnotation2D& operator=(const AxisAnnotation2D&) = delete;
|
||||
@ -104,8 +101,8 @@ public:
|
||||
void SetLabelFontScale(vtkm::Float32 s)
|
||||
{
|
||||
this->FontScale = s;
|
||||
for (unsigned int i = 0; i < this->Labels.size(); i++)
|
||||
this->Labels[i]->SetScale(s);
|
||||
for (auto& label : this->Labels)
|
||||
label->SetScale(s);
|
||||
}
|
||||
|
||||
void SetRangeForAutoTicks(const vtkm::Range& range);
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <vtkm/rendering/AxisAnnotation3D.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
@ -36,8 +38,6 @@ AxisAnnotation3D::AxisAnnotation3D()
|
||||
{
|
||||
}
|
||||
|
||||
AxisAnnotation3D::~AxisAnnotation3D() {}
|
||||
|
||||
void AxisAnnotation3D::SetTickInvert(bool x, bool y, bool z)
|
||||
{
|
||||
this->Invert[0] = x ? +1.0f : -1.0f;
|
||||
@ -48,9 +48,9 @@ void AxisAnnotation3D::SetTickInvert(bool x, bool y, bool z)
|
||||
void AxisAnnotation3D::SetLabelFontScale(Float64 s)
|
||||
{
|
||||
this->FontScale = s;
|
||||
for (unsigned int i = 0; i < this->Labels.size(); i++)
|
||||
for (auto& label : this->Labels)
|
||||
{
|
||||
this->Labels[i]->SetScale(vtkm::Float32(s));
|
||||
label->SetScale(vtkm::Float32(s));
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,12 +65,11 @@ void AxisAnnotation3D::Render(const Camera& camera,
|
||||
std::vector<vtkm::Float64> proportions;
|
||||
// major ticks
|
||||
CalculateTicks(this->Range, false, positions, proportions, this->MoreOrLessTickAdjustment);
|
||||
unsigned int nmajor = (unsigned int)proportions.size();
|
||||
auto nmajor = (unsigned int)proportions.size();
|
||||
while (this->Labels.size() < nmajor)
|
||||
{
|
||||
this->Labels.push_back(
|
||||
std::unique_ptr<TextAnnotationBillboard>(new vtkm::rendering::TextAnnotationBillboard(
|
||||
"test", this->Color, vtkm::Float32(this->FontScale), vtkm::Vec3f_32(0, 0, 0), 0)));
|
||||
this->Labels.push_back(std::make_unique<TextAnnotationBillboard>(
|
||||
"test", this->Color, vtkm::Float32(this->FontScale), vtkm::Vec3f_32(0, 0, 0)));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
@ -144,15 +143,12 @@ void AxisAnnotation3D::Render(const Camera& camera,
|
||||
this->Labels[i]->SetPosition(vtkm::Float32(tickPos[0] - tickSize[0]),
|
||||
vtkm::Float32(tickPos[1] - tickSize[1]),
|
||||
vtkm::Float32(tickPos[2] - tickSize[2]));
|
||||
vtkm::Vec3f_32 pp(vtkm::Float32(tickPos[0] - tickSize[0]),
|
||||
vtkm::Float32(tickPos[1] - tickSize[1]),
|
||||
vtkm::Float32(tickPos[2] - tickSize[2]));
|
||||
this->Labels[i]->SetAlignment(TextAnnotation::HCenter, TextAnnotation::VCenter);
|
||||
}
|
||||
|
||||
// minor ticks
|
||||
CalculateTicks(this->Range, true, positions, proportions, this->MoreOrLessTickAdjustment);
|
||||
unsigned int nminor = (unsigned int)proportions.size();
|
||||
auto nminor = (unsigned int)proportions.size();
|
||||
for (unsigned int i = 0; i < nminor; ++i)
|
||||
{
|
||||
vtkm::Vec3f_64 tickPos = proportions[i] * (this->Point1 - this->Point0) + this->Point0;
|
||||
@ -197,9 +193,9 @@ void AxisAnnotation3D::Render(const Camera& camera,
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nmajor; ++i)
|
||||
for (auto& label : this->Labels)
|
||||
{
|
||||
this->Labels[i]->Render(camera, worldAnnotator, canvas);
|
||||
label->Render(camera, worldAnnotator, canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <vtkm/rendering/TextAnnotationBillboard.h>
|
||||
#include <vtkm/rendering/WorldAnnotator.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -49,8 +49,6 @@ protected:
|
||||
public:
|
||||
AxisAnnotation3D();
|
||||
|
||||
~AxisAnnotation3D();
|
||||
|
||||
AxisAnnotation3D(const AxisAnnotation3D&) = delete;
|
||||
|
||||
AxisAnnotation3D& operator=(const AxisAnnotation3D&) = delete;
|
||||
@ -111,9 +109,9 @@ public:
|
||||
this->SetRange(vtkm::Range(lower, upper));
|
||||
}
|
||||
|
||||
virtual void Render(const vtkm::rendering::Camera& camera,
|
||||
const vtkm::rendering::WorldAnnotator& worldAnnotator,
|
||||
vtkm::rendering::Canvas& canvas) override;
|
||||
void Render(const vtkm::rendering::Camera& camera,
|
||||
const vtkm::rendering::WorldAnnotator& worldAnnotator,
|
||||
vtkm::rendering::Canvas& canvas) override;
|
||||
};
|
||||
}
|
||||
} //namespace vtkm::rendering
|
||||
|
@ -25,7 +25,7 @@ TextAnnotation::TextAnnotation(const std::string& text,
|
||||
{
|
||||
}
|
||||
|
||||
TextAnnotation::~TextAnnotation() {}
|
||||
TextAnnotation::~TextAnnotation() = default;
|
||||
|
||||
void TextAnnotation::SetText(const std::string& text)
|
||||
{
|
||||
|
@ -28,8 +28,6 @@ TextAnnotationBillboard::TextAnnotationBillboard(const std::string& text,
|
||||
{
|
||||
}
|
||||
|
||||
TextAnnotationBillboard::~TextAnnotationBillboard() {}
|
||||
|
||||
void TextAnnotationBillboard::SetPosition(const vtkm::Vec3f_32& position)
|
||||
{
|
||||
this->Position = position;
|
||||
|
@ -30,8 +30,6 @@ public:
|
||||
const vtkm::Vec3f_32& position,
|
||||
vtkm::Float32 angleDegrees = 0);
|
||||
|
||||
~TextAnnotationBillboard();
|
||||
|
||||
void SetPosition(const vtkm::Vec3f_32& position);
|
||||
|
||||
void SetPosition(vtkm::Float32 posx, vtkm::Float32 posy, vtkm::Float32 posz);
|
||||
|
@ -26,8 +26,6 @@ TextAnnotationScreen::TextAnnotationScreen(const std::string& text,
|
||||
{
|
||||
}
|
||||
|
||||
TextAnnotationScreen::~TextAnnotationScreen() {}
|
||||
|
||||
void TextAnnotationScreen::SetPosition(const vtkm::Vec2f_32& position)
|
||||
{
|
||||
this->Position = position;
|
||||
|
@ -30,8 +30,6 @@ public:
|
||||
const vtkm::Vec2f_32& position,
|
||||
vtkm::Float32 angleDegrees = 0);
|
||||
|
||||
~TextAnnotationScreen();
|
||||
|
||||
void SetPosition(const vtkm::Vec2f_32& position);
|
||||
|
||||
void SetPosition(vtkm::Float32 posx, vtkm::Float32 posy);
|
||||
|
@ -51,7 +51,7 @@ void WorldAnnotator::AddText(const vtkm::Vec3f_32& origin,
|
||||
const vtkm::Vec2f_32& anchor,
|
||||
const vtkm::rendering::Color& color,
|
||||
const std::string& text,
|
||||
const vtkm::Float32 depth) const
|
||||
vtkm::Float32 depth) const
|
||||
{
|
||||
vtkm::Vec3f_32 n = vtkm::Cross(right, up);
|
||||
vtkm::Normalize(n);
|
||||
|
@ -27,7 +27,7 @@ class Canvas;
|
||||
class VTKM_RENDERING_EXPORT WorldAnnotator
|
||||
{
|
||||
public:
|
||||
WorldAnnotator(const vtkm::rendering::Canvas* canvas);
|
||||
explicit WorldAnnotator(const vtkm::rendering::Canvas* canvas);
|
||||
|
||||
void AddLine(const vtkm::Vec3f_64& point0,
|
||||
const vtkm::Vec3f_64& point1,
|
||||
@ -63,7 +63,7 @@ public:
|
||||
const vtkm::Vec2f_32& anchor,
|
||||
const vtkm::rendering::Color& color,
|
||||
const std::string& text,
|
||||
const vtkm::Float32 depth = 0.f) const;
|
||||
vtkm::Float32 depth = 0.f) const;
|
||||
|
||||
VTKM_CONT
|
||||
void AddText(vtkm::Float32 originX,
|
||||
|
Loading…
Reference in New Issue
Block a user