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 ) { _geometryRefresh = true; }
315 #else
316  /** Causes the VBO for this object to be recomputed */
317  GLSGEN_GLSANGULARSCALE_EXPORT void InvalidateGeometry( void ) { _displayList.Invalidate(); }
318 
319  /** Returns a reference to this object's display list */
320  GLSGEN_GLSANGULARSCALE_EXPORT GlsDisplayList& DisplayList( void ) { return _displayList; }
321 #endif
322 
323 protected:
324  /** True when the object's vertices need to be recalculated */
326 
327  /** Calculates _radii based on_magnitude and _radiiUnit */
328  void MagnitudeChanged( void );
329 
330  /** Calculates _radiiUnit and _magnitude based on _radii */
331  void CalculateRadiiUnit( void );
332 
333 #ifdef GLES
334  /** Manages a VBO for drawing the tick marks */
335  GlsQuadListVC_3D _quads;
336 
337  /** Updates the VBO when the object changes */
338  void BakeVBO();
339 #endif
340 
341 #ifndef GLES
342  /** Minimizes calls to glColor when drawing the scale */
343  void CurrentColor( const GlsColor& newColor );
344 
345  /** Minimizes calls to glLineWidth when drawing the scale */
346  void CurrentLineWidth( const float& newLineWidth );
347 
348  /** Stores the current color. Used when calculating a new display list so that redundant
349  * glColor calls are not made */
351 
352  /** Stores the current line width. Used when calculating a new display list so that redundant
353  * glLineWidth calls are not made */
355 
356  /** True if the current color has been set. Gets reset every time a new display list is
357  * recalculated. */
359 
360  /** True if the current line width has been set. Gets reset every time a new display list is
361  * recalculated. */
363 
364  /** Stores the scale in a display list for faster drawing */
366 #endif
367 
368  /** Recomputes the object's vertices from its radii */
369  void RecomputeVertices( void );
370 
371  /** Determines if a tick with the given angle should be drawn or not. If a higher priority
372  * scale already has a tick at that level and deconfliction is enabled, then this method
373  * will return false */
374  bool TickNeeded( int currentLevel, float currentAngle );
375 
376  /// Calculates and draws a single scale using the given halo length and thickness
377  /// \param i The index of the scale to draw
378  /// \param haloLength The length of the halo
379  /// \param haloThickness The thickness of the halo
380 #ifdef GLES
381  /// \param color The color of the scale
382  void DrawScale( int i, float haloLength, float haloThickness, GlsColor& color );
383 #else
384  void DrawScale( int i, float haloLength, float haloThickness );
385 #endif
386 
387 #ifdef GLES
388  /** Set a single attribute from the GLO file.
389  * \param data The attribute to set and its associated data.
390  */
391  virtual GLSGEN_GLSANGULARSCALE_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
392 #endif
393 
394 #ifndef GLES
395  /** Calculates current tick mark locations and performs OpenGL drawing commands */
396  virtual void DrawGeometry( void );
397 #endif
398 
399  /** Always equal to _radiiUnit * _magnitude */
401 
402  /** Unit vectors describing the radii */
404 
405  /** Magnitudes of the two radii */
406  float _magnitude[ 2 ];
407 
408  /** The particulars of each scale */
409  GlsAngularScaleDataArray _scale;
410 
411  /** True if duplicated tick marks are removed */
413 
414  /** True if haloing is enabled */
416 
417  /** Width of the halo in logical units */
418  float _haloWidth;
419 
420  /** Color of the halo */
422 
423 #ifndef GLES
424  /** True if scale is drawn with polygon quads instead of lines*/
426 #endif
427 };
428 
429 /** Metadata for scale data */
431 {
432 protected:
433  GlsAngularScaleDataArray* _attribPtr;
434  unsigned int _arraySize;
435 
436 public:
437  DistiAttributeConnectionGlsAngularScaleDataArray( CallbackMethodCallerBase* callback, const AttributeName& name, GlsAngularScaleDataArray* attribPtr, int arraySize )
438  : DistiAttributeBase( callback, name, false )
439  , _attribPtr( attribPtr )
440  , _arraySize( arraySize )
441  {
442  }
443 
445  virtual bool OkToWrite() const;
446  virtual std::ostream& WriteValue( std::ostream& outstr );
447  virtual std::istream& ReadValue( std::istream& instr );
448 };
449 
450 } // namespace disti
451 
452 #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:415
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:278
GlsColor _haloColor
Definition: gls_angular_scale.h:421
bool _needsRecalculate
Definition: gls_angular_scale.h:325
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:425
GlsDisplayList _displayList
Definition: gls_angular_scale.h:365
Definition: display.h:97
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:320
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:835
void CurrentColor(const GlsColor &newColor)
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:350
float _haloWidth
Definition: gls_angular_scale.h:418
bool _currentLineWidthSet
Definition: gls_angular_scale.h:362
Definition: disti_metadata.h:174
void InvalidateGeometry(void)
Definition: gls_angular_scale.h:317
Definition: events.h:110
Definition: gls_color.h:53
Definition: disti_metadata.h:667
Definition: callback_caller_base.h:55
bool TickNeeded(int currentLevel, float currentAngle)
bool _currentColorSet
Definition: gls_angular_scale.h:358
GlsColor HaloColor(void)
Definition: gls_angular_scale.h:280
The gls_auto_lib.
virtual Vertex * Vertices()
Vector _radii[2]
Definition: gls_angular_scale.h:400
virtual void DrawGeometry(void)
bool useLineColor
Definition: gls_angular_scale.h:96
GlsAngularScaleDataArray _scale
Definition: gls_angular_scale.h:409
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:403
bool _deconflictTicks
Definition: gls_angular_scale.h:412
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:406
float _currentLineWidth
Definition: gls_angular_scale.h:354
void MagnitudeChanged(void)