OpenWalnut  1.3.1
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 
39 /**
40  * This node is able to represent a grid in certain ways. It can show its boundary or the whole grid if desired.
41  */
42 class WGEGridNode: public osg::MatrixTransform
43 {
44 public:
45  /**
46  * Convenience typedef for a osg::ref_ptr< WGEGridNode >.
47  */
48  typedef osg::ref_ptr< WGEGridNode > SPtr;
49 
50  /**
51  * Convenience typedef for a osg::ref_ptr< const WGEGridNode >.
52  */
53  typedef osg::ref_ptr< const WGEGridNode > ConstSPtr;
54 
55  /**
56  * Creates a node representing the specified grid.
57  *
58  * \param grid the grid to represent.
59  */
60  explicit WGEGridNode( WGridRegular3D::ConstSPtr grid );
61 
62  /**
63  * Destructor.
64  */
65  virtual ~WGEGridNode();
66 
67  /**
68  * Updates the node to use the new specified grid
69  *
70  * \param grid the new grid to use
71  */
73 
74  /**
75  * Returns the currently set grid.
76  *
77  * \return the current grid.
78  */
80 
81  /**
82  * Returns whether labels on the corners are enabled or not.
83  *
84  * \return true if labels are enabled
85  */
86  bool getEnableLabels() const;
87 
88  /**
89  * En- or disable labels on the boundary corners.
90  *
91  * \param enable true to enbable
92  */
93  void setEnableLabels( bool enable = true );
94 
95  /**
96  * Returns whether bbox mode is enabled or not.
97  *
98  * \return true if bbox rendering are enabled
99  */
100  bool getEnableBBox() const;
101 
102  /**
103  * En- or disable bbox mode.
104  *
105  * \param enable true to enbable
106  */
107  void setEnableBBox( bool enable = true );
108 
109  /**
110  * Returns whether grid mode is enabled or not.
111  *
112  * \return true if grid rendering are enabled
113  */
114  bool getEnableGrid() const;
115 
116  /**
117  * En- or disable grid mode.
118  *
119  * \param enable true to enbable
120  */
121  void setEnableGrid( bool enable = true );
122 
123  /**
124  * The currently set color used for rendering the bbox.
125  *
126  * \return the current color.
127  */
128  const WColor& getBBoxColor() const;
129 
130  /**
131  * Sets the color of the rendered bbox.
132  *
133  * \param color the color
134  */
135  void setBBoxColor( const WColor& color );
136 
137  /**
138  * The currently set color used for rendering the grid.
139  *
140  * \return the current color.
141  */
142  const WColor& getGridColor() const;
143 
144  /**
145  * Sets the color of the rendered grid.
146  *
147  * \param color the color
148  */
149  void setGridColor( const WColor& color );
150 
151 protected:
152 private:
153  /**
154  * The actual grid which should be represented by this node.
155  */
157 
158  /**
159  * The geometry for the boundary.
160  */
161  osg::ref_ptr< osg::Geode > m_boundaryGeode;
162 
163  /**
164  * The geometry for the whole grid.
165  */
166  osg::ref_ptr< osg::Geode > m_innerGridGeode;
167 
168  /**
169  * The labels at the corner.
170  */
172 
173  /**
174  * The geode keeping the labels
175  */
176  osg::ref_ptr< osg::Geode > m_labelGeode;
177 
178  /**
179  * The actual callback handling changes in the grid
180  *
181  * \param node the node. This will be the this pointer.
182  */
183  void callback( osg::Node* node );
184 
185  /**
186  * If true, the labels and geometry gets adapted properly.
187  */
189 
190  /**
191  * If true, the inner grid geometry gets recreated.
192  */
194 
195  /**
196  * If true, labels get used.
197  */
199 
200  /**
201  * True if the bbox should be rendered
202  */
204 
205  /**
206  * True if the grid should be rendered.
207  */
209 
210  /**
211  * The color of bbox/grid
212  */
213  WColor m_bbColor;
214 
215  /**
216  * The color of the grid.
217  */
218  WColor m_gridColor;
219 };
220 
221 #endif // WGEGRIDNODE_H
222