TextRepresentation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_TEXTREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_TEXTREPRESENTATION_H
18 
19 #include <memory>
20 
23 #include "SurgSim/Math/Vector.h"
24 
25 namespace SurgSim
26 {
27 namespace Framework
28 {
29 class Asset;
30 }
31 namespace Graphics
32 {
33 
34 class Font;
35 
39 class TextRepresentation : public virtual Representation
40 {
41 public:
44  explicit TextRepresentation(const std::string name);
45 
47  virtual ~TextRepresentation() {}
48 
51  virtual void loadFont(const std::string& fileName) = 0;
52 
55  virtual void setFont(std::shared_ptr<SurgSim::Framework::Asset> font) = 0;
56 
58  virtual std::shared_ptr<Font> getFont() const = 0;
59 
62  virtual void setLocation(double x, double y) = 0;
63 
66  virtual void getLocation(double* x, double* y) const = 0;
67 
70  virtual void setText(const std::string& text) = 0;
71 
73  virtual std::string getText() const = 0;
74 
79  virtual void setMaximumWidth(double width) = 0;
80 
82  virtual double getMaximumWidth() = 0;
83 
86  virtual void setFontSize(double size) = 0;
87 
89  virtual double getFontSize() const = 0;
90 
93  virtual void setColor(SurgSim::Math::Vector4d color) = 0;
94 
96  virtual SurgSim::Math::Vector4d getColor() const = 0;
97 
102  virtual void setUseScreenSpace(bool value) = 0;
103 
105  virtual bool isUsingScreenSpace() const = 0;
106 
109  virtual void setDrawBackground(bool value) = 0;
110 
112  virtual bool isDrawingBackground() const = 0;
113 
116  virtual void setBackgroundColor(Math::Vector4d color) = 0;
117 
120 
125  virtual void setBackgroundMargin(double margin) = 0;
126 
128  virtual double getBackgroundMargin() const = 0;
129 
130 protected:
136 
140 };
141 
142 }; // Graphics
143 }; // SurgSim
144 
145 #endif // SURGSIM_GRAPHICS_TEXTREPRESENTATION_H
SurgSim::Graphics::TextRepresentation::getColor
virtual SurgSim::Math::Vector4d getColor() const =0
SurgSim::Graphics::TextRepresentation::isDrawingBackground
virtual bool isDrawingBackground() const =0
SurgSim::Graphics::TextRepresentation::setUseScreenSpace
virtual void setUseScreenSpace(bool value)=0
If set to true all the coordinate values are in screen-space coordinates (i.e.
Vector.h
Definitions of small fixed-size vector types.
SurgSim::DataStructures::OptionalValue< double >
SurgSim::Graphics::TextRepresentation::getText
virtual std::string getText() const =0
SurgSim::Graphics::TextRepresentation::setBackgroundColor
virtual void setBackgroundColor(Math::Vector4d color)=0
Set the color of the background (if drawn)
SurgSim::Graphics::TextRepresentation::setFontSize
virtual void setFontSize(double size)=0
Set the vertical size of the font.
SurgSim::Graphics::TextRepresentation::setLocation
virtual void setLocation(double x, double y)=0
Sets the location in screen space.
SurgSim::Graphics::TextRepresentation::getFont
virtual std::shared_ptr< Font > getFont() const =0
SurgSim::Graphics::TextRepresentation::setMaximumWidth
virtual void setMaximumWidth(double width)=0
Sets a maximum width to the text display, the text should be broken up into multiple lines if the it ...
SurgSim::Graphics::TextRepresentation::~TextRepresentation
virtual ~TextRepresentation()
Destructor.
Definition: TextRepresentation.h:47
Representation.h
SurgSim::Graphics::TextRepresentation::setFont
virtual void setFont(std::shared_ptr< SurgSim::Framework::Asset > font)=0
Replace the current font with the one passed.
OptionalValue.h
SurgSim::Graphics::TextRepresentation::setBackgroundMargin
virtual void setBackgroundMargin(double margin)=0
Set the margin between background and text.
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Graphics::TextRepresentation::isUsingScreenSpace
virtual bool isUsingScreenSpace() const =0
SurgSim::Math::Vector4d
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
SurgSim::Graphics::TextRepresentation::setText
virtual void setText(const std::string &text)=0
Sets the text to be shown on the screen.
SurgSim::Graphics::TextRepresentation
A text to be displayed on the screen in screen space coordinates, use setPose() to set the position b...
Definition: TextRepresentation.h:40
SurgSim::Graphics::TextRepresentation::loadFont
virtual void loadFont(const std::string &fileName)=0
Load the font with the given file name, this will overwrite the current font.
SurgSim::Graphics::TextRepresentation::setDrawBackground
virtual void setDrawBackground(bool value)=0
Draw a filled background behind the text.
SurgSim::Graphics::TextRepresentation::TextRepresentation
TextRepresentation(const std::string name)
Constructor.
Definition: TextRepresentation.cpp:27
SurgSim::Graphics::TextRepresentation::getBackgroundColor
virtual Math::Vector4d getBackgroundColor()=0
SurgSim::Graphics::TextRepresentation::getBackgroundMargin
virtual double getBackgroundMargin() const =0
SurgSim::Graphics::TextRepresentation::setColor
virtual void setColor(SurgSim::Math::Vector4d color)=0
Set the color for the text.
SurgSim::Graphics::Representation
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:40
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::Graphics::TextRepresentation::getLocation
virtual void getLocation(double *x, double *y) const =0
Gets the location in screen space.
SurgSim::Graphics::TextRepresentation::getFontSize
virtual double getFontSize() const =0
SurgSim::Graphics::TextRepresentation::getOptionalMaximumWidth
virtual SurgSim::DataStructures::OptionalValue< double > getOptionalMaximumWidth()=0
Get the current status of the width.
SurgSim::Graphics::TextRepresentation::getMaximumWidth
virtual double getMaximumWidth()=0
SurgSim::Graphics::TextRepresentation::setOptionalMaximumWidth
virtual void setOptionalMaximumWidth(SurgSim::DataStructures::OptionalValue< double > width)=0
Optionally sets a maximum width to the text display, the text should be broken up into multiple lines...