Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
9f85fa8b
Commit
9f85fa8b
authored
Apr 04, 2013
by
Sebastian Eichelbaum
Browse files
[ADD
#61
] drag and drop support accross branches works.
parent
d70127d1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
176 additions
and
8 deletions
+176
-8
src/core/graphicsEngine/WROI.h
src/core/graphicsEngine/WROI.h
+5
-0
src/core/kernel/WRMBranch.cpp
src/core/kernel/WRMBranch.cpp
+0
-1
src/core/kernel/WRMBranch.h
src/core/kernel/WRMBranch.h
+0
-2
src/qt4gui/controlPanel/WQtBranchTreeItem.cpp
src/qt4gui/controlPanel/WQtBranchTreeItem.cpp
+4
-0
src/qt4gui/controlPanel/WQtBranchTreeItem.h
src/qt4gui/controlPanel/WQtBranchTreeItem.h
+4
-0
src/qt4gui/controlPanel/WQtControlPanel.cpp
src/qt4gui/controlPanel/WQtControlPanel.cpp
+49
-5
src/qt4gui/events/WEventTypes.h
src/qt4gui/events/WEventTypes.h
+4
-0
src/qt4gui/events/WRoiSortEvent.cpp
src/qt4gui/events/WRoiSortEvent.cpp
+44
-0
src/qt4gui/events/WRoiSortEvent.h
src/qt4gui/events/WRoiSortEvent.h
+66
-0
No files found.
src/core/graphicsEngine/WROI.h
View file @
9f85fa8b
...
...
@@ -43,6 +43,11 @@ class WPickHandler;
class
WROI
:
public
osg
::
Geode
{
public:
/**
* Ref Pointer type.
*/
typedef
osg
::
ref_ptr
<
WROI
>
RefPtr
;
WROI
();
/**
...
...
src/core/kernel/WRMBranch.cpp
View file @
9f85fa8b
...
...
@@ -85,7 +85,6 @@ void WRMBranch::addRoi( osg::ref_ptr< WROI > roi )
{
m_rois
.
push_back
(
roi
);
roi
->
addROIChangeNotifier
(
m_changeRoiSignal
);
setDirty
();
}
...
...
src/core/kernel/WRMBranch.h
View file @
9f85fa8b
...
...
@@ -186,7 +186,6 @@ public:
*/
void
addChangeNotifier
(
boost
::
shared_ptr
<
boost
::
function
<
void
()
>
>
notifier
);
/**
* Remove a specified notifier from the list of default notifiers which get connected to each branch
*
...
...
@@ -194,7 +193,6 @@ public:
*/
void
removeChangeNotifier
(
boost
::
shared_ptr
<
boost
::
function
<
void
()
>
>
notifier
);
protected:
/**
* initializes properties
...
...
src/qt4gui/controlPanel/WQtBranchTreeItem.cpp
View file @
9f85fa8b
...
...
@@ -143,3 +143,7 @@ QWidget* WQtBranchTreeItem::getWidget() const
return
m_itemWidget
;
}
void
WQtBranchTreeItem
::
updateRoiManagerSorting
()
{
wlog
::
error
(
"WQtBranchTreeItem"
)
<<
"resort not yet implemented"
;
}
src/qt4gui/controlPanel/WQtBranchTreeItem.h
View file @
9f85fa8b
...
...
@@ -77,6 +77,10 @@ public:
*/
QWidget
*
getWidget
()
const
;
/**
* Update internal Roi Manager sorting using the sorting of the children of this tree item.
*/
void
updateRoiManagerSorting
();
protected:
private:
boost
::
shared_ptr
<
WRMBranch
>
m_branch
;
//!< ROI
...
...
src/qt4gui/controlPanel/WQtControlPanel.cpp
View file @
9f85fa8b
...
...
@@ -30,6 +30,7 @@
#include <vector>
#include <QtCore/QList>
#include <QtCore/QCoreApplication>
#include <QtGui/QMenu>
#include <QtGui/QScrollArea>
#include <QtGui/QShortcut>
...
...
@@ -59,6 +60,7 @@
#include "../events/WModuleRemovedEvent.h"
#include "../events/WRoiAssocEvent.h"
#include "../events/WRoiRemoveEvent.h"
#include "../events/WRoiSortEvent.h"
#include "../guiElements/WQtModuleMetaInfo.h"
#include "../guiElements/WQtMenuFiltered.h"
#include "../networkEditor/WQtNetworkEditor.h"
...
...
@@ -276,6 +278,16 @@ bool WQtControlPanel::event( QEvent* event )
return
true
;
}
if
(
event
->
type
()
==
WQT_ROI_SORT_EVENT
)
{
WRoiSortEvent
*
e3
=
dynamic_cast
<
WRoiSortEvent
*
>
(
event
);
if
(
e3
)
{
e3
->
getBranch
()
->
updateRoiManagerSorting
();
}
return
true
;
}
// a module got associated with the root container -> add it to the list
if
(
event
->
type
()
==
WQT_ASSOC_EVENT
)
...
...
@@ -1247,11 +1259,17 @@ void WQtControlPanel::selectUpperMostEntry()
m_tiModules
->
setSelected
(
true
);
}
void
WQtControlPanel
::
handleRoiDragDrop
(
QDropEvent
*
event
)
void
WQtControlPanel
::
handleRoiDragDrop
(
QDropEvent
*
/*
event
*/
)
{
WROI
::
RefPtr
droppedRoi
;
WRMBranch
::
SPtr
droppedBranch
;
WQtBranchTreeItem
*
droppedBranchTreeItem
=
NULL
;
for
(
int
branchID
=
0
;
branchID
<
m_tiRois
->
childCount
();
++
branchID
)
{
QTreeWidgetItem
*
branchTreeItem
=
m_tiRois
->
child
(
branchID
);
WQtBranchTreeItem
*
branchTreeItem
=
dynamic_cast
<
WQtBranchTreeItem
*
>
(
m_tiRois
->
child
(
branchID
)
);
// go through each roi
for
(
int
roiID
=
0
;
roiID
<
branchTreeItem
->
childCount
();
++
roiID
)
{
WQtRoiTreeItem
*
roiTreeItem
=
dynamic_cast
<
WQtRoiTreeItem
*
>
(
branchTreeItem
->
child
(
roiID
)
);
...
...
@@ -1260,18 +1278,44 @@ void WQtControlPanel::handleRoiDragDrop( QDropEvent* event )
QWidget
*
w
=
m_roiTreeWidget
->
itemWidget
(
roiTreeItem
,
0
);
if
(
!
w
)
{
// let us hope that this really is the dropped item
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
// we need this later: the dropped ROI
droppedRoi
=
roiTreeItem
->
getRoi
();
droppedBranch
=
branchTreeItem
->
getBranch
();
droppedBranchTreeItem
=
branchTreeItem
;
// 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. It looks like expanding is enough.
// roiTreeItem->setSizeHint( 0, w->sizeHint() );
//roiTreeItem->parent()->setExpanded( false );
//
roiTreeItem->parent()->setExpanded( false );
roiTreeItem
->
parent
()
->
setExpanded
(
true
);
}
}
}
// something went wrong
if
(
!
(
droppedBranch
&&
droppedBranchTreeItem
)
)
{
wlog
::
error
(
"WQtControlPanel::handleRoiDragDrop"
)
<<
"Was not able to find dropped ROI item. This should not happen!"
;
}
// as the current branch/Roi code is quite ugly ... we need some manual re-sorting and re-inserting stuff
WRMBranch
::
SPtr
realParent
=
WKernel
::
getRunningKernel
()
->
getRoiManager
()
->
getBranch
(
droppedRoi
);
if
(
realParent
!=
droppedBranch
)
{
// ROI changed in branch:
realParent
->
removeRoi
(
droppedRoi
);
droppedBranch
->
addRoi
(
droppedRoi
);
}
// initiate re-sorting the widget items. We cannot do this directly, as we might have changed the ROI parent in the lines above. The GUI has
// not yet been updated so that the sorting would fail.
// NOTE: it is enough to re-sort the target branch of a cross-branch moved item.
QCoreApplication
::
postEvent
(
this
,
new
WRoiSortEvent
(
droppedBranchTreeItem
)
);
}
WQtDockWidget
*
WQtControlPanel
::
getRoiDock
()
const
...
...
src/qt4gui/events/WEventTypes.h
View file @
9f85fa8b
...
...
@@ -86,4 +86,8 @@
// Log entry added
#define WQT_LOG_EVENT QEvent::User + 18
// re-sort a branch
#define WQT_ROI_SORT_EVENT QEvent::User + 19
#endif // WEVENTTYPES_H
src/qt4gui/events/WRoiSortEvent.cpp
0 → 100644
View file @
9f85fa8b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WEventTypes.h"
#include "WRoiSortEvent.h"
WRoiSortEvent
::
WRoiSortEvent
(
WQtBranchTreeItem
*
branch
)
:
QEvent
(
static_cast
<
QEvent
::
Type
>
(
WQT_ROI_SORT_EVENT
)
),
m_branch
(
branch
)
{
// initialize members
}
WRoiSortEvent
::~
WRoiSortEvent
()
{
// cleanup
}
WQtBranchTreeItem
*
WRoiSortEvent
::
getBranch
()
{
return
m_branch
;
}
src/qt4gui/events/WRoiSortEvent.h
0 → 100644
View file @
9f85fa8b
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WROISORTEVENT_H
#define WROISORTEVENT_H
#include <boost/shared_ptr.hpp>
#include <QtCore/QEvent>
#include "../controlPanel/WQtBranchTreeItem.h"
/**
* Event signalling that a sorting of the ROIs needs to be done.
*/
class
WRoiSortEvent
:
public
QEvent
{
public:
/**
* Constructor
* \param branch the branch to sort.
*/
explicit
WRoiSortEvent
(
WQtBranchTreeItem
*
branch
);
/**
* Destructor
*/
virtual
~
WRoiSortEvent
();
/**
* Getter for the branch.
*
* \return the branch.
*/
WQtBranchTreeItem
*
getBranch
();
protected:
/**
* The branch to re-sort.
*/
WQtBranchTreeItem
*
m_branch
;
private:
};
#endif // WROISORTEVENT_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment