OpenWalnut  1.5.0dev
WMImageExtractor.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 WMIMAGEEXTRACTOR_H
26 #define WMIMAGEEXTRACTOR_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include "core/dataHandler/WDataSetRawHARDI.h"
32 #include "core/dataHandler/WDataSetScalar.h"
33 #include "core/dataHandler/WValueSet.h"
34 #include "core/kernel/WModule.h"
35 #include "core/kernel/WModuleInputData.h"
36 #include "core/kernel/WModuleOutputData.h"
37 
38 /**
39  * This module extracts single images from a dataset.
40  *
41  * \ingroup modules
42  */
44 {
45 public:
46  /**
47  * Standard constructor.
48  */
50 
51  /**
52  * Destructor.
53  */
54  virtual ~WMImageExtractor();
55 
56  /**
57  * Gives back the name of this module.
58  * \return the module's name.
59  */
60  virtual const std::string getName() const;
61 
62  /**
63  * Gives back a description of this module.
64  * \return description to module.
65  */
66  virtual const std::string getDescription() const;
67 
68  /**
69  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
70  * should never be initialized or modified in some other way. A simple new instance is required.
71  *
72  * \return the prototype used to create every module in OpenWalnut.
73  */
74  virtual std::shared_ptr< WModule > factory() const;
75 
76  /**
77  * Return an icon for this module.
78  *
79  * \return the icon
80  */
81  virtual const char** getXPMIcon() const;
82 
83 protected:
84  /**
85  * Entry point after loading the module. Runs in separate thread.
86  */
87  virtual void moduleMain();
88 
89  /**
90  * Initialize the connectors this module is using.
91  */
92  virtual void connectors();
93 
94  /**
95  * Initialize the properties for this module.
96  */
97  virtual void properties();
98 
99  /**
100  * Callback for m_active.
101  */
102  virtual void activate();
103 
104 private:
105  /**
106  * Extract the ith image from the dataset. If there is no
107  * ith image, an invalid pointer will be returned. For scalar datasets, only the 0th
108  * image can be extracted and so on.
109  *
110  * \param i The number of the image to be extracted.
111  * \return A pointer to extracted image as a scalar dataset or an invalid pointer, if no ith image exists.
112  */
113  std::shared_ptr< WDataSetScalar > extract( std::size_t i ) const;
114 
115  /**
116  * Create a name for the extracted image.
117  *
118  * \param i The number of the image.
119  * \return The name.
120  */
121  const std::string makeImageName( std::size_t i );
122 
123  /**
124  * Write property values to output dataset.
125  */
126  void setOutputProps();
127 
128  /**
129  * A property that allows selecting the number of the desired image.
130  */
131  WPropInt m_selectedImage;
132 
133  //! The data value percent that maps to 0.0 in the texture.
134  WPropDouble m_minValuePct;
135 
136  //! The data value percent that maps to 1.0 in the texture.
137  WPropDouble m_maxValuePct;
138 
139  // { TODO(ebaum): this is deprecated and will be replaced by WGEColormapping
140  // the following 5 members are taken from WMData
141  /**
142  * Interpolation?
143  */
144  WPropBool m_interpolation;
145 
146  /**
147  * A list of color map selection types
148  */
149  std::shared_ptr< WItemSelection > m_colorMapSelectionsList;
150 
151  /**
152  * Selection property for color map
153  */
154  WPropSelection m_colorMapSelection;
155 
156  /**
157  * Threshold value for this data.
158  */
159  WPropDouble m_threshold;
160 
161  /**
162  * Opacity value for this data.
163  */
164  WPropInt m_opacity;
165  // }
166 
167  /**
168  * An input connector that accepts order 1 datasets.
169  */
170  std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input;
171 
172  /**
173  * An output connector for the output scalar dataset.
174  */
175  std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output;
176 
177  /**
178  * This is a pointer to the dataset the module is currently working on.
179  */
180  std::shared_ptr< WDataSetSingle > m_dataSet;
181 
182  /**
183  * This is a pointer to the current output.
184  */
185  std::shared_ptr< WDataSetScalar > m_outData;
186 
187  /**
188  * A condition used to notify about changes in several properties.
189  */
190  std::shared_ptr< WCondition > m_propCondition;
191 };
192 
193 #endif // WMIMAGEEXTRACTOR_H
This module extracts single images from a dataset.
void setOutputProps()
Write property values to output dataset.
virtual const char ** getXPMIcon() const
Return an icon for this module.
WPropBool m_interpolation
Interpolation?
WPropDouble m_maxValuePct
The data value percent that maps to 1.0 in the texture.
std::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output
An output connector for the output scalar dataset.
std::shared_ptr< WDataSetScalar > m_outData
This is a pointer to the current output.
virtual void connectors()
Initialize the connectors this module is using.
virtual const std::string getName() const
Gives back the name of this module.
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.
WPropInt m_selectedImage
A property that allows selecting the number of the desired image.
WPropInt m_opacity
Opacity value for this data.
WMImageExtractor()
Standard constructor.
virtual ~WMImageExtractor()
Destructor.
virtual void moduleMain()
Entry point after loading the module.
std::shared_ptr< WDataSetSingle > m_dataSet
This is a pointer to the dataset the module is currently working on.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropDouble m_minValuePct
The data value percent that maps to 0.0 in the texture.
const std::string makeImageName(std::size_t i)
Create a name for the extracted image.
WPropDouble m_threshold
Threshold value for this data.
std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input
An input connector that accepts order 1 datasets.
std::shared_ptr< WItemSelection > m_colorMapSelectionsList
A list of color map selection types.
virtual void activate()
Callback for m_active.
std::shared_ptr< WDataSetScalar > extract(std::size_t i) const
Extract the ith image from the dataset.
WPropSelection m_colorMapSelection
Selection property for color map.
virtual void properties()
Initialize the properties for this module.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72