OpenWalnut  1.5.0dev
WMFiberDisplay.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 WMFIBERDISPLAY_H
26 #define WMFIBERDISPLAY_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <boost/thread.hpp>
32 
33 #include "core/dataHandler/WDataSetFiberClustering.h"
34 #include "core/dataHandler/WDataSetFibers.h"
35 #include "core/kernel/WFiberSelector.h"
36 #include "core/kernel/WModule.h"
37 #include "core/kernel/WModuleInputData.h"
38 #include "core/kernel/WModuleOutputData.h"
39 
40 // forward declarations
41 class WGEShader;
42 
43 /**
44  * This modules takes a dataset and equalizes its histogram.
45  *
46  * \ingroup modules
47  */
48 class WMFiberDisplay: public WModule
49 {
50 public:
51  /**
52  * Default constructor.
53  */
55 
56  /**
57  * Destructor.
58  */
59  virtual ~WMFiberDisplay();
60 
61  /**
62  * Gives back the name of this module.
63  * \return the module's name.
64  */
65  virtual const std::string getName() const;
66 
67  /**
68  * Gives back a description of this module.
69  * \return description to module.
70  */
71  virtual const std::string getDescription() const;
72 
73  /**
74  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
75  * should never be initialized or modified in some other way. A simple new instance is required.
76  *
77  * \return the prototype used to create every module in OpenWalnut.
78  */
79  virtual std::shared_ptr< WModule > factory() const;
80 
81 protected:
82  /**
83  * Entry point after loading the module. Runs in separate thread.
84  */
85  virtual void moduleMain();
86 
87  /**
88  * Initialize the connectors this module is using.
89  */
90  virtual void connectors();
91 
92  /**
93  * Initialize the properties for this module.
94  */
95  virtual void properties();
96 
97 private:
98  /**
99  * Geometry update callback. Handles fiber cluster filtering
100  *
101  * \param geometry the geometry instance to handle
102  */
103  void geometryUpdate( osg::Drawable* geometry );
104 
105  /**
106  * If true, the geometryUpdate() callback will upload a new filter attribute array.
107  */
109 
110  /**
111  * A mutex used to atomically update the fibers and their selector.
112  */
113  boost::mutex m_mutex;
114 
115  /**
116  * The fiber dataset which is going to be filtered.
117  */
118  std::shared_ptr< WModuleInputData< WDataSetFibers > > m_fiberInput;
119 
120  /**
121  * An optional fiber clustering can be specified to filter in m_fiberInput.
122  */
123  std::shared_ptr< WModuleInputData< WDataSetFiberClustering > > m_fiberClusteringInput;
124 
125  /**
126  * The current fiber data
127  */
129 
130  /**
131  * The current fiber clustering
132  */
134 
135 
136  WPropInt m_nbVertices; //!< Info-property showing the number of vertices in the fiber data set.
137  WPropInt m_nbFibers; //!< Info-property showing the number of fibers in the fiber data set.
138 
139  /**
140  * A condition used to notify about changes in several properties.
141  */
142  std::shared_ptr< WCondition > m_propCondition;
143 
144  /**
145  * The properties of the fiber dataset.
146  */
148 
149  /**
150  * The shader used for actually drawing the fake tubes or lines.
151  */
152  osg::ref_ptr< WGEShader > m_shader;
153 
154  /**
155  * The shader used for drawing end cap sprites if in tube mode.
156  */
157  osg::ref_ptr< WGEShader > m_endCapShader;
158 
159  /**
160  * Illumination.
161  */
163 
164  /**
165  * Allow disabling ROI filter mode.
166  */
167  WPropBool m_roiFiltering;
168 
169  /**
170  * Use coloring defined by the roi branches.
171  */
172  WPropBool m_roiFilterColors;
173 
174  /**
175  * Group containing several coloring options
176  */
177  WPropGroup m_coloringGroup;
178 
179  /**
180  * Define whether to use a single color or the dataset color.
181  */
182  WPropBool m_plainColorMode;
183 
184  /**
185  * Define a color to use if in plain color mode.
186  */
187  WPropColor m_plainColor;
188 
189  /**
190  * The ratio between colormap and fiber color.
191  */
192  WPropDouble m_colormapRatio;
193 
194  /**
195  * True if colormapping should be used.
196  */
197  WPropBool m_colormapEnabled;
198 
199  /**
200  * A property group for all the clipping related props.
201  */
202  WPropGroup m_clipPlaneGroup;
203 
204  /**
205  * Property for en-/disable clipping.
206  */
208 
209  /**
210  * Property for en-/disabling of the clip plane plane.
211  */
213 
214  /**
215  * Point on the plane. Defines the plane.
216  */
217  WPropPosition m_clipPlanePoint;
218 
219  /**
220  * Vector of the plane. Defines the plane.
221  */
222  WPropPosition m_clipPlaneVector;
223 
224  /**
225  * Distance from plane. Used as threshold.
226  */
227  WPropDouble m_clipPlaneDistance;
228 
229  /**
230  * Prop denoting whether to use tubes or line strips
231  */
232  WPropBool m_tubeEnable;
233 
234  /**
235  * Property denoting whether to use end-caps on tubes
236  */
238 
239  /**
240  * Prop denoting whether tubes can be zoomed or not.
241  */
242  WPropBool m_tubeZoomable;
243 
244  /**
245  * Creates a ribbon-like appearance.
246  */
247  WPropBool m_tubeRibbon;
248 
249  /**
250  * The size. The meaning somehow relates to tubeZoomable. If a tube is zoomable, the size is the smallest size in pixels on screen of totally
251  * zoomed out.
252  */
253  WPropDouble m_tubeSize;
254 
255  /**
256  * Group containing tube specific properties
257  */
258  WPropGroup m_tubeGroup;
259 
260  /**
261  * Group containing line specific properties
262  */
263  WPropGroup m_lineGroup;
264 
265  /**
266  * Line width.
267  */
268  WPropDouble m_lineWidth;
269 
270  /**
271  * Line smoothing.
272  */
273  WPropBool m_lineSmooth;
274 
275  /**
276  * Update the transform node to provide an cue were the plane actually is.
277  *
278  * \param node the transform node
279  */
280  void clipPlaneCallback( osg::Node* node ) const;
281 
282  /**
283  * Creates the clip plane with corresponding callbacks.
284  *
285  * \return the clip plane node
286  */
287  osg::ref_ptr< osg::Node > createClipPlane() const;
288 
289  /**
290  * Creates a geode containing the fiber geometry
291  *
292  * \param fibers the fiber data
293  * \param fibGeode the geode with the fibers as tube strip or lines
294  * \param endCapGeode the end cap sprites. Not used if not in tube mode.
295  */
296  void createFiberGeode( std::shared_ptr< WDataSetFibers > fibers, osg::ref_ptr< osg::Geode > fibGeode,
297  osg::ref_ptr< osg::Geode > endCapGeode );
298 
299  /**
300  * The plane node.
301  */
302  osg::ref_ptr< osg::Node > m_plane;
303 
304  /**
305  * Callback for the line geode to allow interactive modification of line smooth and width states.
306  *
307  * \param state the state
308  */
309  void lineGeodeStateCallback( osg::StateSet* state );
310 
311  /**
312  * Point to a fiber selector, which is an adapter between the ROI manager and the this module
313  */
314  std::shared_ptr< WFiberSelector > m_fiberSelector;
315 
316  /**
317  * Is true when received a change signal from m_fiberSelector
318  */
320 
321  /**
322  * Connection to the roi dirty signal.
323  */
324  boost::signals2::connection m_roiUpdateConnection;
325 
326  /**
327  * Called when updating the selection.
328  */
329  void roiUpdate();
330 
331  /**
332  * Contains the ROI bitfield
333  */
334  osg::ref_ptr< osg::FloatArray > m_bitfieldAttribs;
335 
336  /**
337  * Contains the ROI color map for live branch coloring.
338  */
339  osg::ref_ptr< osg::Vec3Array > m_secondaryColor;
340 
341  /**
342  * Ratio between dataset color and ROI color.
343  */
344  osg::ref_ptr< osg::Uniform > m_roiFilterColorsOverride;
345 };
346 
347 #endif // WMFIBERDISPLAY_H
std::shared_ptr< WDataSetFiberClustering > SPtr
Convenience typedef for a std::shared_ptr< WDataSetFiberClustering >.
std::shared_ptr< WDataSetFibers > SPtr
Pointer to dataset.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Definition: WGEShader.h:48
This modules takes a dataset and equalizes its histogram.
std::shared_ptr< WModuleInputData< WDataSetFiberClustering > > m_fiberClusteringInput
An optional fiber clustering can be specified to filter in m_fiberInput.
WPropBool m_lineSmooth
Line smoothing.
osg::ref_ptr< WGEShader > m_endCapShader
The shader used for drawing end cap sprites if in tube mode.
WPropBool m_clipPlaneShowPlane
Property for en-/disabling of the clip plane plane.
bool m_fiberClusteringUpdate
If true, the geometryUpdate() callback will upload a new filter attribute array.
WPropBool m_tubeEndCapsEnable
Property denoting whether to use end-caps on tubes.
WDataSetFibers::SPtr m_fibers
The current fiber data.
bool m_fiberSelectorChanged
Is true when received a change signal from m_fiberSelector.
void geometryUpdate(osg::Drawable *geometry)
Geometry update callback.
boost::mutex m_mutex
A mutex used to atomically update the fibers and their selector.
void lineGeodeStateCallback(osg::StateSet *state)
Callback for the line geode to allow interactive modification of line smooth and width states.
osg::ref_ptr< osg::Vec3Array > m_secondaryColor
Contains the ROI color map for live branch coloring.
virtual ~WMFiberDisplay()
Destructor.
WPropDouble m_colormapRatio
The ratio between colormap and fiber color.
boost::signals2::connection m_roiUpdateConnection
Connection to the roi dirty signal.
osg::ref_ptr< osg::Node > createClipPlane() const
Creates the clip plane with corresponding callbacks.
osg::ref_ptr< osg::FloatArray > m_bitfieldAttribs
Contains the ROI bitfield.
WPropGroup m_clipPlaneGroup
A property group for all the clipping related props.
WPropInt m_nbVertices
Info-property showing the number of vertices in the fiber data set.
virtual const std::string getDescription() const
Gives back a description of this module.
osg::ref_ptr< osg::Uniform > m_roiFilterColorsOverride
Ratio between dataset color and ROI color.
WPropBool m_tubeZoomable
Prop denoting whether tubes can be zoomed or not.
WPropBool m_clipPlaneEnabled
Property for en-/disable clipping.
WPropBool m_colormapEnabled
True if colormapping should be used.
osg::ref_ptr< WGEShader > m_shader
The shader used for actually drawing the fake tubes or lines.
WPropBool m_roiFiltering
Allow disabling ROI filter mode.
WPropDouble m_clipPlaneDistance
Distance from plane.
WPropBool m_illuminationEnable
Illumination.
WPropBool m_tubeEnable
Prop denoting whether to use tubes or line strips.
std::shared_ptr< WFiberSelector > m_fiberSelector
Point to a fiber selector, which is an adapter between the ROI manager and the this module.
virtual void properties()
Initialize the properties for this module.
virtual void connectors()
Initialize the connectors this module is using.
virtual void moduleMain()
Entry point after loading the module.
void clipPlaneCallback(osg::Node *node) const
Update the transform node to provide an cue were the plane actually is.
WPropDouble m_lineWidth
Line width.
WMFiberDisplay()
Default constructor.
WProperties::SPtr m_fibProps
The properties of the fiber dataset.
WPropInt m_nbFibers
Info-property showing the number of fibers in the fiber data set.
WPropBool m_plainColorMode
Define whether to use a single color or the dataset color.
WPropPosition m_clipPlanePoint
Point on the plane.
WPropPosition m_clipPlaneVector
Vector of the plane.
void createFiberGeode(std::shared_ptr< WDataSetFibers > fibers, osg::ref_ptr< osg::Geode > fibGeode, osg::ref_ptr< osg::Geode > endCapGeode)
Creates a geode containing the fiber geometry.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropBool m_tubeRibbon
Creates a ribbon-like appearance.
WDataSetFiberClustering::SPtr m_fiberClustering
The current fiber clustering.
void roiUpdate()
Called when updating the selection.
WPropBool m_roiFilterColors
Use coloring defined by the roi branches.
WPropColor m_plainColor
Define a color to use if in plain color mode.
WPropDouble m_tubeSize
The size.
std::shared_ptr< WModuleInputData< WDataSetFibers > > m_fiberInput
The fiber dataset which is going to be filtered.
WPropGroup m_tubeGroup
Group containing tube specific properties.
virtual const std::string getName() const
Gives back the name of this module.
WPropGroup m_lineGroup
Group containing line specific properties.
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...
WPropGroup m_coloringGroup
Group containing several coloring options.
osg::ref_ptr< osg::Node > m_plane
The plane node.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type