OpenWalnut  1.5.0dev
WVisualizationPropertyHandler.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/WTransferFunction.h"
26 
27 #include "WVisualizationPropertyHandler.h"
28 
29 
31  WPropertyGroup::SPtr properties,
33  m_protonData( protonData ),
34  m_properties( properties ),
35  m_dataUpdate( dataUpdate )
36 {
37 }
38 
40 {
41  m_visualizationGroup = m_properties->addPropertyGroup( "Visualization", "Visualization options" );
42 
43  WPropertyBase::PropertyChangeNotifierType notifier = boost::bind(
44  &WVisualizationPropertyHandler::propertyCallback, this, boost::placeholders::_1 );
45 
46  m_enabledClusterSize = m_visualizationGroup->addProperty( "Enable cluster size", "Enables the edep to clustersize conversion", false, notifier );
47 
48  m_sizesFromEdep = m_visualizationGroup->addProperty( "Size by energy deposition", "Scale track and point sizes based on energy deposition.",
49  true, notifier );
50  m_colorFromEdep = m_visualizationGroup->addProperty( "Color by energy deposition", "Colorize tracks and points based on energy deposition.",
51  true, notifier );
52  m_colorSelection = m_visualizationGroup->addProperty( "Point color", "Points colorized in the chosen color when "
53  "\"Color by energy deposition\" is disabled.",
54  defaultColor::WHITE, notifier );
55 
56  m_gradient = m_visualizationGroup->addProperty( "Gradient color", "Colorize tracks and points based on energy deposition "
57  "with the configured gradient.", setColorGradient() , false );
58 
59  m_applyGradient = m_visualizationGroup->addProperty( "Set gradient", "Apply", WPVBaseTypes::PV_TRIGGER_READY, notifier );
60 
62 }
63 
65 {
66  if( m_protonData->isColumnAvailable( WSingleSelectorName::getX() ) &&
67  m_protonData->isColumnAvailable( WSingleSelectorName::getY() ) &&
68  m_protonData->isColumnAvailable( WSingleSelectorName::getZ() ) &&
69  m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
70  {
71  m_sizesFromEdep->setHidden( false );
72  m_colorFromEdep->setHidden( false );
73  m_enabledClusterSize->setHidden( false );
75  }
76  else
77  {
78  m_sizesFromEdep->setHidden( true );
79  m_colorFromEdep->setHidden( true );
80  m_gradient->setHidden( true );
81  m_applyGradient->setHidden( true );
82  m_enabledClusterSize->setHidden( true );
83  m_colorSelection->setHidden( false );
84  }
85 }
86 
88 {
89  if( m_colorFromEdep->get() )
90  {
91  m_gradient->setHidden( false );
92  m_applyGradient->setHidden( false );
93  m_colorSelection->setHidden( true );
94  }
95  else
96  {
97  m_gradient->setHidden( true );
98  m_applyGradient->setHidden( true );
99  m_colorSelection->setHidden( false );
100  }
101 }
102 
104 {
105  m_dataUpdate();
106 
107  if( property == m_applyGradient && m_applyGradient->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
108  {
110  }
111 
112  updateProperty();
113 }
114 
116 {
117  return m_colorFromEdep;
118 }
119 
121 {
122  return m_sizesFromEdep;
123 }
124 
126 {
127  return m_enabledClusterSize;
128 }
129 
131 {
132  return m_colorSelection;
133 }
134 
136 {
137  return m_gradient;
138 }
139 
141 {
143 
144  tf.addColor( 0.0, WColor( 0.0, 0.0, 1.0, 1.0 ) );
145  tf.addColor( 0.25, WColor( 0.5, 0.0, 0.91, 1.0 ) );
146  tf.addColor( 0.5, WColor( 0.75, 0.0, 0.73, 1.0 ) );
147  tf.addColor( 0.75, WColor( 0.97, 0.0, 0.53, 1.0 ) );
148  tf.addColor( 1.0, WColor( 1.0, 0.0, 0.0, 1.0 ) );
149 
150  tf.addAlpha( 0.0, 1.0 );
151  tf.addAlpha( 0.25, 1.0 );
152  tf.addAlpha( 0.5, 1.0 );
153  tf.addAlpha( 0.75, 1.0 );
154  tf.addAlpha( 1.0, 1.0 );
155 
156  return tf;
157 }
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
static std::string getX()
getter
static std::string getY()
getter
static std::string getZ()
getter
static std::string getEdep()
getter
A class that stores a 1D transfer function which consists of a linear interpolation of alpha and colo...
void addColor(double iso, const WColor &color)
Insert a new color point.
void addAlpha(double iso, double alpha)
Insert a new alpha point.
WPropBool m_enabledClusterSize
En-/Disables the clustersize conversion.
void toggleColorProperties()
toggle the visibility of plain color and transfer function
WPropBool m_sizesFromEdep
Decides whether to scale the points sizes according to their deposited energy.
boost::function< void() > CallbackPtr
Function variables for updating the data.
WPropTrigger m_applyGradient
Property that holds a trigger to apply the current transfer function for the gradient.
WTransferFunction setColorGradient()
Sets the transfer function.
WPropColor m_colorSelection
Property that holds the current selected color when not coloring points based on their deposited ener...
WPropTransferFunction m_gradient
Property that holds the current transfer function for the gradient.
void propertyCallback(WPropertyBase::SPtr property)
Reload data when properties for selection of primaries and secondaries changed.
WPropTransferFunction getTransferFunction()
Getter.
WVisualizationPropertyHandler(WProtonData::SPtr protonData, WPropertyGroup::SPtr properties, WVisualizationPropertyHandler::CallbackPtr dataUpdate)
constructor
void createProperties()
creates the group property and the subproperty
WPropBool m_colorFromEdep
Decides whether to color points based on the deposited energy or not.
WProtonData::SPtr m_protonData
Pointer to the content and header of the CSV.
WPropertyGroup::SPtr m_properties
A property variable that is generated by the WModul.
void updateProperty()
update current group property and subproperty
WPropGroup m_visualizationGroup
Property group for visualization modes.
WVisualizationPropertyHandler::CallbackPtr m_dataUpdate
A function variable that reinitializes the WDataSets.
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)