Adding ability to modify axis color as well as legend label color.

This commit is contained in:
James 2017-08-02 12:32:19 -04:00
parent bd561b1e50
commit 1eb585121c
7 changed files with 21 additions and 12 deletions

@ -73,6 +73,8 @@ void ColorLegendAnnotation::Render(const vtkm::rendering::Camera& camera,
"test", this->LabelColor, this->FontScale, vtkm::Vec<vtkm::Float32, 2>(0, 0), 0));
}
std::cerr << this->LabelColor << std::endl;
for (unsigned int i = 0; i < this->Annot.size(); ++i)
{
TextAnnotationScreen* txt = Annot[i];

@ -78,8 +78,8 @@ void View::SaveAs(const std::string& fileName) const
void View::RenderAnnotations()
{
for (unsigned int i = 0; i < annotations.size(); ++i)
annotations[i]->Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
for (unsigned int i = 0; i < Annotations.size(); ++i)
Annotations[i]->Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
}
void View::SetupForWorldSpace(bool viewportClip)

@ -103,10 +103,13 @@ public:
void SaveAs(const std::string& fileName) const;
VTKM_CONT
void ClearAnnotations() { annotations.clear(); }
void SetAxisColor(vtkm::rendering::Color c) { this->AxisColor = c; }
VTKM_CONT
void AddAnnotation(vtkm::rendering::TextAnnotation* ann) { annotations.push_back(ann); }
void ClearAnnotations() { Annotations.clear(); }
VTKM_CONT
void AddAnnotation(vtkm::rendering::TextAnnotation* ann) { Annotations.push_back(ann); }
protected:
void SetupForWorldSpace(bool viewportClip = true);
@ -115,12 +118,14 @@ protected:
void RenderAnnotations();
vtkm::rendering::Color AxisColor = vtkm::rendering::Color::white;
private:
vtkm::rendering::Scene Scene;
std::shared_ptr<vtkm::rendering::Mapper> MapperPointer;
std::shared_ptr<vtkm::rendering::Canvas> CanvasPointer;
std::shared_ptr<vtkm::rendering::WorldAnnotator> WorldAnnotatorPointer;
std::vector<vtkm::rendering::TextAnnotation*> annotations;
std::vector<vtkm::rendering::TextAnnotation*> Annotations;
vtkm::rendering::Camera Camera;
};
}

@ -86,7 +86,7 @@ void View1D::RenderScreenAnnotations()
viewportBottom,
viewportTop);
this->HorizontalAxisAnnotation.SetColor(vtkm::rendering::Color(1, 1, 1));
this->HorizontalAxisAnnotation.SetColor(AxisColor);
this->HorizontalAxisAnnotation.SetScreenPosition(
viewportLeft, viewportBottom, viewportRight, viewportBottom);
vtkm::Bounds viewRange = this->GetCamera().GetViewRange2D();
@ -102,7 +102,7 @@ void View1D::RenderScreenAnnotations()
vtkm::Float32 windowaspect =
vtkm::Float32(this->GetCanvas().GetWidth()) / vtkm::Float32(this->GetCanvas().GetHeight());
this->VerticalAxisAnnotation.SetColor(vtkm::rendering::Color(1, 1, 1));
this->VerticalAxisAnnotation.SetColor(AxisColor);
this->VerticalAxisAnnotation.SetScreenPosition(
viewportLeft, viewportBottom, viewportLeft, viewportTop);
this->VerticalAxisAnnotation.SetRangeForAutoTicks(viewRange.Y.Min, viewRange.Y.Max);

@ -49,8 +49,10 @@ public:
void RenderScreenAnnotations() VTKM_OVERRIDE;
void RenderWorldAnnotations() VTKM_OVERRIDE;
void RenderColorLegendAnnotations();
void EnableLegend();
void DisableLegend();
void SetLegendLabelColor(vtkm::rendering::Color c) { this->Legend.SetLabelColor(c); }
private:
// 1D-specific annotations

@ -82,7 +82,7 @@ void View2D::RenderScreenAnnotations()
viewportBottom,
viewportTop);
this->HorizontalAxisAnnotation.SetColor(vtkm::rendering::Color(1, 1, 1));
this->HorizontalAxisAnnotation.SetColor(AxisColor);
this->HorizontalAxisAnnotation.SetScreenPosition(
viewportLeft, viewportBottom, viewportRight, viewportBottom);
vtkm::Bounds viewRange = this->GetCamera().GetViewRange2D();
@ -97,7 +97,7 @@ void View2D::RenderScreenAnnotations()
vtkm::Float32 windowaspect =
vtkm::Float32(this->GetCanvas().GetWidth()) / vtkm::Float32(this->GetCanvas().GetHeight());
this->VerticalAxisAnnotation.SetColor(Color(1, 1, 1));
this->VerticalAxisAnnotation.SetColor(AxisColor);
this->VerticalAxisAnnotation.SetScreenPosition(
viewportLeft, viewportBottom, viewportLeft, viewportTop);
this->VerticalAxisAnnotation.SetRangeForAutoTicks(viewRange.Y.Min, viewRange.Y.Max);

@ -103,7 +103,7 @@ void View3D::RenderWorldAnnotations()
vtkm::Float64 zrel = vtkm::Abs(dz) / size;
this->XAxisAnnotation.SetAxis(0);
this->XAxisAnnotation.SetColor(Color(1, 1, 1));
this->XAxisAnnotation.SetColor(AxisColor);
this->XAxisAnnotation.SetTickInvert(xtest, ytest, ztest);
this->XAxisAnnotation.SetWorldPosition(
xmin, ytest ? ymin : ymax, ztest ? zmin : zmax, xmax, ytest ? ymin : ymax, ztest ? zmin : zmax);
@ -115,7 +115,7 @@ void View3D::RenderWorldAnnotations()
this->XAxisAnnotation.Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
this->YAxisAnnotation.SetAxis(1);
this->YAxisAnnotation.SetColor(Color(1, 1, 1));
this->YAxisAnnotation.SetColor(AxisColor);
this->YAxisAnnotation.SetTickInvert(xtest, ytest, ztest);
this->YAxisAnnotation.SetWorldPosition(
xtest ? xmin : xmax, ymin, ztest ? zmin : zmax, xtest ? xmin : xmax, ymax, ztest ? zmin : zmax);
@ -127,7 +127,7 @@ void View3D::RenderWorldAnnotations()
this->YAxisAnnotation.Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
this->ZAxisAnnotation.SetAxis(2);
this->ZAxisAnnotation.SetColor(Color(1, 1, 1));
this->ZAxisAnnotation.SetColor(AxisColor);
this->ZAxisAnnotation.SetTickInvert(xtest, ytest, ztest);
this->ZAxisAnnotation.SetWorldPosition(
xtest ? xmin : xmax, ytest ? ymin : ymax, zmin, xtest ? xmin : xmax, ytest ? ymin : ymax, zmax);