Open Inventor Reference
SoAsciiText.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 /**************************************************************************
38  * Copyright (C) 1991-94, Silicon Graphics, Inc. *
39  * These coded instructions, statements, and computer programs contain *
40  * unpublished proprietary information of Silicon Graphics, Inc., and *
41  * are protected by Federal copyright law. They may not be disclosed *
42  * to third parties or copied or duplicated in any form, in whole or *
43  * in part, without the prior written consent of Silicon Graphics, Inc. *
44  **************************************************************************/
45 
46 
47 /*
48  *
49  _______________________________________________________________________
50  ______________ S I L I C O N G R A P H I C S I N C . ____________
51  |
52  | $Revision: 1.1.1.1 $
53  |
54  | Description:
55  | This file defines the SoAsciiText node class.
56  |
57  | Author(s) : Chris Marrin, Gavin Bell
58  |
59  ______________ S I L I C O N G R A P H I C S I N C . ____________
60  _______________________________________________________________________
61  */
62 
63 #ifndef _SO_ASCIITEXT_
64 #define _SO_ASCIITEXT_
65 
66 #include <Inventor/SbBox.h>
72 #include <Inventor/nodes/SoShape.h>
73 
74 #include <Inventor/system/SbOpenGL.h> // For GLenum declaration
75 
77 #ifndef gluTESSELATOR
78 #if defined(__glu_h__) && (GLU_VERSION_1_2)
79 #define gluTESSELATOR GLUtesselator
80 #else
81 #define gluTESSELATOR GLUtriangulatorObj
82 extern "C" struct GLUtriangulatorObj;
83 #endif
84 #endif
85 
86 
87 
88 class MyOutlineFontCache;
89 class SoPrimitiveVertex;
91 
94 
147 
149 
151 
152  public:
155  LEFT = 0x01,
156  RIGHT = 0x02,
157  CENTER = 0x03
158  };
159 
161 
162 
165 
171 
179 
183 
185 
188 
189  SoEXTENDER public:
190 
191  virtual void GLRender(SoGLRenderAction *action);
192  virtual void rayPick(SoRayPickAction *action);
193 
194  SoINTERNAL public:
195  static void initClass();
196 
197  protected:
199  virtual void computeBBox(SoAction *action, SbBox3f &box,
200  SbVec3f &center);
201 
203  virtual void generatePrimitives(SoAction *);
204 
205  virtual ~SoAsciiText();
206 
207  private:
209  bool setupFontCache(SoState *state, bool forRender = FALSE);
210 
212  void getFrontBBox(SbBox2f &result);
213 
215 
218  SbVec2f getStringOffset(int line, float width);
219 
221  void renderFront(SoGLRenderAction *action, const SbString &string,
222  float width, GLUtriangulatorObj *tobj);
223 
226  const SoPrimitiveVertex *,
227  const SoPrimitiveVertex *,
228  const SoPrimitiveVertex *,
229  SoPickedPoint *);
230 
233  void generateFront(const SbString &string, float width);
234 
236  static void CALLBACK beginCB(GLenum primType);
237  static void CALLBACK endCB();
238  static void CALLBACK vtxCB(void *vertex);
239 
244  MyOutlineFontCache *myFont;
245 
247  static SoAsciiText *currentGeneratingNode;
248  static SoPrimitiveVertex *genPrimVerts[3];
249  static SbVec3f genTranslate;
250  static int genWhichVertex;
251  static uint32_t genPrimType;
252  static SoAction *genAction;
253  static bool genBack;
254  static bool genTexCoord;
255  static const SoTextureCoordinateElement *tce;
256 };
257 
258 #endif /* _SO_ASCIITEXT_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
unsigned int uint32_t
Definition: SbTypeDefs.h:44
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition: SoSubNode.h:170
2D box class.
Definition: SbBox.h:372
3D box class.
Definition: SbBox.h:81
Class for smart character strings.
Definition: SbString.h:85
2D vector class.
Definition: SbLinear.h:246
3D vector class.
Definition: SbLinear.h:120
Abstract base class for all actions.
Definition: SoAction.h:179
Simple 3D text shape node.
Definition: SoAsciiText.h:148
Justification
Justification types.
Definition: SoAsciiText.h:154
SoMFString string
The text string(s) to display. Each string will appear on its own line.
Definition: SoAsciiText.h:164
SoMFFloat width
Defines the width of each text string.
Definition: SoAsciiText.h:182
virtual void GLRender(SoGLRenderAction *action)
Implements rendering by rendering each primitive generated by subclass.
SoSFEnum justification
Indicates placement and alignment of strings.
Definition: SoAsciiText.h:178
SoSFFloat spacing
Defines the distance (in the negative y direction) between the base points of successive strings,...
Definition: SoAsciiText.h:170
SoAsciiText()
Creates an ascii text node with default settings.
virtual void rayPick(SoRayPickAction *action)
Implements picking along a ray by intersecting the ray with each primitive generated by subclass.
virtual void generatePrimitives(SoAction *)
Generates primitives.
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
Computes bounding box of text.
virtual ~SoAsciiText()
static void initClass()
Base class for describing detail information about a shape node.
Definition: SoDetail.h:78
Renders a scene graph using OpenGL.
Multiple-value field containing any number of floating point values.
Definition: SoMFFloat.h:82
Multiple-value field containing any number of strings.
Definition: SoMFString.h:80
Represents point on surface of picked object.
Definition: SoPickedPoint.h:89
Represents a vertex of a generated primitive.
Intersects objects with a ray cast into scene.
Field containing an enumerated value.
Definition: SoSFEnum.h:93
Field containing a floating-point value.
Definition: SoSFFloat.h:77
Abstract base class for all shape nodes.
Definition: SoShape.h:101
virtual SoDetail * createTriangleDetail(SoRayPickAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3, SoPickedPoint *pp)
These methods are called during picking to create details representing extra info about a pick inters...
An SoState collects and holds state while traversing a scene graph.
Definition: SoState.h:82
Element storing the current texture coordinates.