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