GL Studio C++ Runtime API
gls_ellipse.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsEllipse class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _GLSELLIPSE_H
41 #define _GLSELLIPSE_H
42 #include "glpolygon.h"
43 #include "gls_cpp_lang_support.h"
44 
45 #ifdef GLES
46 # include "gls_index_array.h"
47 # include "gls_vertex_array.h"
48 #else
49 # include "gls_display_list.h"
50 #endif
51 //////////////////// Provides support for creating DLLs ////////////////////////
52 #if( defined( GLSGEN_EXPORT_GLSELLIPSE ) || defined( GLSGEN_IMPORT_GLSELLIPSE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
53  && defined( _MSC_VER )
54 # if defined( GLSGEN_EXPORT_GLSELLIPSE ) || defined( GLS_EXPORT_GENERATED )
55 # define GLSGEN_GLSELLIPSE_EXPORT __declspec( dllexport )
56 # else
57 # define GLSGEN_GLSELLIPSE_EXPORT __declspec( dllimport )
58 # endif
59 #else
60 # define GLSGEN_GLSELLIPSE_EXPORT
61 #endif
62 ///////////////////////////////////////////////////////////////////////////////
63 
64 #define LIB_BASE_NAME "gls_ellipse"
65 #include "gls_auto_lib.h"
66 #undef LIB_BASE_NAME
67 
68 namespace disti
69 {
70 // SetValue enumerations
71 enum
72 {
73  GLS_ELLIPSE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
74  GLS_ELLIPSE_RADII,
75  GLS_ELLIPSE_THICKNESS,
76  GLS_ELLIPSE_SOLID,
77  GLS_ELLIPSE_INTERVAL,
78  GLS_ELLIPSE_START_ANGLE,
79  GLS_ELLIPSE_END_ANGLE,
80  GLS_ELLIPSE_COLOR
81 };
82 
83 /** Runtime implementation of a GlsEllipse */
84 class GlsEllipse : public GLPolygon
85 {
86  friend class GlsEllipseEditor;
87 
88 public:
89  typedef GLPolygon _BaseClass;
90 
91  /** Create a new GlsEllipse.
92  * \param generateInstance Whether or not to generate an instance name
93  * for this inputdevice */
94  GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( bool generateInstance = false );
95 
96  // Copy Constructor
97  GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( const GlsEllipse& that, const bool generateNames );
98 
99  /** Destructs a GlsEllipse object */
100  virtual GLSGEN_GLSELLIPSE_EXPORT ~GlsEllipse();
101 
102  static GLSGEN_GLSELLIPSE_EXPORT DisplayObject* CreateInstance();
103 
104  virtual GLSGEN_GLSELLIPSE_EXPORT void SetAvailableAttributes( unsigned int value );
105 
106  virtual GLSGEN_GLSELLIPSE_EXPORT DisplayObject* CloneObject( bool generateNames = false );
107 
108  virtual GLSGEN_GLSELLIPSE_EXPORT void CopyProperties( DisplayObject* src );
109  virtual GLSGEN_GLSELLIPSE_EXPORT void CopyGeometry( DisplayObject* srcArg );
110 
111 #ifndef GLES
112  virtual GLSGEN_GLSELLIPSE_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
113  virtual GLSGEN_GLSELLIPSE_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
114 #endif
115 
116  virtual GLSGEN_GLSELLIPSE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
117  virtual GLSGEN_GLSELLIPSE_EXPORT void Draw( void );
118 
119  virtual GLSGEN_GLSELLIPSE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar );
120  virtual GLSGEN_GLSELLIPSE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis );
121  virtual GLSGEN_GLSELLIPSE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
122  virtual GLSGEN_GLSELLIPSE_EXPORT void CalculateTextureCoordinates();
123 
124  virtual GLSGEN_GLSELLIPSE_EXPORT Vertex* Vertices();
125  virtual GLSGEN_GLSELLIPSE_EXPORT void GetExtents( float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz );
126  virtual GLSGEN_GLSELLIPSE_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax );
127  virtual GLSGEN_GLSELLIPSE_EXPORT void UpdateBoundingVolume( void );
128 
129  /* Unhides base class implementation. */
131 
132  /* Unhides base class implementation. */
134 
135  /** Sets the color for filling the object
136  * \param color The new color for the object
137  */
138  virtual GLSGEN_GLSELLIPSE_EXPORT void SetFillColor( const GlsColor& color );
139 
140  /** Gets the color for filling the object
141  * \return The fill color for the object
142  */
143  virtual GLSGEN_GLSELLIPSE_EXPORT GlsColor GetFillColor( void );
144 
146 
147  virtual GLSGEN_GLSELLIPSE_EXPORT void SetValue( int spec, va_list& args );
148 
149  /* GlsEllipse does not use texture inheritance */
150  virtual GLSGEN_GLSELLIPSE_EXPORT bool SetupTexture( void );
151 
152  //////////////////////////////////////////////////
153  // GlsEllipse specific operations
154  //////////////////////////////////////////////////
155 
156  /** Sets the radius vectors
157  * \param r1
158  * \param r2
159  */
160  virtual GLSGEN_GLSELLIPSE_EXPORT void RadiusVectors( const Vector& r1, const Vector& r2 );
161 
162  /** Gets the radius vector
163  * \param index
164  */
165  virtual GLSGEN_GLSELLIPSE_EXPORT Vector RadiusVector( unsigned int index );
166 
167  /** Gets the unit vector
168  * \param index
169  */
170  virtual GLSGEN_GLSELLIPSE_EXPORT Vector UnitVector( unsigned int index );
171 
172  /** Sets the angular interval between vertices
173  * \param value the interval in degrees.
174  */
175  virtual GLSGEN_GLSELLIPSE_EXPORT void Interval( const unsigned int& value );
176  /** Gets the angular interval between vertices.
177  * \return the interval.
178  */
179  virtual GLSGEN_GLSELLIPSE_EXPORT unsigned int Interval();
180 
181  /** Sets the thickness of the ellipse in logical units.
182  * \param value The thickness in logical units.
183  */
184  virtual GLSGEN_GLSELLIPSE_EXPORT void Thickness( const float& value );
185  /** Gets the thickness of the ellipse.
186  * \return The current thickness of the ellipse in logical units.
187  */
188  virtual GLSGEN_GLSELLIPSE_EXPORT float Thickness();
189 
190  /** Sets the Start Angle in degrees
191  * \param value The start angle
192  */
193  virtual GLSGEN_GLSELLIPSE_EXPORT void StartAngle( const float& value );
194  /** Gets the Start Angle in degrees
195  * \return The start angle in degrees
196  */
197  virtual GLSGEN_GLSELLIPSE_EXPORT float StartAngle();
198 
199  /** Sets the end angle in degrees
200  * \param value The end angle in degrees
201  */
202  virtual GLSGEN_GLSELLIPSE_EXPORT void EndAngle( const float& value );
203  /** Gets the end angle in degrees
204  * \return The end angle in degrees
205  */
206  virtual GLSGEN_GLSELLIPSE_EXPORT float EndAngle();
207 
208  /** Sets the magnitude
209  */
210  virtual GLSGEN_GLSELLIPSE_EXPORT void Magnitude( const float& value, unsigned int index );
211  /** Gets the magnitude
212  */
213  virtual GLSGEN_GLSELLIPSE_EXPORT float Magnitude( unsigned int index );
214 
215  /** Sets the solid flag
216  * \param value When true the elipse is drawn solid
217  */
218  virtual GLSGEN_GLSELLIPSE_EXPORT void Solid( const bool& value );
219  /** Gets the solid flag
220  * \return The current solid flag value
221  */
222  virtual GLSGEN_GLSELLIPSE_EXPORT bool Solid();
223 
224 #ifdef GLES
225  /** Causes the display list for this object to be recomputed */
226  GLSGEN_GLSELLIPSE_EXPORT void InvalidateGeometry( void )
227  {
228  _geometryRefresh = true;
230  }
231 #else
232  /** Causes the display list for this object to be recomputed */
233  GLSGEN_GLSELLIPSE_EXPORT void InvalidateGeometry( void )
234  {
237  }
238 
239  /** Returns a reference to this object's display list */
240  GLSGEN_GLSELLIPSE_EXPORT GlsDisplayList& DisplayList( void ) { return _displayList; }
241 #endif
242 protected:
243  /** Calculates _radiiUnit and _magnitude based on _radii */
244  void CalculateRadiiUnit( void );
245 
246  /** callback called when the ellipse needs to be recalculated because an attribute has changed
247  */
248  void SetNeedsRecalculate( void );
249 
250 #ifdef GLES
251  /** Draws the arc segment mode
252  * \param textureObject TRUE if object should be drawn textured
253  */
254  void ComputeArcSegment( bool textureObject );
255 
256  /** Draws the solid circle mode
257  * \param textureObject TRUE if object should be drawn textured
258  */
259  void ComputeSolidCircle( bool textureObject );
260 
261  /** Set a single attribute from the GLO file.
262  * \param data The attribute to set and its associated data.
263  */
264  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
265 #else
266  /** Draws the arc segment mode
267  * \param textureObject TRUE if object should be drawn textured
268  */
269  void DrawArcSegment( bool textureObject );
270 
271  /** Draws the solid circle mode
272  * \param textureObject TRUE if object should be drawn textured
273  */
274  void DrawSolidCircle( bool textureObject );
275 
276  /** Performs OpenGL drawing commands */
277  void DrawGeometry( void );
278 #endif
279  /** Recomputes the object's vertices from its radii */
280  void RecomputeVertices( void );
281 
282  /** Calculates the start vertices */
283  void CalculateStartVertices( void );
284 
285  /** Calculates the end vertices */
286  void CalculateEndVertices( void );
287 
288  /** Gets starting and ending indices for vertices */
289  void GetSegmentIndices( const float startAngle, unsigned int& startIndex, const float endAngle, unsigned int& endIndex );
290  unsigned int InnerIndex( const unsigned int index );
291  unsigned int OuterIndex( const unsigned int index );
292 
293 #ifndef GLES
294  /** Stores the scale in a display list for faster drawing */
296 #else
297  GlsVertexArray _outlineVertexArray;
298 #endif
299  /** Stores the scale in a display list for faster drawing */
300  Vector _radii[ 2 ], /** Two radii defining the ellipse size and orientation
301  * Only used to read/write file. _radiiNormal is in control
302  */
303 
304  _normal, /**< Normal to surface defined by radii */
305  _radiiUnit[ 2 ], /**< Unit vector of radii */
306  _start[ 2 ], /**< Two points defining the starting edge of a partial ellipse. */
307  _startTex[ 2 ], /**< Texture coordinates of starting points */
308  _end[ 2 ], /**< Two points defining the ending edge of a partial ellipse. */
309  _endTex[ 2 ], /**< Texture coordinates of starting points */
310  _centerTex; /**< Texture coordinate of center point */
311 
312  GlsColor _objectColor; /**< Fill color of object */
313 
314  float _thickness, /**< Thickness of the outer edge of the ellipse in logical units */
315  _startAngle, /**< Starting angle of ellipse segment in degrees */
316  _endAngle, /**< Ending angle of ellipse segment in degrees */
317  _magnitude[ 2 ]; /**< Magnitude of radii */
318 
319  unsigned int _interval; /**< Interval between subdivisions, in degrees */
320  bool _solid; /**< If true, ellipse drawn as solid not as "donut" */
321  bool _needsRecalculate;
322 
323  GlsMatrixType _world2tex; /**< Matrix used to calculate texture coordinates for the object */
324 
325 private:
326  // disallow implicit assignments and copy constructor
327  GlsEllipse& operator=( const GlsEllipse& ) DISTI_SPECIAL_MEM_FUN_DELETE;
328  GlsEllipse( const GlsEllipse& ) DISTI_SPECIAL_MEM_FUN_DELETE;
329 };
330 
331 } // namespace disti
332 
333 #endif
Definition: cull.h:49
virtual Vector UnitVector(unsigned int index)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax)
virtual void CopyGeometry(DisplayObject *srcArg)
float _magnitude[2]
Definition: gls_ellipse.h:314
Definition: vertex.h:409
virtual float EndAngle()
void Invalidate(void)
Definition: gls_display_list.h:82
float _startAngle
Definition: gls_ellipse.h:314
Vector _normal
Definition: gls_ellipse.h:300
Definition: dynamic_array.h:62
virtual void UpdateBoundingVolume(void)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:301
GlsEllipse(bool generateInstance=false)
Vector _start[2]
Definition: gls_ellipse.h:300
virtual void Rotate(const Vector &orig, float angle, const Vector &axis)
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
virtual void SetAvailableAttributes(unsigned int value)
virtual bool Solid()
GlsColor _objectColor
Definition: gls_ellipse.h:312
virtual void SetFillColor(const GlsColor &color)
Definition: display.h:98
virtual float Thickness()
The disti::GLPolygon class. Implements Polygons.
void GetSegmentIndices(const float startAngle, unsigned int &startIndex, const float endAngle, unsigned int &endIndex)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
void RecomputeVertices(void)
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar)
void DrawArcSegment(bool textureObject)
Vector _end[2]
Definition: gls_ellipse.h:300
Definition: gls_display_list.h:50
virtual void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz)
Definition: gls_glo_file.h:982
void InvalidateGeometry(void)
Definition: gls_ellipse.h:233
virtual ~GlsEllipse()
bool _solid
Definition: gls_ellipse.h:320
void InvalidatePainter()
Definition: display.h:1717
virtual unsigned int Interval()
virtual Vector RadiusVector(unsigned int index)
virtual GlsColor GetFillColor(void)
void CalculateRadiiUnit(void)
GlsDisplayList & DisplayList(void)
Definition: gls_ellipse.h:240
unsigned int _interval
Definition: gls_ellipse.h:319
float _thickness
Definition: gls_ellipse.h:314
Vector _radii[2]
Definition: gls_ellipse.h:300
virtual float StartAngle()
virtual DisplayObject * CloneObject(bool generateNames=false)
Definition: gls_vertex_array.h:58
Vector _startTex[2]
Definition: gls_ellipse.h:300
float _endAngle
Definition: gls_ellipse.h:314
Definition: events.h:111
Vector _centerTex
Definition: gls_ellipse.h:300
Definition: gls_color.h:53
virtual void Draw(void)
void DrawGeometry(void)
virtual void SetValue(int spec, va_list &args)
virtual void RadiusVectors(const Vector &r1, const Vector &r2)
The gls_auto_lib.
void DrawSolidCircle(bool textureObject)
void CalculateEndVertices(void)
Vector _endTex[2]
Definition: gls_ellipse.h:300
GlsDisplayList _displayList
Definition: gls_ellipse.h:295
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
virtual void CalculateTextureCoordinates()
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: vertex.h:84
GlsMatrixType _world2tex
Definition: gls_ellipse.h:323
virtual GlsColor GetFillColor(void)
DisplayObject * handle(DisplayEvent *ev)
virtual void Magnitude(const float &value, unsigned int index)
Definition: gls_ellipse.h:84
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
Macros and helper code to determine what subset of C++11/14/17 is available.
virtual Vertex * Vertices()
The disti::GlsIndexArray class, for managing index buffers.
void CalculateStartVertices(void)
Definition: bmpimage.h:46
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:664
The disti::GlsDisplayList class.
virtual void CopyProperties(DisplayObject *src)
void SetNeedsRecalculate(void)
Vector _radiiUnit[2]
Definition: gls_ellipse.h:300