Commit 394143b2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE #261] ROI dock now uses similar coloring and direct property style...

[CHANGE #261] ROI dock now uses similar coloring and direct property style (props in the tree widget) as the colormapper and control panel
parent ae97fbc2
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <list>
#include <string>
#include "WROI.h"
#include "WPickHandler.h"
......@@ -41,15 +42,33 @@ void WROI::properties()
{
m_properties = boost::shared_ptr< WProperties >( new WProperties( "Properties", "This ROI's properties" ) );
m_active = m_properties->addProperty( "active", "", true, boost::bind( &WROI::propertyChanged, this ) );
m_active->setHidden( true );
m_show = m_properties->addProperty( "Show", "Toggles visibility of the roi", true, boost::bind( &WROI::propertyChanged, this ) );
m_name = m_properties->addProperty( "Name", "The name of this ROI.", std::string( "ROI" ) );
m_active = m_properties->addProperty( "Active", "Enable or disable the ROI.", true, boost::bind( &WROI::propertyChanged, this ) );
m_show = m_properties->addProperty( "Show", "Toggles visibility of the ROI but does not disable it.", true,
boost::bind( &WROI::propertyChanged, this ) );
m_not = m_properties->addProperty( "Not", "Negates the effect of this ROI.", false, boost::bind( &WROI::propertyChanged, this ) );
m_dirty = m_properties->addProperty( "Dirty", "", true ); // boost::bind( &WROI::propertyChanged, this ) );
m_dirty->setHidden( true );
}
m_not = m_properties->addProperty( "Not", "Negates the effect of this ROI.", false, boost::bind( &WROI::propertyChanged, this ) );
WPropBool WROI::invertProperty()
{
return m_not;
}
WPropBool WROI::showProperty()
{
return m_show;
}
WPropString WROI::nameProperty()
{
return m_name;
}
WPropBool WROI::activeProperty()
{
return m_active;
}
void WROI::propertyChanged()
......
......@@ -35,9 +35,6 @@
#include "../common/WProperties.h"
class WPickHandler;
/**
......@@ -122,7 +119,33 @@ public:
*/
void removeROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
/**
* Invert property.
*
* \return the property
*/
WPropBool invertProperty();
/**
* The property for toggling ROI visibility.
*
* \return the property
*/
WPropBool showProperty();
/**
* The active property
*
* \return the property.
*/
WPropBool activeProperty();
/**
* The name property
*
* \return the property.
*/
WPropString nameProperty();
protected:
/**
* initializes the roi's properties
......@@ -168,6 +191,11 @@ protected:
*/
WPropBool m_not;
/**
* name of the ROI.
*/
WPropString m_name;
/**
* threshold for an arbitrary roi
*/
......
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <list>
#include <string>
#include <vector>
#include "../graphicsEngine/WGraphicsEngine.h"
......@@ -47,9 +48,11 @@ void WRMBranch::properties()
m_dirty = m_properties->addProperty( "Dirty", "", true, boost::bind( &WRMBranch::propertyChanged, this ) );
m_dirty->setHidden( true );
m_name = m_properties->addProperty( "Name", "The name of this branch.", std::string( "Branch" ) );
m_isNot = m_properties->addProperty( "Not", "Negate the effect of this branch.", false, boost::bind( &WRMBranch::propertyChanged, this ) );
m_bundleColor = m_properties->addProperty( "Bundle color", "", WColor( 1.0, 0.0, 0.0, 1.0 ),
m_bundleColor = m_properties->addProperty( "Bundle color", "Color the selected fibers using this color.", WColor( 1.0, 0.0, 0.0, 1.0 ),
boost::bind( &WRMBranch::propertyChanged, this ) );
m_changeRoiSignal = boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WRMBranch::setDirty, this ) ) );
}
......@@ -58,6 +61,20 @@ void WRMBranch::propertyChanged()
setDirty();
}
WPropString WRMBranch::nameProperty()
{
return m_name;
}
WPropBool WRMBranch::invertProperty()
{
return m_isNot;
}
WPropColor WRMBranch::colorProperty()
{
return m_bundleColor;
}
void WRMBranch::addRoi( osg::ref_ptr< WROI > roi )
{
......
......@@ -56,6 +56,27 @@ public:
*/
~WRMBranch();
/**
* Get name property.
*
* \return name property
*/
WPropString nameProperty();
/**
* Get the "not" property.
*
* \return the property
*/
WPropBool invertProperty();
/**
* The branch color property.
*
* \return the color property
*/
WPropColor colorProperty();
/**
* adds a roi to the branch
*
......@@ -185,6 +206,11 @@ private:
*/
WPropColor m_bundleColor;
/**
* Name property.
*/
WPropString m_name;
/**
* The notifiers connected to added rois by default.
*/
......
......@@ -65,19 +65,20 @@ WPropertyColorWidget::WPropertyColorWidget( WPropColor property, QGridLayout* pr
wLayout->setContentsMargins( 0, 0, 0, 0 );
wLayout->setSpacing( 0 );
QToolButton* colButton = new QToolButton( this );
m_colButton = new QToolButton( this );
m_colorPickerAction = new QAction( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "colorwheel" ), "Select Color", this );
connect( m_colorPickerAction, SIGNAL( triggered( bool ) ), this, SLOT( buttonClicked() ) );
colButton->setDefaultAction( m_colorPickerAction );
colButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
colButton->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
m_colButton->setDefaultAction( m_colorPickerAction );
m_colButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
m_colButton->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
m_colPanel = new QWidget( &m_widget );
m_colPanel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
m_colPanel->setFixedSize( 32, 32 );
m_colPanel = new QPushButton( &m_widget );
m_colPanel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
m_colPanel->setMinimumSize( 24, 24 );
connect( m_colPanel, SIGNAL( clicked( bool ) ), this, SLOT( buttonClicked() ) );
wLayout->addWidget( m_colPanel );
wLayout->addWidget( colButton );
wLayout->addWidget( m_colButton );
// accept drag and drop
setAcceptDrops( true );
......@@ -91,6 +92,11 @@ WPropertyColorWidget::~WPropertyColorWidget()
// cleanup
}
void WPropertyColorWidget::setColorPickerButtonHidden( bool hide )
{
m_colButton->setVisible( !hide );
}
void WPropertyColorWidget::update()
{
QColor bgColor = toQColor( m_colorProperty->get() );
......@@ -105,6 +111,7 @@ void WPropertyColorWidget::setColor( const QColor& bgColor )
<< bgColor.red() << ","
<< bgColor.green() << ","
<< bgColor.blue() << ");"
<< "border:none;"
<< "}";
std::stringstream buttonColorText;
......
......@@ -31,6 +31,7 @@
#include <QtGui/QLabel>
#include <QtGui/QAction>
#include <QtGui/QHBoxLayout>
#include <QtGui/QToolButton>
#include "../guiElements/WScaleLabel.h"
......@@ -57,6 +58,13 @@ public:
*/
virtual ~WPropertyColorWidget();
/**
* Hide the button for a more compact layout.
*
* \param hide true to hide
*/
void setColorPickerButtonHidden( bool hide = true );
protected:
/**
* Internal helper, called to set the color
......@@ -96,6 +104,11 @@ protected:
*/
QWidget* m_colPanel;
/**
* Color picker button
*/
QToolButton* m_colButton;
/**
* Layout used to position the label and the checkbox
*/
......
......@@ -24,15 +24,102 @@
#include <string>
#include <QtCore/QList>
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include <QtGui/QListWidgetItem>
#include <QtGui/QApplication>
#include <QtGui/QWidgetAction>
#include "../guiElements/WScaleLabel.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WPropertyBoolWidget.h"
#include "WPropertyDoubleWidget.h"
#include "WPropertyColorWidget.h"
#include "WQtPropertyGroupWidget.h"
#include "WTreeItemTypes.h"
#include "WQtRoiTreeItem.h"
#include "WQtBranchTreeItem.h"
WQtBranchTreeItem::WQtBranchTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMBranch > branch ) :
WQtBranchTreeItem::WQtBranchTreeItem( QTreeWidgetItem* parent, boost::shared_ptr< WRMBranch > branch ) :
QTreeWidgetItem( parent, ROIBRANCH ),
m_branch( branch )
{
setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled );
// create nice widget
m_itemWidget = new QWidget( );
QHBoxLayout* containerLayout = new QHBoxLayout();
m_itemWidget->setLayout( containerLayout );
// create a slider for the for the texture
QWidget* labelContainer = new QWidget( m_itemWidget );
QHBoxLayout* labelContainerLayout = new QHBoxLayout();
labelContainer->setLayout( labelContainerLayout );
QWidget* propertyContainer = new QWidget( m_itemWidget );
QHBoxLayout* propertyContainerLayout = new QHBoxLayout();
propertyContainer->setLayout( propertyContainerLayout );
propertyContainer->setObjectName( "propertyContainer" );
WScaleLabel* l = new WScaleLabel( QString::fromStdString( "Branch" ), 5, labelContainer );
l->setTextInteractionFlags( Qt::NoTextInteraction );
l->setToolTip( "The name of this branch." );
labelContainerLayout->addWidget( l );
// color
WPropertyColorWidget* color = new WPropertyColorWidget( branch->colorProperty(), NULL, m_itemWidget );
color->setToolTip( QString::fromStdString( branch->colorProperty()->getDescription() ) );
color->setColorPickerButtonHidden();
// inverse
WPropertyBoolWidget* isnot = new WPropertyBoolWidget( branch->invertProperty(), NULL, m_itemWidget );
isnot->setToolTip( QString::fromStdString( branch->invertProperty()->getDescription() ) );
QLabel* grabWidget = new QLabel( m_itemWidget );
grabWidget->setPixmap( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "touchpoint_small" ).pixmap( 24, 32 ) );
grabWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
grabWidget->setFixedWidth( 24 );
grabWidget->setToolTip( "Drag and drop these textures to change their composition ordering." );
// style
QPalette palette;
QColor defaultCol = palette.window().color();
// label color
QColor labelCol = defaultCol.darker( 150 );
// property color
QColor propertyCol = defaultCol;
l->setStyleSheet( "background-color:" + labelCol.name() + ";" );
labelContainer->setStyleSheet( "background-color:" + labelCol.name() + ";" );
propertyContainer->setStyleSheet( "QWidget#propertyContainer{ background-color:" + propertyCol.name() + ";}" );
propertyContainerLayout->addWidget( isnot );
propertyContainerLayout->addWidget( color );
// fill layout
containerLayout->addWidget( grabWidget );
containerLayout->addWidget( labelContainer );
containerLayout->addWidget( propertyContainer );
// compact layout
containerLayout->setContentsMargins( 0, 2, 0, 2 );
containerLayout->setSpacing( 0 );
labelContainerLayout->setContentsMargins( 5, 2, 0, 2 );
labelContainerLayout->setSpacing( 0 );
propertyContainerLayout->setContentsMargins( 2, 2, 0, 2 );
propertyContainerLayout->setSpacing( 0 );
// prefer stretching the label
containerLayout->setStretchFactor( grabWidget, 0 );
containerLayout->setStretchFactor( labelContainer, 100 );
containerLayout->setStretchFactor( propertyContainer, 0 );
// widget size constraints and policies
m_itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
}
WQtBranchTreeItem::~WQtBranchTreeItem()
......@@ -42,8 +129,6 @@ WQtBranchTreeItem::~WQtBranchTreeItem()
WQtRoiTreeItem* WQtBranchTreeItem::addRoiItem( osg::ref_ptr< WROI > roi )
{
WQtRoiTreeItem* rti = new WQtRoiTreeItem( this, roi, ROI );
rti->setText( 0, QString( roi->getName().c_str() ) );
return rti;
}
......@@ -51,3 +136,9 @@ boost::shared_ptr< WRMBranch > WQtBranchTreeItem::getBranch()
{
return m_branch;
}
QWidget* WQtBranchTreeItem::getWidget() const
{
return m_itemWidget;
}
......@@ -70,10 +70,21 @@ public:
*/
boost::shared_ptr< WRMBranch > getBranch();
/**
* Create a representation widget for this item.
*
* \return the widget.
*/
QWidget* getWidget() const;
protected:
private:
boost::shared_ptr< WRMBranch > m_branch; //!< ROI
/**
* Widget representing the item.
*/
QWidget* m_itemWidget;
};
#endif // WQTBRANCHTREEITEM_H
......@@ -190,7 +190,7 @@ WQtColormapper::WQtTextureListItem::WQtTextureListItem( const osg::ref_ptr< WGET
propActionBtn->setToolTip( "Show all the configuration options for this texture and its colormap." );
QLabel* grabWidget = new QLabel( m_itemWidget );
grabWidget->setPixmap( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "touchpoint" ).pixmap( 24, 48 ) );
grabWidget->setPixmap( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "touchpoint_small" ).pixmap( 24, 32 ) );
grabWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
grabWidget->setFixedWidth( 24 );
grabWidget->setToolTip( "Drag and drop these textures to change their composition ordering." );
......@@ -220,9 +220,12 @@ WQtColormapper::WQtTextureListItem::WQtTextureListItem( const osg::ref_ptr< WGET
// compact layout
containerLayout->setContentsMargins( 0, 2, 0, 2 );
containerLayout->setSpacing( 0 );
labelContainerLayout->setContentsMargins( 2, 2, 0, 2 );
labelContainerLayout->setSpacing( 0 );
// prefer stretching the label
containerLayout->setStretchFactor( active, 0 );
containerLayout->setStretchFactor( grabWidget, 0 );
containerLayout->setStretchFactor( labelContainer, 100 );
containerLayout->setStretchFactor( alpha, 75 );
containerLayout->setStretchFactor( propActionBtn, 0 );
......
......@@ -196,7 +196,7 @@ WQtControlPanel::WQtControlPanel( WMainWindow* parent )
m_tiModules->setText( 0, QString( "Subject-independent Modules" ) );
m_tiModules->setToolTip( 0, "Subject-independent modules and modules for which no parent module could be detected." );
m_tiRois = new WQtRoiHeaderTreeItem( m_roiTreeWidget );
m_tiRois->setText( 0, QString( "ROIs" ) );
m_roiTreeWidget->setItemWidget( m_tiRois, 0, m_tiRois->getWidget() );
connectSlots();
......@@ -630,11 +630,15 @@ void WQtControlPanel::addRoi( osg::ref_ptr< WROI > roi )
if( !found )
{
branchItem = m_tiRois->addBranch( WKernel::getRunningKernel()->getRoiManager()->getBranch( roi ) );
m_roiTreeWidget->setItemWidget( branchItem, 0, branchItem->getWidget() );
}
branchItem->setExpanded( true );
newItem = branchItem->addRoiItem( roi );
newItem->setDisabled( false );
m_roiTreeWidget->setItemWidget( newItem, 0, newItem->getWidget() );
m_roiTreeWidget->setCurrentItem( newItem );
WKernel::getRunningKernel()->getRoiManager()->setSelectedRoi( getSelectedRoi() );
selectRoiTreeItem( newItem );
......@@ -767,7 +771,6 @@ void WQtControlPanel::selectRoiTreeItem( QTreeWidgetItem* item )
break;
case ROI:
props = ( static_cast< WQtRoiTreeItem* >( item ) )->getRoi()->getProperties();
props->getProperty( "active" )->toPropBool()->set( item->checkState( 0 ) );
WKernel::getRunningKernel()->getRoiManager()->setSelectedRoi( getSelectedRoi() );
m_deleteRoiAction->setEnabled( true );
break;
......
......@@ -24,6 +24,17 @@
#include <string>
#include <QtCore/QList>
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include <QtGui/QListWidgetItem>
#include <QtGui/QApplication>
#include <QtGui/QWidgetAction>
#include "../guiElements/WScaleLabel.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WQtRoiHeaderTreeItem.h"
#include "WQtRoiTreeItem.h"
#include "WTreeItemTypes.h"
......@@ -32,6 +43,47 @@ WQtRoiHeaderTreeItem::WQtRoiHeaderTreeItem( QTreeWidget * parent ) :
QTreeWidgetItem( parent, ROIHEADER )
{
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
// create nice widget
m_itemWidget = new QWidget( );
QHBoxLayout* containerLayout = new QHBoxLayout();
m_itemWidget->setLayout( containerLayout );
// create a slider for the for the texture
QWidget* labelContainer = new QWidget( m_itemWidget );
QHBoxLayout* labelContainerLayout = new QHBoxLayout();
labelContainer->setLayout( labelContainerLayout );
WScaleLabel* l = new WScaleLabel( QString::fromStdString( "ROIs" ), 5, labelContainer );
l->setTextInteractionFlags( Qt::NoTextInteraction );
l->setToolTip( "Define a selection of fibers using ROIs which are interpreted as logical formula." );
labelContainerLayout->addWidget( l );
// style
QPalette palette;
QColor defaultCol = palette.window().color();
// label color
QColor labelCol = defaultCol.darker( 120 );
l->setStyleSheet( "background-color:" + labelCol.name() + ";" );
labelContainer->setStyleSheet( "background-color:" + labelCol.name() + ";" );
// fill layout
containerLayout->addWidget( labelContainer );
labelContainerLayout->setContentsMargins( 5, 2, 0, 2 );
labelContainerLayout->setSpacing( 0 );
// compact layout
containerLayout->setContentsMargins( 0, 2, 0, 2 );
containerLayout->setSpacing( 0 );
// prefer stretching the label
containerLayout->setStretchFactor( labelContainer, 100 );
// widget size constraints and policies
m_itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
}
WQtRoiHeaderTreeItem::~WQtRoiHeaderTreeItem()
......@@ -41,7 +93,11 @@ WQtRoiHeaderTreeItem::~WQtRoiHeaderTreeItem()
WQtBranchTreeItem* WQtRoiHeaderTreeItem::addBranch( boost::shared_ptr< WRMBranch> branch )
{
WQtBranchTreeItem* rti = new WQtBranchTreeItem( this, branch );
rti->setText( 0, QString( "Branch" ) );
return rti;
}
QWidget* WQtRoiHeaderTreeItem::getWidget() const
{
return m_itemWidget;
}
......@@ -59,9 +59,18 @@ public:
*/
WQtBranchTreeItem* addBranch( boost::shared_ptr< WRMBranch> branch );
/**
* Create a representation widget for this item.
*
* \return the widget.
*/
QWidget* getWidget() const;
protected:
private:
/**
* Widget representing the item.
*/
QWidget* m_itemWidget;
};
#endif // WQTROIHEADERTREEITEM_H
......@@ -24,6 +24,18 @@
#include <string>
#include <QtCore/QList>
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include <QtGui/QListWidgetItem>
#include <QtGui/QApplication>
#include <QtGui/QWidgetAction>
#include "../guiElements/WScaleLabel.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WPropertyBoolWidget.h"
#include "WTreeItemTypes.h"
#include "WQtRoiTreeItem.h"
......@@ -31,16 +43,87 @@ WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, osg::ref_ptr< WROI > r
QTreeWidgetItem( parent, type ),
m_roi( roi )
{
setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled );
if( m_roi->getProperties()->getProperty( "active" )->toPropBool()->get() )
{
setCheckState( 0, Qt::Checked );
}
else
{
setCheckState( 0, Qt::Unchecked );
}
setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled );