CHAI3D  3.0.0
CLabel.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, 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.0.0 $Rev: 1652 $
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 //------------------------------------------------------------------------------
56 namespace chai3d {
57 //------------------------------------------------------------------------------
58 
59 //==============================================================================
66 //==============================================================================
67 
68 //==============================================================================
79 //==============================================================================
80 class cLabel : public cPanel
81 {
82  //--------------------------------------------------------------------------
83  // CONSTRUCTOR & DESTRUCTOR:
84  //--------------------------------------------------------------------------
85 
86 public:
87 
89  cLabel(cFont* a_font);
90 
92  virtual ~cLabel();
93 
94 
95  //-----------------------------------------------------------------------
96  // PUBLIC MEMBERS:
97  //--------------------------------------------------------------------------
98 
99 public:
100 
103 
106 
107 
108  //--------------------------------------------------------------------------
109  // PUBLIC MEMBERS:
110  //--------------------------------------------------------------------------
111 
112 public:
113 
115  void setText(const std::string a_text);
116 
118  std::string getText() const { return (m_text); }
119 
121  void setFontScale(const double a_scale);
122 
124  double getFontScale() const { return (m_fontScale); }
125 
126 
127  //--------------------------------------------------------------------------
128  // PUBLIC MEMBERS:
129  //--------------------------------------------------------------------------
130 
131 public:
132 
134  virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
135  cVector3d& a_segmentPointB,
136  cCollisionRecorder& a_recorder,
137  cCollisionSettings& a_settings);
138 
139 
140  //--------------------------------------------------------------------------
141  // PROTECTED MEMBERS:
142  //--------------------------------------------------------------------------
143 
144 protected:
145 
147  double m_fontScale;
148 
150  std::string m_text;
151 
154 
155 
156  //--------------------------------------------------------------------------
157  // PUBLIC METHODS:
158  //--------------------------------------------------------------------------
159 
160 public:
161 
163  cLabel* copy(const bool a_duplicateMaterialData = false,
164  const bool a_duplicateTextureData = false,
165  const bool a_duplicateMeshData = false,
166  const bool a_buildCollisionDetector = false);
167 
169  virtual double getTextWidth() const;
170 
172  virtual double getTextHeight() const;
173 
174 
175  //--------------------------------------------------------------------------
176  // PROTECTED METHODS:
177  //--------------------------------------------------------------------------
178 
179 protected:
180 
182  virtual void render(cRenderOptions& a_options);
183 
185  void copyLabelProperties(cLabel* a_obj,
186  const bool a_duplicateMaterialData,
187  const bool a_duplicateTextureData,
188  const bool a_duplicateMeshData,
189  const bool a_buildCollisionDetector);
190 };
191 
192 //------------------------------------------------------------------------------
193 } // namespace chai3d
194 //------------------------------------------------------------------------------
195 
196 //------------------------------------------------------------------------------
197 #endif
198 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:85
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
void setText(const std::string a_text)
This method assign a string text to this label.
Definition: CLabel.cpp:140
Implements a panel widget.
This class implements a 2D panel widget.
Definition: CPanel.h:80
std::string m_text
Text to be displayed.
Definition: CLabel.h:150
This class implements a 2D label widget to display one line of text.
Definition: CLabel.h:80
This class implements support for 2D fonts.
Definition: CFont.h:159
virtual void render(cRenderOptions &a_options)
This method renders the object graphically using OpenGL.
Definition: CLabel.cpp:98
Implements utility functions for manipulating strings.
cColorf m_fontColor
Font color.
Definition: CLabel.h:105
This class implements a collision detection recorder that stores all collision events that are report...
Definition: CCollisionBasics.h:185
void setFontScale(const double a_scale)
This method sets the font scale factor.
Definition: CLabel.cpp:188
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
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:250
Implements support for fonts.
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:315
cLabel(cFont *a_font)
Constructor of cLabel.
Definition: CLabel.cpp:59
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
Implements color properties.
double getFontScale() const
This method returns the font scale factor.
Definition: CLabel.h:124
virtual double getTextWidth() const
This method returns the width of the text in pixels.
Definition: CLabel.cpp:205
Definition: CAudioBuffer.cpp:56
double m_fontScale
Scale factor of fonts.
Definition: CLabel.h:147
virtual ~cLabel()
Destructor of cLabel.
Definition: CLabel.cpp:86
cVector3d m_textPosition
Position of string in reference to panel origin.
Definition: CLabel.h:153
std::string getText() const
This method returns the text associated with this label.
Definition: CLabel.h:118
cFont * m_font
Font type.
Definition: CLabel.h:102
virtual double getTextHeight() const
This method returns the height of the text in pixels.
Definition: CLabel.cpp:225
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:280

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.