OpenWalnut  1.5.0dev
WMDatasetProfile.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 WMDATASETPROFILE_H
26 #define WMDATASETPROFILE_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <osg/Geode>
33 #include <osgWidget/WindowManager> // NOLINT: brainlint thinks this is C System Header
34 
35 #include "core/dataHandler/WDataSetScalar.h"
36 #include "core/dataHandler/WDataSetSingle.h"
37 #include "core/graphicsEngine/WGECamera.h"
38 #include "core/graphicsEngine/WGEManagedGroupNode.h"
39 #include "core/graphicsEngine/WROISphere.h"
40 #include "core/kernel/WModule.h"
41 #include "core/kernel/WModuleInputData.h"
42 #include "core/kernel/WModuleOutputData.h"
43 
44 const unsigned int MASK_2D = 0xF0000000; //!< used for osgWidget stuff
45 const unsigned int MASK_3D = 0x0F000000; //!< used for osgWidget stuff
46 
47 /**
48  * Someone should add some documentation here.
49  * Probably the best person would be the module's
50  * creator, i.e. "schurade".
51  *
52  * This is only an empty template for a new module. For
53  * an example module containing many interesting concepts
54  * and extensive documentation have a look at "src/modules/template"
55  *
56  * \ingroup modules
57  */
59 {
60 public:
61  /**
62  *
63  */
65 
66  /**
67  *
68  */
69  virtual ~WMDatasetProfile();
70 
71  /**
72  * Gives back the name of this module.
73  * \return the module's name.
74  */
75  virtual const std::string getName() const;
76 
77  /**
78  * Gives back a description of this module.
79  * \return description to module.
80  */
81  virtual const std::string getDescription() const;
82 
83  /**
84  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
85  * should never be initialized or modified in some other way. A simple new instance is required.
86  *
87  * \return the prototype used to create every module in OpenWalnut.
88  */
89  virtual std::shared_ptr< WModule > factory() const;
90 
91  /**
92  * Get the icon for this module in XPM format.
93  * \return The icon.
94  */
95  virtual const char** getXPMIcon() const;
96 
97 protected:
98  /**
99  * Entry point after loading the module. Runs in separate thread.
100  */
101  virtual void moduleMain();
102 
103  /**
104  * Initialize the connectors this module is using.
105  */
106  virtual void connectors();
107 
108  /**
109  * Initialize the properties for this module.
110  */
111  virtual void properties();
112 
113  /**
114  * Initialize requirements for this module.
115  */
116  virtual void requirements();
117 
118  /**
119  * update function, called with each update pass of the osg render loop
120  */
121  void updateCallback();
122 
123 
124 private:
125  /**
126  * initializes the controls and osg nodes
127  */
128  void init();
129 
130  /**
131  * updates the osg nodes
132  */
133  void update();
134 
135  /**
136  * sets the dirty flag, used as callback for control knob changes
137  */
138  void setDirty();
139 
140  /**
141  * dirty flag to indicate that redrawing is needed
142  */
143  bool m_dirty;
144 
145  /**
146  * creates an osg node that contains the underlying grid
147  * \return osg::ref_ptr< osg::Geode >
148  */
149  osg::ref_ptr< osg::Geode > createGraphGridGeode();
150 
151  /**
152  * creates an osg node that contains the graph
153  * \return osg::ref_ptr< osg::Geode >
154  */
155  osg::ref_ptr< osg::Geode > createGraphGeode();
156 
157  /**
158  * adds a control knob
159  * \param pos Position of the new knob
160  */
161  void addKnob( WPosition pos );
162 
163  /**
164  * An input connector that accepts order 1 datasets.
165  */
166  std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input;
167 
168  /**
169  * This is a pointer to the dataset the module is currently working on.
170  */
171  std::shared_ptr< WDataSetScalar > m_dataSet;
172 
173  /**
174  * stores a pointer to the grid we use;
175  */
176  std::shared_ptr< WGridRegular3D > m_grid;
177 
178 
179 
180  /**
181  * A condition used to notify about changes in several properties.
182  */
183  std::shared_ptr< WCondition > m_propCondition;
184 
185  /**
186  * A list of cluster selection methods
187  */
188  std::shared_ptr< WItemSelection > m_snapSelectionsList;
189 
190  /**
191  * Selection property for clusters
192  */
193  WPropSelection m_snapSelection;
194 
195  WPropTrigger m_propAddKnobTrigger; //!< Adds a knob
196 
197 
198  WPropColor m_graphColor; //!< color of the graph
199 
200  WPropDouble m_propLength; //!< length between knobs
201 
202  WPropBool m_propUseLength; //!< enforce lengths
203 
204  WPropBool m_propInterpolate; //!< interpolate the graph
205 
206  WPropInt m_propNumSamples; //!< number of sample points on the graph
207 
208  /**
209  * The root node used for this modules graphics.
210  */
211  osg::ref_ptr< WGEManagedGroupNode > m_rootNode;
212 
213  osg::ref_ptr< WGEManagedGroupNode > m_graphNode; //!< Pointer to the graph group node.
214 
215  /**
216  * The geometry rendered by this module.
217  */
218  osg::ref_ptr< osg::Geode > m_lineGeode;
219 
220  /**
221  * osg node for the grid
222  */
223  osg::ref_ptr< osg::Geode > m_graphGridGeode;
224 
225  /**
226  * osg node for the graph
227  */
228  osg::ref_ptr< osg::Geode > m_graphGeode;
229 
230  /**
231  * stores pointers to the control knobs
232  */
233  std::vector< osg::ref_ptr<WROISphere> >knobs;
234 
235  std::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the graph
236 
237  int m_oldViewHeight; //!< stores the old viewport resolution to check whether a resize happened
238  int m_oldViewWidth; //!< stores the old viewport resolution to check whether a resize happened
239 
240  osgWidget::WindowManager* m_wm; //!< stores a pointer to the window manager used for osg wdgets and overlay stuff
241 
242  WGECamera* m_camera; //!< stores the camera object
243 };
244 
245 #endif // WMDATASETPROFILE_H
Class for wrapping around the OSG Camera class.
Definition: WGECamera.h:36
Someone should add some documentation here.
WPropSelection m_snapSelection
Selection property for clusters.
std::shared_ptr< WGridRegular3D > m_grid
stores a pointer to the grid we use;
osg::ref_ptr< osg::Geode > createGraphGeode()
creates an osg node that contains the graph
int m_oldViewWidth
stores the old viewport resolution to check whether a resize happened
WGECamera * m_camera
stores the camera object
WPropBool m_propUseLength
enforce lengths
bool m_dirty
dirty flag to indicate that redrawing is needed
WPropTrigger m_propAddKnobTrigger
Adds a knob.
virtual const std::string getDescription() const
Gives back a description of this module.
std::vector< osg::ref_ptr< WROISphere > > knobs
stores pointers to the control knobs
osg::ref_ptr< WGEManagedGroupNode > m_rootNode
The root node used for this modules graphics.
osg::ref_ptr< osg::Geode > m_lineGeode
The geometry rendered by this module.
std::shared_ptr< WDataSetScalar > m_dataSet
This is a pointer to the dataset the module is currently working on.
osg::ref_ptr< WGEManagedGroupNode > m_graphNode
Pointer to the graph group node.
std::shared_ptr< WItemSelection > m_snapSelectionsList
A list of cluster selection methods.
osg::ref_ptr< osg::Geode > m_graphGeode
osg node for the graph
virtual const std::string getName() const
Gives back the name of this module.
virtual void moduleMain()
Entry point after loading the module.
osg::ref_ptr< osg::Geode > m_graphGridGeode
osg node for the grid
void addKnob(WPosition pos)
adds a control knob
int m_oldViewHeight
stores the old viewport resolution to check whether a resize happened
virtual void connectors()
Initialize the connectors this module is using.
osg::ref_ptr< osg::Geode > createGraphGridGeode()
creates an osg node that contains the underlying grid
void updateCallback()
update function, called with each update pass of the osg render loop
std::shared_ptr< boost::function< void() > > m_changeRoiSignal
Signal that can be used to update the graph.
WPropInt m_propNumSamples
number of sample points on the graph
void setDirty()
sets the dirty flag, used as callback for control knob changes
void init()
initializes the controls and osg nodes
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
std::shared_ptr< WModuleInputData< WDataSetScalar > > m_input
An input connector that accepts order 1 datasets.
WPropBool m_propInterpolate
interpolate the graph
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
void update()
updates the osg nodes
virtual void properties()
Initialize the properties for this module.
WPropDouble m_propLength
length between knobs
WPropColor m_graphColor
color of the graph
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...
osgWidget::WindowManager * m_wm
stores a pointer to the window manager used for osg wdgets and overlay stuff
virtual void requirements()
Initialize requirements for this module.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
This only is a 3d double vector.