1 //============================================================================
2 //  Copyright (c) Kitware, Inc.
3 //  All rights reserved.
4 //  See LICENSE.txt for details.
5 //  This software is distributed WITHOUT ANY WARRANTY; without even
6 //  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 //  PURPOSE.  See the above copyright notice for more information.
8 //
9 //  Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 //  Copyright 2015 UT-Battelle, LLC.
11 //  Copyright 2015 Los Alamos National Security.
12 //
13 //  Under the terms of Contract DE-NA0003525 with NTESS,
14 //  the U.S. Government retains certain rights in this software.
15 //
16 //  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 //  Laboratory (LANL), the U.S. Government retains certain rights in
18 //  this software.
19 //============================================================================
20 #ifndef vtk_m_rendering_TextAnnotation_h
21 #define vtk_m_rendering_TextAnnotation_h
22 
23 #include <vtkm/rendering/vtkm_rendering_export.h>
24 
25 #include <vtkm/rendering/Camera.h>
26 #include <vtkm/rendering/Canvas.h>
27 #include <vtkm/rendering/WorldAnnotator.h>
28 
29 namespace vtkm
30 {
31 namespace rendering
32 {
33 
34 class VTKM_RENDERING_EXPORT TextAnnotation
35 {
36 public:
37   enum HorizontalAlignment
38   {
39     Left,
40     HCenter,
41     Right
42   };
43   enum VerticalAlignment
44   {
45     Bottom,
46     VCenter,
47     Top
48   };
49 
50 protected:
51   std::string Text;
52   Color TextColor;
53   vtkm::Float32 Scale;
54   vtkm::Vec<vtkm::Float32, 2> Anchor;
55 
56 public:
57   TextAnnotation(const std::string& text,
58                  const vtkm::rendering::Color& color,
59                  vtkm::Float32 scalar);
60 
61   virtual ~TextAnnotation();
62 
63   void SetText(const std::string& text);
64 
65   const std::string& GetText() const;
66 
67   /// Set the anchor point relative to the box containing the text. The anchor
68   /// is scaled in both directions to the range [-1,1] with -1 at the lower
69   /// left and 1 at the upper right.
70   ///
71   void SetRawAnchor(const vtkm::Vec<vtkm::Float32, 2>& anchor);
72 
73   void SetRawAnchor(vtkm::Float32 h, vtkm::Float32 v);
74 
75   void SetAlignment(HorizontalAlignment h, VerticalAlignment v);
76 
77   void SetScale(vtkm::Float32 scale);
78 
79   virtual void Render(const vtkm::rendering::Camera& camera,
80                       const vtkm::rendering::WorldAnnotator& worldAnnotator,
81                       vtkm::rendering::Canvas& canvas) const = 0;
82 };
83 }
84 } //namespace vtkm::rendering
85 
86 #endif //vtk_m_rendering_TextAnnotation_h
87