Commit d70127d1 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD #61] drag and drop works in GUI. ROI structure is not updated internally yet.

parent db321eac
...@@ -239,7 +239,7 @@ void WQtControlPanel::connectSlots() ...@@ -239,7 +239,7 @@ void WQtControlPanel::connectSlots()
connect( m_roiTreeWidget, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( selectRoiTreeItem( QTreeWidgetItem* ) ) ); connect( m_roiTreeWidget, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( selectRoiTreeItem( QTreeWidgetItem* ) ) );
connect( m_colormapper, SIGNAL( textureSelectionChanged( osg::ref_ptr< WGETexture3D > ) ), connect( m_colormapper, SIGNAL( textureSelectionChanged( osg::ref_ptr< WGETexture3D > ) ),
this, SLOT( selectDataModule( osg::ref_ptr< WGETexture3D > ) ) ); this, SLOT( selectDataModule( osg::ref_ptr< WGETexture3D > ) ) );
connect( m_roiTreeWidget, SIGNAL( dragDrop() ), this, SLOT( handleRoiDragDrop() ) ); connect( m_roiTreeWidget, SIGNAL( dragDrop( QDropEvent* ) ), this, SLOT( handleRoiDragDrop( QDropEvent* ) ) );
} }
WQtSubjectTreeItem* WQtControlPanel::addSubject( std::string name ) WQtSubjectTreeItem* WQtControlPanel::addSubject( std::string name )
...@@ -637,7 +637,7 @@ void WQtControlPanel::addRoi( osg::ref_ptr< WROI > roi ) ...@@ -637,7 +637,7 @@ void WQtControlPanel::addRoi( osg::ref_ptr< WROI > roi )
newItem = branchItem->addRoiItem( roi ); newItem = branchItem->addRoiItem( roi );
newItem->setDisabled( false ); newItem->setDisabled( false );
m_roiTreeWidget->setItemWidget( newItem, 0, newItem->getWidget() ); m_roiTreeWidget->setItemWidget( newItem, 0, newItem->createWidget() );
m_roiTreeWidget->setCurrentItem( newItem ); m_roiTreeWidget->setCurrentItem( newItem );
WKernel::getRunningKernel()->getRoiManager()->setSelectedRoi( getSelectedRoi() ); WKernel::getRunningKernel()->getRoiManager()->setSelectedRoi( getSelectedRoi() );
...@@ -1247,9 +1247,31 @@ void WQtControlPanel::selectUpperMostEntry() ...@@ -1247,9 +1247,31 @@ void WQtControlPanel::selectUpperMostEntry()
m_tiModules->setSelected( true ); m_tiModules->setSelected( true );
} }
void WQtControlPanel::handleRoiDragDrop() void WQtControlPanel::handleRoiDragDrop( QDropEvent* event )
{ {
WLogger::getLogger()->addLogMessage( "Drag and drop handler not implemented yet!", "ControlPanel", LL_DEBUG ); for( int branchID = 0; branchID < m_tiRois->childCount(); ++branchID )
{
QTreeWidgetItem* branchTreeItem = m_tiRois->child( branchID );
for( int roiID = 0; roiID < branchTreeItem->childCount(); ++roiID )
{
WQtRoiTreeItem* roiTreeItem = dynamic_cast< WQtRoiTreeItem* >( branchTreeItem->child( roiID ) );
// has the widget been removed?
QWidget* w = m_roiTreeWidget->itemWidget( roiTreeItem, 0 );
if( !w )
{
w = roiTreeItem->createWidget();
m_roiTreeWidget->setItemWidget( roiTreeItem, 0, w );
m_roiTreeWidget->setCurrentItem( roiTreeItem );
// NOTE: there is a bug. After setting the new widget. the treewidget does not update the size of the item. To force this, we
// collapse and expand the branch here
// roiTreeItem->setSizeHint( 0, w->sizeHint() );
//roiTreeItem->parent()->setExpanded( false );
roiTreeItem->parent()->setExpanded( true );
}
}
}
} }
WQtDockWidget* WQtControlPanel::getRoiDock() const WQtDockWidget* WQtControlPanel::getRoiDock() const
......
...@@ -463,8 +463,10 @@ private slots: ...@@ -463,8 +463,10 @@ private slots:
/** /**
* function to notify the ROI manager of any drag&drop action in the ROI tree * function to notify the ROI manager of any drag&drop action in the ROI tree
*
* \param event the drop event
*/ */
void handleRoiDragDrop(); void handleRoiDragDrop( QDropEvent* event );
}; };
#endif // WQTCONTROLPANEL_H #endif // WQTCONTROLPANEL_H
...@@ -45,41 +45,53 @@ WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, osg::ref_ptr< WROI > r ...@@ -45,41 +45,53 @@ WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, osg::ref_ptr< WROI > r
m_roi( roi ) m_roi( roi )
{ {
setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled ); setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled );
}
WQtRoiTreeItem::~WQtRoiTreeItem()
{
}
osg::ref_ptr< WROI > WQtRoiTreeItem::getRoi()
{
return m_roi;
}
QWidget* WQtRoiTreeItem::createWidget() const
{
// create nice widget // create nice widget
m_itemWidget = new QWidget( ); QWidget* itemWidget = new QWidget( );
QHBoxLayout* containerLayout = new QHBoxLayout(); QHBoxLayout* containerLayout = new QHBoxLayout();
m_itemWidget->setLayout( containerLayout ); itemWidget->setLayout( containerLayout );
// create a slider for the for the texture // create a slider for the for the texture
QWidget* labelContainer = new QWidget( m_itemWidget ); QWidget* labelContainer = new QWidget( itemWidget );
QHBoxLayout* labelContainerLayout = new QHBoxLayout(); QHBoxLayout* labelContainerLayout = new QHBoxLayout();
labelContainer->setLayout( labelContainerLayout ); labelContainer->setLayout( labelContainerLayout );
QWidget* propertyContainer = new QWidget( m_itemWidget ); QWidget* propertyContainer = new QWidget( itemWidget );
QHBoxLayout* propertyContainerLayout = new QHBoxLayout(); QHBoxLayout* propertyContainerLayout = new QHBoxLayout();
propertyContainer->setLayout( propertyContainerLayout ); propertyContainer->setLayout( propertyContainerLayout );
propertyContainer->setObjectName( "propertyContainer" ); propertyContainer->setObjectName( "propertyContainer" );
// name // name
WPropertyStringWidget* name = new WPropertyStringWidget( roi->nameProperty(), NULL, m_itemWidget ); WPropertyStringWidget* name = new WPropertyStringWidget( m_roi->nameProperty(), NULL, itemWidget );
name->setToolTip( "The name of this ROI." ); name->setToolTip( "The name of this ROI." );
name->forceInformationMode(); name->forceInformationMode();
name->disableTextInteraction(); name->disableTextInteraction();
// inverse // inverse
WPropertyBoolWidget* isnot = new WPropertyBoolWidget( roi->invertProperty(), NULL, m_itemWidget ); WPropertyBoolWidget* isnot = new WPropertyBoolWidget( m_roi->invertProperty(), NULL, itemWidget );
isnot->setToolTip( QString::fromStdString( roi->invertProperty()->getDescription() ) ); isnot->setToolTip( QString::fromStdString( m_roi->invertProperty()->getDescription() ) );
// active // active
WPropertyBoolWidget* active = new WPropertyBoolWidget( roi->activeProperty(), NULL, m_itemWidget ); WPropertyBoolWidget* active = new WPropertyBoolWidget( m_roi->activeProperty(), NULL, itemWidget );
active->setToolTip( QString::fromStdString( roi->activeProperty()->getDescription() ) ); active->setToolTip( QString::fromStdString( m_roi->activeProperty()->getDescription() ) );
// show // show
WPropertyBoolWidget* show = new WPropertyBoolWidget( roi->showProperty(), NULL, m_itemWidget ); WPropertyBoolWidget* show = new WPropertyBoolWidget( m_roi->showProperty(), NULL, itemWidget );
show->setToolTip( QString::fromStdString( roi->showProperty()->getDescription() ) ); show->setToolTip( QString::fromStdString( m_roi->showProperty()->getDescription() ) );
QLabel* grabWidget = new QLabel( m_itemWidget ); QLabel* grabWidget = new QLabel( itemWidget );
grabWidget->setPixmap( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "touchpoint_small" ).pixmap( 24, 32 ) ); grabWidget->setPixmap( WQt4Gui::getMainWindow()->getIconManager()->getIcon( "touchpoint_small" ).pixmap( 24, 32 ) );
grabWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); grabWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
grabWidget->setFixedWidth( 24 ); grabWidget->setFixedWidth( 24 );
...@@ -126,20 +138,8 @@ WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, osg::ref_ptr< WROI > r ...@@ -126,20 +138,8 @@ WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, osg::ref_ptr< WROI > r
containerLayout->setStretchFactor( propertyContainer, 0 ); containerLayout->setStretchFactor( propertyContainer, 0 );
// widget size constraints and policies // widget size constraints and policies
m_itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); itemWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
}
WQtRoiTreeItem::~WQtRoiTreeItem()
{
}
osg::ref_ptr< WROI > WQtRoiTreeItem::getRoi() return itemWidget;
{
return m_roi;
}
QWidget* WQtRoiTreeItem::getWidget() const
{
return m_itemWidget;
} }
...@@ -64,16 +64,11 @@ public: ...@@ -64,16 +64,11 @@ public:
* *
* \return the widget. * \return the widget.
*/ */
QWidget* getWidget() const; QWidget* createWidget() const;
protected: protected:
private: private:
osg::ref_ptr< WROI > m_roi; //!< Pointer to the ROI represented by this item. osg::ref_ptr< WROI > m_roi; //!< Pointer to the ROI represented by this item.
/**
* Widget representing the item.
*/
QWidget* m_itemWidget;
}; };
#endif // WQTROITREEITEM_H #endif // WQTROITREEITEM_H
...@@ -46,8 +46,9 @@ void WQtTreeWidget::deleteItem( QTreeWidgetItem* item ) ...@@ -46,8 +46,9 @@ void WQtTreeWidget::deleteItem( QTreeWidgetItem* item )
delete item; delete item;
} }
void WQtTreeWidget::dropEvent( QDropEvent* /*event*/ ) void WQtTreeWidget::dropEvent( QDropEvent* event )
{ {
emit dragDrop(); QTreeWidget::dropEvent( event );
emit dragDrop( event );
} }
...@@ -61,7 +61,12 @@ public: ...@@ -61,7 +61,12 @@ public:
protected: protected:
private: private:
signals: signals:
void dragDrop(); //!< signal to notify higher ups of the drag&drop action /**
* Item was dropped
*
* \param event the event
*/
void dragDrop( QDropEvent* event );
}; };
#endif // WQTTREEWIDGET_H #endif // WQTTREEWIDGET_H
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