GL Studio C++ Runtime API
gls_ellipse.h
Go to the documentation of this file.
1/// \file gls_ellipse.h
2/// \brief The disti::GlsEllipse class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef DISTI_INCLUDED_GLS_ELLIPSE_H
40#define DISTI_INCLUDED_GLS_ELLIPSE_H
41
42#include "glpolygon.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/// Automatically link the runtime library plugin (on Windows).
65#define LIB_BASE_NAME "gls_ellipse"
66#include "gls_auto_lib.h"
67#undef LIB_BASE_NAME
68
69namespace disti
70{
71// SetValue enumerations
72enum
73{
74 GLS_ELLIPSE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
75 GLS_ELLIPSE_RADII,
76 GLS_ELLIPSE_THICKNESS,
77 GLS_ELLIPSE_SOLID,
78 GLS_ELLIPSE_INTERVAL,
79 GLS_ELLIPSE_START_ANGLE,
80 GLS_ELLIPSE_END_ANGLE,
81 GLS_ELLIPSE_COLOR
82};
83
84/** Runtime implementation of a GlsEllipse */
85class GlsEllipse : public GLPolygon
86{
87 friend class GlsEllipseEditor;
88
89public:
90 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
91 typedef GLPolygon _BaseClass; ///< Deprecated typedef for the base class.
92 typedef GLPolygon BaseClass; ///< Typedef for the base class.
93
94 /** Create a new GlsEllipse.
95 * \param generateInstance Whether or not to generate an instance name
96 * for this inputdevice */
97 GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( bool generateInstance = false );
98
99 /// Copy Constructor
100 /// \param that The object to copy from.
101 /// \param generateNames Whether or not to generate an instance name.
102 GLSGEN_GLSELLIPSE_EXPORT GlsEllipse( const GlsEllipse& that, const bool generateNames );
103
104 /** Destructs a GlsEllipse object */
106
107 /// \return A pointer to a new GlsEllipse object.
109
114
115#ifndef GLES
118#endif
119
122 GLSGEN_GLSELLIPSE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
123 GLSGEN_GLSELLIPSE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
124 GLSGEN_GLSELLIPSE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
127 GLSGEN_GLSELLIPSE_EXPORT void GetExtents( float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz ) DISTI_METHOD_OVERRIDE;
130
131 /* Unhides base class implementation. */
132 using BaseClass::SetFillColor;
133
134 /* Unhides base class implementation. */
135 using BaseClass::GetFillColor;
136
137 /** Sets the color for filling the object
138 * \param color The new color for the object
139 */
141
142 /** Gets the color for filling the object
143 * \return The fill color for the object
144 */
146
148
150
151 /// Configure the OpenGL texture state for this object.
152 /// \note Not normally called by users.
153 /// \return True if the OpenGL state was changed.
155
156 //////////////////////////////////////////////////
157 // GlsEllipse specific operations
158 //////////////////////////////////////////////////
159
160 /** Sets the radius vectors
161 * \param r1
162 * \param r2
163 */
164 virtual GLSGEN_GLSELLIPSE_EXPORT void RadiusVectors( const Vector& r1, const Vector& r2 );
165
166 /// \param index The index of the radius vector to return (0 or 1).
167 /// \return The radius vector for the specified index.
168 virtual GLSGEN_GLSELLIPSE_EXPORT Vector RadiusVector( unsigned int index );
169
170 /// \param index The index of the unit vector to return (0 or 1).
171 /// \return The unit vector for the specified index.
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 */
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 */
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 */
209
210 /// Sets the magnitude (thickness of the ellipse outer edge).
211 /// \param value The new magnitude value to set.
212 /// \param index The axis to set the magnitude on (0 or 1).
213 virtual GLSGEN_GLSELLIPSE_EXPORT void Magnitude( const float& value, unsigned int index );
214
215 /// \param index The axis to get the magnitude for (0 or 1).
216 /// \return The magnitude (thickness of the ellipse outer edge) on the given axis.
217 virtual GLSGEN_GLSELLIPSE_EXPORT float Magnitude( unsigned int index );
218
219 /** Sets the solid flag
220 * \param value When true the elipse is drawn solid
221 */
222 virtual GLSGEN_GLSELLIPSE_EXPORT void Solid( const bool& value );
223 /** Gets the solid flag
224 * \return The current solid flag value
225 */
227
228#ifdef GLES
229 /** Causes the display list for this object to be recomputed */
230 void InvalidateGeometry()
231 {
232 _geometryRefresh = true;
234 }
235#else
236 /** Causes the display list for this object to be recomputed */
238 {
241 }
242
243 /// \return A reference to this object's display list.
245#endif
246protected:
247 /** Calculates _radiiUnit and _magnitude based on _radii */
249
250 /** callback called when the ellipse needs to be recalculated because an attribute has changed
251 */
253
254#ifdef GLES
255 /** Draws the arc segment mode
256 * \param textureObject TRUE if object should be drawn textured
257 */
258 void GLSGEN_GLSELLIPSE_EXPORT ComputeArcSegment( bool textureObject );
259
260 /** Draws the solid circle mode
261 * \param textureObject TRUE if object should be drawn textured
262 */
263 void GLSGEN_GLSELLIPSE_EXPORT ComputeSolidCircle( bool textureObject );
264
265 /** Set a single attribute from the GLO file.
266 * \param data The attribute to set and its associated data.
267 */
268 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
269#else
270 /** Draws the arc segment mode
271 * \param textureObject TRUE if object should be drawn textured
272 */
273 void GLSGEN_GLSELLIPSE_EXPORT DrawArcSegment( bool textureObject );
274
275 /** Draws the solid circle mode
276 * \param textureObject TRUE if object should be drawn textured
277 */
278 void GLSGEN_GLSELLIPSE_EXPORT DrawSolidCircle( bool textureObject );
279
280 /** Performs OpenGL drawing commands */
282#endif
283 /** Recomputes the object's vertices from its radii */
285
286 /** Calculates the start vertices */
288
289 /** Calculates the end vertices */
291
292 /// Gets starting and ending indices for vertices.
293 /// \param startAngle The start angle to calculate from in degrees.
294 /// \param startIndex The returned segment index closest to the start angle.
295 /// \param endAngle The end angle to calculate from in degrees.
296 /// \param endIndex The returned segment index closest to the end angle.
297 void GLSGEN_GLSELLIPSE_EXPORT GetSegmentIndices( const float startAngle, unsigned int& startIndex, const float endAngle, unsigned int& endIndex );
298
299 /// Get the inner index, the index of the vertex on the inner edge of a non-solid ellipse.
300 /// Used for picking.
301 /// \param index The segment index to derive the vertex index from.
302 /// \return The vertex index associated with the segment.
303 unsigned int GLSGEN_GLSELLIPSE_EXPORT InnerIndex( const unsigned int index );
304
305 /// Get the outer index, the index of the vertex on the outer edge of the ellipse.
306 /// Used for picking.
307 /// \param index The segment index to derive the vertex index from.
308 /// \return The vertex index associated with the segment.
309 unsigned int GLSGEN_GLSELLIPSE_EXPORT OuterIndex( const unsigned int index );
310
311#ifndef GLES
312 /** Stores the scale in a display list for faster drawing */
314#else
315 GlsVertexArray _outlineVertexArrayExterior; ///< The outline vertices that trace the outer radius
316 GlsVertexArray _outlineVertexArrayInterior; ///< The outline vertices that trace inner radius, and connecting edges
317#endif
318 /** Stores the scale in a display list for faster drawing */
319 Vector _radii[ 2 ], /** Two radii defining the ellipse size and orientation
320 * Only used to read/write file. _radiiNormal is in control
321 */
322
323 _normal, /**< Normal to surface defined by radii */
324 _radiiUnit[ 2 ], /**< Unit vector of radii */
325 _start[ 2 ], /**< Two points defining the starting edge of a partial ellipse. */
326 _startTex[ 2 ], /**< Texture coordinates of starting points */
327 _end[ 2 ], /**< Two points defining the ending edge of a partial ellipse. */
328 _endTex[ 2 ], /**< Texture coordinates of starting points */
329 _centerTex; /**< Texture coordinate of center point */
330
331 GlsColor _objectColor; /**< Fill color of object */
332
333 float _thickness, /**< Thickness of the outer edge of the ellipse in logical units */
334 _startAngle, /**< Starting angle of ellipse segment in degrees */
335 _endAngle, /**< Ending angle of ellipse segment in degrees */
336 _magnitude[ 2 ]; /**< Magnitude of radii */
337
338 unsigned int _interval; /**< Interval between subdivisions, in degrees */
339 bool _solid; /**< If true, ellipse drawn as solid not as "donut" */
340 bool _needsRecalculate; ///< If true, the ellipse vertices will be recalculated next frame from angle and radius data.
341
342 GlsMatrixType _world2tex; /**< Matrix used to calculate texture coordinates for the object */
343
344private:
345 // disallow implicit assignments and copy constructor
348};
349
350} // namespace disti
351
352#endif
Definition: cull.h:49
Definition: events.h:111
Definition: display.h:95
Definition: dynamic_array.h:79
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
Definition: gls_color.h:53
Definition: gls_display_list.h:51
void Invalidate()
Definition: gls_display_list.h:85
Definition: gls_ellipse.h:86
Vector _start[2]
Definition: gls_ellipse.h:325
Vector _centerTex
Definition: gls_ellipse.h:329
virtual bool Solid()
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
float _startAngle
Definition: gls_ellipse.h:334
Vector _startTex[2]
Definition: gls_ellipse.h:326
virtual float StartAngle()
void DrawSolidCircle(bool textureObject)
void GetSegmentIndices(const float startAngle, unsigned int &startIndex, const float endAngle, unsigned int &endIndex)
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
void CalculateStartVertices()
void RecomputeVertices()
Vector _endTex[2]
Definition: gls_ellipse.h:328
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
GlsColor GetFillColor() DISTI_METHOD_OVERRIDE
void SetFillColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
void CalculateEndVertices()
GlsDisplayList & DisplayList()
Definition: gls_ellipse.h:244
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
virtual unsigned int Interval()
GlsColor _objectColor
Definition: gls_ellipse.h:331
virtual Vector RadiusVector(unsigned int index)
void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
void Draw() DISTI_METHOD_OVERRIDE
void CopyGeometry(DisplayObject *srcArg) DISTI_METHOD_OVERRIDE
Vector _radii[2]
Definition: gls_ellipse.h:319
virtual float Thickness()
void DrawArcSegment(bool textureObject)
GlsDisplayList _displayList
Definition: gls_ellipse.h:313
unsigned int InnerIndex(const unsigned int index)
Vector _end[2]
Definition: gls_ellipse.h:327
virtual void RadiusVectors(const Vector &r1, const Vector &r2)
void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE
float _thickness
Definition: gls_ellipse.h:333
bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
GlsMatrixType _world2tex
Definition: gls_ellipse.h:342
unsigned int _interval
Definition: gls_ellipse.h:338
virtual bool SetupTexture()
void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax) DISTI_METHOD_OVERRIDE
void CalculateRadiiUnit()
virtual void Magnitude(const float &value, unsigned int index)
Vector _radiiUnit[2]
Definition: gls_ellipse.h:324
void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
bool _solid
Definition: gls_ellipse.h:339
unsigned int OuterIndex(const unsigned int index)
float _endAngle
Definition: gls_ellipse.h:335
GlsEllipse(bool generateInstance=false)
virtual Vector UnitVector(unsigned int index)
virtual float EndAngle()
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void InvalidateGeometry()
Definition: gls_ellipse.h:237
bool _needsRecalculate
If true, the ellipse vertices will be recalculated next frame from angle and radius data.
Definition: gls_ellipse.h:340
void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE
float _magnitude[2]
Definition: gls_ellipse.h:336
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz) DISTI_METHOD_OVERRIDE
void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
Vertex * Vertices() DISTI_METHOD_OVERRIDE
Vector _normal
Definition: gls_ellipse.h:323
void SetNeedsRecalculate()
Definition: gls_glo_file.h:1241
Definition: gls_vertex_array.h:58
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
Definition: vertex.h:419
The disti::GLPolygon class. Implements Polygons.
The gls_auto_lib.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
The disti::GlsDisplayList class.
#define GLSGEN_GLSELLIPSE_EXPORT
Provides support for creating DLLs.
Definition: gls_ellipse.h:60
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
The disti::GlsIndexArray class, for managing index buffers.
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: bmpimage.h:46