GL Studio SCECpp Runtime Library
gls_component_base.h
Go to the documentation of this file.
1 #ifndef _GLS_COMPONENT_BASE_H
2 #define _GLS_COMPONENT_BASE_H
3 
4 /*! \file gls_component_base.h
5 
6 \brief This header defines GlsComponentBase which serves as a base
7  class for all user derived display components
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_composite_object.h"
48 #include "gls_texture_palette.h"
50 #include "gls_class_invariant.h"
51 
52 /** This class serves as an abstract base class for all user derived display components.
53  * \invariant base class invariant holds, _componentTransformMatrix invariant holds,
54  * _clipPlanes array has valid elements
55  */
57 {
58 public:
60 
61  /** initialization parameters for a component */
63  {
64  const GlsCompositeObject::InitParameters compositeInitParameters; /**< base class init parameters */
65 
66  const GlsMatrixAffineD::CStyleMatrix componentTransformMatrix; /**< Contains the rotation, and scaling that
67  * the parent did to this component */
68 
69  #if defined( GLS_DEBUG )
70  /** Determine if the parameters are valid ( GLS_DEBUG only )
71  * \return GLS_TRUE if valid else GLS_FALSE
72  * \pre none
73  * \post none
74  */
75  GlsBool IsValid( void ) const;
76  #endif // GLS_DEBUG
77  };
78 
79  /** Called after objects in the component are created. This allows a derived class to
80  * have custom initialization code.
81  * \pre none
82  * \post custom initialization (if any) is complete
83  */
84  virtual void Initialize( void ) = 0;
85 
86  /** Enable and configure the six clipping planes ( left, right, top, bottom, front, back ) against
87  * which the component will be clipped when rendered. The clipping planes are defined by the
88  * 3D box described by the given points.
89  * \param lowerFarLeft lower far left side point of 3D box describing clip planes
90  * \param upperNearRight upper near right side point of 3D box describing clip planes
91  * \pre lowerFarLeft.IsValid(), upperNearRight.IsValid(), no child of this component can have
92  * its clip planes enabled
93  * \post the component will be clipped against the clip planes described by the given points
94  * when drawn
95  */
96  void SetClipPlanes( const GlsVector3D &lowerFarLeft, const GlsVector3D &upperNearRight );
97 
98  /** Draws the component
99  * \param gl GL State manager for OpenGL into which object is drawn
100  * \param time the elaspsed time in seconds since program start
101  * \pre time >= 0.0
102  * \post component drawn to OpenGL if visible and not blinked off
103  */
104  virtual void Draw( GlsStateManager &gl, const GlsFloat64 time );
105 
106  /** Provides a mechanism for performing regular calculations, separate
107  * from drawing.
108  * \param time The elaspsed time in seconds since program start
109  * \pre time >= 0.0
110  * \post calculations (if any) completed for all contained objects
111  */
112  virtual void Calculate( const GlsFloat64 time );
113 
114  /** Perform a pick test of the given point in window coordinates against this object
115  * \param windowCoord point in question
116  * \param inputManager input manager managing input for this object
117  * \param parentDrawMatrix draw matrix used when rendering parent object
118  * \return object that is picked by given window coordinate else GLS_NULL
119  * \pre windowCoord.IsValid(), GLMatrixAffineFIsValid( parentDrawMatrix )
120  * \post none
121  */
122  virtual GlsDisplayObject* PickTest( const GlsVector2D &windowCoord, GlsInputManager &inputManager,
123  const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix );
124 
125  /** Set the alpha mode of the contained objects
126  * \param alphaMode desired alpha mode
127  * \pre GlsAlphaModeIsValid( alphaMode )
128  * \post contained objects have new alpha mode
129  */
130  virtual void SetChildrenAlphaMode( const GlsAlphaMode alphaMode );
131 
132  /** Set the fill color of the contained objects
133  * \param fillColor desired fill color
134  * \pre fillColor.IsValid()
135  * \post contained objects have new fill color
136  */
137  virtual void SetChildrenFillColor( const GlsColor &fillColor );
138 
139  /** Set the line color of the contained objects
140  * \param lineColor desired line color
141  * \pre lineColor.IsValid()
142  * \post contained objects have new line color
143  */
144  virtual void SetChildrenLineColor( const GlsColor &lineColor );
145 
146  /** Set the line width of the contained objects
147  * \param lineWidth new line width,
148  * GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX
149  * \pre GlsLineWidthIsValid( lineWidth )
150  * \post contained objects have new line width
151  */
152  virtual void SetChildrenLineWidth( const GlsFloat32 lineWidth );
153 
154  /** Set the polygon mode of the contained objects
155  * \param polygonMode new polygon mode
156  * \pre GlsPolygonModeIsValid( polygonMode )
157  * \post contained objects have new polygon mode
158  */
159  virtual void SetChildrenPolygonMode( const GlsPolygonMode polygonMode );
160 
161 protected:
162  /** desribes available clip planes */
163  enum
164  {
172  };
173 
174  /** describes clip plane eqn coefficients */
175  enum
176  {
182  };
183 
184  /** Constructor - create an instance, can only be called by a derived class
185  * \param initParameters initialization parameters
186  * \param eventDispatcher event dispatcher for this object else GLS_NULL
187  * \pre initParameters.IsValid()
188  * \post instance created
189  */
190  GlsComponentBase( const InitParameters &initParameters, GlsEventDispatcher* const eventDispatcher );
191 
192  /** Activate the GL clip planes described by _clipPlanes
193  * \pre none of the GL clip planes are activated
194  * \post GL clip planes described _clipPlanes are activated
195  */
196  void ActivateClipPlanes( void ) const;
197 
198  /** Deactivate the GL clip planes
199  * \pre none
200  * \post GL clip planes are deactivated
201  */
202  void DeactivateClipPlanes( void ) const;
203 
204  /** Get the object array that contains all of the objects in the component
205  * \return the object array that contains all of the objects in the component
206  * \pre none
207  * \post none
208  */
209  virtual GlsDisplayObjectArray& GetObjects( void ) = 0;
210 
211  /** Destructor - shall never be called
212  * \pre none
213  * \post none
214  */
215  virtual ~GlsComponentBase();
216 
217  GlsMatrixAffineD _componentTransformMatrix; /**< The static transformation from the internal component
218  * coordinates to the parent's coordinate system.
219  * the rotation, and scaling that the parent
220  * did to this component, including translation for
221  * _location*/
222 
223  GlsBool _clippingEnabled; /**< GLS_TRUE if clipping is enabled when drawing
224  * else GLS_FALSE */
225  GLdouble _clipPlanes[ NUM_CLIP_PLANES ][ NUM_PLANE_COEFF ]; /**< plane equation coefficients for each plane */
226 
227 private:
228  typedef GlsCompositeObject _BaseClass; /**< base class alias */
229 
230  // Disable implicit generated Members
231  GlsComponentBase& operator=( const GlsComponentBase &rhs );
232  GlsComponentBase( const GlsComponentBase &src );
233 };
234 
235 #endif // _GLS_COMPONENT_BASE_H
Definition: gls_component_base.h:62
virtual ~GlsComponentBase()
Definition: gls_component_base.h:179
Definition: gls_component_base.h:171
Definition: gls_color.h:47
virtual void SetChildrenAlphaMode(const GlsAlphaMode alphaMode)
bool GlsBool
Definition: gls_types.h:96
virtual GlsDisplayObject * PickTest(const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
Definition: gls_component_base.h:166
Definition: gls_composite_object.h:58
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
Definition: gls_vertex.h:65
Definition: gls_state_manager.h:63
virtual void Draw(GlsStateManager &gl, const GlsFloat64 time)
virtual void SetChildrenLineColor(const GlsColor &lineColor)
Definition: gls_component_base.h:170
Definition: gls_component_base.h:165
virtual void Calculate(const GlsFloat64 time)
Definition: gls_input_manager.h:53
virtual void SetChildrenLineWidth(const GlsFloat32 lineWidth)
GlsMatrixAffineD _componentTransformMatrix
Definition: gls_component_base.h:217
This header defines The GlsMatrixAffineD class for use in the GL Studio DO-178B Runtime Library...
Definition: gls_component_base.h:180
const GlsMatrixAffineD::CStyleMatrix componentTransformMatrix
Definition: gls_component_base.h:66
GlsAlphaMode
Definition: gls_render_settings.h:162
Definition: gls_event.h:304
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
virtual GlsDisplayObjectArray & GetObjects(void)=0
Definition: gls_component_base.h:181
Definition: gls_component_base.h:56
GlsFloat64 CStyleMatrix[DIMENSION][DIMENSION]
Definition: gls_matrix_affine_double.h:60
GLfloat GLMatrixAffineF[DIMENSION *DIMENSION]
Definition: gls_matrix_affine_double.h:63
virtual void Initialize(void)=0
Definition: gls_composite_object.h:52
float GlsFloat32
Definition: gls_types.h:78
GLdouble _clipPlanes[NUM_CLIP_PLANES][NUM_PLANE_COEFF]
Definition: gls_component_base.h:225
void ActivateClipPlanes(void) const
Definition: gls_display_object.h:64
void DeactivateClipPlanes(void) const
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
This header defines the GlsCompositeObject class used in the GL Studio DO-178B Runtime Library...
GlsBool _clippingEnabled
Definition: gls_component_base.h:223
void SetClipPlanes(const GlsVector3D &lowerFarLeft, const GlsVector3D &upperNearRight)
Definition: gls_matrix_affine_double.h:54
Definition: gls_component_base.h:169
double GlsFloat64
Definition: gls_types.h:87
Definition: gls_vertex.h:49
virtual void SetChildrenFillColor(const GlsColor &fillColor)
GlsComponentBase(const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
Definition: gls_display_object_array.h:58
GlsPolygonMode
Definition: gls_render_settings.h:131
Definition: gls_component_base.h:167
const GlsCompositeObject::InitParameters compositeInitParameters
Definition: gls_component_base.h:64
Definition: gls_component_base.h:177
This header defines the GlsTexturePalette class used in the GL Studio DO-178B Runtime Library...
virtual void SetChildrenPolygonMode(const GlsPolygonMode polygonMode)
Definition: gls_component_base.h:168
This header defines GlsDisplayObjectArray which encapsulates\ an array of display object pointers in ...
Definition: gls_component_base.h:178