VTK-m  2.0
AxisAnnotation2D.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_rendering_AxisAnnotation2D_h
11 #define vtk_m_rendering_AxisAnnotation2D_h
12 
13 #include <vtkm/rendering/vtkm_rendering_export.h>
14 
15 #include <vtkm/Range.h>
16 #include <vtkm/cont/DataSet.h>
18 #include <vtkm/rendering/Camera.h>
19 #include <vtkm/rendering/Canvas.h>
20 #include <vtkm/rendering/Color.h>
23 
24 namespace vtkm
25 {
26 namespace rendering
27 {
28 
29 class VTKM_RENDERING_EXPORT AxisAnnotation2D : public AxisAnnotation
30 {
31 protected:
32  vtkm::Float64 MajorTickSizeX, MajorTickSizeY, MajorTickOffset;
33  vtkm::Float64 MinorTickSizeX, MinorTickSizeY, MinorTickOffset;
34  vtkm::Float64 PosX0, PosY0, PosX1, PosY1;
40 
43  std::vector<std::unique_ptr<TextAnnotation>> Labels;
44  // std::vector<TextAnnotation*> Labels;
45 
46  std::vector<vtkm::Float64> PositionsMajor;
47  std::vector<vtkm::Float64> ProportionsMajor;
48 
49  std::vector<vtkm::Float64> PositionsMinor;
50  std::vector<vtkm::Float64> ProportionsMinor;
51 
53 
54 public:
56 
58 
59  AxisAnnotation2D(const AxisAnnotation2D&) = delete;
60 
61  AxisAnnotation2D& operator=(const AxisAnnotation2D&) = delete;
62 
63  void SetLogarithmic(bool l) { this->Logarithmic = l; }
64 
65  void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; }
66 
67  void SetColor(vtkm::rendering::Color c) { this->Color = c; }
68 
69  void SetLineWidth(vtkm::Float32 lw) { this->LineWidth = lw; }
70 
72  {
76  this->MajorTickSizeX = xlen;
77  this->MajorTickSizeY = ylen;
78  this->MajorTickOffset = offset;
79  }
80 
82  {
83  this->MinorTickSizeX = xlen;
84  this->MinorTickSizeY = ylen;
85  this->MinorTickOffset = offset;
86  }
87 
90  {
91  this->PosX0 = x0;
92  this->PosY0 = y0;
93 
94  this->PosX1 = x1;
95  this->PosY1 = y1;
96  }
97 
99  {
100  this->AlignH = h;
101  this->AlignV = v;
102  }
103 
105  {
106  this->FontScale = s;
107  for (unsigned int i = 0; i < this->Labels.size(); i++)
108  this->Labels[i]->SetScale(s);
109  }
110 
111  void SetRangeForAutoTicks(const vtkm::Range& range);
113  {
114  this->SetRangeForAutoTicks(vtkm::Range(lower, upper));
115  }
116 
117  void SetMajorTicks(const std::vector<vtkm::Float64>& positions,
118  const std::vector<vtkm::Float64>& proportions);
119 
120  void SetMinorTicks(const std::vector<vtkm::Float64>& positions,
121  const std::vector<vtkm::Float64>& proportions);
122 
123  void Render(const vtkm::rendering::Camera& camera,
124  const vtkm::rendering::WorldAnnotator& worldAnnotator,
125  vtkm::rendering::Canvas& canvas) override;
126 };
127 }
128 } //namespace vtkm::rendering
129 
130 #endif // vtk_m_rendering_AxisAnnotation2D_h
vtkm::rendering::Color
It's a color!
Definition: Color.h:28
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::rendering::AxisAnnotation2D::PositionsMinor
std::vector< vtkm::Float64 > PositionsMinor
Definition: AxisAnnotation2D.h:49
vtkm::rendering::AxisAnnotation2D::Color
vtkm::rendering::Color Color
Definition: AxisAnnotation2D.h:38
vtkm::rendering::AxisAnnotation2D::SetScreenPosition
void SetScreenPosition(vtkm::Float64 x0, vtkm::Float64 y0, vtkm::Float64 x1, vtkm::Float64 y1)
Definition: AxisAnnotation2D.h:89
vtkm::rendering::AxisAnnotation2D::SetLogarithmic
void SetLogarithmic(bool l)
Definition: AxisAnnotation2D.h:63
vtkm::rendering::AxisAnnotation2D::SetMinorTickSize
void SetMinorTickSize(vtkm::Float64 xlen, vtkm::Float64 ylen, vtkm::Float64 offset)
Definition: AxisAnnotation2D.h:81
vtkm::rendering::AxisAnnotation2D::SetMoreOrLessTickAdjustment
void SetMoreOrLessTickAdjustment(int offset)
Definition: AxisAnnotation2D.h:65
vtkm::rendering::AxisAnnotation2D::FontScale
vtkm::Float32 FontScale
Definition: AxisAnnotation2D.h:36
vtkm::rendering::AxisAnnotation2D::TickRange
vtkm::Range TickRange
Definition: AxisAnnotation2D.h:35
vtkm::rendering::AxisAnnotation2D::MinorTickSizeY
vtkm::Float64 MinorTickSizeY
Definition: AxisAnnotation2D.h:33
vtkm::rendering::AxisAnnotation2D::Logarithmic
bool Logarithmic
Definition: AxisAnnotation2D.h:39
vtkm::rendering::Canvas
Definition: Canvas.h:34
TextAnnotation.h
vtkm::rendering::AxisAnnotation2D::ProportionsMinor
std::vector< vtkm::Float64 > ProportionsMinor
Definition: AxisAnnotation2D.h:50
vtkm::rendering::AxisAnnotation2D::SetLabelAlignment
void SetLabelAlignment(TextAnnotation::HorizontalAlignment h, TextAnnotation::VerticalAlignment v)
Definition: AxisAnnotation2D.h:98
WorldAnnotator.h
vtkm::rendering::AxisAnnotation2D::SetMajorTickSize
void SetMajorTickSize(vtkm::Float64 xlen, vtkm::Float64 ylen, vtkm::Float64 offset)
Definition: AxisAnnotation2D.h:71
Range.h
vtkm::rendering::AxisAnnotation2D::AlignH
TextAnnotation::HorizontalAlignment AlignH
Definition: AxisAnnotation2D.h:41
vtkm::rendering::AxisAnnotation2D
Definition: AxisAnnotation2D.h:29
vtkm::rendering::AxisAnnotation2D::AlignV
TextAnnotation::VerticalAlignment AlignV
Definition: AxisAnnotation2D.h:42
vtkm::rendering::AxisAnnotation2D::MoreOrLessTickAdjustment
int MoreOrLessTickAdjustment
Definition: AxisAnnotation2D.h:52
vtkm::rendering::WorldAnnotator
Definition: WorldAnnotator.h:27
vtkm::rendering::AxisAnnotation2D::SetLineWidth
void SetLineWidth(vtkm::Float32 lw)
Definition: AxisAnnotation2D.h:69
vtkm::rendering::AxisAnnotation2D::PosY1
vtkm::Float64 PosY1
Definition: AxisAnnotation2D.h:34
vtkm::rendering::AxisAnnotation2D::PositionsMajor
std::vector< vtkm::Float64 > PositionsMajor
Definition: AxisAnnotation2D.h:46
vtkm::rendering::TextAnnotation::VerticalAlignment
VerticalAlignment
Definition: TextAnnotation.h:33
vtkm::rendering::AxisAnnotation2D::LineWidth
vtkm::Float32 LineWidth
Definition: AxisAnnotation2D.h:37
vtkm::rendering::AxisAnnotation2D::SetRangeForAutoTicks
void SetRangeForAutoTicks(vtkm::Float64 lower, vtkm::Float64 upper)
Definition: AxisAnnotation2D.h:112
vtkm::rendering::AxisAnnotation2D::ProportionsMajor
std::vector< vtkm::Float64 > ProportionsMajor
Definition: AxisAnnotation2D.h:47
vtkm::Float32
float Float32
Definition: Types.h:154
Camera.h
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::rendering::AxisAnnotation2D::Labels
std::vector< std::unique_ptr< TextAnnotation > > Labels
Definition: AxisAnnotation2D.h:43
AxisAnnotation.h
Color.h
vtkm::rendering::Camera
Definition: Camera.h:28
vtkm::rendering::AxisAnnotation2D::SetColor
void SetColor(vtkm::rendering::Color c)
Definition: AxisAnnotation2D.h:67
vtkm::rendering::AxisAnnotation2D::MajorTickSizeY
vtkm::Float64 MajorTickSizeY
Definition: AxisAnnotation2D.h:32
Canvas.h
vtkm::rendering::TextAnnotation::HorizontalAlignment
HorizontalAlignment
Definition: TextAnnotation.h:27
vtkm::rendering::AxisAnnotation
Definition: AxisAnnotation.h:24
vtkm::rendering::AxisAnnotation2D::SetLabelFontScale
void SetLabelFontScale(vtkm::Float32 s)
Definition: AxisAnnotation2D.h:104
DataSet.h
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31