My Project
Loading...
Searching...
No Matches
CLabel.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CLabelH
46#define CLabelH
47//------------------------------------------------------------------------------
48#include "widgets/CPanel.h"
49#include "graphics/CFont.h"
50#include "graphics/CColor.h"
51#include "system/CString.h"
52#include <string>
53//------------------------------------------------------------------------------
54
55//------------------------------------------------------------------------------
56namespace chai3d {
57//------------------------------------------------------------------------------
58
59//==============================================================================
66//==============================================================================
67
68//==============================================================================
79//==============================================================================
80class cLabel : public cPanel
81{
82 //--------------------------------------------------------------------------
83 // CONSTRUCTOR & DESTRUCTOR:
84 //--------------------------------------------------------------------------
85
86public:
87
89 cLabel(cFontPtr a_font);
90
92 virtual ~cLabel();
93
94
95 //--------------------------------------------------------------------------
96 // PUBLIC METHODS:
97 //--------------------------------------------------------------------------
98
99public:
100
102 virtual std::string getClassName() { return ("Label"); }
103
105 cLabel* copy(const bool a_duplicateMaterialData = false,
106 const bool a_duplicateTextureData = false,
107 const bool a_duplicateMeshData = false,
108 const bool a_buildCollisionDetector = false);
109
110
111 //-----------------------------------------------------------------------
112 // PUBLIC MEMBERS:
113 //--------------------------------------------------------------------------
114
115public:
116
119
122
123
124 //--------------------------------------------------------------------------
125 // PUBLIC MEMBERS:
126 //--------------------------------------------------------------------------
127
128public:
129
131 virtual double getTextWidth() const;
132
134 virtual double getTextHeight() const;
135
137 void setText(const std::string a_text);
138
140 std::string getText() const { return (m_text); }
141
143 void setFontScale(const double a_scale);
144
146 double getFontScale() const { return (m_fontScale); }
147
149 void setLetterSpacing(const double a_letterSpacing) { m_letterSpacing = a_letterSpacing; }
150
152 double getLetterSpacing() { return (m_letterSpacing); }
153
155 void setLineSpacing(const double a_lineSpacing) { m_lineSpacing = a_lineSpacing; }
156
158 double getLineSpacing() { return (m_lineSpacing); }
159
160
161 //--------------------------------------------------------------------------
162 // PUBLIC MEMBERS:
163 //--------------------------------------------------------------------------
164
165public:
166
168 virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
169 cVector3d& a_segmentPointB,
170 cCollisionRecorder& a_recorder,
171 cCollisionSettings& a_settings);
172
173
174 //--------------------------------------------------------------------------
175 // PROTECTED MEMBERS:
176 //--------------------------------------------------------------------------
177
178protected:
179
182
185
188
190 std::string m_text;
191
192
193 //--------------------------------------------------------------------------
194 // PROTECTED METHODS:
195 //--------------------------------------------------------------------------
196
197protected:
198
200 virtual void render(cRenderOptions& a_options);
201
203 void copyLabelProperties(cLabel* a_obj,
204 const bool a_duplicateMaterialData,
205 const bool a_duplicateTextureData,
206 const bool a_duplicateMeshData,
207 const bool a_buildCollisionDetector);
208};
209
210//------------------------------------------------------------------------------
211} // namespace chai3d
212//------------------------------------------------------------------------------
213
214//------------------------------------------------------------------------------
215#endif
216//------------------------------------------------------------------------------
Implements color properties.
Implements support for fonts.
Implements a panel widget.
Implements utility functions for manipulating strings.
This class implements a collision detection recorder that stores all collision events that are report...
Definition CCollisionBasics.h:186
This class implements a 2D label widget to display one line of text.
Definition CLabel.h:81
double m_lineSpacing
Line spacing. Default value is 1.0.
Definition CLabel.h:187
cLabel * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method creates a copy of this object.
Definition CLabel.cpp:239
std::string getText() const
This method returns the text associated with this label.
Definition CLabel.h:140
double getLineSpacing()
This method returns the current line spacing value.
Definition CLabel.h:158
void setLetterSpacing(const double a_letterSpacing)
This method sets the letter spacing.
Definition CLabel.h:149
std::string m_text
Text to be displayed.
Definition CLabel.h:190
cFontPtr m_font
Font type.
Definition CLabel.h:118
virtual void render(cRenderOptions &a_options)
This method renders the object graphically using OpenGL.
Definition CLabel.cpp:99
void setLineSpacing(const double a_lineSpacing)
This method sets the line spacing when multiple lines of text are used.
Definition CLabel.h:155
cColorf m_fontColor
Font color.
Definition CLabel.h:121
virtual ~cLabel()
Destructor of cLabel.
Definition CLabel.cpp:87
virtual std::string getClassName()
This method returns the name of the object class.
Definition CLabel.h:102
double getLetterSpacing()
This method returns the current letter spacing value.
Definition CLabel.h:152
void copyLabelProperties(cLabel *a_obj, const bool a_duplicateMaterialData, const bool a_duplicateTextureData, const bool a_duplicateMeshData, const bool a_buildCollisionDetector)
This method copies all properties of this object to another.
Definition CLabel.cpp:269
void setText(const std::string a_text)
This method assign a string text to this label.
Definition CLabel.cpp:141
virtual double getTextWidth() const
This method returns the width of the text in pixels.
Definition CLabel.cpp:194
virtual bool computeOtherCollisionDetection(cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings)
This method computes any collisions between a segment and this object.
Definition CLabel.cpp:304
double m_letterSpacing
Letter spacing. Default value is 1.0.
Definition CLabel.h:184
double m_fontScale
Scale factor of fonts.
Definition CLabel.h:181
void setFontScale(const double a_scale)
This method sets the font scale factor.
Definition CLabel.cpp:173
virtual double getTextHeight() const
This method returns the height of the text in pixels.
Definition CLabel.cpp:214
double getFontScale() const
This method returns the font scale factor.
Definition CLabel.h:146
This class implements a 2D panel widget.
Definition CPanel.h:81
Definition CAudioBuffer.cpp:57
std::shared_ptr< cFont > cFontPtr
Definition CFont.h:72
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition CCollisionBasics.h:243
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 3D vector.
Definition CVector3d.h:89