GL Studio C++ Runtime API
gls_angular_scale.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsAngularScale class and global enumerations.
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 _GLS_ANGULAR_SCALE_H
41 #define _GLS_ANGULAR_SCALE_H
42 
43 #include "glpolygon.h"
44 #include "gls_cpp_lang_support.h"
45 
46 #ifdef GLES
47 # include "gls_quad_storage.h"
48 #else
49 # include "gls_display_list.h"
50 #endif
51 
52 //////////////////// Provides support for creating DLLs ////////////////////////
53 #if( defined( GLSGEN_EXPORT_GLSANGULARSCALE ) || defined( GLSGEN_IMPORT_GLSANGULARSCALE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
54  && defined( _MSC_VER )
55 # if defined( GLSGEN_EXPORT_GLSANGULARSCALE ) || defined( GLS_EXPORT_GENERATED )
56 # define GLSGEN_GLSANGULARSCALE_EXPORT __declspec( dllexport )
57 # else
58 # define GLSGEN_GLSANGULARSCALE_EXPORT __declspec( dllimport )
59 # endif
60 #else
61 # define GLSGEN_GLSANGULARSCALE_EXPORT
62 #endif
63 ///////////////////////////////////////////////////////////////////////////////
64 
65 #define LIB_BASE_NAME "gls_angular_scale"
66 #include "gls_auto_lib.h"
67 #undef LIB_BASE_NAME
68 
69 namespace disti
70 {
71 #ifdef GLES
72 // Forward Declaration
73 class GlsGloFileAttribute;
74 #endif
75 // SetValue enumerations
76 enum
77 {
78  GLS_ANGULAR_SCALE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
79  GLS_ANGULAR_SCALE_RADII,
80  GLS_ANGULAR_SCALE_DECONFLICT_TICKS,
81  GLS_ANGULAR_SCALE_HALO_ENABLED,
82  GLS_ANGULAR_SCALE_HALO_WIDTH,
83  GLS_ANGULAR_SCALE_HALO_COLOR,
84  GLS_ANGULAR_SCALE_USE_SCALABLE_LINES,
85  GLS_ANGULAR_SCALE_RADIUS,
86  GLS_ANGULAR_SCALE_DATA
87 };
88 
90 {
91 protected:
92  DistiAttribDict _attribDict;
93 
94 public:
95  bool active; /**< True if this scale is active */
96  bool useLineColor; /**< True if this scale draws with line color */
97  unsigned int ticks; /**< Number of ticks on this scale */
98  float startAngle; /**< Start angle in degrees */
99  float interval; /**< Interval between ticks in degrees */
100  float length; /**< Length of ticks in logical units */
101  float thickness; /**< Thickness of ticks in logical units */
102  GlsColor color; /**< Color to draw ticks if line color is not being used*/
103 
104  GlsAngularScaleData( void )
105  : active( false )
106  , useLineColor( false )
107  , ticks( 0 )
108  , startAngle( 0 )
109  , interval( 0 )
110  , length( 0 )
111  , thickness( 1 )
112  , color( 255, 255, 255, 255 )
113  {
114  InitMetaData();
115  }
116 
118  bool _active,
119  bool _useLineColor,
120  unsigned int _ticks,
121  float _startAngle,
122  float _interval,
123  float _length,
124  float _thickness,
125  const GlsColor& _color )
126  : active( _active )
127  , useLineColor( _useLineColor )
128  , ticks( _ticks )
129  , startAngle( _startAngle )
130  , interval( _interval )
131  , length( _length )
132  , thickness( _thickness )
133  , color( _color )
134  {
135  InitMetaData();
136  }
137 
138  GlsAngularScaleData( const GlsAngularScaleData& src )
139  {
140  *this = src;
141  }
142 
143  ~GlsAngularScaleData( void )
144  {
145  }
146 
147  bool GLSGEN_GLSANGULARSCALE_EXPORT operator==( const GlsAngularScaleData& right ) const;
148 
149  bool GLSGEN_GLSANGULARSCALE_EXPORT operator!=( const GlsAngularScaleData& right ) const
150  {
151  return !( this->operator==( right ) );
152  }
153 
154  void GLSGEN_GLSANGULARSCALE_EXPORT InitMetaData( void );
155 
156  // Writes this to a stream
157  virtual GLSGEN_GLSANGULARSCALE_EXPORT std::ostream& WriteValue( std::ostream& outstr );
158 
159  // Reads this from a stream
160  virtual GLSGEN_GLSANGULARSCALE_EXPORT std::istream& ReadValue( std::istream& instr );
161 };
162 
163 #define GLS_ANGULAR_SCALE_MAX 5
164 
165 typedef GlsAngularScaleData GlsAngularScaleDataArray[ GLS_ANGULAR_SCALE_MAX ];
166 
167 /** Runtime implementation of a GlsAngularScale */
169 {
170  friend class GlsAngularScaleEditor;
171 
172 private:
173  GlsAngularScale& operator=( const GlsAngularScale& ) DISTI_SPECIAL_MEM_FUN_DELETE;
174  GlsAngularScale( const GlsAngularScale& ) DISTI_SPECIAL_MEM_FUN_DELETE;
175 
176 public:
177  typedef GLPolygon _BaseClass;
178 
179  /** Create a new GlsAngularScale.
180  * \param generateInstance Whether or not to generate an instance name
181  * for this inputdevice */
182  GLSGEN_GLSANGULARSCALE_EXPORT GlsAngularScale( bool generateInstance = false );
183 
184  /** The copy constructor for GlsAngularScale
185  *
186  * \param that The GlsAngularScale object that is being copied
187  * \param generateNames Whether or not to generate a new instance name
188  */
189  GLSGEN_GLSANGULARSCALE_EXPORT GlsAngularScale( const GlsAngularScale& that, const bool generateNames );
190 
191  /** Destructs a GlsAngularScale object */
192  virtual GLSGEN_GLSANGULARSCALE_EXPORT ~GlsAngularScale();
193 
194  static GLSGEN_GLSANGULARSCALE_EXPORT DisplayObject* CreateInstance();
195 
196  virtual GLSGEN_GLSANGULARSCALE_EXPORT void SetAvailableAttributes( unsigned int value );
197 
198  virtual GLSGEN_GLSANGULARSCALE_EXPORT DisplayObject* CloneObject( bool generateNames = false );
199 
200  virtual GLSGEN_GLSANGULARSCALE_EXPORT void CopyProperties( DisplayObject* src );
201 
202  virtual GLSGEN_GLSANGULARSCALE_EXPORT void CopyGeometry( DisplayObject* srcArg );
203 
204 #ifndef GLES
205  virtual GLSGEN_GLSANGULARSCALE_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
206  virtual GLSGEN_GLSANGULARSCALE_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
207 #endif
208  virtual GLSGEN_GLSANGULARSCALE_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
209  virtual GLSGEN_GLSANGULARSCALE_EXPORT void Draw( void );
210 
211  virtual GLSGEN_GLSANGULARSCALE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar );
212  virtual GLSGEN_GLSANGULARSCALE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis );
213  virtual GLSGEN_GLSANGULARSCALE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
214 
215  virtual GLSGEN_GLSANGULARSCALE_EXPORT Vertex* Vertices();
216  virtual GLSGEN_GLSANGULARSCALE_EXPORT void GetExtents( float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz );
217  virtual GLSGEN_GLSANGULARSCALE_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax );
218  virtual GLSGEN_GLSANGULARSCALE_EXPORT void UpdateBoundingVolume( void );
219 
220  virtual GLSGEN_GLSANGULARSCALE_EXPORT void SetColor( const GlsColor& color );
221  inline void SetLineColor( const GlsColor& color ) { SetColor( color ); }
222 
223 #ifndef GLES
224  virtual GLSGEN_GLSANGULARSCALE_EXPORT void AntiAlias( bool alias );
225 #endif
226 
228 
229  virtual void SetValue( int spec, va_list& args );
230 
231  //////////////////////////////////////////////////
232  // GlsAngularScale specific operations
233  //////////////////////////////////////////////////
234 
235  /** Initializes data for one of the scales
236  * \param index Zero based index of the scale to set
237  * \param data The data to set
238  */
239  GLSGEN_GLSANGULARSCALE_EXPORT void SetScale( int index, const GlsAngularScaleData& data );
240 
241  /** Gets data for one of the scales
242  * \param index Zero based index of the scale to get
243  * \param data The GlsAngularScaleData structure to fill
244  */
245  GLSGEN_GLSANGULARSCALE_EXPORT void GetScale( int index, GlsAngularScaleData& data );
246 
247  /** Sets the tick deconfliction state for this scale
248  * \param val Wether or not to enable tick deconfliction
249  */
250  GLSGEN_GLSANGULARSCALE_EXPORT void DeconflictTicks( const bool& val );
251 
252  /** Gets the tick deconfliction state for this scale
253  * \return Whether or not tick deconfliction is enabled
254  */
255  GLSGEN_GLSANGULARSCALE_EXPORT bool DeconflictTicks( void ) { return _deconflictTicks; }
256 
257  /** Gets the halo state for this scale
258  * \return Whether or not halo is enabled
259  */
260  GLSGEN_GLSANGULARSCALE_EXPORT bool HaloEnabled( void ) { return _haloEnabled; }
261 
262  /** Sets the halo state for this scale
263  * \param val Wether or not to enable halo
264  */
265  GLSGEN_GLSANGULARSCALE_EXPORT void HaloEnabled( const bool& val );
266 
267  /** Gets the halo width for this scale
268  * \return The halo width for this scale
269  */
270  GLSGEN_GLSANGULARSCALE_EXPORT float HaloWidth( void ) { return _haloWidth; }
271 
272  /** Sets the halo width for this scale
273  * \param val New halo width
274  */
275  GLSGEN_GLSANGULARSCALE_EXPORT void HaloWidth( const float& val );
276 
277  /** Gets the halo color for this scale
278  * \return The halo color for this scale
279  */
280  GLSGEN_GLSANGULARSCALE_EXPORT GlsColor HaloColor( void ) { return _haloColor; }
281 
282  /** Sets the halo color for this scale
283  * \param val New halo color
284  */
285  GLSGEN_GLSANGULARSCALE_EXPORT void HaloColor( const GlsColor& val );
286 
287 #ifndef GLES
288  /** Gets the drawing mode for this scale
289  * \return The drawing mode for this scale
290  */
291  GLSGEN_GLSANGULARSCALE_EXPORT bool UseScalableLines( void ) { return _useScalableLines; }
292 
293  /** Sets the drawing mode for this scale
294  * \param val New drawing mode
295  */
296  GLSGEN_GLSANGULARSCALE_EXPORT void UseScalableLines( const bool& val );
297 
298 #endif
299  /** Gets the radius for this scale
300  * \return The radius for this scale
301  */
302  GLSGEN_GLSANGULARSCALE_EXPORT float Radius( void )
303  {
304  return _magnitude[ 0 ];
305  }
306 
307  /** Sets the radius for this scale
308  * \param val New radius
309  */
310  GLSGEN_GLSANGULARSCALE_EXPORT void Radius( const float& val );
311 
312 #ifdef GLES
313  /** Causes the VBO for this object to be recomputed */
314  GLSGEN_GLSANGULARSCALE_EXPORT void InvalidateGeometry( void )
315  {
316  _geometryRefresh = true;
318  }
319 #else
320  /** Causes the VBO for this object to be recomputed */
321  GLSGEN_GLSANGULARSCALE_EXPORT void InvalidateGeometry( void )
322  {
325  }
326 
327  /** Returns a reference to this object's display list */
328  GLSGEN_GLSANGULARSCALE_EXPORT GlsDisplayList& DisplayList( void ) { return _displayList; }
329 #endif
330 
331 protected:
332  /** True when the object's vertices need to be recalculated */
334 
335  /** Calculates _radii based on_magnitude and _radiiUnit */
336  void MagnitudeChanged( void );
337 
338  /** Calculates _radiiUnit and _magnitude based on _radii */
339  void CalculateRadiiUnit( void );
340 
341 #ifdef GLES
342  /** Manages a VBO for drawing the tick marks */
343  GlsQuadListVC_3D _quads;
344 
345  /** Updates the VBO when the object changes */
346  void BakeVBO();
347 #endif
348 
349 #ifndef GLES
350  /** Minimizes calls to glColor when drawing the scale */
351  void CurrentColor( const GlsColor& newColor );
352 
353  /** Minimizes calls to glLineWidth when drawing the scale */
354  void CurrentLineWidth( const float& newLineWidth );
355 
356  /** Stores the current color. Used when calculating a new display list so that redundant
357  * glColor calls are not made */
359 
360  /** Stores the current line width. Used when calculating a new display list so that redundant
361  * glLineWidth calls are not made */
363 
364  /** True if the current color has been set. Gets reset every time a new display list is
365  * recalculated. */
367 
368  /** True if the current line width has been set. Gets reset every time a new display list is
369  * recalculated. */
371 
372  /** Stores the scale in a display list for faster drawing */
374 #endif
375 
376  /** Recomputes the object's vertices from its radii */
377  void RecomputeVertices( void );
378 
379  /** Determines if a tick with the given angle should be drawn or not. If a higher priority
380  * scale already has a tick at that level and deconfliction is enabled, then this method
381  * will return false */
382  bool TickNeeded( int currentLevel, float currentAngle );
383 
384  /// Calculates and draws a single scale using the given halo length and thickness
385  /// \param i The index of the scale to draw
386  /// \param haloLength The length of the halo
387  /// \param haloThickness The thickness of the halo
388 #ifdef GLES
389  /// \param color The color of the scale
390  void DrawScale( int i, float haloLength, float haloThickness, GlsColor& color );
391 #else
392  void DrawScale( int i, float haloLength, float haloThickness );
393 #endif
394 
395 #ifdef GLES
396  /** Set a single attribute from the GLO file.
397  * \param data The attribute to set and its associated data.
398  */
399  virtual GLSGEN_GLSANGULARSCALE_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
400 #endif
401 
402 #ifndef GLES
403  /** Calculates current tick mark locations and performs OpenGL drawing commands */
404  virtual void DrawGeometry( void );
405 #endif
406 
407  /** Always equal to _radiiUnit * _magnitude */
409 
410  /** Unit vectors describing the radii */
412 
413  /** Magnitudes of the two radii */
414  float _magnitude[ 2 ];
415 
416  /** The particulars of each scale */
417  GlsAngularScaleDataArray _scale;
418 
419  /** True if duplicated tick marks are removed */
421 
422  /** True if haloing is enabled */
424 
425  /** Width of the halo in logical units */
426  float _haloWidth;
427 
428  /** Color of the halo */
430 
431 #ifndef GLES
432  /** True if scale is drawn with polygon quads instead of lines*/
434 #endif
435 };
436 
437 /** Metadata for scale data */
439 {
440 protected:
441  GlsAngularScaleDataArray* _attribPtr;
442  unsigned int _arraySize;
443 
444 public:
445  DistiAttributeConnectionGlsAngularScaleDataArray( CallbackMethodCallerBase* callback, const AttributeName& name, GlsAngularScaleDataArray* attribPtr, int arraySize )
446  : DistiAttributeBase( callback, name, false )
447  , _attribPtr( attribPtr )
448  , _arraySize( arraySize )
449  {
450  }
451 
452  virtual GLSGEN_GLSANGULARSCALE_EXPORT ~DistiAttributeConnectionGlsAngularScaleDataArray();
453  virtual GLSGEN_GLSANGULARSCALE_EXPORT bool OkToWrite() const;
454  virtual GLSGEN_GLSANGULARSCALE_EXPORT std::ostream& WriteValue( std::ostream& outstr );
455  virtual GLSGEN_GLSANGULARSCALE_EXPORT std::istream& ReadValue( std::istream& instr );
456 };
457 
458 } // namespace disti
459 
460 #endif
Definition: cull.h:49
virtual void GetExtents(float &minx, float &miny, float &minz, float &maxx, float &maxy, float &maxz)
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
void SetScale(int index, const GlsAngularScaleData &data)
float thickness
Definition: gls_angular_scale.h:101
Definition: vertex.h:408
Definition: gls_angular_scale.h:89
virtual std::ostream & WriteValue(std::ostream &outstr)
float HaloWidth(void)
Definition: gls_angular_scale.h:270
void Invalidate(void)
Definition: gls_display_list.h:82
void DrawScale(int i, float haloLength, float haloThickness)
Definition: dynamic_array.h:62
bool _haloEnabled
Definition: gls_angular_scale.h:423
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:276
GlsColor _haloColor
Definition: gls_angular_scale.h:429
bool _needsRecalculate
Definition: gls_angular_scale.h:333
virtual void UpdateBoundingVolume(void)
void GetScale(int index, GlsAngularScaleData &data)
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
virtual void SetAvailableAttributes(unsigned int value)
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
virtual void SetValue(int spec, va_list &args)
bool _useScalableLines
Definition: gls_angular_scale.h:433
GlsDisplayList _displayList
Definition: gls_angular_scale.h:373
Definition: display.h:98
virtual void CopyGeometry(DisplayObject *srcArg)
The disti::GLPolygon class. Implements Polygons.
bool HaloEnabled(void)
Definition: gls_angular_scale.h:260
void CalculateRadiiUnit(void)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
bool UseScalableLines(void)
Definition: gls_angular_scale.h:291
float length
Definition: gls_angular_scale.h:100
GlsDisplayList & DisplayList(void)
Definition: gls_angular_scale.h:328
GlsColor color
Definition: gls_angular_scale.h:102
float startAngle
Definition: gls_angular_scale.h:98
Definition: gls_display_list.h:50
Definition: gls_glo_file.h:982
void CurrentColor(const GlsColor &newColor)
void InvalidatePainter()
Definition: display.h:1717
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
GlsColor _currentColor
Definition: gls_angular_scale.h:358
float _haloWidth
Definition: gls_angular_scale.h:426
bool _currentLineWidthSet
Definition: gls_angular_scale.h:370
Definition: disti_metadata.h:180
void InvalidateGeometry(void)
Definition: gls_angular_scale.h:321
Definition: events.h:111
Definition: gls_color.h:53
Definition: disti_metadata.h:673
Definition: callback_caller_base.h:55
bool TickNeeded(int currentLevel, float currentAngle)
bool _currentColorSet
Definition: gls_angular_scale.h:366
GlsColor HaloColor(void)
Definition: gls_angular_scale.h:280
The gls_auto_lib.
virtual Vertex * Vertices()
Vector _radii[2]
Definition: gls_angular_scale.h:408
virtual void DrawGeometry(void)
bool useLineColor
Definition: gls_angular_scale.h:96
GlsAngularScaleDataArray _scale
Definition: gls_angular_scale.h:417
virtual void Draw(void)
void CurrentLineWidth(const float &newLineWidth)
virtual void SetColor(const GlsColor &color)
float Radius(void)
Definition: gls_angular_scale.h:302
virtual std::istream & ReadValue(std::istream &instr)
virtual void Rotate(const Vector &orig, float angle, const Vector &axis)
virtual void CopyProperties(DisplayObject *src)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax)
virtual bool AntiAlias(void)
DisplayObject * handle(DisplayEvent *ev)
bool DeconflictTicks(void)
Definition: gls_angular_scale.h:255
Definition: vertex.h:83
unsigned int ticks
Definition: gls_angular_scale.h:97
bool active
Definition: gls_angular_scale.h:95
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar)
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
float interval
Definition: gls_angular_scale.h:99
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: disti_metadata.h:79
Vector _radiiUnit[2]
Definition: gls_angular_scale.h:411
bool _deconflictTicks
Definition: gls_angular_scale.h:420
Definition: gls_quad_storage.h:63
void RecomputeVertices(void)
Definition: bmpimage.h:46
The disti::GlsDisplayList class.
Definition: gls_angular_scale.h:168
float _magnitude[2]
Definition: gls_angular_scale.h:414
float _currentLineWidth
Definition: gls_angular_scale.h:362
void MagnitudeChanged(void)