Chemical Data Processing Library C++ API - Version 1.2.0
TextLabelPrimitive2D.hpp
Go to the documentation of this file.
1 /*
2  * TextLabelPrimitive2D.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_TEXTLABELPRIMITIVE2D_HPP
30 #define CDPL_VIS_TEXTLABELPRIMITIVE2D_HPP
31 
32 #include <string>
33 #include <memory>
34 
36 #include "CDPL/Vis/Pen.hpp"
37 #include "CDPL/Vis/Font.hpp"
38 #include "CDPL/Math/Vector.hpp"
39 
40 
41 namespace CDPL
42 {
43 
44  namespace Vis
45  {
46 
51  {
52 
53  public:
57  typedef std::shared_ptr<TextLabelPrimitive2D> SharedPointer;
58 
63 
64  void render(Renderer2D& renderer) const;
65 
70  void setText(const std::string& text);
71 
76  const std::string& getText() const;
77 
82  void setPosition(const Math::Vector2D& pos);
83 
89  void setPosition(double x, double y);
90 
95  const Math::Vector2D& getPosition() const;
96 
101  void setPen(const Pen& pen);
102 
107  const Pen& getPen() const;
108 
113  void setFont(const Font& font);
114 
119  const Font& getFont() const;
120 
122 
123  void getBounds(Rectangle2D& bounds, FontMetrics* font_metrics) const;
124 
125  private:
126  Pen pen;
127  Font font;
128  Math::Vector2D position;
129  std::string text;
130  };
131  } // namespace Vis
132 } // namespace CDPL
133 
134 #endif // CDPL_VIS_TEXTLABELPRIMITIVE2D_HPP
Definition of the class CDPL::Vis::Font.
Definition of the class CDPL::Vis::GraphicsPrimitive2D.
Definition of the class CDPL::Vis::Pen.
Definition of vector data types.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
An interface class with methods that provide information about the metrics of a font.
Definition: FontMetrics.hpp:71
Specifies a font for drawing text.
Definition: Font.hpp:54
The abstract base class of all 2D graphics primitives.
Definition: GraphicsPrimitive2D.hpp:57
std::shared_ptr< GraphicsPrimitive2D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated GraphicsPrimitive2D instances.
Definition: GraphicsPrimitive2D.hpp:63
Specifies how to draw lines and outlines of shapes.
Definition: Pen.hpp:53
Specifies an axis aligned rectangular area in 2D space.
Definition: Rectangle2D.hpp:51
An interface that provides methods for low level 2D drawing operations.
Definition: Renderer2D.hpp:86
A graphics primitive representing a text label.
Definition: TextLabelPrimitive2D.hpp:51
std::shared_ptr< TextLabelPrimitive2D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated TextLabelPrimitive2D instances.
Definition: TextLabelPrimitive2D.hpp:57
void setPen(const Pen &pen)
Sets the pen defining the color of the text label.
void render(Renderer2D &renderer) const
Visualizes the graphics primitive by means of the Renderer2D instance renderer.
void setFont(const Font &font)
Sets the font of the text label.
const Pen & getPen() const
Returns the pen defining the color of the text label.
void getBounds(Rectangle2D &bounds, FontMetrics *font_metrics) const
Calculates the bounds of the graphics primitive.
const Math::Vector2D & getPosition() const
Returns the position of the text label.
void setText(const std::string &text)
Sets the text of the label.
TextLabelPrimitive2D()
Construct an empty text label primitive at position (0, 0).
void setPosition(double x, double y)
Sets the position of the text label to (x, y).
GraphicsPrimitive2D::SharedPointer clone() const
Creates a dynamically allocated copy of the graphics primitive.
void setPosition(const Math::Vector2D &pos)
Sets the position of the text label.
const std::string & getText() const
Returns the text of the label.
const Font & getFont() const
Returns the font of the text label.
CVector< double, 2 > Vector2D
A bounded 2 element vector holding floating point values of type double.
Definition: Vector.hpp:1632
The namespace of the Chemical Data Processing Library.