mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Updating leak fix to use uniq_ptr.
This commit is contained in:
parent
70c50f72e5
commit
7906e89ed4
@ -43,11 +43,6 @@ AxisAnnotation2D::AxisAnnotation2D()
|
||||
|
||||
AxisAnnotation2D::~AxisAnnotation2D()
|
||||
{
|
||||
for (int i = 0; i < Labels.size(); i++)
|
||||
{
|
||||
delete Labels[i];
|
||||
}
|
||||
Labels.clear();
|
||||
}
|
||||
|
||||
void AxisAnnotation2D::SetRangeForAutoTicks(const Range& range)
|
||||
@ -104,8 +99,9 @@ void AxisAnnotation2D::Render(const vtkm::rendering::Camera& camera,
|
||||
unsigned int nmajor = (unsigned int)this->ProportionsMajor.size();
|
||||
while (this->Labels.size() < nmajor)
|
||||
{
|
||||
this->Labels.push_back(new vtkm::rendering::TextAnnotationScreen(
|
||||
"test", this->Color, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0));
|
||||
this->Labels.push_back(
|
||||
std::move(std::unique_ptr<TextAnnotation>(new vtkm::rendering::TextAnnotationScreen(
|
||||
"test", this->Color, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0))));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
@ -132,7 +128,9 @@ 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");
|
||||
((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);
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ protected:
|
||||
|
||||
TextAnnotation::HorizontalAlignment AlignH;
|
||||
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> ProportionsMajor;
|
||||
|
@ -48,11 +48,6 @@ AxisAnnotation3D::AxisAnnotation3D()
|
||||
|
||||
AxisAnnotation3D::~AxisAnnotation3D()
|
||||
{
|
||||
for (int i = 0; i < Labels.size(); i++)
|
||||
{
|
||||
delete Labels[i];
|
||||
}
|
||||
Labels.clear();
|
||||
}
|
||||
|
||||
void AxisAnnotation3D::SetTickInvert(bool x, bool y, bool z)
|
||||
@ -85,11 +80,12 @@ void AxisAnnotation3D::Render(const Camera& camera,
|
||||
unsigned int nmajor = (unsigned int)proportions.size();
|
||||
while (this->Labels.size() < nmajor)
|
||||
{
|
||||
this->Labels.push_back(new TextAnnotationBillboard("test",
|
||||
this->Color,
|
||||
vtkm::Float32(this->FontScale),
|
||||
vtkm::Vec<vtkm::Float32, 3>(0, 0, 0),
|
||||
0));
|
||||
this->Labels.push_back(std::move(std::unique_ptr<TextAnnotationBillboard>(
|
||||
new vtkm::rendering::TextAnnotationBillboard("test",
|
||||
this->Color,
|
||||
vtkm::Float32(this->FontScale),
|
||||
vtkm::Vec<vtkm::Float32, 3>(0, 0, 0),
|
||||
0))));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
|
@ -53,7 +53,7 @@ protected:
|
||||
vtkm::Float32 FontOffset;
|
||||
vtkm::Float32 LineWidth;
|
||||
vtkm::rendering::Color Color;
|
||||
std::vector<TextAnnotationBillboard*> Labels;
|
||||
std::vector<std::unique_ptr<TextAnnotationBillboard>> Labels;
|
||||
int MoreOrLessTickAdjustment;
|
||||
|
||||
public:
|
||||
|
@ -33,11 +33,6 @@ ColorLegendAnnotation::ColorLegendAnnotation()
|
||||
|
||||
ColorLegendAnnotation::~ColorLegendAnnotation()
|
||||
{
|
||||
for (int i = 0; i < Annot.size(); i++)
|
||||
{
|
||||
delete Annot[i];
|
||||
}
|
||||
Annot.clear();
|
||||
}
|
||||
|
||||
void ColorLegendAnnotation::Clear()
|
||||
@ -74,13 +69,14 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera,
|
||||
|
||||
while (this->Annot.size() < this->Labels.size())
|
||||
{
|
||||
this->Annot.push_back(new vtkm::rendering::TextAnnotationScreen(
|
||||
"test", this->LabelColor, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0));
|
||||
this->Annot.push_back(
|
||||
std::move(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)
|
||||
{
|
||||
TextAnnotationScreen* txt = Annot[i];
|
||||
TextAnnotationScreen* txt = Annot[i].get();
|
||||
txt->SetText(Labels[i]);
|
||||
txt->SetPosition(r + .02f, (b + t) / 2.f);
|
||||
txt->SetAlignment(TextAnnotationScreen::Left, TextAnnotationScreen::VCenter);
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
vtkm::Float32 FontScale;
|
||||
vtkm::rendering::Color LabelColor;
|
||||
std::vector<std::string> Labels;
|
||||
std::vector<TextAnnotationScreen*> Annot;
|
||||
std::vector<std::unique_ptr<TextAnnotationScreen>> Annot;
|
||||
std::vector<vtkm::rendering::Color> ColorSwatchList;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user