Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
TextBox.h
1// TextBox utility class
2
4//
5// This class is part of the Open Inventor Medical utility library.
6//
7// The medical utility classes are provided as a prebuilt library named
8// "fei_inventor_medical", that can be used directly in an Open Inventor
9// application. The classes in the prebuilt library are documented and
10// supported by Thermo Fisher Scientific. These classes are also provided as source code.
11//
12// Please see $OIVHOME/include/Medical/InventorMedical.h for the full text.
13//
15
16#ifndef _TEXT_BOX_H_
17#define _TEXT_BOX_H_
18
19#include <Medical/InventorMedical.h>
20
21#include <Inventor/nodes/SoAnnotation.h>
22#include <Inventor/nodes/SoTextProperty.h>
23
24#include <Inventor/fields/SoSFBool.h>
25#include <Inventor/fields/SoSFColor.h>
26#include <Inventor/fields/SoSFEnum.h>
27#include <Inventor/fields/SoSFFloat.h>
28#include <Inventor/fields/SoSFInt32.h>
29#include <Inventor/fields/SoSFString.h>
30#include <Inventor/fields/SoSFVec3f.h>
31#include <Inventor/SbViewportRegion.h>
32
33// Note we need the actual header files to use SoRef (not just just a 'class' declaration).
34#include <Inventor/nodes/SoBBox.h>
35#include <Inventor/nodes/SoFont.h>
36#include <Inventor/nodes/SoLineSet.h>
37#include <Inventor/nodes/SoSwitch.h>
38#include <Inventor/nodes/SoText2.h>
39#include <Inventor/nodes/SoTranslation.h>
40
41class SoNodeSensor;
42
105class INVENTORMEDICAL_API TextBox : public SoAnnotation {
106
107 SO_NODE_HEADER(TextBox);
108
109public:
113
116
119
122
126
129
132
135
145
155
157 void setLine( const SbString& text, int line = 0 );
158
160 const SbString& getLine( int line );
161
163 void addLine( const SbString& text );
164
170 void deleteLines( int startLine, int numToDelete = 1 );
171
173 void deleteAll();
174
176 int getNumLines() const;
177
180
183
185 static void initClass();
186
188 static void exitClass();
189
192
193private:
195 virtual ~TextBox();
196
197 SoRef<SoFont> m_fontNode;
198 SoRef<SoLineSet> m_borderGeom;
199 SoRef<SoSwitch> m_fontSwitch;
200 SoRef<SoSwitch> m_borderSwitch;
201 SoRef<SoText2> m_textNode;
202 SoRef<SoTranslation> m_tranNode;
203 SoRef<SoSeparator> m_textSep;
204
205 bool m_isModified;
206 SbViewportRegion m_curViewport;
207 SbBox3f m_curBBox;
208
209 SoNodeSensor* m_nodeSensor;
210 static void nodeSensorCB( void* data, SoSensor* sensor );
211
212 static void callbackNodeCB( void* data, SoAction* action );
213
214 void updatePosAndGeom( SoState* state = NULL );
215};
216
217#endif
3D box class.
Definition SbBox.h:649
Class for smart character strings.
Definition SbString.h:202
Class for representing a viewport.
Abstract base class for all actions.
Definition SoAction.h:132
Annotation group node.
Node that defines font name, size, and type for text.
Definition SoFont.h:303
Sensor class that can be attached to Open Inventor nodes.
Smart pointer for any class inheriting SoRefCounter.
Definition SoRef.h:90
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an RGB color.
Definition SoSFColor.h:82
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a floating-point value.
Definition SoSFFloat.h:78
Field containing a string.
Definition SoSFString.h:117
Field containing a three-dimensional vector.
Definition SoSFVec3f.h:80
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:100
Traversal state.
Definition SoState.h:74
Screen-aligned 2D text shape node.
Definition SoText2.h:194
@ BOTTOM
Bottom edges of all strings are aligned.
@ TOP
Top edges of all strings are aligned.
@ HALF
Vertical centers of all strings are aligned.
@ LEFT
Left edges of all strings are aligned.
@ CENTER
Horizontal centers of all strings are aligned.
@ RIGHT
Right edges of all strings are aligned.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> (Preview feature...
Definition TextBox.h:105
static void initClass()
Initialize the class.
void deleteLines(int startLine, int numToDelete=1)
Delete one or more lines of text.
TextBox()
Constructor.
SoSFString fontName
Specify the font name (default is "Arial:Bold").
Definition TextBox.h:125
SoSFColor borderColor
Border color (default is 1,1,1).
Definition TextBox.h:134
AlignmentV
Vertical alignment values.
Definition TextBox.h:147
void setLine(const SbString &text, int line=0)
Set the contents of the specified line of text (convenience method).
SoSFEnum textAlignH
Horizontal alignment of the text inside the box (default is LEFT).
Definition TextBox.h:121
SoSFEnum alignmentV
Vertical alignment of the text box (default is TOP).
Definition TextBox.h:118
SoSFFloat fontSize
Specify the font size in pixels (default is 15).
Definition TextBox.h:128
SoFont * getFontNode()
Get the internal font node (allows to modify font parameters directly).
AlignmentH
Horizontal alignment values.
Definition TextBox.h:137
int getNumLines() const
Get number of lines of text currently in the box.
SoSFBool border
Enable drawing a border around the text box (default is FALSE).
Definition TextBox.h:131
SoSFEnum alignmentH
Horizontal alignment of the text box (default is LEFT).
Definition TextBox.h:115
void addLine(const SbString &text)
Add a line of text at the bottom of the box.
void deleteAll()
Delete all lines of text.
static void exitClass()
Finish using the class.
SoSFVec3f position
Position of the text box in normalized screen coordinates (-1 to 1).
Definition TextBox.h:112
const SbString & getLine(int line)
Get the contents of the specified line of text.
SoText2 * getTextNode()
Get the internal text node (allows to modify line spacing directly).