GL Studio SCECpp Runtime Library
gls_display_object_array.h
Go to the documentation of this file.
1 #ifndef _GLS_DISPLAY_OBJECT_ARRAY_H
2 #define _GLS_DISPLAY_OBJECT_ARRAY_H
3 
4 /*! \file gls_display_object_array.h
5 
6 \brief This header defines GlsDisplayObjectArray which encapsulates\
7  an array of display object pointers
8  in the GL Studio DO-178B Runtime Library.
9 
10 \par Copyright Information
11 Copyright (C) 1999-2012 The DiSTI Corporation<br>
12 Orlando, FL USA<br>
13 All rights reserved.<br>
14 
15  This file is copyrighted software and contains proprietary trade secrets of
16 DiSTI, and embodies substantial creative efforts as well as confidential
17 information, ideas, and expressions.
18 
19  Permission to use, and copy this software and its documentation for any
20 purpose is hereby granted per the Distribution Agreement and/or the Licensing
21 Agreement signed with DiSTI. This permission is granted provided that:
22  1. The above copyright notice appears in all copies.
23  2. That both the copyright notice and this permission notice appear in
24  the supporting documentation.
25  3. That the names DiSTI and GL Studio not be used in advertising or
26  publicity pertaining to distribution of the software without specific,
27  written prior permission of DiSTI.
28 
29  Permission to modify the software is granted, but not the right to
30 distribute the source code whether modified, or non-modified. Modifying the
31 software might invalidate the DO-178B certification package.
32 
33  Permission to distribute binaries produced by compiling source code, or
34 modified source code is granted, provided you:
35  1. Provide your name and address as the primary contact for the support
36  of your modified version.
37  2. Retain our contact information in regard to use of the base software.
38 
39  DiSTI does not provide warranty for this software or guarantee that it
40 satisfies any specification or requirement unless otherwise stated in a
41 specific contractual arrangement between the customer and DiSTI.
42 
43 */
44 
45 #include "gls_include.h"
46 #include "gls_pointer_array.h"
47 #include "gls_render_settings.h"
48 #include "gls_display_object.h"
49 #include "gls_state_manager.h"
50 #include "gls_class_invariant.h"
51 
52 /** This class encapsulates an array of display objects and allows operations to be
53  * performed on all of the entries in the array
54  * \invariant _objects.Invariant(),
55  * there are no null pointers in the array,
56  * the invariant holds for all objects in the array
57  */
59 {
60 public:
62 
63  /** initialization parameters for a GlsDisplayObjectArray */
65  {
66  const GlsUInt32 numObjects; /**< number of objects in objects array */
67  GlsDisplayObject* const *objects; /**< array of objects to make up the array */
68 
69  #if defined( GLS_DEBUG )
70  /** Determine if the initialization parameters are correct
71  * \return GLS_TRUE if parameters are valid else GLS_FALSE
72  * \pre none
73  * \post none
74  */
75  GlsBool IsValid( void ) const;
76  #endif // GLS_DEBUG
77  };
78 
79  /** Constructor - create an instance
80  * \param initParameters initialization parameters
81  * \pre initParameters.IsValid()
82  * \post instance created
83  */
84  GlsDisplayObjectArray( InitParameters &initParameters );
85 
86  /** Destructor - shall never be called
87  * \pre none
88  * \post none
89  */
90  virtual ~GlsDisplayObjectArray();
91 
92  /** Draws the objects in the array.
93  * \param gl GL State manager for OpenGL into which object is drawn
94  * \param time the elaspsed time in seconds since program start
95  * \pre time >= 0.0
96  * \post contained objects are drawn to OpenGL if visible and not blinked off
97  */
98  void Draw( GlsStateManager &gl, const GlsFloat64 time );
99 
100  /** Provides a mechanism for performing regular calculations, separate
101  * from drawing.
102  * \param time The elaspsed time in seconds since program start
103  * \pre time >= 0.0
104  * \post calculations (if any) completed for all objects in array
105  */
106  void Calculate( const GlsFloat64 time );
107 
108  /** Perform a pick test of the given point in window coordinates against the contained objects
109  * \param windowCoord point in question
110  * \param inputManager input manager managing input for this object
111  * \param parentDrawMatrix draw matrix used when rendering parent object
112  * \return object that is picked by given window coordinate else GLS_NULL
113  * \pre windowCoord.IsValid(), GLMatrixAffineFIsValid( parentDrawMatrix )
114  * \post none
115  */
116  GlsDisplayObject* PickChildrenTest( const GlsVector2D &windowCoord, GlsInputManager &inputManager,
117  const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix );
118 
119  /** Set the alpha mode of the contained objects
120  * \param alphaMode desired alpha mode
121  * \pre GlsAlphaModeIsValid( alphaMode )
122  * \post contained objects have new alpha mode
123  */
124  void SetChildrenAlphaMode( const GlsAlphaMode alphaMode );
125 
126  /** Set the fill color of the contained objects
127  * \param fillColor desired fill color
128  * \pre fillColor.IsValid()
129  * \post contained objects have new fill color
130  */
131  void SetChildrenFillColor( const GlsColor &fillColor );
132 
133  /** Set the line color of the contained objects
134  * \param lineColor desired line color
135  * \pre lineColor.IsValid()
136  * \post contained objects have new line color
137  */
138  void SetChildrenLineColor( const GlsColor &lineColor );
139 
140  /** Set the line width of the contained objects
141  * \param lineWidth new line width, GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX
142  * \pre GlsLineWidthIsValid( lineWidth )
143  * \post contained objects have new line width
144  */
145  void SetChildrenLineWidth( const GlsFloat32 lineWidth );
146 
147  /** Set the polygon mode of the contained objects
148  * \param polygonMode new polygon mode
149  * \pre GlsPolygonModeIsValid( polygonMode )
150  * \post contained objects have new polygon mode
151  */
152  void SetChildrenPolygonMode( const GlsPolygonMode polygonMode );
153 
154  /** Set the parent of the contained objects
155  * \param parent parent of contained objects
156  * \pre parent != GLS_NULL
157  * \post contained objects have new parent
158  */
159  void SetChildrenParent( GlsDisplayObject* const parent );
160 
161  /** Invalidate cached picking screen coordinates for contained objects
162  * \pre none
163  * \post cached screen picking coordinates are marked invalid for children
164  */
165  void InvalidateChildrenPickCache( void );
166 
167  /** Get the number of display objects in the array
168  * \return number of display objects in the array
169  * \pre none
170  * \post none
171  */
172  GlsUInt32 GetSize( void ) const;
173 
174  /** get a ref to the display object at the given index
175  * \param index index of desired object ( index < _objects.GetSize() )
176  * \return ref to display object at given index
177  * \pre index < _objects.GetSize()
178  * \post none
179  */
180  GlsDisplayObject& GetObject( const GlsUInt32 index );
181 
182 protected:
183  GlsPointerArray _objects; /**< array of display object pointers */
184  GlsBool _needCalculate; /**< GLS_TRUE if any of the objects needs its Calculate() method called,
185  * else GLS_FALSE */
186 
187 private:
188  // Disable implicit generated Members
189  GlsDisplayObjectArray& operator=( const GlsDisplayObjectArray &rhs );
191 };
192 
193 #endif // _GLS_DISPLAY_OBJECT_ARRAY_H
void Calculate(const GlsFloat64 time)
This header defines GlsPointerArray which encapsulates an array of pointers in the GL Studio DO-178B ...
Definition: gls_color.h:47
bool GlsBool
Definition: gls_types.h:96
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
This header defines the basic render setting types used in the GL Studio DO-178B Runtime Library...
GlsDisplayObjectArray(InitParameters &initParameters)
Definition: gls_state_manager.h:63
Definition: gls_input_manager.h:53
const GlsUInt32 numObjects
Definition: gls_display_object_array.h:66
Definition: gls_pointer_array.h:51
GlsDisplayObject & GetObject(const GlsUInt32 index)
unsigned int GlsUInt32
Definition: gls_types.h:73
This header defines the GL State Manager class for managing the GL state in the GL Studio DO-178B Run...
GlsAlphaMode
Definition: gls_render_settings.h:162
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
void SetChildrenLineWidth(const GlsFloat32 lineWidth)
GLfloat GLMatrixAffineF[DIMENSION *DIMENSION]
Definition: gls_matrix_affine_double.h:63
void InvalidateChildrenPickCache(void)
float GlsFloat32
Definition: gls_types.h:78
GlsPointerArray _objects
Definition: gls_display_object_array.h:183
Definition: gls_display_object.h:64
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
void SetChildrenAlphaMode(const GlsAlphaMode alphaMode)
double GlsFloat64
Definition: gls_types.h:87
Definition: gls_vertex.h:49
This header defines the base class for all graphical objects in the GL Studio DO-178B Runtime Library...
Definition: gls_display_object_array.h:58
GlsPolygonMode
Definition: gls_render_settings.h:131
GlsBool _needCalculate
Definition: gls_display_object_array.h:184
GlsDisplayObject * PickChildrenTest(const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
Definition: gls_display_object_array.h:64
GlsUInt32 GetSize(void) const
void SetChildrenLineColor(const GlsColor &lineColor)
void SetChildrenPolygonMode(const GlsPolygonMode polygonMode)
virtual ~GlsDisplayObjectArray()
GlsDisplayObject *const * objects
Definition: gls_display_object_array.h:67
void SetChildrenParent(GlsDisplayObject *const parent)
void Draw(GlsStateManager &gl, const GlsFloat64 time)
void SetChildrenFillColor(const GlsColor &fillColor)