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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40#ifndef _GLSELLIPSE_H
41#define _GLSELLIPSE_H
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
120 virtual GLSGEN_GLSELLIPSE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
122 virtual GLSGEN_GLSELLIPSE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
123 virtual GLSGEN_GLSELLIPSE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
124 virtual GLSGEN_GLSELLIPSE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) 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;
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
149 virtual GLSGEN_GLSELLIPSE_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
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 */
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 virtual 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 _outlineVertexArray;
316#endif
317 /** Stores the scale in a display list for faster drawing */
318 Vector _radii[ 2 ], /** Two radii defining the ellipse size and orientation
319 * Only used to read/write file. _radiiNormal is in control
320 */
321
322 _normal, /**< Normal to surface defined by radii */
323 _radiiUnit[ 2 ], /**< Unit vector of radii */
324 _start[ 2 ], /**< Two points defining the starting edge of a partial ellipse. */
325 _startTex[ 2 ], /**< Texture coordinates of starting points */
326 _end[ 2 ], /**< Two points defining the ending edge of a partial ellipse. */
327 _endTex[ 2 ], /**< Texture coordinates of starting points */
328 _centerTex; /**< Texture coordinate of center point */
329
330 GlsColor _objectColor; /**< Fill color of object */
331
332 float _thickness, /**< Thickness of the outer edge of the ellipse in logical units */
333 _startAngle, /**< Starting angle of ellipse segment in degrees */
334 _endAngle, /**< Ending angle of ellipse segment in degrees */
335 _magnitude[ 2 ]; /**< Magnitude of radii */
336
337 unsigned int _interval; /**< Interval between subdivisions, in degrees */
338 bool _solid; /**< If true, ellipse drawn as solid not as "donut" */
339 bool _needsRecalculate; ///< If true, the ellipse vertices will be recalculated next frame from angle and radius data.
340
341 GlsMatrixType _world2tex; /**< Matrix used to calculate texture coordinates for the object */
342
343private:
344 // disallow implicit assignments and copy constructor
347};
348
349} // namespace disti
350
351#endif
Definition: cull.h:50
Definition: events.h:113
Definition: display.h:96
Definition: dynamic_array.h:79
The Polygon class. Implements Polygons.
Definition: glpolygon.h:56
Definition: gls_color.h:54
Definition: gls_display_list.h:51
void Invalidate()
Definition: gls_display_list.h:85
Definition: gls_ellipse.h:86
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual void CalculateTextureCoordinates() DISTI_METHOD_OVERRIDE
Vector _start[2]
Definition: gls_ellipse.h:324
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
Vector _centerTex
Definition: gls_ellipse.h:328
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual bool Solid()
float _startAngle
Definition: gls_ellipse.h:333
Vector _startTex[2]
Definition: gls_ellipse.h:325
virtual float StartAngle()
void DrawSolidCircle(bool textureObject)
void GetSegmentIndices(const float startAngle, unsigned int &startIndex, const float endAngle, unsigned int &endIndex)
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void CalculateStartVertices()
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) DISTI_METHOD_OVERRIDE
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
void RecomputeVertices()
Vector _endTex[2]
Definition: gls_ellipse.h:327
void CalculateEndVertices()
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
GlsDisplayList & DisplayList()
Definition: gls_ellipse.h:244
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
virtual unsigned int Interval()
virtual Vertex * Vertices() DISTI_METHOD_OVERRIDE
GlsColor _objectColor
Definition: gls_ellipse.h:330
virtual Vector RadiusVector(unsigned int index)
static DisplayObject * CreateInstance()
virtual void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz) DISTI_METHOD_OVERRIDE
Vector _radii[2]
Definition: gls_ellipse.h:318
virtual void CopyGeometry(DisplayObject *srcArg) DISTI_METHOD_OVERRIDE
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:326
virtual void RadiusVectors(const Vector &r1, const Vector &r2)
float _thickness
Definition: gls_ellipse.h:332
GlsMatrixType _world2tex
Definition: gls_ellipse.h:341
unsigned int _interval
Definition: gls_ellipse.h:337
virtual bool SetupTexture()
void CalculateRadiiUnit()
virtual void Magnitude(const float &value, unsigned int index)
Vector _radiiUnit[2]
Definition: gls_ellipse.h:323
bool _solid
Definition: gls_ellipse.h:338
unsigned int OuterIndex(const unsigned int index)
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
float _endAngle
Definition: gls_ellipse.h:334
GlsEllipse(bool generateInstance=false)
virtual void UpdateBoundingVolume() DISTI_METHOD_OVERRIDE
virtual Vector UnitVector(unsigned int index)
virtual GlsColor GetFillColor() DISTI_METHOD_OVERRIDE
virtual float EndAngle()
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax) 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:339
float _magnitude[2]
Definition: gls_ellipse.h:335
virtual void SetFillColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
Vector _normal
Definition: gls_ellipse.h:322
void SetNeedsRecalculate()
Definition: gls_glo_file.h:1243
Definition: gls_vertex_array.h:60
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:85
Definition: vertex.h:420
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:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
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:52
The disti::GlsIndexArray class, for managing index buffers.
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47