Commit 0c458578 authored by Hung Dang-Quoc's avatar Hung Dang-Quoc
Browse files

Merge remote-tracking branch 'origin/sprint_3' into top2021s3/#60_support_new_csv_dataset

# Conflicts:
#	src/modules/filterProtonData/WMCsvConverter.cpp
#	src/modules/filterProtonData/WMCsvConverter.h
#	src/modules/filterProtonData/propertyHandler/WMColumnPropertyHandler.h
#	src/modules/filterProtonData/propertyHandler/WMFilterPropertyHandler.cpp
parents 89a02464 31fdb9a9
This directory is intended to serve as the place where one can compile OpenWalnut.
This .README file is in the build directory so that the directory will be recognized and created by git. Only remove it if you know what you are doing.
\ No newline at end of file
......@@ -129,8 +129,8 @@ bool WMCsvConverter::canShow( WDataSetCSV::Content::iterator dataRow )
if( m_protonData->IsColumnAvailable( "PDGEncoding" ) )
{
if( !m_propertyStatus->getFilterPropertyHandler()->isPDGTypeSelected( std::stoi( dataRow->at( m_indexes->getPDGEncoding() ) ) ) )
{
if (!m_propertyStatus->getFilterPropertyHandler()->isPDGTypeSelected(
std::stoi(dataRow->at(m_propertyStatus->getFilterPropertyHandler()->getCurrentColumnIndex())))) {
return false;
}
}
......
......@@ -71,25 +71,20 @@ void WMFilterProtonData::moduleMain()
{
m_moduleState.wait();
if( m_shutdownFlag() )
if(m_input->getData() == NULL)
{
break;
continue;
}
m_dataset = m_input->getData();
WDataSetCSV::ContentSPtr csvHeader = m_dataset->getHeader();
WDataSetCSV::ContentSPtr csvData = m_dataset->getData();
if( m_protonData == NULL )
{
m_protonData = WMProtonData::SPtr( new WMProtonData( csvHeader, csvData ) );
m_protonData = WMProtonData::SPtr( new WMProtonData( m_input->getData()->getHeader(), m_input->getData()->getData() ) );
m_propertyStatus->setColumnPropertyHandler( WMColumnPropertyHandler::SPtr( new WMColumnPropertyHandler( m_protonData, m_properties,
boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
m_propertyStatus->setFilterPropertyHandler( WMFilterPropertyHandler::SPtr( new WMFilterPropertyHandler( m_protonData, m_properties,
boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
m_propertyStatus->setFilterPropertyHandler( WMFilterPropertyHandler::SPtr( new WMFilterPropertyHandler( m_protonData, m_properties,
m_propertyStatus->getColumnPropertyHandler(), boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
m_propertyStatus->setVisualizationPropertyHandler( WMVisualizationPropertyHandler::SPtr(
new WMVisualizationPropertyHandler( m_protonData, m_properties, boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
......@@ -101,15 +96,13 @@ void WMFilterProtonData::moduleMain()
}
else
{
m_protonData->setCSVHeader( csvHeader );
m_protonData->setCSVData( csvData );
m_protonData->setCSVHeader( m_input->getData()->getHeader() );
m_protonData->setCSVData( m_input->getData()->getData() );
}
m_propertyStatus->getColumnPropertyHandler()->createProperties();
m_propertyStatus->getFilterPropertyHandler()->createProperties();
m_propertyStatus->getVisualizationPropertyHandler()->createProperties();
m_propertyStatus->getEventIDLimitationPropertyHandler()->createProperties();
setOutputFromCSV( );
}
}
......@@ -120,7 +113,6 @@ void WMFilterProtonData::connectors()
m_output_points = WModuleOutputData< WDataSetPoints >::createAndAdd( shared_from_this(), "output points", "Output CSV data as Point data" );
m_output_fibers = WModuleOutputData< WDataSetFibers >::createAndAdd( shared_from_this(), "output fibers", "Output CSV data as Fiber data" );
WModule::connectors();
}
......
......@@ -163,3 +163,8 @@ void WMColumnPropertyHandler::propertyNotifier( WPropertyBase::SPtr property )
}
}
}
boost::shared_ptr< WItemSelection > WMColumnPropertyHandler::getColumnItems()
{
return m_possibleSelectionsUsingTypes;
}
\ No newline at end of file
......@@ -67,7 +67,12 @@ public:
void createProperties();
/**
* update current group property and subproperty
* Get reference of selectable column types
*/
boost::shared_ptr< WItemSelection > getColumnItems();
/**
* update current group property and subproperty
*/
void updateProperty();
......
......@@ -81,47 +81,38 @@ void WMFilterPropertyHandler::createCheckBoxForPrimaryAndSecondary()
void WMFilterPropertyHandler::createMultiSelectionForPDG()
{
WPropertyBase::PropertyChangeNotifierType pdgColumnNotifier = boost::bind(
&WMFilterPropertyHandler::onSingleSelectionChanged, this, boost::placeholders::_1 );
WPropertyBase::PropertyChangeNotifierType pdgEncodingnotifier = boost::bind(
&WMFilterPropertyHandler::updateSelectedPDGTypes, this, boost::placeholders::_1 );
m_possibleSelection = WItemSelection::SPtr( new WItemSelection() );
m_columnItemSelectionList = m_columnPropertyHandler->getColumnItems();
searchPDGTypes();
WItemSelector itemSelector = m_columnItemSelectionList->getSelectorAll();
for( auto pdgType : m_pdgTypes )
{
m_possibleSelection->addItem( std::to_string( pdgType ) );
}
m_currentColumnIndex = selectColumn( "PDGEncoding", itemSelector );
if(m_pdgTypes.size() > 0)
{
m_selectedPDGTypes.push_back( std::to_string( m_pdgTypes[0] ) );
m_singleSelection = m_filteringGroup->addProperty( "Particle Data Group", "", itemSelector, pdgColumnNotifier );
WPropertyHelper::PC_NOTEMPTY::addTo( m_singleSelection );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_singleSelection );
m_multiSelection = m_filteringGroup->addProperty( "PDGEncoding", "Choose particle type(s) you want show",
m_possibleSelection->getSelectorFirst(), pdgEncodingnotifier );
}
else
{
m_multiSelection = m_filteringGroup->addProperty( "PDGEncoding", "Choose particle type(s) you want show",
m_possibleSelection->getSelectorNone(), pdgEncodingnotifier );
}
m_particleItemSelectionList = WItemSelection::SPtr( new WItemSelection() );
WPropertyHelper::PC_NOTEMPTY::addTo( m_multiSelection );
}
setPDGTypes( m_currentColumnIndex );
WPropBool WMFilterPropertyHandler::getShowPrimaries()
{
return m_showPrimaries;
}
updatePDGTypesProperty( m_particleItemSelectionList );
WPropBool WMFilterPropertyHandler::getShowSecondaries()
{
return m_showSecondaries;
m_selectedPDGTypes.push_back( std::to_string( m_pdgTypes[0] ) );
m_multiSelection = m_filteringGroup->addProperty( "Particle Type", "Choose particle type(s) you want show",
m_particleItemSelectionList->getSelectorFirst(), pdgEncodingnotifier );
WPropertyHelper::PC_NOTEMPTY::addTo( m_multiSelection );
}
void WMFilterPropertyHandler::searchPDGTypes()
void WMFilterPropertyHandler::setPDGTypes( int columnIndex )
{
int pdgColumnIndex = m_protonData->getColumnIndex( "PDGEncoding" );
m_pdgTypes.clear();
if(pdgColumnIndex < 0)
{
......@@ -131,7 +122,7 @@ void WMFilterPropertyHandler::searchPDGTypes()
for( auto idx = 0; idx < m_protonData->getCSVData()->size(); idx++)
{
std::vector< std::string > row = m_protonData->getCSVData()->at( idx );
int currentParticleID = std::stoi( row.at( pdgColumnIndex ) );
int currentParticleID = std::stoi( row.at( columnIndex ) );
if( std::find( m_pdgTypes.begin(), m_pdgTypes.end(), currentParticleID ) == m_pdgTypes.end() )
{
......@@ -150,7 +141,7 @@ void WMFilterPropertyHandler::updateSelectedPDGTypes( WPropertyBase::SPtr proper
for( int i = 0; i < selectedItems.size(); ++i )
{
m_selectedPDGTypes.push_back( selectedItems.at( i )->getName() );
m_selectedPDGTypes.push_back( selectedItems.at( i )->getName() );
}
}
......@@ -169,6 +160,59 @@ bool WMFilterPropertyHandler::isPDGTypeSelected( int pdgType )
return false;
}
int WMFilterPropertyHandler::getCurrentColumnIndex()
{
return m_currentColumnIndex;
}
int WMFilterPropertyHandler::selectColumn( std::string columnName, WItemSelector& itemSelector )
{
for( int i = 0; i < itemSelector.size(); i++ )
{
WItemSelectionItem item = *itemSelector.at( i );
if( item.getName() == columnName )
{
itemSelector = m_columnItemSelectionList->getSelector( i );
return i;
}
}
itemSelector = m_columnItemSelectionList->getSelectorNone();
return 0;
}
void WMFilterPropertyHandler::updatePDGTypesProperty( WItemSelection::SPtr particleItemSelectionList )
{
if ( !m_pdgTypes.empty() )
{
particleItemSelectionList->clear();
for( auto pdgType : m_pdgTypes )
{
particleItemSelectionList->addItem( std::to_string( pdgType ) );
}
}
}
void WMFilterPropertyHandler::onSingleSelectionChanged( WPropertyBase::SPtr property )
{
WItemSelector itemSelector = m_columnItemSelectionList->getSelectorAll();
std::string columnName = m_singleSelection->get().at( 0 )->getName();
bool columnIsValid = m_singleSelection->isValid();
m_multiSelection->setHidden( !columnIsValid );
m_currentColumnIndex = selectColumn( columnName, itemSelector );
setPDGTypes( m_currentColumnIndex );
updatePDGTypesProperty( m_particleItemSelectionList );
m_multiSelection->set( m_particleItemSelectionList->getSelectorFirst() );
}
void WMFilterPropertyHandler::updateCheckboxProperty( WPropertyBase::SPtr property )
{
if( m_showPrimaries->get() || m_showSecondaries->get() )
......@@ -188,3 +232,13 @@ void WMFilterPropertyHandler::updateCheckboxProperty( WPropertyBase::SPtr proper
}
}
}
WPropBool WMFilterPropertyHandler::getShowPrimaries()
{
return m_showPrimaries;
}
WPropBool WMFilterPropertyHandler::getShowSecondaries()
{
return m_showSecondaries;
}
\ No newline at end of file
......@@ -29,6 +29,7 @@
#include <vector>
#include "../WMProtonData.h"
#include "WMColumnPropertyHandler.h"
/**
* Creates, updates and handles the filter properties.
......@@ -55,6 +56,7 @@ public:
*/
explicit WMFilterPropertyHandler( WMProtonData::SPtr protonData,
WPropertyGroup::SPtr properties,
WMColumnPropertyHandler::SPtr columnPropertyHandler,
WMFilterPropertyHandler::CallbackPtr dataUpdate );
/**
......@@ -89,7 +91,19 @@ public:
*/
bool isPDGTypeSelected( int pdgType );
/**
* Get selected columns index
*
* \return current column index that is selected as particle data group
*/
int getCurrentColumnIndex();
private:
/**
* Reference of m_columnPropertyHandler
*/
WMColumnPropertyHandler::SPtr m_columnPropertyHandler;
/**
* Pointer to the content and header of the CSV
*/
......@@ -122,8 +136,33 @@ private:
/**
* Collect all particle types from your input data.
*
* \param columnIndex determines column whose elements should be collected
*/
void searchPDGTypes();
void setPDGTypes( int columnIndex );
/**
* Updates itemSelector depending on the columnName that is selected
*
* \param ColumnName name of the column that should be selected
* \param itemSelector reference of selectable column names list
* \return index of column that is selected
*/
int selectColumn( std::string columnName, WItemSelector& itemSelector );
/**
* Updates possible selectable particle types in multiselection
*
* \param particleItemSelectionList selectable partyle types as itemSelectionList
*/
void updatePDGTypesProperty( WItemSelection::SPtr particleItemSelectionList );
/**
* Updates property ui once a new particle data group column is selected
*
* \param property contains reference to the property which called updateProperty()
*/
void onSingleSelectionChanged( WPropertyBase::SPtr property );
/**
* Reload data when properties for selection of primaries and secondaries changed
......@@ -132,6 +171,11 @@ private:
*/
void updateCheckboxProperty( WPropertyBase::SPtr property );
/**
* The current column that is selected as particle data group
*/
int m_currentColumnIndex = 0;
/**
* Stores every unique particle id.
*/
......@@ -152,15 +196,25 @@ private:
*/
WPropBool m_showSecondaries;
/**
* Stores users selected item.
*/
WPropSelection m_singleSelection;
/**
* Stores users selected items.
*/
WPropSelection m_multiSelection;
/**
* Reference of column name list
*/
boost::shared_ptr< WItemSelection > m_columnItemSelectionList;
/**
* Stores selectable items.
*/
boost::shared_ptr< WItemSelection > m_possibleSelection;
boost::shared_ptr< WItemSelection > m_particleItemSelectionList;
/**
* vector of the options of PDG
......
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