OpenWalnut  1.4.0
WGEGridNode.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEGRIDNODE_H
26 #define WGEGRIDNODE_H
27 
28 #include <osg/Geode>
29 #include <osg/MatrixTransform>
30 
31 #include "../../dataHandler/WGridRegular3D.h"
32 #include "../../common/WSharedObject.h"
33 #include "../../common/WProperties_Fwd.h"
34 
35 #include "../widgets/labeling/WGELabel.h"
36 
37 /**
38  * This node is able to represent a grid in certain ways. It can show its boundary or the whole grid if desired.
39  */
40 class WGEGridNode: public osg::MatrixTransform
41 {
42 public:
43  /**
44  * Convenience typedef for a osg::ref_ptr< WGEGridNode >.
45  */
46  typedef osg::ref_ptr< WGEGridNode > SPtr;
47 
48  /**
49  * Convenience typedef for a osg::ref_ptr< const WGEGridNode >.
50  */
51  typedef osg::ref_ptr< const WGEGridNode > ConstSPtr;
52 
53  /**
54  * Creates a node representing the specified grid.
55  *
56  * \param grid the grid to represent.
57  */
58  explicit WGEGridNode( WGridRegular3D::ConstSPtr grid );
59 
60  /**
61  * Destructor.
62  */
63  virtual ~WGEGridNode();
64 
65  /**
66  * Updates the node to use the new specified grid
67  *
68  * \param grid the new grid to use
69  */
71 
72  /**
73  * Returns the currently set grid.
74  *
75  * \return the current grid.
76  */
78 
79  /**
80  * Returns whether labels on the corners are enabled or not.
81  *
82  * \return true if labels are enabled
83  */
84  bool getEnableLabels() const;
85 
86  /**
87  * En- or disable labels on the boundary corners.
88  *
89  * \param enable true to enbable
90  */
91  void setEnableLabels( bool enable = true );
92 
93  /**
94  * Returns whether bbox mode is enabled or not.
95  *
96  * \return true if bbox rendering are enabled
97  */
98  bool getEnableBBox() const;
99 
100  /**
101  * En- or disable bbox mode.
102  *
103  * \param enable true to enbable
104  */
105  void setEnableBBox( bool enable = true );
106 
107  /**
108  * Returns whether grid mode is enabled or not.
109  *
110  * \return true if grid rendering are enabled
111  */
112  bool getEnableGrid() const;
113 
114  /**
115  * En- or disable grid mode.
116  *
117  * \param enable true to enbable
118  */
119  void setEnableGrid( bool enable = true );
120 
121  /**
122  * The currently set color used for rendering the bbox.
123  *
124  * \return the current color.
125  */
126  const WColor& getBBoxColor() const;
127 
128  /**
129  * Sets the color of the rendered bbox.
130  *
131  * \param color the color
132  */
133  void setBBoxColor( const WColor& color );
134 
135  /**
136  * The currently set color used for rendering the grid.
137  *
138  * \return the current color.
139  */
140  const WColor& getGridColor() const;
141 
142  /**
143  * Sets the color of the rendered grid.
144  *
145  * \param color the color
146  */
147  void setGridColor( const WColor& color );
148 
149 protected:
150 private:
151  /**
152  * The actual grid which should be represented by this node.
153  */
155 
156  /**
157  * The geometry for the boundary.
158  */
159  osg::ref_ptr< osg::Geode > m_boundaryGeode;
160 
161  /**
162  * The geometry for the whole grid.
163  */
164  osg::ref_ptr< osg::Geode > m_innerGridGeode;
165 
166  /**
167  * The labels at the corner.
168  */
170 
171  /**
172  * The geode keeping the labels
173  */
174  osg::ref_ptr< osg::Geode > m_labelGeode;
175 
176  /**
177  * The actual callback handling changes in the grid
178  *
179  * \param node the node. This will be the this pointer.
180  */
181  void callback( osg::Node* node );
182 
183  /**
184  * If true, the labels and geometry gets adapted properly.
185  */
187 
188  /**
189  * If true, the inner grid geometry gets recreated.
190  */
192 
193  /**
194  * If true, labels get used.
195  */
197 
198  /**
199  * True if the bbox should be rendered
200  */
202 
203  /**
204  * True if the grid should be rendered.
205  */
207 
208  /**
209  * The color of bbox/grid
210  */
211  WColor m_bbColor;
212 
213  /**
214  * The color of the grid.
215  */
216  WColor m_gridColor;
217 };
218 
219 #endif // WGEGRIDNODE_H
220 
bool getEnableGrid() const
Returns whether grid mode is enabled or not.
void setEnableLabels(bool enable=true)
En- or disable labels on the boundary corners.
void setEnableGrid(bool enable=true)
En- or disable grid mode.
osg::ref_ptr< const WGEGridNode > ConstSPtr
Convenience typedef for a osg::ref_ptr< const WGEGridNode >.
Definition: WGEGridNode.h:51
bool m_showLabels
If true, labels get used.
Definition: WGEGridNode.h:196
bool m_gridGeometryUpdate
If true, the inner grid geometry gets recreated.
Definition: WGEGridNode.h:191
osg::ref_ptr< WGEGridNode > SPtr
Convenience typedef for a osg::ref_ptr< WGEGridNode >.
Definition: WGEGridNode.h:46
osg::ref_ptr< osg::Geode > m_labelGeode
The geode keeping the labels.
Definition: WGEGridNode.h:174
bool getEnableBBox() const
Returns whether bbox mode is enabled or not.
void setEnableBBox(bool enable=true)
En- or disable bbox mode.
osg::ref_ptr< WGELabel > SPtr
Convenience typedef for a osg::ref_ptr< WGELabel >.
Definition: WGELabel.h:44
WColor m_bbColor
The color of bbox/grid.
Definition: WGEGridNode.h:211
bool m_gridUpdate
If true, the labels and geometry gets adapted properly.
Definition: WGEGridNode.h:186
WGridRegular3D::ConstSPtr getGrid() const
Returns the currently set grid.
void setBBoxColor(const WColor &color)
Sets the color of the rendered bbox.
bool m_showGrid
True if the grid should be rendered.
Definition: WGEGridNode.h:206
void callback(osg::Node *node)
The actual callback handling changes in the grid.
const WColor & getGridColor() const
The currently set color used for rendering the grid.
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
Definition: WSharedObject.h:41
bool getEnableLabels() const
Returns whether labels on the corners are enabled or not.
osg::ref_ptr< osg::Geode > m_innerGridGeode
The geometry for the whole grid.
Definition: WGEGridNode.h:164
virtual ~WGEGridNode()
Destructor.
WColor m_gridColor
The color of the grid.
Definition: WGEGridNode.h:216
This node is able to represent a grid in certain ways.
Definition: WGEGridNode.h:40
WGEGridNode(WGridRegular3D::ConstSPtr grid)
Creates a node representing the specified grid.
Definition: WGEGridNode.cpp:34
WGELabel::SPtr m_borderLabels[8]
The labels at the corner.
Definition: WGEGridNode.h:169
boost::shared_ptr< const WGridRegular3DTemplate > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WGridRegular3DTemplate >.
void setGrid(WGridRegular3D::ConstSPtr grid)
Updates the node to use the new specified grid.
WSharedObject< WGridRegular3D::ConstSPtr > m_grid
The actual grid which should be represented by this node.
Definition: WGEGridNode.h:154
osg::ref_ptr< osg::Geode > m_boundaryGeode
The geometry for the boundary.
Definition: WGEGridNode.h:159
void setGridColor(const WColor &color)
Sets the color of the rendered grid.
const WColor & getBBoxColor() const
The currently set color used for rendering the bbox.
bool m_showBBox
True if the bbox should be rendered.
Definition: WGEGridNode.h:201