OpenWalnut  1.5.0dev
WFilterPropertyHandler.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 WFILTERPROPERTYHANDLER_H
26 #define WFILTERPROPERTYHANDLER_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <boost/bimap.hpp>
33 #include <boost/lexical_cast.hpp>
34 
35 #include "../WProtonData.h"
36 #include "../WSingleSelectorName.h"
37 #include "WColumnPropertyHandler.h"
38 #include "core/common/WPathHelper.h"
39 
40 
41 /**
42  * Creates, updates and handles the filter properties.
43  */
45 {
46 public:
47  /**
48  * Function variables for updating the data
49  */
50  typedef std::shared_ptr< WFilterPropertyHandler > SPtr;
51 
52  /**
53  * shared_ptr that points to itself
54  */
55  typedef boost::function< void( ) > CallbackPtr;
56 
57  /**
58  * bimap to save the pdg to a particlename
59  */
60  typedef boost::bimap< std::string, int > BM_PDG;
61 
62  /**
63  * represent an Element of a pdg and a particlename for the map
64  */
65  typedef BM_PDG::value_type PdgElement;
66 
67  /**
68  * constructor
69  *
70  * \param protonData Pointer to the content and header of the CSV
71  * \param properties A property variable that is generated by the WModul
72  * \param dataUpdate A function variable that reinitializes the WDataSets
73  */
74  explicit WFilterPropertyHandler( WProtonData::SPtr protonData,
75  WPropertyGroup::SPtr properties,
77 
78  /**
79  * creates the group property and the subproperty
80  */
81  void createProperties();
82 
83  /**
84  * update current group property and subproperty
85  */
86  void updateProperty();
87 
88  /**
89  * Getter
90  *
91  * \return WPropBool of the ShowPrimaries
92  */
93  WPropBool getShowPrimaries();
94 
95  /**
96  * Getter
97  *
98  * \return WPropBool of the ShowSecondaries
99  */
100  WPropBool getShowSecondaries();
101 
102  /**
103  * Check whether the PDG type is contained in the m_selectedPDGTypes
104  *
105  * \param pdgType the int value of the PDG-Type
106  * \return true, if it includes. false, if it does not includes
107  */
108  bool isPDGTypeSelected( int pdgType );
109 
110  /**
111  * creates a bimap out of the names and ids of PDG txt
112  *
113  * \param path fielpath of the pdg particlename file
114  * \throws WException
115  */
116  void createPDGMap( std:: string path );
117 
118 private:
119  /**
120  * Pointer to the content and header of the CSV
121  */
123 
124  /**
125  * A property variable that is generated by the WModul
126  */
128 
129  /**
130  * A function variable that reinitializes the WDataSets
131  */
133 
134  /**
135  * \return the path of the particle names file
136  */
137  std::string getParticleNameFilePath();
138 
139  /**
140  * Helperfunction to copy the particlename file
141  *
142  * \param shareDirFile sourcepath of the particle name file in the share directory
143  * \param homeDirFile destinypath of the local directory for the particle name file
144  * \return true copy was succesful
145  * \return false copy was unsuccesful
146  */
147  bool copyFileToHomePath( std::string shareDirFile, std::string homeDirFile );
148 
149  /**
150  * Collect all particle types from your input data.
151  */
152  void searchPDGTypes();
153 
154  /**
155  * Update the m_selectedPDGTypes
156  */
157  void updateSelectedPDGTypes();
158 
159  /**
160  * Event of the save button in the rename pdg subgroup
161  *
162  * \param property contains reference to the property which called updateProperty()
163  *
164  */
166 
167  /**
168  * Update PDG Properties (Multiselector and change-Name-Properties)
169  */
170  void updatePDGProperties();
171 
172  /**
173  * Create the Checkbox for primaries and secondaries
174  */
176 
177  /**
178  * Create the multiselection for the option of PDG
179  */
181 
182  /**
183  * Create the Subgroup for change of PDG names
184  */
186 
187  /**
188  * Set the default string for the string property textfield
189  *
190  * \return the string of the selected item of the itemselector
191  */
192  std::string setDefaultForRenameField();
193 
194  /**
195  * Updates possible selectable particle types in multiselection
196  *
197  * \param particleItemSelectionList selectable partyle types as itemSelectionList
198  */
199  void updatePDGTypesProperty( WItemSelection::SPtr particleItemSelectionList );
200 
201  /**
202  * Reload data when properties for selection of primaries and secondaries changed
203  *
204  * \param property contains reference to the property which called updateProperty()
205  */
207 
208  /**
209  * Seatch the ParticleName in the map with a given pdg
210  *
211  * \param pdg pdg number of a particlename
212  * \return the particle name
213  */
214  std::string getParticleNameFromPdg( int pdg );
215 
216  /**
217  * Search the pdg in the map with a given particlename
218  *
219  * \param particleName particlename of a pdg number
220  * \return pdg number
221  */
222  int getPdgFromName( std::string particleName );
223 
224  /**
225  * get the PDG number of an unknown particle element with
226  * the help of regex
227  * \param particleName particle name of an unknown number
228  * \return pdg number
229  */
230  int getPdgFromUnkownParticle( std::string particleName );
231 
232  /**
233  * write the BiMap in the Pdg particle name file
234  */
236 
237  /**
238  * set or replace a particlename and pdg in the bimap
239  *
240  * \param pdg pdg number of a selected particle name
241  * \param newParticleName new particlename of a pdg number
242  * \throws WException
243  */
244  void changePdgBiMap( int pdg, std::string newParticleName );
245 
246  /**
247  * A Map of the PDG and their names
248  */
250 
251  /**
252  * The current column that is selected as particle data group
253  */
255 
256  /**
257  * Stores every unique particle id.
258  */
259  std::vector < int > m_pdgTypes;
260 
261  /**
262  * Property group for filtering options
263  */
264  WPropGroup m_filteringGroup;
265 
266  /**
267  * Decides whether to hide or show primaries.
268  */
269  WPropBool m_showPrimaries;
270 
271  /**
272  * Decides whether to hide or show secondaries.
273  */
274  WPropBool m_showSecondaries;
275 
276  /**
277  * Stores users selected items.
278  */
279  WPropSelection m_multiSelection;
280 
281  /**
282  * Stores subgroup for change the pdg-Name
283  */
285 
286  /**
287  * Stores selectable items.
288  */
289  std::shared_ptr< WItemSelection > m_particleItemSelectionList;
290 
291  /**
292  * vector of the options of PDG
293  */
294  std::vector < int > m_selectedPDGTypes;
295 
296  /**
297  * A string for the new particle name
298  */
300 
301  /**
302  * A trigger for the save button to save changes
303  */
304  WPropTrigger m_saveButton;
305 
306  /**
307  * A property to select one pdg to change
308  */
309  WPropSelection m_PdgForRenameSelection;
310 
311  /**
312  * A notifier for the Changeevents of the Rename PDG property
313  */
315 };
316 
317 #endif // WFILTERPROPERTYHANDLER_H
Creates, updates and handles the filter properties.
WPropBool getShowSecondaries()
Getter.
void createCheckBoxForPrimaryAndSecondary()
Create the Checkbox for primaries and secondaries.
BM_PDG m_PdgNamesByID
A Map of the PDG and their names.
WPropTrigger m_saveButton
A trigger for the save button to save changes.
WPropBool getShowPrimaries()
Getter.
void createPDGMap(std::string path)
creates a bimap out of the names and ids of PDG txt
WPropBool m_showPrimaries
Decides whether to hide or show primaries.
void createMultiSelectionForPDG()
Create the multiselection for the option of PDG.
void writePdgMapInParticleNameFile()
write the BiMap in the Pdg particle name file
WPropSelection m_multiSelection
Stores users selected items.
WPropGroup m_filteringsubGroup
Stores subgroup for change the pdg-Name.
void updateProperty()
update current group property and subproperty
WPropSelection m_PdgForRenameSelection
A property to select one pdg to change.
boost::function< void() > CallbackPtr
shared_ptr that points to itself
boost::bimap< std::string, int > BM_PDG
bimap to save the pdg to a particlename
WFilterPropertyHandler::CallbackPtr m_dataUpdate
A function variable that reinitializes the WDataSets.
WFilterPropertyHandler(WProtonData::SPtr protonData, WPropertyGroup::SPtr properties, WFilterPropertyHandler::CallbackPtr dataUpdate)
constructor
void createProperties()
creates the group property and the subproperty
std::string setDefaultForRenameField()
Set the default string for the string property textfield.
int getPdgFromName(std::string particleName)
Search the pdg in the map with a given particlename.
void changePdgBiMap(int pdg, std::string newParticleName)
set or replace a particlename and pdg in the bimap
WPropBool m_showSecondaries
Decides whether to hide or show secondaries.
int m_currentColumnIndex
The current column that is selected as particle data group.
void updatePDGProperties()
Update PDG Properties (Multiselector and change-Name-Properties)
WPropGroup m_filteringGroup
Property group for filtering options.
void searchPDGTypes()
Collect all particle types from your input data.
std::shared_ptr< WFilterPropertyHandler > SPtr
Function variables for updating the data.
bool copyFileToHomePath(std::string shareDirFile, std::string homeDirFile)
Helperfunction to copy the particlename file.
WPropString m_inputNewParticleName
A string for the new particle name.
WProtonData::SPtr m_protonData
Pointer to the content and header of the CSV.
void createPropToSetParticleNames()
Create the Subgroup for change of PDG names.
std::vector< int > m_selectedPDGTypes
vector of the options of PDG
WPropertyBase::PropertyChangeNotifierType m_notifierSetParticleName
A notifier for the Changeevents of the Rename PDG property.
std::shared_ptr< WItemSelection > m_particleItemSelectionList
Stores selectable items.
void selectPdgAndSaveEvent(WPropertyBase::SPtr property)
Event of the save button in the rename pdg subgroup.
std::string getParticleNameFromPdg(int pdg)
Seatch the ParticleName in the map with a given pdg.
void updateCheckboxProperty(WPropertyBase::SPtr property)
Reload data when properties for selection of primaries and secondaries changed.
void updatePDGTypesProperty(WItemSelection::SPtr particleItemSelectionList)
Updates possible selectable particle types in multiselection.
int getPdgFromUnkownParticle(std::string particleName)
get the PDG number of an unknown particle element with the help of regex
void updateSelectedPDGTypes()
Update the m_selectedPDGTypes.
WPropertyGroup::SPtr m_properties
A property variable that is generated by the WModul.
BM_PDG::value_type PdgElement
represent an Element of a pdg and a particlename for the map
std::vector< int > m_pdgTypes
Stores every unique particle id.
bool isPDGTypeSelected(int pdgType)
Check whether the PDG type is contained in the m_selectedPDGTypes.
std::shared_ptr< WItemSelection > SPtr
Convenience typedef for a std::shared_ptr< WItemSelection >
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
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