OpenWalnut  1.5.0dev
WMWriteCSV.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 WMWRITECSV_H
26 #define WMWRITECSV_H
27 
28 #include <list>
29 #include <memory>
30 #include <string>
31 
32 #include "../filterProtonData/WProtonData.h"
33 #include "core/dataHandler/WDataSetCSV.h"
34 #include "core/dataHandler/WDataSetFibers.h"
35 #include "core/kernel/WModule.h"
36 #include "core/kernel/WModuleInputData.h"
37 
38 
39 /**
40  * Class for safe the point-connector data
41  */
42 class WMWriteCSV : public WModule
43 {
44 /**
45  * only test class may be friend
46  */
47 friend class WMWriteCSVTest;
48 
49 public:
50  /**
51  * Standard constructor.
52  */
53  WMWriteCSV();
54 
55  /**
56  * Destructor.
57  */
58  ~WMWriteCSV();
59 
60  /**
61  * Gives back the name of this module.
62  * \return the module's name.
63  */
64  virtual const std::string getName() const;
65 
66  /**
67  * Gives back a description of this module.
68  * \return description of module.
69  */
70  virtual const std::string getDescription() const;
71 
72  /**
73  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
74  * should never be initialized or modified in some other way. A simple new instance is required.
75  *
76  * \return the prototype used to create every module in OpenWalnut.
77  */
78  virtual std::shared_ptr< WModule > factory() const;
79 
80  /**
81  * Get the icon for this module in XPM format.
82  * \return The icon.
83  */
84  virtual const char** getXPMIcon() const;
85 
86 
87 protected:
88  /**
89  * Entry point after loading the module. Runs in separate thread.
90  */
91  virtual void moduleMain();
92 
93  /**
94  * Initialize the connectors this module is using.
95  */
96  virtual void connectors();
97 
98  /**
99  * Initialize the properties for this module.
100  */
101  virtual void properties();
102 
103 private:
104  /**
105  * This performs all work necessary to actually write the data to the file
106  */
107  void writeToFile();
108 
109  /**
110  * Trigger Event for Dialogfile
111  */
112  void propertyCallback();
113 
114  /**
115  * Helpermethod to create a List of internal vertex with id
116  * \param fibers selected points as fibers from Point-Connector
117  * \return list of internal vertex with id
118  */
119  std::list< std::tuple < float, float, float, size_t > > getListOfInternalVertex( WDataSetFibers::SPtr fibers );
120 
121  /**
122  * Helpermethod: Returns the path from Filedialog
123  * \return Returns the filename
124  */
125  std::string getPathToSave();
126 
127  /**
128  * The Helpermethod goes through the header and searches for -SelectedEventID-,
129  * if one was found, append the number of headers found
130  * to the header (example: SelectedEventID_4)
131  * \return return the new Headername
132  */
133  std::string getNewCSVHeader();
134 
135  /**
136  * Helpermethod: checks whether the source domain contains the specified float
137  * \param sourceString source string
138  * \param num search number
139  * \return If found then true otherwise false
140  */
141  bool contains( std::string sourceString, float num );
142 
143  /**
144  * Helpermethod goes through the existing EvenIDs and returns the next one.
145  * \param listOfInternalVertex get selected EventIDs
146  * \return next free EventID
147  */
148  size_t createStartCounter( std::list< std::tuple < float, float, float, size_t > > listOfInternalVertex );
149 
150  /**
151  * The filename property -> where to write the csv file
152  */
153  WPropFilename m_filename;
154 
155  std::shared_ptr< WModuleInputData< WDataSetCSV > > m_CSVInput; //!< Input connector required by this module.
156  std::shared_ptr< WModuleInputData< WDataSetFibers > > m_fibersInput; //!< Input connector required by this module.
157 };
158 
159 
160 #endif // WMWRITECSV_H
std::shared_ptr< WDataSetFibers > SPtr
Pointer to dataset.
test class of the writeCSV class
Class for safe the point-connector data.
Definition: WMWriteCSV.h:43
void writeToFile()
This performs all work necessary to actually write the data to the file.
Definition: WMWriteCSV.cpp:223
std::list< std::tuple< float, float, float, size_t > > getListOfInternalVertex(WDataSetFibers::SPtr fibers)
Helpermethod to create a List of internal vertex with id.
Definition: WMWriteCSV.cpp:133
WPropFilename m_filename
The filename property -> where to write the csv file.
Definition: WMWriteCSV.h:153
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...
Definition: WMWriteCSV.cpp:46
std::string getNewCSVHeader()
The Helpermethod goes through the header and searches for -SelectedEventID-, if one was found,...
Definition: WMWriteCSV.cpp:186
void propertyCallback()
Trigger Event for Dialogfile.
Definition: WMWriteCSV.cpp:115
std::shared_ptr< WModuleInputData< WDataSetCSV > > m_CSVInput
Input connector required by this module.
Definition: WMWriteCSV.h:155
virtual const std::string getName() const
Gives back the name of this module.
Definition: WMWriteCSV.cpp:64
size_t createStartCounter(std::list< std::tuple< float, float, float, size_t > > listOfInternalVertex)
Helpermethod goes through the existing EvenIDs and returns the next one.
Definition: WMWriteCSV.cpp:207
std::shared_ptr< WModuleInputData< WDataSetFibers > > m_fibersInput
Input connector required by this module.
Definition: WMWriteCSV.h:156
virtual const std::string getDescription() const
Gives back a description of this module.
Definition: WMWriteCSV.cpp:69
bool contains(std::string sourceString, float num)
Helpermethod: checks whether the source domain contains the specified float.
Definition: WMWriteCSV.cpp:200
virtual void properties()
Initialize the properties for this module.
Definition: WMWriteCSV.cpp:104
virtual void connectors()
Initialize the connectors this module is using.
Definition: WMWriteCSV.cpp:90
virtual void moduleMain()
Entry point after loading the module.
Definition: WMWriteCSV.cpp:74
WMWriteCSV()
Standard constructor.
Definition: WMWriteCSV.cpp:36
std::string getPathToSave()
Helpermethod: Returns the path from Filedialog.
Definition: WMWriteCSV.cpp:179
~WMWriteCSV()
Destructor.
Definition: WMWriteCSV.cpp:41
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
Definition: WMWriteCSV.cpp:51
Class representing a single module of OpenWalnut.
Definition: WModule.h:72