Commit 3719723b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - switched items to be pointers for easier handling.

parent d8e07c2a
......@@ -32,7 +32,8 @@
#include "WItemSelection.h"
WItemSelection::WItemSelection()
WItemSelection::WItemSelection():
WSharedSequenceContainer< std::vector< boost::shared_ptr< WItemSelectionItem > > >()
{
// initialize members
}
......@@ -88,6 +89,6 @@ WItemSelector WItemSelection::getSelector( size_t item )
void WItemSelection::addItem( std::string name, std::string description, const char** icon )
{
push_back( WItemSelectionItem( name, description, icon ) );
push_back( boost::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) ) );
}
......@@ -48,7 +48,7 @@ class WItemSelector;
* automatically using the change condition of the inherited WSharedSequenceContainer.
*/
class OWCOMMON_EXPORT WItemSelection: public boost::enable_shared_from_this< WItemSelection >,
public WSharedSequenceContainer< std::vector< WItemSelectionItem > >
public WSharedSequenceContainer< std::vector< boost::shared_ptr< WItemSelectionItem > > >
{
friend class WItemSelector; // for proper locking and unlocking
public:
......@@ -101,9 +101,9 @@ public:
*
* \return the Item.
*/
static WItemSelectionItem Item( std::string name, std::string description = "", const char** icon = NULL )
static boost::shared_ptr< WItemSelectionItem > Item( std::string name, std::string description = "", const char** icon = NULL )
{
return WItemSelectionItem( name, description, icon );
return boost::shared_ptr< WItemSelectionItem >( new WItemSelectionItem( name, description, icon ) );
}
/**
......
......@@ -145,12 +145,12 @@ size_t WItemSelector::size() const
return m_selected.size();
}
const WItemSelectionItem& WItemSelector::atAll( size_t index ) const
const boost::shared_ptr< WItemSelectionItem > WItemSelector::atAll( size_t index ) const
{
return m_selection->at( index );
}
const WItemSelectionItem& WItemSelector::at( size_t index ) const
const boost::shared_ptr< WItemSelectionItem > WItemSelector::at( size_t index ) const
{
return m_selection->at( getItemIndexOfSelected( index ) );
}
......
......@@ -176,7 +176,7 @@ public:
*
* \return the item
*/
virtual const WItemSelectionItem& atAll( size_t index ) const;
virtual const boost::shared_ptr< WItemSelectionItem > atAll( size_t index ) const;
/**
* Gets the selected item with the given index. This is not the same index as the element has in the corresponding WItemSelection!
......@@ -186,7 +186,7 @@ public:
*
* \return the item
*/
virtual const WItemSelectionItem& at( size_t index ) const;
virtual const boost::shared_ptr< WItemSelectionItem > at( size_t index ) const;
/**
* Helps to get the index of an selected item in the WItemSelection. This is somehow similar to \ref at, but does not return the item but the
......
......@@ -152,12 +152,12 @@ void WPropertySelectionWidget::update()
// add all items from the selection set:
for ( size_t i = 0; i < sValid.sizeAll(); ++i )
{
m_combo->addItem( QString::fromStdString( sValid.atAll( i ).getName() ) );
m_combo->addItem( QString::fromStdString( sValid.atAll( i )->getName() ) );
// if there is an icon -> show it
if ( sValid.atAll( i ).getIcon() )
if ( sValid.atAll( i )->getIcon() )
{
// scale the pixmap to a maximum size if larger
QPixmap pix = ensureSize( QPixmap( sValid.atAll( i ).getIcon() ) );
QPixmap pix = ensureSize( QPixmap( sValid.atAll( i )->getIcon() ) );
// set icon
m_combo->setItemIcon( i, QIcon( pix ) );
......@@ -194,23 +194,23 @@ void WPropertySelectionWidget::update()
int column = 0;
// if there is an icon -> show it
if ( sValid.atAll( i ).getIcon() )
if ( sValid.atAll( i )->getIcon() )
{
QLabel* icon = new QLabel();
QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); // <-- scale it down
icon->setSizePolicy( sizePolicy );
icon->setPixmap( ensureSize( QPixmap( sValid.atAll( i ).getIcon() ) ) );
icon->setPixmap( ensureSize( QPixmap( sValid.atAll( i )->getIcon() ) ) );
layoutWidget->addWidget( icon, 0, 0, 2, 1 );
++column;
}
// Add Name and Description
layoutWidget->addWidget( new QLabel( "<b>" + QString::fromStdString( sValid.atAll( i ).getName() )+ "</b>" ), 0, column );
layoutWidget->addWidget( new QLabel( "<b>" + QString::fromStdString( sValid.atAll( i )->getName() )+ "</b>" ), 0, column );
// if there is no description -> no widget added to save space
if ( !sValid.atAll( i ).getDescription().empty() )
if ( !sValid.atAll( i )->getDescription().empty() )
{
layoutWidget->addWidget( new QLabel( QString::fromStdString( sValid.atAll( i ).getDescription() ) ), 1, column );
layoutWidget->addWidget( new QLabel( QString::fromStdString( sValid.atAll( i )->getDescription() ) ), 1, column );
}
layoutWidget->setSizeConstraint( QLayout::SetMaximumSize );
......
......@@ -402,6 +402,17 @@ void WMData::moduleMain()
debugLog() << "Loading data done.";
// register the dataset properties
m_properties->addProperty( m_dataSet->getProperties() );
m_infoProperties->addProperty( m_dataSet->getInformationProperties() );
// textures also provide properties
if ( m_dataSet->isTexture() )
{
m_properties->addProperty( m_dataSet->getTexture()->getProperties() );
m_infoProperties->addProperty( m_dataSet->getTexture()->getInformationProperties() );
}
// i am interested in the active property ( manually subscribe signal )
m_active->getCondition()->subscribeSignal( boost::bind( &WMData::propertyChanged, this, m_active ) );
......
......@@ -122,17 +122,17 @@ void WMCoordinateHUD::moduleMain()
while( !m_shutdownFlag() )
{
WItemSelector s = m_aSingleSelection->get( true );
debugLog() << "New mode selected: " << s.at( 0 ).getName();
debugLog() << "New mode selected: " << s.at( 0 )->getName();
if ( s.at( 0 ).getName() == "colored axis" )
if ( s.at( 0 )->getName() == "colored axis" )
{
buildColorAxis();
}
else if ( s.at( 0 ).getName() == "b/w axis" )
else if ( s.at( 0 )->getName() == "b/w axis" )
{
buildBWAxis();
}
else if ( s.at( 0 ).getName() == "colored cube" )
else if ( s.at( 0 )->getName() == "colored cube" )
{
buildColorCube();
}
......
......@@ -162,7 +162,7 @@ void WMCoordinateSystem::propertyChanged()
if ( m_csSelection->changed() )
{
WItemSelector s = m_csSelection->get( true );
infoLog() << "Selected " << s.at( 0 ).getName() << " coordinate system.";
infoLog() << "Selected " << s.at( 0 )->getName() << " coordinate system.";
m_coordConverter->setCoordinateSystemMode( static_cast< coordinateSystemMode > ( s.getItemIndexOfSelected( 0 ) ) );
}
......
......@@ -609,13 +609,13 @@ void WMTemplate::moduleMain()
// The single selector allows only one selected item and requires one item to be selected all the time. So accessing it by index
// is trivial:
WItemSelector s = m_aSingleSelection->get( true );
infoLog() << "The user likes " << s.at( 0 ).getName() << " the most.";
infoLog() << "The user likes " << s.at( 0 )->getName() << " the most.";
// The multi property allows the selection of several items. So, iteration needs to be done here:
s = m_aMultiSelection->get( true );
for ( size_t i = 0; i < s.size(); ++i )
{
infoLog() << "The user likes " << s.at( i ).getName();
infoLog() << "The user likes " << s.at( i )->getName();
}
}
}
......
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