Commit 0831891d authored by hungdangquoc's avatar hungdangquoc
Browse files

[MERGE #49] merge #49 to top2021s3_60_support_new_csv_dataset, refact...

[MERGE #49] merge #49 to top2021s3_60_support_new_csv_dataset, refact FilterPropertyHandler, add icon for FilterProtoData, add part of #53-functionallity, merge refact ColumnProperty
parent 9bd6e769
......@@ -130,7 +130,8 @@ bool WMCsvConverter::canShow( WDataSetCSV::Content::iterator dataRow )
if( m_protonData->IsColumnAvailable( "PDGEncoding" ) )
{
if (!m_propertyStatus->getFilterPropertyHandler()->isPDGTypeSelected(
std::stoi(dataRow->at(m_propertyStatus->getFilterPropertyHandler()->getCurrentColumnIndex())))) {
std::stoi( dataRow->at( m_protonData->getColumnIndex( "PDGEncoding" ) ) ) ) )
{
return false;
}
}
......@@ -233,6 +234,7 @@ void WMCsvConverter::createOutputPoints()
{
if( m_propertyStatus->getVisualizationPropertyHandler()->getSizesFromEdep()->get() )
{
std::cout << "MATCH 1" << std::endl << std::endl;
m_points = boost::shared_ptr< WDataSetPointsAndSizes >(
new WDataSetPointsAndSizes(
m_vectors->getVertices(),
......@@ -240,17 +242,17 @@ void WMCsvConverter::createOutputPoints()
m_vectors->getSizes()
)
);
return;
}
}
else
{
m_points = boost::shared_ptr < WDataSetPoints >(
new WDataSetPoints(
m_vectors->getVertices(),
m_vectors->getColors()
)
);
}
std::cout << "MATCH 3" << std::endl << std::endl;
m_points = boost::shared_ptr < WDataSetPoints >(
new WDataSetPoints(
m_vectors->getVertices(),
m_vectors->getColors()
)
);
}
void WMCsvConverter::createOutputFibers()
......
......@@ -83,8 +83,8 @@ void WMFilterProtonData::moduleMain()
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,
m_propertyStatus->getColumnPropertyHandler(), boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
m_propertyStatus->setFilterPropertyHandler( WMFilterPropertyHandler::SPtr( new WMFilterPropertyHandler( m_protonData, m_properties,
boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
m_propertyStatus->setVisualizationPropertyHandler( WMVisualizationPropertyHandler::SPtr(
new WMVisualizationPropertyHandler( m_protonData, m_properties, boost::bind( &WMFilterProtonData::setOutputFromCSV, this ) ) ) );
......
......@@ -80,7 +80,7 @@ void WMColumnPropertyHandler::InitializeSelectionItem()
WPropSelection WMColumnPropertyHandler::addHeaderProperty( std::string columnName, WPropertyBase::PropertyChangeNotifierType notifier )
{
int index = m_protonData->getColumnIndex( columnName );
WItemSelector selector = index < 0 ? m_possibleSelectionsUsingTypes->getSelectorNone() : m_possibleSelectionsUsingTypes->getSelector( index );
WItemSelector selector = index < 0 ? m_possibleSelectionsUsingTypes->getSelectorLast() : m_possibleSelectionsUsingTypes->getSelector( index );
WPropSelection selection = m_columnSelectionGroup->addProperty(
columnName,
"Choose the " + columnName + " column from csv",
......
......@@ -30,11 +30,9 @@
WMFilterPropertyHandler::WMFilterPropertyHandler( WMProtonData::SPtr protonData,
WPropertyGroup::SPtr properties,
WMColumnPropertyHandler::SPtr columnPropertyHandler,
WMFilterPropertyHandler::CallbackPtr dataUpdate ):
m_protonData( protonData ),
m_properties( properties ),
m_columnPropertyHandler ( columnPropertyHandler ),
m_dataUpdate( dataUpdate )
{
}
......@@ -49,9 +47,12 @@ void WMFilterPropertyHandler::createProperties()
updateProperty();
}
void WMFilterPropertyHandler::updateProperty()
{
m_currentColumnIndex = m_protonData->getColumnIndex("PDGEncoding");
m_filteringGroup->removeProperty( m_multiSelection );
createMultiSelectionForPDG();
if(m_protonData->IsColumnAvailable("parentID") && m_protonData->IsColumnAvailable("trackID"))
{
m_showPrimaries->setHidden( false );
......@@ -82,42 +83,11 @@ void WMFilterPropertyHandler::createCheckBoxForPrimaryAndSecondary()
m_showSecondaries = m_filteringGroup->addProperty( "Show secondaries", "Show/hide secondaries", true, notifierCheckBox );
}
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_columnItemSelectionList = m_columnPropertyHandler->getColumnItems();
WItemSelector itemSelector = m_columnItemSelectionList->getSelectorAll();
m_currentColumnIndex = selectColumn( "PDGEncoding", itemSelector );
m_singleSelection = m_filteringGroup->addProperty( "Particle Data Group", "", itemSelector, pdgColumnNotifier );
WPropertyHelper::PC_NOTEMPTY::addTo( m_singleSelection );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_singleSelection );
m_particleItemSelectionList = WItemSelection::SPtr( new WItemSelection() );
setPDGTypes( m_currentColumnIndex );
updatePDGTypesProperty( m_particleItemSelectionList );
m_selectedPDGTypes.push_back( 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::setPDGTypes( int columnIndex )
void WMFilterPropertyHandler::searchPDGTypes()
{
m_pdgTypes.clear();
int pdgColumnIndex = m_protonData->getColumnIndex( "PDGEncoding" );
if(columnIndex < 0)
if(pdgColumnIndex < 0)
{
return;
}
......@@ -125,7 +95,7 @@ void WMFilterPropertyHandler::setPDGTypes( int columnIndex )
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( columnIndex ) );
int currentParticleID = std::stoi( row.at( pdgColumnIndex ) );
if( std::find( m_pdgTypes.begin(), m_pdgTypes.end(), currentParticleID ) == m_pdgTypes.end() )
{
......@@ -134,6 +104,37 @@ void WMFilterPropertyHandler::setPDGTypes( int columnIndex )
}
}
void WMFilterPropertyHandler::createMultiSelectionForPDG()
{
WPropertyBase::PropertyChangeNotifierType pdgEncodingnotifier = boost::bind(
&WMFilterPropertyHandler::updateSelectedPDGTypes, this, boost::placeholders::_1 );
boost::shared_ptr< WItemSelection > possibleSelection = WItemSelection::SPtr( new WItemSelection() );
m_pdgTypes.clear();
searchPDGTypes();
for( auto pdgType : m_pdgTypes )
{
possibleSelection->addItem(
getParticleNameFromPdg( pdgType ) + "(" + std::to_string( pdgType) + ")"
);
}
if(m_pdgTypes.size() > 0)
{
m_multiSelection = m_filteringGroup->addProperty( "PDGEncoding", "Choose particle type(s) you want to show",
possibleSelection->getSelectorFirst(), pdgEncodingnotifier );
}
else
{
m_multiSelection = m_filteringGroup->addProperty( "PDGEncoding", "Choose particle type(s) you want to show",
possibleSelection->getSelectorNone(), pdgEncodingnotifier );
}
WPropertyHelper::PC_NOTEMPTY::addTo( m_multiSelection );
}
void WMFilterPropertyHandler::updateSelectedPDGTypes( WPropertyBase::SPtr property )
{
m_selectedPDGTypes.clear();
......@@ -163,60 +164,6 @@ 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(
getParticleNameFromPdg( pdgType ) + "(" + 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 )
{
......
......@@ -67,7 +67,6 @@ public:
*/
explicit WMFilterPropertyHandler( WMProtonData::SPtr protonData,
WPropertyGroup::SPtr properties,
WMColumnPropertyHandler::SPtr columnPropertyHandler,
WMFilterPropertyHandler::CallbackPtr dataUpdate );
/**
......@@ -110,18 +109,7 @@ public:
*/
void createPDGMap(std:: string path);
/**
* 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
......@@ -138,6 +126,11 @@ private:
*/
WMFilterPropertyHandler::CallbackPtr m_dataUpdate;
/**
* Collect all particle types from your input data.
*/
void searchPDGTypes();
/**
* update the m_selectedPDGTypes
*/
......@@ -153,22 +146,6 @@ private:
*/
void createMultiSelectionForPDG();
/**
* Collect all particle types from your input data.
*
* \param columnIndex determines column whose elements should be collected
*/
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
*
......@@ -176,13 +153,6 @@ private:
*/
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
*
......@@ -236,26 +206,11 @@ 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_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