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