OpenWalnut  1.5.0dev
WMGridRenderer.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 WMGRIDRENDERER_H
26 #define WMGRIDRENDERER_H
27 
28 #include <map>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 
33 #include <osg/Geode>
34 #include <osg/Node>
35 #include <osg/Uniform>
36 
37 #include "core/dataHandler/WDataSet.h"
38 #include "core/graphicsEngine/WGEGroupNode.h"
39 #include "core/graphicsEngine/geodes/WGEGridNode.h"
40 #include "core/kernel/WModule.h"
41 #include "core/kernel/WModuleInputData.h"
42 
43 /**
44  * Show the bounding box and grid of a WDataSetSingle
45  * \ingroup modules
46  */
47 class WMGridRenderer : public WModule
48 {
49 public:
50  /**
51  * Standard constructor.
52  */
54 
55  /**
56  * Destructor.
57  */
59 
60  /**
61  * Gives back the name of this module.
62  * \return the module's name.
63  */
64  virtual const std::string getName() const;
65 
66  /**
67  * Gives back a description of this module.
68  * \return description of module.
69  */
70  virtual const std::string getDescription() const;
71 
72  /**
73  * Determine what to do if a property was changed.
74  * \param propertyName Name of the property.
75  */
76  void slotPropertyChanged( std::string propertyName );
77 
78  /**
79  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
80  * should never be initialized or modified in some other way. A simple new instance is required.
81  *
82  * \return the prototype used to create every module in OpenWalnut.
83  */
84  virtual std::shared_ptr< WModule > factory() const;
85 
86  /**
87  * Get the icon for this module in XPM format.
88  * \return The icon.
89  */
90  virtual const char** getXPMIcon() const;
91 
92 protected:
93  /**
94  * Entry point after loading the module. Runs in separate thread.
95  */
96  virtual void moduleMain();
97 
98  /**
99  * Initialize the connectors this module is using.
100  */
101  virtual void connectors();
102 
103  /**
104  * Initialize the properties for this module.
105  */
106  virtual void properties();
107 
108 private:
109  std::shared_ptr< WModuleInputData< WDataSet > > m_input; //!< Input connector required by this module.
110 
111  WItemSelection::SPtr m_possibleModes; //!< the modes available.
112 
113  WPropSelection m_mode; //!< the mode (bbox, grid, both)
114 
115  WPropColor m_bboxColor; //!< the color of the bounding box
116 
117  WPropColor m_gridColor; //!< the color of the grid
118 
119  WPropInt m_boxLineWidth; //!< the width of the boundary lines
120 
121  WPropInt m_gridLineWidth; //!< the width of the grid lines
122 
123  std::shared_ptr< WProperties > currentDataInfoProperties; //!< Kept reference to current data infos as properties
124 
125  /**
126  * This condition denotes whether we need to recompute the surface
127  */
128  std::shared_ptr< WCondition > m_recompute;
129 
130  /**
131  * The node actually drawing the grid.
132  */
134 
135  /**
136  * The currently handled data.
137  */
139 
140  /**
141  * Handles updates in properties.
142  *
143  * \param property the property that has updated.
144  */
145  void updateNode( WPropertyBase::SPtr property );
146 };
147 #endif // WMGRIDRENDERER_H
std::shared_ptr< WDataSet > SPtr
Shared pointer abbreviation to a instance of this class.
Definition: WDataSet.h:55
osg::ref_ptr< WGEGridNode > SPtr
Convenience typedef for a osg::ref_ptr< WGEGridNode >.
Definition: WGEGridNode.h:46
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
Show the bounding box and grid of a WDataSetSingle.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual const std::string getDescription() const
Gives back a description of this module.
~WMGridRenderer()
Destructor.
WPropColor m_gridColor
the color of the grid
void slotPropertyChanged(std::string propertyName)
Determine what to do if a property was changed.
virtual void properties()
Initialize the properties for this module.
std::shared_ptr< WCondition > m_recompute
This condition denotes whether we need to recompute the surface.
WPropColor m_bboxColor
the color of the bounding box
std::shared_ptr< WModuleInputData< WDataSet > > m_input
Input connector required by this module.
WMGridRenderer()
Standard constructor.
virtual const std::string getName() const
Gives back the name of this module.
virtual void moduleMain()
Entry point after loading the module.
void updateNode(WPropertyBase::SPtr property)
Handles updates in properties.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
WDataSet::SPtr m_dataSetOld
The currently handled data.
WItemSelection::SPtr m_possibleModes
the modes available.
virtual void connectors()
Initialize the connectors this module is using.
WPropSelection m_mode
the mode (bbox, grid, both)
WGEGridNode::SPtr m_gridNode
The node actually drawing the grid.
WPropInt m_boxLineWidth
the width of the boundary lines
WPropInt m_gridLineWidth
the width of the grid lines
std::shared_ptr< WProperties > currentDataInfoProperties
Kept reference to current data infos as properties.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
Definition: WPropertyBase.h:53