vtk-m/vtkm/rendering/TextAnnotation.h

83 lines
2.4 KiB
C
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_rendering_TextAnnotation_h
#define vtk_m_rendering_TextAnnotation_h
#include <vtkm/rendering/vtkm_rendering_export.h>
2016-06-02 19:04:01 +00:00
#include <vtkm/rendering/Camera.h>
#include <vtkm/rendering/Canvas.h>
#include <vtkm/rendering/WorldAnnotator.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace rendering
{
class VTKM_RENDERING_EXPORT TextAnnotation
{
public:
enum struct HorizontalAlignment
2017-05-18 14:29:41 +00:00
{
Left,
HCenter,
Right
};
enum struct VerticalAlignment
2017-05-18 14:29:41 +00:00
{
Bottom,
VCenter,
Top
};
static constexpr HorizontalAlignment Left = HorizontalAlignment::Left;
static constexpr HorizontalAlignment HCenter = HorizontalAlignment::HCenter;
static constexpr HorizontalAlignment Right = HorizontalAlignment::Right;
static constexpr VerticalAlignment Bottom = VerticalAlignment::Bottom;
static constexpr VerticalAlignment VCenter = VerticalAlignment::VCenter;
static constexpr VerticalAlignment Top = VerticalAlignment::Top;
protected:
2017-05-18 14:29:41 +00:00
std::string Text;
Color TextColor;
vtkm::Float32 Scale;
vtkm::Vec2f_32 Anchor;
public:
TextAnnotation(const std::string& text,
const vtkm::rendering::Color& color,
vtkm::Float32 scalar);
virtual ~TextAnnotation();
2017-05-18 14:29:41 +00:00
void SetText(const std::string& text);
2017-05-18 14:29:41 +00:00
const std::string& GetText() const;
/// Set the anchor point relative to the box containing the text. The anchor
/// is scaled in both directions to the range [-1,1] with -1 at the lower
/// left and 1 at the upper right.
///
void SetRawAnchor(const vtkm::Vec2f_32& anchor);
void SetRawAnchor(vtkm::Float32 h, vtkm::Float32 v);
void SetAlignment(HorizontalAlignment h, VerticalAlignment v);
void SetScale(vtkm::Float32 scale);
2017-05-18 14:29:41 +00:00
virtual void Render(const vtkm::rendering::Camera& camera,
const vtkm::rendering::WorldAnnotator& worldAnnotator,
vtkm::rendering::Canvas& canvas) const = 0;
};
}
} //namespace vtkm::rendering
#endif //vtk_m_rendering_TextAnnotation_h