OpenWalnut  1.5.0dev
WEventIDLimitationPropertyHandler.cpp
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 #include "core/common/WLimits.h"
26 #include "WEventIDLimitationPropertyHandler.h"
27 
28 
30  WPropertyGroup::SPtr properties,
32  m_protonData( protonData ),
33  m_properties( properties ),
34  m_dataUpdate( dataUpdate )
35 {
36 }
37 
39 {
41  WPropGroup eventIDGroup = m_properties->addPropertyGroup( "Event Id Limitation", "Adjust the range of eventIDs to be shown.", 0 );
42  m_minCap = eventIDGroup->addProperty( "Minimum event id", "Filters out every event id which is lower than the set value.", 1 );
43  m_maxCap = eventIDGroup->addProperty( "Maximum event id", "Filters out every event id which is higher than the set value.", 2000 );
44  m_applySelection = eventIDGroup->addProperty( "Set selection", "Apply", WPVBaseTypes::PV_TRIGGER_READY, eventIDNotifier );
45 
47 }
48 
50 {
51  if( m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
52  {
53  m_minCap->setHidden( false );
54  m_maxCap->setHidden( false );
55  m_applySelection->setHidden( false );
56 
58  }
59  else
60  {
61  m_minCap->setHidden( true );
62  m_maxCap->setHidden( true );
63  m_applySelection->setHidden( true );
64  }
65 }
66 
68 {
69  m_dataUpdate( );
70 
72  {
74  }
75 }
76 
78 {
79  int eventIDIndex = m_protonData->getColumnIndexBySelection( WSingleSelectorName::getEventId() );
80 
81  if( eventIDIndex < 0 )
82  {
83  return;
84  }
85 
86  int minCap = wlimits::MAX_INT32_T;
87  int maxCap = wlimits::MIN_INT32_T;
88  for( auto iter = m_protonData->getCSVData()->begin(); iter != m_protonData->getCSVData()->end(); iter++ )
89  {
90  int calc = std::stoi( ( *iter ).at( eventIDIndex ) );
91  if( calc < minCap )
92  {
93  minCap = calc;
94  }
95  if( calc > maxCap )
96  {
97  maxCap = calc;
98  }
99  }
100 
101  m_minCap->setMin( minCap );
102  m_minCap->setMax( maxCap );
103  m_maxCap->setMin( minCap );
104  m_maxCap->setMax( maxCap );
105 
106  m_minCap->set( minCap );
107  m_maxCap->set( maxCap );
108 }
109 
111 {
112  return m_minCap;
113 }
114 
116 {
117  return m_maxCap;
118 }
void updateMesh()
Update your mesh when changing properties.
void determineMinMaxEventID()
Determines smalles und biggest eventID.
void createProperties()
creates the group property and the subproperty
WProtonData::SPtr m_protonData
Pointer to the content and header of the CSV.
WEventIDLimitationPropertyHandler(WProtonData::SPtr protonData, WPropertyGroup::SPtr properties, WEventIDLimitationPropertyHandler::CallbackPtr dataUpdate)
constructor
WEventIDLimitationPropertyHandler::CallbackPtr m_dataUpdate
A function variable that reinitializes the WDataSets.
void updateProperty()
update current group property and subproperty
WPropertyGroup::SPtr m_properties
A property variable that is generated by the WModul.
boost::function< void() > CallbackPtr
Function variables for updating the data.
WPropInt m_maxCap
Set upper border of range of eventID selection.
WPropTrigger m_applySelection
Apply the current event ID selection.
WPropInt m_minCap
Set lower border of range of eventID selection.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
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
static std::string getEventId()
getter
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)
const int32_t MAX_INT32_T
Maximum int32_t value.
Definition: WLimits.cpp:34
const int32_t MIN_INT32_T
Lowest/Minimum int32_t value (equivalent to LOWEST_INT32_T)
Definition: WLimits.cpp:39