Page MenuHomePhabricator

Enable Drag-Drop of Multiple Nodes
Closed, ResolvedPublic

Description

Dear MITK,

please can I have the following enhancement?

When i click and select multiple nodes (normally images, but could be points/surfaces), I want to drag and drop them into a render window.

The current code in QmitkDataStorageTreeModel only stores a single mitk::DataNode* pointer in the drag mime data under type application/x-mitk-datanode.

To minimise impact, a comma separated list of mitk::DataNode* pointers could be stored (serialized) and extracted (deserialized) on the target widget dropEvent.

Thanks

Matt

Event Timeline

Thank you, Matt for the contribution. The changes look basically good. Perhaps you could also extend the dropMimeData() method to also allow dropping data of type "application/x-mitk-datanodes".
I'll add a core change request soon as the class is part of the CoreUI module of MITK.

Change sounds ok. The only thing that I don't understand (but not that important): why a special case for a single DataNode? Could a generic "list of nodes"-Type not solve all drag&drop operations? A single item could just be a short list, right?

(In reply to comment #4)

Change sounds ok. The only thing that I don't understand (but not that
important): why a special case for a single DataNode? Could a generic "list of
nodes"-Type not solve all drag&drop operations? A single item could just be a
short list, right?

Hi there Alex and Daniel,

Sure, I'm happy to help. However, with regards to Alex's point, when is dropMimeData called? (i.e. how do I test it? It looks like that method should have to cope with DataNodes that are dropped onto the data manager, but aren't already loaded in the application. So is that drag and drop between two instances of the application.

Second, I agree with Daniel's point, about not having application/x-mitk-datanode and application/x-mitk-datanodes. However, I didn't want to do a big change to core. The only place I could find code for dropping application/x-mitk-datanode was in the python console. Is this right? Is it still used? I also just tried to build the python console, but after installing cswig on my mac via macports, I could not build the code, due to

CMake Error at Wrapping/CSwig/CMakeLists.txt:431 (ADD_LIBRARY):

Cannot find source file:

  /Users/mattclarkson/build/UCLToolkit-SuperBuildRelease/CMakeExternals/Source/MITK/Wrapping/CSwig/Core/wrap_MitkPython.cxx

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

Call Stack (most recent call first):

Wrapping/CSwig/Core/CMakeLists.txt:10 (MITK_WRAP_LIBRARY)

So, is the python stuff still used?

Thanks

Matt

hi matt, you can get the best info on the drag and drop behaviour and when those methods are called from here:
http://doc.qt.nokia.com/stable/model-view-programming.html#using-drag-and-drop-with-item-views

the python stuff is still used but under refactoring at the moment. there will be a big update in the next two weeks for the python wrapping. i will also check if the error occurs for me as well

Hi there,

I checked in this code
https://github.com/MattClarkson/MITK/commit/88c515838e9d59caec30d6fe917e58a8a17c75be

I believe that I encorporated the suggested changes.
However, I have been unable to test the Python Console stuff.

Matt

(In reply to comment #6)

hi matt, you can get the best info on the drag and drop behaviour and when
those methods are called from here:
http://doc.qt.nokia.com/stable/model-view-programming.html#using-drag-and-drop-with-item-views

the python stuff is still used but under refactoring at the moment. there will
be a big update in the next two weeks for the python wrapping. i will also
check if the error occurs for me as well

I just had a quick look on your changes and found out that there is a crash when you try to move multiple nodes within the DataStorage:

  • Load at least two arbitrary data sets
  • Mark both
  • Move them within the DataStorage bundle

-> Crash

Perhaps you could take a look at this. I'll then check your code also with the Phython stuff enabled.

Thanks,
Alex

(In reply to comment #8)

I just had a quick look on your changes and found out that there is a crash

Hi there,

sorry, yes, thats poor testing.
I tried this:
https://github.com/MattClarkson/MITK/commit/49f96e8b39c02d2570e13fc9e565322b7247c4cd

which seems much better.

Also, I noted that when I drag/drop within the same widget, you can either drag and drop onto an existing row number, or drag and drop between the rows. In this between-the-rows case, the parent index is always -1, so it's useless. This means that you have to either ignore it, or drop onto the end of the list.

Do you agree?

Matt

[071926]: Merge branch 'bug-10124-trac-993-dragdrop-multiple-nodes'

Merged commits:

2011-11-29 10:22:04 MattClarkson [f12958]
Fix for invalid index


2011-11-25 13:55:58 MattClarkson [49f96e]
Fixed crash when dropping multiple nodes onto blank area


2011-11-19 10:21:52 MattClarkson [88c515]
Now using application/x-mitk-datanodes with lists of size 1


2011-11-19 08:35:06 MattClarkson [4127cb]
Changes to QmitkDataStorageTreeModel to properly support multiple drag drops


2011-11-11 15:14:07 MattClarkson [2e8dd6]
10124: pass multiple data nodes as application/x-mitk-datanodes