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