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  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
90  typedef GLPolygon _BaseClass;
91  typedef GLPolygon BaseClass;
92 
93  /** Create a new GlsEllipse.
94  * \param generateInstance Whether or not to generate an instance name
95  * for this inputdevice */
96  GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( bool generateInstance = false );
97 
98  // Copy Constructor
99  GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( const GlsEllipse& that, const bool generateNames );
100 
101  /** Destructs a GlsEllipse object */
102  virtual GLSGEN_GLSELLIPSE_EXPORT ~GlsEllipse();
103 
104  static GLSGEN_GLSELLIPSE_EXPORT DisplayObject* CreateInstance();
105 
106  virtual GLSGEN_GLSELLIPSE_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
107 
108  virtual GLSGEN_GLSELLIPSE_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
109 
110  virtual GLSGEN_GLSELLIPSE_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
111  virtual GLSGEN_GLSELLIPSE_EXPORT void CopyGeometry( DisplayObject* srcArg ) DISTI_METHOD_OVERRIDE;
112 
113 #ifndef GLES
114  virtual GLSGEN_GLSELLIPSE_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
115  virtual GLSGEN_GLSELLIPSE_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
116 #endif
117 
118  virtual GLSGEN_GLSELLIPSE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
119  virtual GLSGEN_GLSELLIPSE_EXPORT void Draw( void ) DISTI_METHOD_OVERRIDE;
120 
121  virtual GLSGEN_GLSELLIPSE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
122  virtual GLSGEN_GLSELLIPSE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
123  virtual GLSGEN_GLSELLIPSE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
124  virtual GLSGEN_GLSELLIPSE_EXPORT void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE;
125 
126  virtual GLSGEN_GLSELLIPSE_EXPORT Vertex* Vertices() DISTI_METHOD_OVERRIDE;
127  virtual GLSGEN_GLSELLIPSE_EXPORT void GetExtents( float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz ) DISTI_METHOD_OVERRIDE;
128  virtual GLSGEN_GLSELLIPSE_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax ) DISTI_METHOD_OVERRIDE;
129  virtual GLSGEN_GLSELLIPSE_EXPORT void UpdateBoundingVolume( void ) DISTI_METHOD_OVERRIDE;
130 
131  /* Unhides base class implementation. */
133 
134  /* Unhides base class implementation. */
136 
137  /** Sets the color for filling the object
138  * \param color The new color for the object
139  */
140  virtual GLSGEN_GLSELLIPSE_EXPORT void SetFillColor( const GlsColor& color ) DISTI_METHOD_OVERRIDE;
141 
142  /** Gets the color for filling the object
143  * \return The fill color for the object
144  */
145  virtual GLSGEN_GLSELLIPSE_EXPORT GlsColor GetFillColor( void ) DISTI_METHOD_OVERRIDE;
146 
147  GLSGEN_GLSELLIPSE_EXPORT DisplayObject* handle( DisplayEvent* ev ) DISTI_METHOD_OVERRIDE;
148 
149  virtual GLSGEN_GLSELLIPSE_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
150 
151  /* GlsEllipse does not use texture inheritance */
152  virtual GLSGEN_GLSELLIPSE_EXPORT bool SetupTexture( void );
153 
154  //////////////////////////////////////////////////
155  // GlsEllipse specific operations
156  //////////////////////////////////////////////////
157 
158  /** Sets the radius vectors
159  * \param r1
160  * \param r2
161  */
162  virtual GLSGEN_GLSELLIPSE_EXPORT void RadiusVectors( const Vector& r1, const Vector& r2 );
163 
164  /** Gets the radius vector
165  * \param index
166  */
167  virtual GLSGEN_GLSELLIPSE_EXPORT Vector RadiusVector( unsigned int index );
168 
169  /** Gets the unit vector
170  * \param index
171  */
172  virtual GLSGEN_GLSELLIPSE_EXPORT Vector UnitVector( unsigned int index );
173 
174  /** Sets the angular interval between vertices
175  * \param value the interval in degrees.
176  */
177  virtual GLSGEN_GLSELLIPSE_EXPORT void Interval( const unsigned int& value );
178  /** Gets the angular interval between vertices.
179  * \return the interval.
180  */
181  virtual GLSGEN_GLSELLIPSE_EXPORT unsigned int Interval();
182 
183  /** Sets the thickness of the ellipse in logical units.
184  * \param value The thickness in logical units.
185  */
186  virtual GLSGEN_GLSELLIPSE_EXPORT void Thickness( const float& value );
187  /** Gets the thickness of the ellipse.
188  * \return The current thickness of the ellipse in logical units.
189  */
190  virtual GLSGEN_GLSELLIPSE_EXPORT float Thickness();
191 
192  /** Sets the Start Angle in degrees
193  * \param value The start angle
194  */
195  virtual GLSGEN_GLSELLIPSE_EXPORT void StartAngle( const float& value );
196  /** Gets the Start Angle in degrees
197  * \return The start angle in degrees
198  */
199  virtual GLSGEN_GLSELLIPSE_EXPORT float StartAngle();
200 
201  /** Sets the end angle in degrees
202  * \param value The end angle in degrees
203  */
204  virtual GLSGEN_GLSELLIPSE_EXPORT void EndAngle( const float& value );
205  /** Gets the end angle in degrees
206  * \return The end angle in degrees
207  */
208  virtual GLSGEN_GLSELLIPSE_EXPORT float EndAngle();
209 
210  /** Sets the magnitude
211  */
212  virtual GLSGEN_GLSELLIPSE_EXPORT void Magnitude( const float& value, unsigned int index );
213  /** Gets the magnitude
214  */
215  virtual GLSGEN_GLSELLIPSE_EXPORT float Magnitude( unsigned int index );
216 
217  /** Sets the solid flag
218  * \param value When true the elipse is drawn solid
219  */
220  virtual GLSGEN_GLSELLIPSE_EXPORT void Solid( const bool& value );
221  /** Gets the solid flag
222  * \return The current solid flag value
223  */
224  virtual GLSGEN_GLSELLIPSE_EXPORT bool Solid();
225 
226 #ifdef GLES
227  /** Causes the display list for this object to be recomputed */
228  GLSGEN_GLSELLIPSE_EXPORT void InvalidateGeometry( void )
229  {
230  _geometryRefresh = true;
232  }
233 #else
234  /** Causes the display list for this object to be recomputed */
235  GLSGEN_GLSELLIPSE_EXPORT void InvalidateGeometry( void )
236  {
239  }
240 
241  /** Returns a reference to this object's display list */
242  GLSGEN_GLSELLIPSE_EXPORT GlsDisplayList& DisplayList( void ) { return _displayList; }
243 #endif
244 protected:
245  /** Calculates _radiiUnit and _magnitude based on _radii */
246  void GLSGEN_GLSELLIPSE_EXPORT CalculateRadiiUnit( void );
247 
248  /** callback called when the ellipse needs to be recalculated because an attribute has changed
249  */
250  void GLSGEN_GLSELLIPSE_EXPORT SetNeedsRecalculate( void );
251 
252 #ifdef GLES
253  /** Draws the arc segment mode
254  * \param textureObject TRUE if object should be drawn textured
255  */
256  void GLSGEN_GLSELLIPSE_EXPORT ComputeArcSegment( bool textureObject );
257 
258  /** Draws the solid circle mode
259  * \param textureObject TRUE if object should be drawn textured
260  */
261  void GLSGEN_GLSELLIPSE_EXPORT ComputeSolidCircle( bool textureObject );
262 
263  /** Set a single attribute from the GLO file.
264  * \param data The attribute to set and its associated data.
265  */
266  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
267 #else
268  /** Draws the arc segment mode
269  * \param textureObject TRUE if object should be drawn textured
270  */
271  void GLSGEN_GLSELLIPSE_EXPORT DrawArcSegment( bool textureObject );
272 
273  /** Draws the solid circle mode
274  * \param textureObject TRUE if object should be drawn textured
275  */
276  void GLSGEN_GLSELLIPSE_EXPORT DrawSolidCircle( bool textureObject );
277 
278  /** Performs OpenGL drawing commands */
279  void GLSGEN_GLSELLIPSE_EXPORT DrawGeometry( void );
280 #endif
281  /** Recomputes the object's vertices from its radii */
282  void GLSGEN_GLSELLIPSE_EXPORT RecomputeVertices( void );
283 
284  /** Calculates the start vertices */
285  void GLSGEN_GLSELLIPSE_EXPORT CalculateStartVertices( void );
286 
287  /** Calculates the end vertices */
288  void GLSGEN_GLSELLIPSE_EXPORT CalculateEndVertices( void );
289 
290  /** Gets starting and ending indices for vertices */
291  void GLSGEN_GLSELLIPSE_EXPORT GetSegmentIndices( const float startAngle, unsigned int& startIndex, const float endAngle, unsigned int& endIndex );
292  unsigned int GLSGEN_GLSELLIPSE_EXPORT InnerIndex( const unsigned int index );
293  unsigned int GLSGEN_GLSELLIPSE_EXPORT OuterIndex( const unsigned int index );
294 
295 #ifndef GLES
296  /** Stores the scale in a display list for faster drawing */
298 #else
299  GlsVertexArray _outlineVertexArray;
300 #endif
301  /** Stores the scale in a display list for faster drawing */
302  Vector _radii[ 2 ], /** Two radii defining the ellipse size and orientation
303  * Only used to read/write file. _radiiNormal is in control
304  */
305 
306  _normal, /**< Normal to surface defined by radii */
307  _radiiUnit[ 2 ], /**< Unit vector of radii */
308  _start[ 2 ], /**< Two points defining the starting edge of a partial ellipse. */
309  _startTex[ 2 ], /**< Texture coordinates of starting points */
310  _end[ 2 ], /**< Two points defining the ending edge of a partial ellipse. */
311  _endTex[ 2 ], /**< Texture coordinates of starting points */
312  _centerTex; /**< Texture coordinate of center point */
313 
314  GlsColor _objectColor; /**< Fill color of object */
315 
316  float _thickness, /**< Thickness of the outer edge of the ellipse in logical units */
317  _startAngle, /**< Starting angle of ellipse segment in degrees */
318  _endAngle, /**< Ending angle of ellipse segment in degrees */
319  _magnitude[ 2 ]; /**< Magnitude of radii */
320 
321  unsigned int _interval; /**< Interval between subdivisions, in degrees */
322  bool _solid; /**< If true, ellipse drawn as solid not as "donut" */
323  bool _needsRecalculate;
324 
325  GlsMatrixType _world2tex; /**< Matrix used to calculate texture coordinates for the object */
326 
327 private:
328  // disallow implicit assignments and copy constructor
329  GlsEllipse& operator=( const GlsEllipse& ) DISTI_SPECIAL_MEM_FUN_DELETE;
330  GlsEllipse( const GlsEllipse& ) DISTI_SPECIAL_MEM_FUN_DELETE;
331 };
332 
333 } // namespace disti
334 
335 #endif
Definition: cull.h:49
virtual Vector UnitVector(unsigned int index)
float _magnitude[2]
Definition: gls_ellipse.h:316
Definition: vertex.h:409
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual float EndAngle()
void Invalidate(void)
Definition: gls_display_list.h:82
float _startAngle
Definition: gls_ellipse.h:316
virtual GlsColor GetFillColor(void) DISTI_METHOD_OVERRIDE
Vector _normal
Definition: gls_ellipse.h:302
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
Definition: dynamic_array.h:66
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:473
GlsEllipse(bool generateInstance=false)
Vector _start[2]
Definition: gls_ellipse.h:302
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
virtual bool Solid()
GlsColor _objectColor
Definition: gls_ellipse.h:314
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
Definition: display.h:98
virtual float Thickness()
virtual void UpdateBoundingVolume(void) DISTI_METHOD_OVERRIDE
The disti::GLPolygon class. Implements Polygons.
void GetSegmentIndices(const float startAngle, unsigned int &startIndex, const float endAngle, unsigned int &endIndex)
virtual void Draw(void) DISTI_METHOD_OVERRIDE
void RecomputeVertices(void)
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
void DrawArcSegment(bool textureObject)
Vector _end[2]
Definition: gls_ellipse.h:302
Definition: gls_display_list.h:50
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
Definition: gls_glo_file.h:988
void InvalidateGeometry(void)
Definition: gls_ellipse.h:235
virtual ~GlsEllipse()
bool _solid
Definition: gls_ellipse.h:322
virtual void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE
virtual unsigned int Interval()
virtual Vector RadiusVector(unsigned int index)
virtual GlsColor GetFillColor(void)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
void CalculateRadiiUnit(void)
GlsDisplayList & DisplayList(void)
Definition: gls_ellipse.h:242
unsigned int _interval
Definition: gls_ellipse.h:321
float _thickness
Definition: gls_ellipse.h:316
Vector _radii[2]
Definition: gls_ellipse.h:302
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
virtual float StartAngle()
virtual Vertex * Vertices() DISTI_METHOD_OVERRIDE
virtual void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz) DISTI_METHOD_OVERRIDE
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
Definition: gls_vertex_array.h:58
Vector _startTex[2]
Definition: gls_ellipse.h:302
float _endAngle
Definition: gls_ellipse.h:316
Definition: events.h:112
Vector _centerTex
Definition: gls_ellipse.h:302
Definition: gls_color.h:53
void DrawGeometry(void)
virtual void RadiusVectors(const Vector &r1, const Vector &r2)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax) DISTI_METHOD_OVERRIDE
The gls_auto_lib.
void DrawSolidCircle(bool textureObject)
void CalculateEndVertices(void)
Vector _endTex[2]
Definition: gls_ellipse.h:302
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
GlsDisplayList _displayList
Definition: gls_ellipse.h:297
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: vertex.h:84
virtual void CopyGeometry(DisplayObject *srcArg) DISTI_METHOD_OVERRIDE
GlsMatrixType _world2tex
Definition: gls_ellipse.h:325
virtual void Magnitude(const float &value, unsigned int index)
Definition: gls_ellipse.h:84
Macros and helper code to determine what subset of C++11/14/17 is available.
The disti::GlsIndexArray class, for managing index buffers.
void CalculateStartVertices(void)
Definition: bmpimage.h:46
virtual void SetFillColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:675
The disti::GlsDisplayList class.
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
void SetNeedsRecalculate(void)
Vector _radiiUnit[2]
Definition: gls_ellipse.h:302