OpenWalnut  1.5.0dev
WMFilterProtonData.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 WMFILTERPROTONDATA_H
26 #define WMFILTERPROTONDATA_H
27 
28 #include <algorithm>
29 #include <memory>
30 #include <string>
31 #include <utility>
32 #include <vector>
33 
34 #include <boost/lexical_cast.hpp>
35 
36 #include "WCsvConverter.h"
37 #include "WPropertyStatus.h"
38 #include "WProtonData.h"
39 #include "core/common/WItemSelectionItem.h"
40 #include "core/common/WItemSelector.h"
41 #include "core/dataHandler/WDataSetCSV.h"
42 #include "core/dataHandler/WDataSetFibers.h"
43 #include "core/dataHandler/WDataSetPoints.h"
44 #include "core/kernel/WKernel.h"
45 #include "core/kernel/WModule.h"
46 #include "core/kernel/WModuleContainer.h"
47 #include "core/kernel/WModuleInputData.h"
48 #include "core/kernel/WModuleOutputData.h"
49 
50 
51 /**
52  * This module simply registers a given csv dataset to the csv handling mechanism.
53  * This allows all outputs to be shown as a fiber-dataset or a point-dataset.
54  *
55  * \ingroup modules
56  */
58 {
59  /**
60  * Only test classes may be friend
61  */
62  friend class WCsvConverterTest;
63 public:
64  /**
65  * represents a std::shared_ptr to a vector containing a vector of floats.
66  */
67  typedef std::shared_ptr< std::vector< float > > SPFloatVector;
68 
69  /**
70  * represents a std::shared_ptr to a vector containing a vector of size_t.
71  */
72  typedef std::shared_ptr< std::vector< size_t > > SPSizeVector;
73 
74  /**
75  * Standard constructor.
76  */
78 
79  /**
80  * Standard destructor.
81  */
82  virtual ~WMFilterProtonData();
83 
84  /**
85  * Returns the name of this module.
86  * \return the module's name.
87  */
88  virtual const std::string getName() const;
89 
90  /**
91  * Retruns the description of this module.
92  * \return description of the module.
93  */
94  virtual const std::string getDescription() const;
95 
96  /**
97  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
98  * should never be initialized or modified in some other way. A simple new instance is required.
99  *
100  * \return the prototype used to create every module in OpenWalnut.
101  */
102  virtual std::shared_ptr< WModule > factory() const;
103 
104  /**
105  * Get the icon for this module in XPM format.
106  * \return The icon.
107  */
108  virtual const char** getXPMIcon() const;
109 
110 protected:
111  /**
112  * Toggles activation for inner module based on activation of this module
113  */
114  virtual void activate();
115 
116  /**
117  * Entry point after loading the module. Runs in separate thread.
118  */
119  virtual void moduleMain();
120 
121  /**
122  * Initialize the connectors this module is using.
123  */
124  virtual void connectors();
125 
126  /**
127  * Initialize the properties for this module.
128  */
129  virtual void properties();
130 
131 private:
132  /**
133  * Pointer that points to the Proton data from the CSV file
134  */
136 
137  /**
138  * Reference to the transfer function color bar module within this module container
139  */
141 
142  /**
143  * Input connector (required for this module).
144  */
145  std::shared_ptr< WModuleInputData< WDataSetCSV > > m_input;
146 
147  /**
148  * WDataSetPoints output connector (required for this module).
149  */
150  std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output_points;
151 
152  /**
153  * WDataSetFibers output connector (required for this module).
154  */
155  std::shared_ptr< WModuleOutputData< WDataSetFibers > > m_output_fibers;
156 
157  /**
158  * WDataSetSingle output connector to output current transfer function
159  */
160  std::shared_ptr< WModuleOutputData< WDataSetSingle > > m_output_transferFunction;
161 
162  /**
163  * WDataSetPointsAndEventIDs output connector to output points and eventIDs for PointConn.
164  */
165  std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output_points_eventIds;
166 
167  /**
168  * Stores information of the input-csv-data
169  */
170  std::shared_ptr< WDataSetCSV > m_dataset;
171 
172  /**
173  * Contains all property-groups and the subproperties
174  */
175  std::shared_ptr < WPropertyStatus > m_propertyStatus;
176 
177  /**
178  * Contains the algorithm that converts the raw CSV file into compatible WDataSets (Points, Fibers, PointsAndSizes, PointConnector etc.)
179  */
180  std::shared_ptr < WCsvConverter > m_converter;
181 
182  /**
183  * Creates the transfer function color bar module within this module container
184  */
185  void createColorBar();
186 
187  /**
188  * Contains the loaded properties.
189  */
190  std::vector< std::pair< std::string, std::string > > m_loadedProperties;
191 
192  /**
193  * Create outputs, so it can be displayed by the fiber display and the point renderer.
194  */
195  void setOutputFromCSV( );
196 
197  /**
198  * update added group property and subproperty
199  */
200  void updateProperty();
201 
202  /**
203  * Notifier for the dummy properties.
204  * \param group The WPropertyGroup this property belongs to.
205  * \param property The property that was updated.
206  */
207  void loadNotifier( WPropertyGroup::SPtr group, WPropertyBase::SPtr property );
208 
209  /**
210  * Sets the current properties to the state of the loaded properties.
211  */
212  void setToLoadedProperties();
213 
214  /**
215  * Removes the property groups.
216  */
217  void clearProperties();
218 };
219 
220 #endif // WMFILTERPROTONDATA_H
Test class of WCsvConverter class.
This module simply registers a given csv dataset to the csv handling mechanism.
void setToLoadedProperties()
Sets the current properties to the state of the loaded properties.
std::shared_ptr< std::vector< size_t > > SPSizeVector
represents a std::shared_ptr to a vector containing a vector of size_t.
std::shared_ptr< WModuleOutputData< WDataSetSingle > > m_output_transferFunction
WDataSetSingle output connector to output current transfer function.
std::shared_ptr< WDataSetCSV > m_dataset
Stores information of the input-csv-data.
virtual ~WMFilterProtonData()
Standard destructor.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
std::shared_ptr< WCsvConverter > m_converter
Contains the algorithm that converts the raw CSV file into compatible WDataSets (Points,...
std::shared_ptr< WModuleOutputData< WDataSetFibers > > m_output_fibers
WDataSetFibers output connector (required for this module).
virtual const std::string getName() const
Returns the name of this module.
void createColorBar()
Creates the transfer function color bar module within this module container.
WModule::SPtr m_colorBar
Reference to the transfer function color bar module within this module container.
WProtonData::SPtr m_protonData
Pointer that points to the Proton data from the CSV file
std::shared_ptr< std::vector< float > > SPFloatVector
represents a std::shared_ptr to a vector containing a vector of floats.
std::shared_ptr< WPropertyStatus > m_propertyStatus
Contains all property-groups and the subproperties.
virtual void activate()
Toggles activation for inner module based on activation of this module.
virtual const std::string getDescription() const
Retruns the description of this module.
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output_points_eventIds
WDataSetPointsAndEventIDs output connector to output points and eventIDs for PointConn.
virtual void connectors()
Initialize the connectors this module is using.
void clearProperties()
Removes the property groups.
void loadNotifier(WPropertyGroup::SPtr group, WPropertyBase::SPtr property)
Notifier for the dummy properties.
virtual void properties()
Initialize the properties for this module.
std::vector< std::pair< std::string, std::string > > m_loadedProperties
Contains the loaded properties.
WMFilterProtonData()
Standard constructor.
void updateProperty()
update added group property and subproperty
virtual void moduleMain()
Entry point after loading the 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...
std::shared_ptr< WModuleInputData< WDataSetCSV > > m_input
Input connector (required for this module).
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output_points
WDataSetPoints output connector (required for this module).
void setOutputFromCSV()
Create outputs, so it can be displayed by the fiber display and the point renderer.
Class able to contain other modules.
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
Definition: WModule.h:106
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
Definition: WPropertyBase.h:53
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type
std::shared_ptr< WProtonData > SPtr
shared_ptr that points to itself
Definition: WProtonData.h:52