GL Studio C++ Runtime API
gls_linear_scale.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsLinearScale 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 _GLS_LINEAR_SCALE_H
41#define _GLS_LINEAR_SCALE_H
42
43#include "glpolygon.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_GLSLINEARSCALE ) || defined( GLSGEN_IMPORT_GLSLINEARSCALE ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
54 && defined( _MSC_VER )
55# if defined( GLSGEN_EXPORT_GLSLINEARSCALE ) || defined( GLS_EXPORT_GENERATED )
56# define GLSGEN_GLSLINEARSCALE_EXPORT __declspec( dllexport )
57# else
58# define GLSGEN_GLSLINEARSCALE_EXPORT __declspec( dllimport )
59# endif
60#else
61# define GLSGEN_GLSLINEARSCALE_EXPORT
62#endif
63///////////////////////////////////////////////////////////////////////////////
64
65/// Automatically link the runtime library plugin (on Windows).
66#define LIB_BASE_NAME "gls_linear_scale"
67#include "gls_auto_lib.h"
68#undef LIB_BASE_NAME
69
70namespace disti
71{
72// SetValue enumerations
73enum
74{
75 GLS_LINEAR_SCALE_FIRST_VALUE = GLS_LAST_INITIALIZER + 1,
76 GLS_LINEAR_SCALE_RADII,
77 GLS_LINEAR_SCALE_DECONFLICT_TICKS,
78 GLS_LINEAR_SCALE_HALO_ENABLED,
79 GLS_LINEAR_SCALE_HALO_WIDTH,
80 GLS_LINEAR_SCALE_HALO_COLOR,
81 GLS_LINEAR_SCALE_TICK_ANCHOR,
82 GLS_LINEAR_SCALE_USE_SCALABLE_LINES,
83 GLS_LINEAR_SCALE_DATA
84};
85
86/// Tick anchor behavior
87typedef enum
88{
89 GLS_TICK_ANCHOR_TOP,
90 GLS_TICK_ANCHOR_BOTTOM,
91 GLS_TICK_ANCHOR_CENTER
93
94/// \details The GlsLinearScaleData class. Stores information for the appearance of one set of tick marks.
96{
97protected:
98 DistiAttribDict _attribDict; ///< The attribute dictionary for this class' members.
99
100public:
101 bool active; ///< True if this scale is active.
102 bool useLineColor; ///< True if this scale draws with line color.
103 unsigned int ticks; ///< Number of ticks on this scale.
104 float startingOffset; ///< Start offset in logical units.
105 float interval; ///< Interval between ticks in logical units.
106 float length; ///< Length of ticks in logical units.
107 float thickness; ///< Thickness of ticks in logical units.
108 GlsColor color; ///< Color to draw ticks if line color is not being used.
109
111 : active( false )
112 , useLineColor( false )
113 , ticks( 0 )
114 , startingOffset( 0 )
115 , interval( 0 )
116 , length( 0 )
117 , thickness( 1 )
118 , color( 255, 255, 255, 255 )
119 {
120 InitMetaData();
121 }
122
123 /// Constructor
124 /// \param _active True if this scale is active.
125 /// \param _useLineColor True if this scale draws with line color.
126 /// \param _ticks Number of ticks on this scale.
127 /// \param _startingOffset Start offset in logical units.
128 /// \param _interval Interval between ticks in degrees.
129 /// \param _length Length of ticks in logical units.
130 /// \param _thickness Thickness of ticks in logical units.
131 /// \param _color Color to draw ticks if line color is not being used.
133 bool _active,
134 bool _useLineColor,
135 unsigned int _ticks,
136 float _startingOffset,
137 float _interval,
138 float _length,
139 float _thickness,
140 const GlsColor& _color )
141 : active( _active )
142 , useLineColor( _useLineColor )
143 , ticks( _ticks )
144 , startingOffset( _startingOffset )
145 , interval( _interval )
146 , length( _length )
147 , thickness( _thickness )
148 , color( _color )
149 {
150 InitMetaData();
151 }
152
153 /// Copy constructor
154 /// \param src The object to copy from.
156 {
157 InitMetaData();
158 *this = src;
159 }
160
161 /// Assignment operator
162 /// \param src The object to copy from.
163 /// \return The resulting object (this).
165 {
166 if( this != &src )
167 {
168 active = src.active;
170 ticks = src.ticks;
172 interval = src.interval;
173 length = src.length;
174 thickness = src.thickness;
175 color = src.color;
176
178 }
179 return *this;
180 }
181
182 /// Equality operator
183 /// \param right The object to compare.
184 /// \return Whether or not the objects are equal.
186
187 /// Inequality operator
188 /// \param right The object to compare.
189 /// \return Whether or not the objects are not equal.
191 {
192 return !( this->operator==( right ) );
193 }
194
195 /// Create DistiAttributes for this object's members.
197
198 /// Writes this to a stream.
199 /// \param outstr The stream to write to.
200 /// \return The stream in its current state.
201 GLSGEN_GLSLINEARSCALE_EXPORT std::ostream& WriteValue( std::ostream& outstr );
202
203 /// Reads this from a stream.
204 /// \param instr The stream to read from.
205 /// \return The stream in its current state.
206 GLSGEN_GLSLINEARSCALE_EXPORT std::istream& ReadValue( std::istream& instr );
207};
208
209#define GLS_LINEAR_SCALE_MAX 5 ///< The maximum number of unique tick mark types.
210
211typedef GlsLinearScaleData GlsLinearScaleDataArray[ GLS_LINEAR_SCALE_MAX ]; ///< Typedef for one GlsLinearScale worth of scale data.
212
213#ifdef GLES
215#endif
216
217/** Runtime implementation of a GlsLinearScale */
219{
220 friend class GlsLinearScaleEditor;
221
222private:
225
226public:
227 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
228 typedef GLPolygon _BaseClass; ///< Deprecated typedef for the base class.
229 typedef GLPolygon BaseClass; ///< Typedef for the base class.
230
231 /** Create a new GlsLinearScale.
232 * \param generateInstance Whether or not to generate an instance name
233 * for this inputdevice */
234 GLSGEN_GLSLINEARSCALE_EXPORT GlsLinearScale( bool generateInstance = false );
235
236 /// Copy constructor
237 /// \param that The object to copy from.
238 /// \param generateNames Whether or not to generate an instance name.
239 GLSGEN_GLSLINEARSCALE_EXPORT GlsLinearScale( const GlsLinearScale& that, const bool generateNames );
240
241 /** Destructs a GlsLinearScale object */
243
244 /// \return A pointer to a new GlsLinearScale object.
246
251
252#ifndef GLES
255#endif
256
259 virtual GLSGEN_GLSLINEARSCALE_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
260 virtual GLSGEN_GLSLINEARSCALE_EXPORT void Rotate( const Vector& orig, float angle, const Vector& axis ) DISTI_METHOD_OVERRIDE;
261 virtual GLSGEN_GLSLINEARSCALE_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
262 virtual GLSGEN_GLSLINEARSCALE_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
264
265 //////////////////////////////////////////////////
266 // GlsLinearScale specific operations
267 //////////////////////////////////////////////////
268
269 /** Initializes data for one of the scales
270 * \param index Zero based index of the scale to set
271 * \param data The data to set
272 */
274
275 /** Gets the data for one of the scales
276 * \param index Zero based index of the scale to get
277 * \param data The GlsLinearScaleData structure to fill
278 */
280
281 /** Sets the tick deconfliction state for this scale
282 * \param val Wether or not to enable tick deconfliction
283 */
285
286 /** Gets the tick deconfliction state for this scale
287 * \return Whether or not tick deconfliction is enabled
288 */
290
291 /** Gets the halo state for this scale
292 * \return Whether or not halo is enabled
293 */
295
296 /** Sets the halo state for this scale
297 * \param val Wether or not to enable halo
298 */
300
301 /** Gets the halo width for this scale
302 * \return The halo width for this scale
303 */
305
306 /** Sets the halo width for this scale
307 * \param val New halo width
308 */
309 GLSGEN_GLSLINEARSCALE_EXPORT void HaloWidth( const float& val );
310
311 /** Gets the halo color for this scale
312 * \return The halo color for this scale
313 */
315
316 /** Sets the halo color for this scale
317 * \param val New halo color
318 */
320
321 /** Gets the tick anchor for this scale
322 * \return The tick anchor for this scale
323 */
325
326 /** Sets the tick anchor for this scale
327 * \param val New tick anchor
328 */
330
331#ifdef GLES
332 /** Causes the VBO for this object to be recomputed */
334 {
335 _geometryRefresh = true;
337 }
338#endif
339
340#ifndef GLES
341 /** Gets the drawing mode for this scale
342 * \return The drawing mode for this scale
343 */
345
346 /** Sets the drawing mode for this scale
347 * \param val New drawing mode
348 */
350
351 /** Causes the display list for this object to be recomputed */
353 {
356 }
357
358 /// \return A reference to this object's display list.
360#endif
361
362protected:
363#ifdef GLES
364 GlsQuadListVC_3D _quads; ///< Manages a VBO for drawing the tick marks.
365# ifdef GLES20
366 GlsQuadListVC_3D _antiAliasQuads; ///< Manages a VBO for drawing a feathered outline for antialiasing.
367# endif
368
369 void BakeVBO(); ///< Updates the VBO(s) when the object changes.
370#else
371 /// Minimizes calls to glColor when drawing the scale.
372 /// \param newColor The new color to set.
373 void CurrentColor( const GlsColor& newColor );
374
375 /// Minimizes calls to glLineWidth when drawing the scale.
376 /// \param newLineWidth The new line width to set.
377 void CurrentLineWidth( const float& newLineWidth );
378
379 /** Stores the current color. Used when calculating a new display list so that redundant
380 * glColor calls are not made */
382
383 /** Stores the current line width. Used when calculating a new display list so that redundant
384 * glLineWidth calls are not made */
386
387 /** True if the current color has been set. Gets reset every time a new display list is
388 * recalculated. */
390
391 /** True if the current line width has been set. Gets reset every time a new display list is
392 * recalculated. */
394
395 /** Stores the scale in a display list for faster drawing */
397#endif
398
399 /** Recomputes the object's vertices from its radii */
401
402 /** Recomputes the object's vertices and its radii */
404
405 /// Determines if a tick with the given offset should be drawn or not. If a higher priority
406 /// scale already has a tick at that level and deconfliction is enabled, then this method
407 /// will return false
408 /// \param currentLevel The current tick type being considered for drawing.
409 /// \param currentOffset The offset of the proposed tick.
410 /// \return True if the tick should be drawn.
411 bool TickNeeded( int currentLevel, float currentOffset );
412
413#ifdef GLES
414 /** Calculates and draws a single scale using the given halo length and thickness
415 * \param i The index of the scale to draw
416 * \param haloLength The length of the halo
417 * \param haloThickness The thickness of the halo
418 * \param color The color of the scale
419 */
420 void DrawScale( int i, float haloLength, float haloThickness, GlsColor& color );
421#else
422 /** Calculates and draws a single scale using the given halo length and thickness
423 * \param i The index of the scale to draw
424 * \param haloLength The length of the halo
425 * \param haloThickness The thickness of the halo
426 */
427 void DrawScale( int i, float haloLength, float haloThickness );
428#endif
429
430#ifdef GLES
431 /** Set a single attribute from the GLO file.
432 * \param data The attribute to set and its associated data.
433 */
435#endif
436
437#ifndef GLES
438 /** Calculates current tick mark locations and performs OpenGL drawing commands */
439 virtual void DrawGeometry();
440#endif
441
442 /** Two radius vectors that are used to define the orientation of the scale */
444
445 /** Normalized radius vectors, cached because they are needed often */
447
448 /** The particulars of each scale */
450
451 /** True if duplicated tick marks are removed */
453
454 /** True if haloing is enabled */
456
457 /** Width of the halo in logical units */
459
460 /** Color of the halo */
462
463 /** Anchor to determine where ticks will draw */
465
466#ifndef GLES
467 /** True if scale is drawn with polygon quads instead of lines*/
469#endif
470};
471
472/** Metadata for scale data */
474{
475protected:
476 GlsLinearScaleDataArray* _attribPtr; ///< Observer of the underlying storage for the property.
477 unsigned int _arraySize; ///< Always GLS_LINEAR_SCALE_MAX.
478
479public:
480 /// Constructor
481 /// \param callback The callback method to call when this property changes.
482 /// \param name The name of this attribute.
483 /// \param attribPtr A pointer to the underlying storage for this property.
484 /// \param arraySize Always GLS_LINEAR_SCALE_MAX.
486 : DistiAttributeBase( callback, name, false )
487 , _attribPtr( attribPtr )
488 , _arraySize( arraySize )
489 {
490 }
491
493
495
496 virtual GLSGEN_GLSLINEARSCALE_EXPORT std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE;
497 virtual GLSGEN_GLSLINEARSCALE_EXPORT std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE;
498};
499
500} // namespace disti
501
502#endif
Definition: disti_metadata.h:87
Definition: callback_caller_base.h:56
Definition: cull.h:50
Definition: display.h:96
Definition: disti_metadata.h:734
void CopyCommonValues(const DistiAttribDict &dict)
Definition: disti_metadata.h:220
GlsLinearScaleDataArray * _attribPtr
Observer of the underlying storage for the property.
Definition: gls_linear_scale.h:476
virtual std::istream & ReadValue(std::istream &instr) DISTI_METHOD_OVERRIDE
unsigned int _arraySize
Always GLS_LINEAR_SCALE_MAX.
Definition: gls_linear_scale.h:477
virtual bool OkToWrite() const DISTI_METHOD_OVERRIDE
DistiAttributeConnectionGlsLinearScaleDataArray(CallbackMethodCallerBase *callback, const AttributeName &name, GlsLinearScaleDataArray *attribPtr, int arraySize)
Definition: gls_linear_scale.h:485
virtual std::ostream & WriteValue(std::ostream &outstr) DISTI_METHOD_OVERRIDE
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_glo_file.h:1243
Definition: gls_linear_scale.h:96
bool active
True if this scale is active.
Definition: gls_linear_scale.h:101
float length
Length of ticks in logical units.
Definition: gls_linear_scale.h:106
GlsLinearScaleData(const GlsLinearScaleData &src)
Definition: gls_linear_scale.h:155
bool operator==(const GlsLinearScaleData &right) const
DistiAttribDict _attribDict
The attribute dictionary for this class' members.
Definition: gls_linear_scale.h:98
float interval
Interval between ticks in logical units.
Definition: gls_linear_scale.h:105
float thickness
Thickness of ticks in logical units.
Definition: gls_linear_scale.h:107
GlsColor color
Color to draw ticks if line color is not being used.
Definition: gls_linear_scale.h:108
float startingOffset
Start offset in logical units.
Definition: gls_linear_scale.h:104
unsigned int ticks
Number of ticks on this scale.
Definition: gls_linear_scale.h:103
bool operator!=(const GlsLinearScaleData &right) const
Definition: gls_linear_scale.h:190
std::istream & ReadValue(std::istream &instr)
std::ostream & WriteValue(std::ostream &outstr)
bool useLineColor
True if this scale draws with line color.
Definition: gls_linear_scale.h:102
void InitMetaData()
Create DistiAttributes for this object's members.
GlsLinearScaleData & operator=(const GlsLinearScaleData &src)
Definition: gls_linear_scale.h:164
GlsLinearScaleData(bool _active, bool _useLineColor, unsigned int _ticks, float _startingOffset, float _interval, float _length, float _thickness, const GlsColor &_color)
Definition: gls_linear_scale.h:132
Definition: gls_linear_scale.h:219
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
float _currentLineWidth
Definition: gls_linear_scale.h:385
GlsColor _haloColor
Definition: gls_linear_scale.h:461
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual void DrawGeometry()
void CurrentLineWidth(const float &newLineWidth)
GlsColor HaloColor()
Definition: gls_linear_scale.h:314
virtual void SetColor(const GlsColor &color) DISTI_METHOD_OVERRIDE
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void HaloEnabled(const bool &val)
void CurrentColor(const GlsColor &newColor)
GlsTickAnchor TickAnchor()
Definition: gls_linear_scale.h:324
bool _haloEnabled
Definition: gls_linear_scale.h:455
bool TickNeeded(int currentLevel, float currentOffset)
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 UseScalableLines(const bool &val)
bool DeconflictTicks()
Definition: gls_linear_scale.h:289
float _haloWidth
Definition: gls_linear_scale.h:458
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
GlsDisplayList & DisplayList()
Definition: gls_linear_scale.h:359
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) DISTI_METHOD_OVERRIDE
bool HaloEnabled()
Definition: gls_linear_scale.h:294
bool _useScalableLines
Definition: gls_linear_scale.h:468
float HaloWidth()
Definition: gls_linear_scale.h:304
static DisplayObject * CreateInstance()
Vector _radii[2]
Definition: gls_linear_scale.h:443
virtual void CopyGeometry(DisplayObject *srcArg) DISTI_METHOD_OVERRIDE
GlsDisplayList _displayList
Definition: gls_linear_scale.h:396
void DrawScale(int i, float haloLength, float haloThickness)
void HaloColor(const GlsColor &val)
GlsColor _currentColor
Definition: gls_linear_scale.h:381
void TickAnchor(const GlsTickAnchor val)
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
bool _deconflictTicks
Definition: gls_linear_scale.h:452
void GetScale(int index, GlsLinearScaleData &data)
Vector _radiiNormalized[2]
Definition: gls_linear_scale.h:446
void HaloWidth(const float &val)
void InvalidateGeometry()
Definition: gls_linear_scale.h:352
bool _currentLineWidthSet
Definition: gls_linear_scale.h:393
bool UseScalableLines()
Definition: gls_linear_scale.h:344
bool _currentColorSet
Definition: gls_linear_scale.h:389
GlsTickAnchor _tickAnchor
Definition: gls_linear_scale.h:464
void SetScale(int index, const GlsLinearScaleData &data)
GlsLinearScaleDataArray _scale
Definition: gls_linear_scale.h:449
Definition: gls_quad_storage.h:64
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 GLS_LINEAR_SCALE_MAX
The maximum number of unique tick mark types.
Definition: gls_linear_scale.h:209
#define GLSGEN_GLSLINEARSCALE_EXPORT
Provides support for creating DLLs.
Definition: gls_linear_scale.h:61
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
GlsLinearScaleData GlsLinearScaleDataArray[5]
Typedef for one GlsLinearScale worth of scale data.
Definition: gls_linear_scale.h:211
GlsTickAnchor
Tick anchor behavior.
Definition: gls_linear_scale.h:88