OpenWalnut  1.5.0dev
WMDatasetManipulator.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 WMDATASETMANIPULATOR_H
26 #define WMDATASETMANIPULATOR_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include "core/common/WObjectNDIP.h"
32 #include "core/common/WStrategyHelper.h"
33 #include "core/dataHandler/WDataSet.h"
34 #include "core/kernel/WModule.h"
35 #include "core/kernel/WModuleInputData.h"
36 #include "core/kernel/WModuleOutputData.h"
37 #include "WManipulatorInterface.h"
38 
39 /**
40  * Module allowing manipulation of the dataset scaling, orientation and position.
41  *
42  * \ingroup modules
43  */
45 {
46 public:
47  /**
48  * Constructor.
49  */
51 
52  /**
53  * Destructor.
54  */
55  virtual ~WMDatasetManipulator();
56 
57  /**
58  * Gives back the name of this module.
59  * \return the module's name.
60  */
61  virtual const std::string getName() const;
62 
63  /**
64  * Gives back a description of this module.
65  * \return description to module.
66  */
67  virtual const std::string getDescription() const;
68 
69  /**
70  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
71  * should never be initialized or modified in some other way. A simple new instance is required.
72  *
73  * \return the prototype used to create every module in OpenWalnut.
74  */
75  virtual std::shared_ptr< WModule > factory() const;
76 
77  /**
78  * Get the icon for this module in XPM format.
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 private:
100  /**
101  * Init the matrix to be applied from the transformations stored in the current dataset.
102  */
103  void initMatrix();
104 
105  /**
106  * Transform the data using the provided transformation matrix.
107  *
108  * \param mat The Transform to apply.
109  *
110  * \return The new and transformed dataset.
111  */
112  std::shared_ptr< WDataSet > transformData( WMatrixFixed< double, 4, 4 > const& mat );
113 
114  //! A condition for property updates.
115  std::shared_ptr< WCondition > m_propCondition;
116 
117  //! A trigger to reset the current transformation to the initial one.
118  WPropTrigger m_resetTrigger;
119 
120  //! A trigger to add the transformation from the currently active strategy to the current transformation.
121  WPropTrigger m_applyTrigger;
122 
123  //! The current data.
124  std::shared_ptr< WDataSet > m_data;
125 
126  //! The current transformation.
128 
129  //! An input connector that accepts any dataset.
130  std::shared_ptr< WModuleInputData< WDataSet > > m_input;
131 
132  //! An output connector for the transformed dataset.
133  std::shared_ptr< WModuleOutputData< WDataSet > > m_output;
134 
135  //! The strategy to use for dataset transformation manipulation.
137 };
138 
139 #endif // WMDATASETMANIPULATOR_H
Module allowing manipulation of the dataset scaling, orientation and position.
std::shared_ptr< WModuleOutputData< WDataSet > > m_output
An output connector for the transformed dataset.
std::shared_ptr< WCondition > m_propCondition
A condition for property updates.
std::shared_ptr< WDataSet > m_data
The current data.
WMatrixFixed< double, 4, 4 > m_currentMat
The current transformation.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual void connectors()
Initialize the connectors this module is using.
WPropTrigger m_applyTrigger
A trigger to add the transformation from the currently active strategy to the current transformation.
virtual void properties()
Initialize the properties for this module.
WPropTrigger m_resetTrigger
A trigger to reset the current transformation to the initial one.
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< WDataSet > > m_input
An input connector that accepts any dataset.
WStrategyHelper< WObjectNDIP< WManipulatorInterface > > m_strategy
The strategy to use for dataset transformation manipulation.
virtual const std::string getName() const
Gives back the name of this module.
std::shared_ptr< WDataSet > transformData(WMatrixFixed< double, 4, 4 > const &mat)
Transform the data using the provided transformation matrix.
void initMatrix()
Init the matrix to be applied from the transformations stored in the current dataset.
virtual const std::string getDescription() const
Gives back a description of this module.
WMDatasetManipulator()
Constructor.
virtual ~WMDatasetManipulator()
Destructor.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
This class allows for an easy strategy pattern-based switching between properties and strategy instan...