OpenWalnut  1.5.0dev
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  /**
150  * Set the line width of the gird.
151  *
152  * \param linewidth the linewidth. Default is 1.
153  */
154  void setGridLineWidth( int linewidth = 1 );
155 
156  /**
157  * Set the line width of the bounding box.
158  *
159  * \param linewidth the linewidth. Default is 4.
160  */
161  void setBoxLineWidth( int linewidth = 4 );
162 
163  /**
164  * Get the line width of the gird.
165  *
166  * \return the linewidth.
167  */
168  int getGridLineWidth() const;
169 
170  /**
171  * get the line width of the bounding box.
172  *
173  * \return the linewidth.
174  */
175  int getBoxLineWidth() const;
176 
177 protected:
178 private:
179  /**
180  * The actual grid which should be represented by this node.
181  */
183 
184  /**
185  * The geometry for the boundary.
186  */
187  osg::ref_ptr< osg::Geode > m_boundaryGeode;
188 
189  /**
190  * The geometry for the whole grid.
191  */
192  osg::ref_ptr< osg::Geode > m_innerGridGeode;
193 
194  /**
195  * The labels at the corner.
196  */
198 
199  /**
200  * The geode keeping the labels
201  */
202  osg::ref_ptr< osg::Geode > m_labelGeode;
203 
204  /**
205  * The actual callback handling changes in the grid
206  *
207  * \param node the node. This will be the this pointer.
208  */
209  void callback( osg::Node* node );
210 
211  /**
212  * If true, the labels and geometry gets adapted properly.
213  */
215 
216  /**
217  * If true, the inner grid geometry gets recreated.
218  */
220 
221  /**
222  * If true, labels get used.
223  */
225 
226  /**
227  * True if the bbox should be rendered
228  */
230 
231  /**
232  * True if the grid should be rendered.
233  */
235 
236  /**
237  * The color of bbox/grid
238  */
239  WColor m_bbColor;
240 
241  /**
242  * The color of the grid.
243  */
244  WColor m_gridColor;
245 
246  /**
247  * Line width used for the grid
248  */
250 
251  /**
252  * The line width of the box.
253  */
255 };
256 
257 #endif // WGEGRIDNODE_H
258 
This node is able to represent a grid in certain ways.
Definition: WGEGridNode.h:41
osg::ref_ptr< osg::Geode > m_boundaryGeode
The geometry for the boundary.
Definition: WGEGridNode.h:187
WGELabel::SPtr m_borderLabels[8]
The labels at the corner.
Definition: WGEGridNode.h:197
osg::ref_ptr< const WGEGridNode > ConstSPtr
Convenience typedef for a osg::ref_ptr< const WGEGridNode >.
Definition: WGEGridNode.h:51
bool m_gridUpdate
If true, the labels and geometry gets adapted properly.
Definition: WGEGridNode.h:214
osg::ref_ptr< osg::Geode > m_labelGeode
The geode keeping the labels.
Definition: WGEGridNode.h:202
virtual ~WGEGridNode()
Destructor.
void setGridLineWidth(int linewidth=1)
Set the line width of the gird.
void setEnableLabels(bool enable=true)
En- or disable labels on the boundary corners.
void setGridColor(const WColor &color)
Sets the color of the rendered grid.
bool m_showLabels
If true, labels get used.
Definition: WGEGridNode.h:224
int getGridLineWidth() const
Get the line width of the gird.
void callback(osg::Node *node)
The actual callback handling changes in the grid.
WColor m_bbColor
The color of bbox/grid.
Definition: WGEGridNode.h:239
WGridRegular3D::ConstSPtr getGrid() const
Returns the currently set grid.
bool m_showGrid
True if the grid should be rendered.
Definition: WGEGridNode.h:234
bool m_gridGeometryUpdate
If true, the inner grid geometry gets recreated.
Definition: WGEGridNode.h:219
WSharedObject< WGridRegular3D::ConstSPtr > m_grid
The actual grid which should be represented by this node.
Definition: WGEGridNode.h:182
bool m_showBBox
True if the bbox should be rendered.
Definition: WGEGridNode.h:229
void setEnableGrid(bool enable=true)
En- or disable grid mode.
osg::ref_ptr< osg::Geode > m_innerGridGeode
The geometry for the whole grid.
Definition: WGEGridNode.h:192
bool getEnableBBox() const
Returns whether bbox mode is enabled or not.
int m_boxLineWidth
The line width of the box.
Definition: WGEGridNode.h:254
osg::ref_ptr< WGEGridNode > SPtr
Convenience typedef for a osg::ref_ptr< WGEGridNode >.
Definition: WGEGridNode.h:46
void setBoxLineWidth(int linewidth=4)
Set the line width of the bounding box.
bool getEnableGrid() const
Returns whether grid mode is enabled or not.
void setBBoxColor(const WColor &color)
Sets the color of the rendered bbox.
WColor m_gridColor
The color of the grid.
Definition: WGEGridNode.h:244
void setGrid(WGridRegular3D::ConstSPtr grid)
Updates the node to use the new specified grid.
int getBoxLineWidth() const
get the line width of the bounding box.
WGEGridNode(WGridRegular3D::ConstSPtr grid)
Creates a node representing the specified grid.
Definition: WGEGridNode.cpp:34
void setEnableBBox(bool enable=true)
En- or disable bbox mode.
bool getEnableLabels() const
Returns whether labels on the corners are enabled or not.
const WColor & getBBoxColor() const
The currently set color used for rendering the bbox.
const WColor & getGridColor() const
The currently set color used for rendering the grid.
int m_gridLineWidth
Line width used for the grid.
Definition: WGEGridNode.h:249
osg::ref_ptr< WGELabel > SPtr
Convenience typedef for a osg::ref_ptr< WGELabel >.
Definition: WGELabel.h:44
std::shared_ptr< const WGridRegular3DTemplate > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGridRegular3DTemplate >.