Commit d9d3e02d authored by Joshua Santana's avatar Joshua Santana
Browse files

[MERGE #52] resolved conflicts

Merge branch 'sprint_3' into 'top2021s3/#52_set_color_gradient_transferfunction'

# Conflicts:
#   src/modules/filterProtonData/WMCsvConverter.cpp
#   src/modules/filterProtonData/WMCsvConverter.h
#   src/modules/filterProtonData/WMFilterProtonData.cpp
parents 53c0f3a5 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
......@@ -102,7 +102,7 @@ bool WMCsvConverter::canShow( WDataSetCSV::Content::iterator dataRow )
return false;
}
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;
}
......@@ -233,6 +233,11 @@ void WMCsvConverter::setOutputFromCSV( WMProtonData::SPtr protonData )
m_vectors->getEventIDs()->push_back( std::stoi( dataRow->at( m_indexes->getEventID() ) ) );
}
if( checkIfOutputIsNull() )
{
return;
}
if( m_propertyStatus->getVisualizationPropertyHandler()->getColorFromEdep()->get() )
{
normalizeEdeps( m_vectors->getEdeps(), m_vectors->getColors(), maxEdep );
......@@ -252,3 +257,14 @@ void WMCsvConverter::setTransferFunction( boost::shared_ptr< std::vector<unsigne
m_transferFunction = newData;
}
bool WMCsvConverter::checkIfOutputIsNull()
{
if( m_vectors->getVertices()->empty() )
{
m_points = NULL;
m_fibers = NULL;
return true;
}
return false;
}
......@@ -182,6 +182,12 @@ private:
* \param data shared_ptr of mapped gradient from transfer function in RGBA format
*/
void setTransferFunction( boost::shared_ptr< std::vector<unsigned char> > data );
/**
* Checks if output variables have to be null, if true, sets them to null
* \return true, if there are no vertices to output; false otherwise
*/
bool checkIfOutputIsNull();
};
#endif // WMCSVCONVERTER_H
......@@ -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 ) ) ) );
......@@ -99,15 +94,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( );
}
}
......
......@@ -142,3 +142,8 @@ void WMColumnPropertyHandler::propertyNotifier( WPropertyBase::SPtr property )
m_dataUpdate( );
}
}
boost::shared_ptr< WItemSelection > WMColumnPropertyHandler::getColumnItems()
{
return m_possibleSelectionsUsingTypes;
}
\ No newline at end of file
......@@ -66,6 +66,11 @@ public:
*/
void createProperties();
/**
* Get reference of selectable column types
*/
boost::shared_ptr< WItemSelection > getColumnItems();
private:
/**
* Pointer to the content and header of the CSV
......
......@@ -29,9 +29,11 @@
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 )
{
}
......@@ -55,41 +57,43 @@ 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_columnItemSelectionList = m_columnPropertyHandler->getColumnItems();
m_possibleSelection = WItemSelection::SPtr( new WItemSelection() );
searchPDGTypes();
for( auto pdgType : m_pdgTypes )
{
m_possibleSelection->addItem( std::to_string( pdgType ) );
}
WItemSelector itemSelector = m_columnItemSelectionList->getSelectorAll();
m_selectedPDGTypes.push_back( std::to_string( m_pdgTypes[0] ) );
m_currentColumnIndex = selectColumn( "PDGEncoding", itemSelector );
m_multiSelection = m_filteringGroup->addProperty( "PDGEncoding", "Choose particle type(s) you want show",
m_possibleSelection->getSelectorFirst(), pdgEncodingnotifier );
WPropertyHelper::PC_NOTEMPTY::addTo( m_multiSelection );
}
m_singleSelection = m_filteringGroup->addProperty( "Particle Data Group", "", itemSelector, pdgColumnNotifier );
WPropertyHelper::PC_NOTEMPTY::addTo( m_singleSelection );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_singleSelection );
WPropBool WMFilterPropertyHandler::getShowPrimaries()
{
return m_showPrimaries;
}
m_particleItemSelectionList = WItemSelection::SPtr( new WItemSelection() );
WPropBool WMFilterPropertyHandler::getShowSecondaries()
{
return m_showSecondaries;
setPDGTypes( m_currentColumnIndex );
updatePDGTypesProperty( m_particleItemSelectionList );
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();
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() )
{
......@@ -108,10 +112,10 @@ 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() );
}
}
m_dataUpdate( );
}
......@@ -127,6 +131,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() )
......@@ -146,3 +203,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 );
/**
......@@ -84,7 +86,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
*/
......@@ -117,8 +131,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
......@@ -127,6 +166,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.
*/
......@@ -147,15 +191,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