VTK-m  2.2
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 
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 
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 
45  std::vector<vtkm::Float64> PositionsMajor;
46  std::vector<vtkm::Float64> ProportionsMajor;
47 
48  std::vector<vtkm::Float64> PositionsMinor;
49  std::vector<vtkm::Float64> ProportionsMinor;
50 
52 
53 public:
55 
56  AxisAnnotation2D(const AxisAnnotation2D&) = delete;
57 
58  AxisAnnotation2D& operator=(const AxisAnnotation2D&) = delete;
59 
60  void SetLogarithmic(bool l) { this->Logarithmic = l; }
61 
62  void SetMoreOrLessTickAdjustment(int offset) { this->MoreOrLessTickAdjustment = offset; }
63 
64  void SetColor(vtkm::rendering::Color c) { this->Color = c; }
65 
66  void SetLineWidth(vtkm::Float32 lw) { this->LineWidth = lw; }
67 
69  {
73  this->MajorTickSizeX = xlen;
74  this->MajorTickSizeY = ylen;
75  this->MajorTickOffset = offset;
76  }
77 
79  {
80  this->MinorTickSizeX = xlen;
81  this->MinorTickSizeY = ylen;
82  this->MinorTickOffset = offset;
83  }
84 
87  {
88  this->PosX0 = x0;
89  this->PosY0 = y0;
90 
91  this->PosX1 = x1;
92  this->PosY1 = y1;
93  }
94 
96  {
97  this->AlignH = h;
98  this->AlignV = v;
99  }
100 
102  {
103  this->FontScale = s;
104  for (auto& label : this->Labels)
105  label->SetScale(s);
106  }
107 
108  void SetRangeForAutoTicks(const vtkm::Range& range);
110  {
111  this->SetRangeForAutoTicks(vtkm::Range(lower, upper));
112  }
113 
114  void SetMajorTicks(const std::vector<vtkm::Float64>& positions,
115  const std::vector<vtkm::Float64>& proportions);
116 
117  void SetMinorTicks(const std::vector<vtkm::Float64>& positions,
118  const std::vector<vtkm::Float64>& proportions);
119 
120  void Render(const vtkm::rendering::Camera& camera,
121  const vtkm::rendering::WorldAnnotator& worldAnnotator,
122  vtkm::rendering::Canvas& canvas) override;
123 };
124 }
125 } //namespace vtkm::rendering
126 
127 #endif // vtk_m_rendering_AxisAnnotation2D_h
vtkm::rendering::Color
Representation of a color.
Definition: Color.h:29
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_RENDERING_EXPORT
#define VTKM_RENDERING_EXPORT
Definition: vtkm_rendering_export.h:44
vtkm::rendering::AxisAnnotation2D::PositionsMinor
std::vector< vtkm::Float64 > PositionsMinor
Definition: AxisAnnotation2D.h:48
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:86
vtkm::rendering::AxisAnnotation2D::SetLogarithmic
void SetLogarithmic(bool l)
Definition: AxisAnnotation2D.h:60
vtkm::rendering::AxisAnnotation2D::SetMinorTickSize
void SetMinorTickSize(vtkm::Float64 xlen, vtkm::Float64 ylen, vtkm::Float64 offset)
Definition: AxisAnnotation2D.h:78
vtkm::rendering::AxisAnnotation2D::SetMoreOrLessTickAdjustment
void SetMoreOrLessTickAdjustment(int offset)
Definition: AxisAnnotation2D.h:62
vtkm_rendering_export.h
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
Represents the image space that is the target of rendering.
Definition: Canvas.h:35
TextAnnotation.h
vtkm::rendering::AxisAnnotation2D::ProportionsMinor
std::vector< vtkm::Float64 > ProportionsMinor
Definition: AxisAnnotation2D.h:49
vtkm::rendering::AxisAnnotation2D::SetLabelAlignment
void SetLabelAlignment(TextAnnotation::HorizontalAlignment h, TextAnnotation::VerticalAlignment v)
Definition: AxisAnnotation2D.h:95
WorldAnnotator.h
vtkm::rendering::AxisAnnotation2D::SetMajorTickSize
void SetMajorTickSize(vtkm::Float64 xlen, vtkm::Float64 ylen, vtkm::Float64 offset)
Definition: AxisAnnotation2D.h:68
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:51
vtkm::rendering::WorldAnnotator
Definition: WorldAnnotator.h:27
vtkm::rendering::AxisAnnotation2D::SetLineWidth
void SetLineWidth(vtkm::Float32 lw)
Definition: AxisAnnotation2D.h:66
vtkm::rendering::AxisAnnotation2D::PosY1
vtkm::Float64 PosY1
Definition: AxisAnnotation2D.h:34
vtkm::rendering::AxisAnnotation2D::PositionsMajor
std::vector< vtkm::Float64 > PositionsMajor
Definition: AxisAnnotation2D.h:45
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:109
vtkm::rendering::AxisAnnotation2D::ProportionsMajor
std::vector< vtkm::Float64 > ProportionsMajor
Definition: AxisAnnotation2D.h:46
vtkm::Float32
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
Camera.h
vtkm::Float64
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
vtkm::rendering::AxisAnnotation2D::Labels
std::vector< std::unique_ptr< TextAnnotation > > Labels
Definition: AxisAnnotation2D.h:43
AxisAnnotation.h
Color.h
vtkm::rendering::Camera
Specifies the viewport for a rendering.
Definition: Camera.h:37
vtkm::rendering::AxisAnnotation2D::SetColor
void SetColor(vtkm::rendering::Color c)
Definition: AxisAnnotation2D.h:64
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:101
DataSet.h
vtkm::Range
Represent a continuous scalar range of values.
Definition: Range.h:31