Commit e28b274d authored by James Kress's avatar James Kress Committed by Kitware Robot

Merge topic 'rendering-label-leak'

a79b4c2f Removing move command to remove warnings.
e19e61f1 Merge branch 'rendering-label-leak' of https://gitlab.kitware.com/jameskress/vtk-m into rendering-label-leak
02a67d64 Merge remote-tracking branch 'upstream/master' into rendering-label-leak
3bab4087 Adding delete and assignment oeprators to annotations.
e3ccd7f8 Adding previous cmake fix.
9f32bbe0 Merge branch 'rendering-label-leak' of https://gitlab.kitware.com/jameskress/vtk-m into rendering-label-leak
7906e89e Updating leak fix to use uniq_ptr.
b92c4801 Update CMakeLists.txt
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard's avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1131
parents de79765c a79b4c2f
...@@ -99,8 +99,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera, ...@@ -99,8 +99,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
unsigned int nmajor = (unsigned int)this->ProportionsMajor.size(); unsigned int nmajor = (unsigned int)this->ProportionsMajor.size();
while (this->Labels.size() < nmajor) while (this->Labels.size() < nmajor)
{ {
this->Labels.push_back(new vtkm::rendering::TextAnnotationScreen( this->Labels.push_back(
"test", this->Color, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0)); std::unique_ptr<TextAnnotation>(new vtkm::rendering::TextAnnotationScreen(
"test", this->Color, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0)));
} }
std::stringstream numberToString; std::stringstream numberToString;
...@@ -127,7 +128,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera, ...@@ -127,7 +128,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
this->Labels[i]->SetText(numberToString.str()); this->Labels[i]->SetText(numberToString.str());
//if (fabs(this->PositionsMajor[i]) < 1e-10) //if (fabs(this->PositionsMajor[i]) < 1e-10)
// this->Labels[i]->SetText("0"); // this->Labels[i]->SetText("0");
((TextAnnotationScreen*)(this->Labels[i]))->SetPosition(vtkm::Float32(xs), vtkm::Float32(ys)); TextAnnotation* tempBase = this->Labels[i].get();
TextAnnotationScreen* tempDerived = static_cast<TextAnnotationScreen*>(tempBase);
tempDerived->SetPosition(vtkm::Float32(xs), vtkm::Float32(ys));
this->Labels[i]->SetAlignment(this->AlignH, this->AlignV); this->Labels[i]->SetAlignment(this->AlignH, this->AlignV);
} }
......
...@@ -50,7 +50,8 @@ protected: ...@@ -50,7 +50,8 @@ protected:
TextAnnotation::HorizontalAlignment AlignH; TextAnnotation::HorizontalAlignment AlignH;
TextAnnotation::VerticalAlignment AlignV; TextAnnotation::VerticalAlignment AlignV;
std::vector<TextAnnotation*> Labels; std::vector<std::unique_ptr<TextAnnotation>> Labels;
// std::vector<TextAnnotation*> Labels;
std::vector<vtkm::Float64> PositionsMajor; std::vector<vtkm::Float64> PositionsMajor;
std::vector<vtkm::Float64> ProportionsMajor; std::vector<vtkm::Float64> ProportionsMajor;
...@@ -65,6 +66,10 @@ public: ...@@ -65,6 +66,10 @@ public:
~AxisAnnotation2D(); ~AxisAnnotation2D();
AxisAnnotation2D(const AxisAnnotation2D&) = delete;
AxisAnnotation2D& operator=(const AxisAnnotation2D&) = delete;
void SetLogarithmic(bool l) { this->Logarithmic = l; } void SetLogarithmic(bool l) { this->Logarithmic = l; }
void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; } void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; }
......
...@@ -80,11 +80,12 @@ void AxisAnnotation3D::Render(const Camera& camera, ...@@ -80,11 +80,12 @@ void AxisAnnotation3D::Render(const Camera& camera,
unsigned int nmajor = (unsigned int)proportions.size(); unsigned int nmajor = (unsigned int)proportions.size();
while (this->Labels.size() < nmajor) while (this->Labels.size() < nmajor)
{ {
this->Labels.push_back(new TextAnnotationBillboard("test", this->Labels.push_back(std::unique_ptr<TextAnnotationBillboard>(
this->Color, new vtkm::rendering::TextAnnotationBillboard("test",
vtkm::Float32(this->FontScale), this->Color,
vtkm::Vec<vtkm::Float32, 3>(0, 0, 0), vtkm::Float32(this->FontScale),
0)); vtkm::Vec<vtkm::Float32, 3>(0, 0, 0),
0)));
} }
std::stringstream numberToString; std::stringstream numberToString;
......
...@@ -53,7 +53,7 @@ protected: ...@@ -53,7 +53,7 @@ protected:
vtkm::Float32 FontOffset; vtkm::Float32 FontOffset;
vtkm::Float32 LineWidth; vtkm::Float32 LineWidth;
vtkm::rendering::Color Color; vtkm::rendering::Color Color;
std::vector<TextAnnotationBillboard*> Labels; std::vector<std::unique_ptr<TextAnnotationBillboard>> Labels;
int MoreOrLessTickAdjustment; int MoreOrLessTickAdjustment;
public: public:
...@@ -61,6 +61,10 @@ public: ...@@ -61,6 +61,10 @@ public:
~AxisAnnotation3D(); ~AxisAnnotation3D();
AxisAnnotation3D(const AxisAnnotation3D&) = delete;
AxisAnnotation3D& operator=(const AxisAnnotation3D&) = delete;
VTKM_CONT VTKM_CONT
void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; } void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; }
......
...@@ -69,13 +69,14 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera, ...@@ -69,13 +69,14 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera,
while (this->Annot.size() < this->Labels.size()) while (this->Annot.size() < this->Labels.size())
{ {
this->Annot.push_back(new vtkm::rendering::TextAnnotationScreen( this->Annot.push_back(
"test", this->LabelColor, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0)); std::unique_ptr<TextAnnotationScreen>(new vtkm::rendering::TextAnnotationScreen(
"test", this->LabelColor, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0)));
} }
for (unsigned int i = 0; i < this->Annot.size(); ++i) for (unsigned int i = 0; i < this->Annot.size(); ++i)
{ {
TextAnnotationScreen* txt = Annot[i]; TextAnnotationScreen* txt = Annot[i].get();
txt->SetText(Labels[i]); txt->SetText(Labels[i]);
txt->SetPosition(r + .02f, (b + t) / 2.f); txt->SetPosition(r + .02f, (b + t) / 2.f);
txt->SetAlignment(TextAnnotationScreen::Left, TextAnnotationScreen::VCenter); txt->SetAlignment(TextAnnotationScreen::Left, TextAnnotationScreen::VCenter);
......
...@@ -39,12 +39,14 @@ private: ...@@ -39,12 +39,14 @@ private:
vtkm::Float32 FontScale; vtkm::Float32 FontScale;
vtkm::rendering::Color LabelColor; vtkm::rendering::Color LabelColor;
std::vector<std::string> Labels; std::vector<std::string> Labels;
std::vector<TextAnnotationScreen*> Annot; std::vector<std::unique_ptr<TextAnnotationScreen>> Annot;
std::vector<vtkm::rendering::Color> ColorSwatchList; std::vector<vtkm::rendering::Color> ColorSwatchList;
public: public:
ColorLegendAnnotation(); ColorLegendAnnotation();
~ColorLegendAnnotation(); ~ColorLegendAnnotation();
ColorLegendAnnotation(const ColorLegendAnnotation&) = delete;
ColorLegendAnnotation& operator=(const ColorLegendAnnotation&) = delete;
void Clear(); void Clear();
void AddItem(const std::string& label, vtkm::rendering::Color color); void AddItem(const std::string& label, vtkm::rendering::Color color);
......
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