Commit ac1a46ba authored by daniel.bub's avatar daniel.bub
Browse files

Merge remote-tracking branch 'origin/sprint_5' into top2021s5/#83_unittest_WMCsvConverter

parents d36086df c0bf0a3e
......@@ -77,9 +77,9 @@ boost::shared_ptr< WDataSetPointsAndEventID > WCsvConverter::getPointsAndIDs()
void WCsvConverter::setOutputFromCSV( )
{
if( !m_protonData->isColumnAvailable( "X" ) ||
!m_protonData->isColumnAvailable( "Y" ) ||
!m_protonData->isColumnAvailable( "Z" ) )
if( !m_protonData->isColumnAvailable( WSingleSelectorName::getX() ) ||
!m_protonData->isColumnAvailable( WSingleSelectorName::getY() ) ||
!m_protonData->isColumnAvailable( WSingleSelectorName::getZ() ) )
{
return;
}
......@@ -136,7 +136,7 @@ boost::shared_ptr< std::vector<unsigned char> > WCsvConverter::sampleTransferFun
void WCsvConverter::normalizeEdeps( SPFloatVector edeps, SPFloatVector colorArray, float maxEdep )
{
if( m_protonData->isColumnAvailable( "Energy deposition" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
{
boost::shared_ptr< std::vector< unsigned char > > data = sampleTransferFunction();
......@@ -176,7 +176,7 @@ bool WCsvConverter::checkConditionToPass( WDataSetCSV::Content::iterator dataRow
return false;
}
if( m_protonData->isColumnAvailable( "Parent id" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getParentId() ) )
{
int PrimaryValue = stringToInt( dataRow->at( m_indexes->getParentID() ) );
......@@ -191,7 +191,7 @@ bool WCsvConverter::checkConditionToPass( WDataSetCSV::Content::iterator dataRow
}
}
if( m_protonData->isColumnAvailable( "Particle Data Group" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getPDG() ) )
{
if( !m_propertyStatus->getFilterPropertyHandler()->isPDGTypeSelected(
( int )stringToDouble( dataRow->at( m_indexes->getPDGEncoding( ) ) ) ) )
......@@ -200,7 +200,7 @@ bool WCsvConverter::checkConditionToPass( WDataSetCSV::Content::iterator dataRow
}
}
if( m_protonData->isColumnAvailable("Event id"))
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
if(dataRow->at( m_indexes->getEventID() ) == "NULL")
{
......@@ -227,7 +227,8 @@ void WCsvConverter::addVertex( WDataSetCSV::Content::iterator dataRow )
void WCsvConverter::addColor( WColor plainColor )
{
if( !m_protonData->isColumnAvailable( "Energy deposition" ) || !m_propertyStatus->getVisualizationPropertyHandler()->getColorFromEdep()->get() )
if( !m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) ||
!m_propertyStatus->getVisualizationPropertyHandler()->getColorFromEdep()->get() )
{
m_vectors->getColors()->push_back( plainColor[0] );
m_vectors->getColors()->push_back( plainColor[1] );
......@@ -237,7 +238,7 @@ void WCsvConverter::addColor( WColor plainColor )
void WCsvConverter::addEdepAndSize( WDataSetCSV::Content::iterator dataRow, float* maxEdep )
{
if( !m_protonData->isColumnAvailable( "Energy deposition" ) )
if( !m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
{
return;
}
......@@ -253,7 +254,7 @@ void WCsvConverter::addEdepAndSize( WDataSetCSV::Content::iterator dataRow, floa
void WCsvConverter::calculateFibers()
{
if(!m_protonData->isColumnAvailable("Event id"))
if( !m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
return;
}
......@@ -287,7 +288,7 @@ void WCsvConverter::calculateFibers()
void WCsvConverter::createOutputPoints()
{
if( m_protonData->isColumnAvailable( "Energy deposition" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
{
if( m_propertyStatus->getVisualizationPropertyHandler()->getSizesFromEdep()->get() )
{
......@@ -312,7 +313,7 @@ void WCsvConverter::createOutputPoints()
void WCsvConverter::createOutputFibers()
{
calculateFibers();
if(!m_protonData->isColumnAvailable("Event id"))
if( !m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
m_fibers = boost::shared_ptr< WDataSetFibers >(
new WDataSetFibers(
......@@ -337,7 +338,7 @@ void WCsvConverter::createOutputFibers()
);
}
if( m_protonData->isColumnAvailable( "Energy deposition" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
{
if( m_propertyStatus->getVisualizationPropertyHandler()->getColorFromEdep()->get() )
{
......@@ -352,7 +353,7 @@ void WCsvConverter::createOutputFibers()
void WCsvConverter::createOutputPointsAndEventIDs()
{
if( m_protonData->isColumnAvailable( "Event id" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
m_selectedEventIDs = boost::shared_ptr < WDataSetPointsAndEventID >(
new WDataSetPointsAndEventID(
......@@ -366,7 +367,7 @@ void WCsvConverter::createOutputPointsAndEventIDs()
void WCsvConverter::addEventID( WDataSetCSV::Content::iterator dataRow )
{
if(m_protonData->isColumnAvailable("Event id"))
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
if(dataRow->at( m_indexes->getEventID() ) == "NULL")
{
......
......@@ -45,6 +45,7 @@
#include "WConverterVectors.h"
#include "WPropertyStatus.h"
#include "WProtonData.h"
#include "WSingleSelectorName.h"
/**
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <list>
#include <string>
#include "WSingleSelectorName.h"
std::string WSingleSelectorName::getX()
{
return "X";
}
std::string WSingleSelectorName::getY()
{
return "Y";
}
std::string WSingleSelectorName::getZ()
{
return "Z";
}
std::string WSingleSelectorName::getPDG()
{
return "Particle Data Group";
}
std::string WSingleSelectorName::getEdep()
{
return "Energy deposition";
}
std::string WSingleSelectorName::getEventId()
{
return "Event id";
}
std::string WSingleSelectorName::getParentId()
{
return "Parent id";
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getXwithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getX(),
"Choose the column which should be used to determine the x coordinate.",
"posX" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getYwithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getY(),
"Choose the column which should be used to determine the y coordinate.",
"posY" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getZwithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getZ(),
"Choose the column which should be used to determine the z coordinate.",
"posZ" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getPDGwithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getPDG(),
"Choose the column which should be used to determine the particle data group.",
"PDGEncoding" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getEdepWithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getEdep(),
"Choose the column which should be used to determine the energy deposition.",
"edep" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getEventIdWithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getEventId(),
"Choose the column which should be used to determine the event id."
"Tracks will be drawn based on the the event id, all particles with the same event id will be connected.",
"eventID" );
}
WSingleSelectorName::NameDescriptionSearch WSingleSelectorName::getParentIdWithDescription()
{
return WSingleSelectorName::NameDescriptionSearch( getParentId(),
"Choose the column which should be used to determine the parent id."
"Primaries and secondaries filtering is based on that id, if a "
"particle has the parent id 0 it is a primary otherwise it is a secondary.",
"parentID" );
}
std::list< WSingleSelectorName::NameDescriptionSearch > WSingleSelectorName::getListOfSelectorContent()
{
std::list< WSingleSelectorName::NameDescriptionSearch > list;
list.push_back( getXwithDescription() );
list.push_back( getYwithDescription() );
list.push_back( getZwithDescription() );
list.push_back( getPDGwithDescription() );
list.push_back( getEdepWithDescription() );
list.push_back( getEventIdWithDescription() );
list.push_back( getParentIdWithDescription() );
return list;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WSINGLESELECTORNAME_H
#define WSINGLESELECTORNAME_H
#include <tuple>
#include <list>
#include <string>
/**
* Holds the single selector content.
*/
class WSingleSelectorName
{
public:
/**
* tuple with 3 string as value
* 1. Name of single-selector,
* 2. Desciption of single-selector,
* 3. Value that is searched for in the csv header
*/
typedef std::tuple< std::string, std::string , std::string > NameDescriptionSearch;
/**
* getter
* \return the name of the single-selector (X)
*/
static std::string getX();
/**
* getter
* \return the name of the single-selector (Y)
*/
static std::string getY();
/**
* getter
* \return the name of the single-selector (Z)
*/
static std::string getZ();
/**
* getter
* \return the name of the single-selector (pdg)
*/
static std::string getPDG();
/**
* getter
* \return the name of the single-selector (edep)
*/
static std::string getEdep();
/**
* getter
* \return the name of the single-selector (Event id)
*/
static std::string getEventId();
/**
* getter
* \return the name of the single-selector (Parent id)
*/
static std::string getParentId();
/**
* getter
* \return the name of the single-selector (X) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getXwithDescription();
/**
* getter
* \return the name of the single-selector (Y) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getYwithDescription();
/**
* getter
* \return the name of the single-selector (Z) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getZwithDescription();
/**
* getter
* \return the name of the single-selector (pdg) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getPDGwithDescription();
/**
* getter
* \return the name of the single-selector (edep) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getEdepWithDescription();
/**
* getter
* \return the name of the single-selector (Event id) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getEventIdWithDescription();
/**
* getter
* \return the name of the single-selector (Parent id) with Description
*/
static WSingleSelectorName::NameDescriptionSearch getParentIdWithDescription();
/**
* getter
* \return Vector of names of the single-selectors with Description and Value that is searched for in the csv header
*/
static std::list< WSingleSelectorName::NameDescriptionSearch > getListOfSelectorContent();
};
#endif // WSINGLESELECTORNAME_H
......@@ -22,13 +22,13 @@
//
//---------------------------------------------------------------------------
#include <list>
#include <map>
#include <string>
#include <vector>
#include "WColumnPropertyHandler.h"
WColumnPropertyHandler::WColumnPropertyHandler( WProtonData::SPtr protonData,
WPropertyGroup::SPtr properties,
WColumnPropertyHandler::CallbackPtr dataUpdate ):
......@@ -48,11 +48,12 @@ void WColumnPropertyHandler::createProperties()
m_columnSelectionGroup = m_properties->addPropertyGroup( "Select columns", "Select the columns which should be used" );
for( int i = 0; i < vecDefaultColumnNames.size(); i++ )
std::list< std::tuple< std::string, std::string, std::string > > names = WSingleSelectorName::getListOfSelectorContent();
for( std::tuple< std::string, std::string, std::string > selectorElement : names )
{
std::string columnName = vecDefaultColumnNames.at( i );
std::string desciption = vecDefaultDescription.at( i );
std::string defName = vecDefaultNames.at( i );
std::string columnName = std::get< 0 >( selectorElement );
std::string desciption = std::get< 1 >( selectorElement );
std::string defName = std::get< 2 >( selectorElement );
mapPropSelectionsToString.insert(
std::map< WPropSelection, std::string >::value_type( addHeaderProperty( columnName, desciption, defName, notifier ), columnName )
......
......@@ -25,6 +25,8 @@
#ifndef WCOLUMNPROPERTYHANDLER_H
#define WCOLUMNPROPERTYHANDLER_H
#include <tuple>
#include <list>
#include <map>
#include <string>
#include <vector>
......@@ -34,7 +36,7 @@
#include "core/common/WItemSelectionItemTyped.h"
#include "../WProtonData.h"
#include "../WSingleSelectorName.h"
/**
* Creates, updates and handles the column properties.
......@@ -85,33 +87,6 @@ public:
void setSelectionEventMethod( WColumnPropertyHandler::CallbackPtr externEventMethod );
private:
/**
* A vector, where all default ColumnPropertyNames are stored in
*/
const std::vector< std::string > vecDefaultColumnNames = { "X", "Y", "Z", "Particle Data Group", "Energy deposition", "Event id",
"Parent id" };
/**
* A vector, where all the default names are stored in
*/
const std::vector< std::string > vecDefaultNames = { "posX", "posY", "posZ", "PDGEncoding", "edep", "eventID",
"parentID" };
/**
* A vector where all default column desciptions are stored in
*/
const std::vector< std::string > vecDefaultDescription = {
"Choose the column which should be used to determine the x coordinate.",
"Choose the column which should be used to determine the y coordinate.",
"Choose the column which should be used to determine the z coordinate.",
"Choose the column which should be used to determine the particle data group.",
"Choose the column which should be used to determine the energy deposition.",
"Choose the column which should be used to determine the event id. "
"Tracks will be drawn based on the the event id, all particles with the same event id will be connected.",
"Choose the column which should be used to determine the parent id."
"Primaries and secondaries filtering is based on that id, if a "
"particle has the parent id 0 it is a primary otherwise it is a secondary."};
/**
* A map between WPropSelection items and column names as strings
*/
......
......@@ -49,7 +49,7 @@ void WEventIDLimitationPropertyHandler::createProperties()
void WEventIDLimitationPropertyHandler::updateProperty()
{
if( m_protonData->isColumnAvailable( "Event id" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getEventId() ) )
{
m_minCap->setHidden( false );
m_maxCap->setHidden( false );
......@@ -76,7 +76,7 @@ void WEventIDLimitationPropertyHandler::updateMesh()
void WEventIDLimitationPropertyHandler::determineMinMaxEventID()
{
int eventIDIndex = m_protonData->getColumnIndexBySelection( "Event id" );
int eventIDIndex = m_protonData->getColumnIndexBySelection( WSingleSelectorName::getEventId() );
if(eventIDIndex < 0)
{
......
......@@ -26,6 +26,7 @@
#define WEVENTIDLIMITATIONPROPERTYHANDLER_H
#include "../WProtonData.h"
#include "../WSingleSelectorName.h"
/**
......
......@@ -54,7 +54,7 @@ void WFilterPropertyHandler::updateProperty()
{
updatePDGProperties();
if( m_protonData->isColumnAvailable( "parentID" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getParentId() ) )
{
m_showPrimaries->setHidden( false );
m_showSecondaries->setHidden( false );
......@@ -65,7 +65,7 @@ void WFilterPropertyHandler::updateProperty()
m_showSecondaries->setHidden( true );
}
if( m_protonData->isColumnAvailable( "Particle Data Group" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getPDG() ) )
{
m_multiSelection->setHidden( false );
m_filteringsubGroup->setHidden( false );
......@@ -79,7 +79,7 @@ void WFilterPropertyHandler::updateProperty()
void WFilterPropertyHandler::updatePDGProperties()
{
m_currentColumnIndex = m_protonData->getColumnIndexBySelection( "Particle Data Group" );
m_currentColumnIndex = m_protonData->getColumnIndexBySelection( WSingleSelectorName::getPDG() );
m_filteringGroup->removeProperty( m_multiSelection );
m_filteringGroup->removeProperty( m_filteringsubGroup );
......
......@@ -32,6 +32,7 @@
#include <boost/lexical_cast.hpp>
#include "core/common/WPathHelper.h"
#include "../WSingleSelectorName.h"
#include "WColumnPropertyHandler.h"
#include "../WProtonData.h"
......
......@@ -61,10 +61,10 @@ void WVisualizationPropertyHandler::createProperties()
void WVisualizationPropertyHandler::updateProperty()
{
if( m_protonData->isColumnAvailable( "X" ) &&
m_protonData->isColumnAvailable( "Y" ) &&
m_protonData->isColumnAvailable( "Z" ) &&
m_protonData->isColumnAvailable( "Energy deposition" ) )
if( m_protonData->isColumnAvailable( WSingleSelectorName::getX() ) &&
m_protonData->isColumnAvailable( WSingleSelectorName::getY() ) &&
m_protonData->isColumnAvailable( WSingleSelectorName::getZ() ) &&
m_protonData->isColumnAvailable( WSingleSelectorName::getEdep() ) )
{
m_sizesFromEdep->setHidden( false );
m_colorFromEdep->setHidden( false );
......
......@@ -26,6 +26,7 @@
#define WVISUALIZATIONPROPERTYHANDLER_H
#include "../WProtonData.h"
#include "../WSingleSelectorName.h"
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment