View Issue Details

IDProjectCategoryView StatusLast Update
0003081Slicer4Core: GUIpublic2017-06-07 23:27
Reporterkikinis Assigned Tofinetjul  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version 
Target VersionSlicer 4.3.0Fixed in VersionSlicer 4.3.0 
Summary0003081: when dragging and dropping a dicom file or folder into slicer, the dicom widget should be invoked by default
Description

This will increase the consistency of the user experience in Slicer

TagsNo tags attached.

Relationships

related to 0003291 closedjcfr Drag and drop feature 

Activities

finetjul

finetjul

2013-04-20 14:10

administrator   ~0008455

r21904: Add mechanism to register dialogs for drag&drop

pieper

pieper

2013-04-25 14:32

administrator   ~0008501

I took a look at this - it is technically doable to make to integrate dicom with drag and drop, but we have a policy question to sort out for dropping folders and dicom files onto the application.

Current behavior: if a folder is dropped on slicer, all individual files are added to the Add Data dialog.

Suggested behavior: all dropped folders should be sent to the dicom module and only dropped files should be handled by the Add Data dialog.

I would think of implementing this suggested behavior by adding something like a directoryDropped(QStringList) signal from the slicer main window.

Other alternatives could be:

(1) we could figure out a way for modules to register their interest in dropped directories and they would have a chance to inspect their contents before grabbing them (i.e. according to a priority scheme). This could be tricking since each module might have to do a recursive search and also it might find some files it understands and some it isn't able to load. At least for DICOM, this would be almost as much work (and redundant with) the actual import process.

(2) when the user drops a folder we could pop up a dialog asking if they want to load this as DICOM or as non-DICOM data. This strikes me as a little messy, but maybe it's not so bad.

finetjul

finetjul

2013-04-25 15:06

administrator   ~0008505

Steve, my commit (r21904) kind of do what you suggest.
A module can now "register" an IO dialog that responds to drag&drop events.
The registered dialog must overwrite the dropEvent() method and decide if it can handle the content of the mime data or not (https://github.com/Slicer/Slicer/blob/master/Base/QTGUI/qSlicerDataDialog.cxx#L370-400). If it does, then the io manager execute the dialog.
If it does not, then the next registered IO dialog is tested and so on.
At last, the qSlicerDataDialog will handle the data if none of the registered io dialog can.

So it should work if the dicom module registers an IO dialog that only accepts DICOM directories in the dropEvent() method. No ?

pieper

pieper

2013-04-25 15:23

administrator   ~0008507

I more-or-less agree with you Julien, but the problem is that without inspecting the contents of folders (and subfolders) it's not clear which IO dialog should handle a folder (DICOM folders can have arbitrary layout and filenames, with no required file extension). So I would see it as more clear at a documentation/user level to say that all folders get sent to the DICOM module but all multiple file drops go to the IO dialogs.

Or, as in my option (2) we could prompt the user to ask which action they have in mind.

kikinis

kikinis

2013-04-25 19:41

developer   ~0008509

I like the "ask the user" option. Let them decide instead of us guessing.

finetjul

finetjul

2013-04-26 04:44

administrator   ~0008511

I'm confused :-), what's the problem with analyzing the contents of the mime data url path. Why the registered DICOM dialog wouldn't be able to do that ?
If you think it's too difficult to know if a url is a DICOM url, then the simpler solution of having the DICOM registered dialog always accepting any directory should be fine too.

Option (2) is also fine and should be easy to implement in qSlicerIOManager::dropEvent() which would get the list of all the readers that handle the mime data content, and popup a menu with such list (let me know if you want to go that way).

Btw, I think the dropevent should stay flexible enough to support more than just filepaths. Mime can contain images or custom content which would make Slicer support drag&drop from other applications(for example, you could drag&drop openIgt configuration to setup a connection...

pieper

pieper

2013-04-26 06:17

administrator   ~0008512

The key point is that a "DICOM url" in this context means exactly "any directory" due to the ambiguity of knowing what is in the directory without looking.

Getting back to the big picture, if Ron likes the idea of prompting the user with a dialog, let's do that.

For that, a clean way to do this would be for the qSlicerAppMainWindow to issue the put up a dialog inside the dropEvent method so that if one or more directories are dropped, it asks if the data should be interpreted as DICOM or non-DICOM data. Then if the user picks DICOM, the qSlicerAppMainWindow can emit a signal like dicomImportRequest(QStringList) and the DICOM module can take it from there.

It's a shame we have to go through convoluted special cases like this, but DICOM data really is not like traditional file formats like .vtk or .nrrd.

finetjul

finetjul

2013-04-26 06:38

administrator   ~0008513

Ok for the dialog.

However, I disagree with you concerning the clean way.
qSlicerAppMainWindow should not be aware of any IO (DICOM in this case). It's qSlicerIOManager's job. Everything can be done within qSlicerIOManager::dropEvent() as long as the DICOM module registers the appropriate dialog (note that qSlicerFileDialog is not a real dialog, but it's more like a plugin).
All that is needed is a mechanism to easily create custom qSlicerFileDialog from Python. A mechanism like qSlicerScriptedLoadableModule would be ideal, but a believe something simpler could work too (e.g. qSlicerScriptableFileDialog could fire signals when dropEvent() and dragEnterEvent() are called and it would expose slot to accept/reject those events)

pieper

pieper

2013-04-26 06:48

administrator   ~0008514

I don't really care if it's the qSlicerIOManger or the qSlicerAppMainWindow that fires the signals.

To me, adding another subclass just to do this seems like overkill. If one of the existing classes emits the signal then everything can be handled with just a few lines of code. Connecting to signals seems much nicer than registering a dialog.

On the other hand, I'm trying to think of what a qSlicerScriptedFileDialog would do. In my view a pure python extension to be able to configure and extend all parts of slicer, so if this adds more scriptable functionality I'm all for it.

finetjul

finetjul

2013-04-29 06:27

administrator   ~0008533

Scriptable file dialog added in r21951:
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/IO#How_to_register_a_dialog_.3F
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/IO#How_to_order_the_list_of_drag.26drop_dialogs_.3F

pieper

pieper

2013-04-29 06:55

administrator   ~0008534

Impressive work Julien - but it's not building for me on mac.

In file included from /Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.cxx:31:
In file included from /Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerIOManager.h:15:
/Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.h:152:1: error: redefinition of 'QMetaTypeId<qSlicerFileDialog::IOAction>'
Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)
^~~~~~~~~~~
/Library/Frameworks/QtCore.framework/Headers/qmetatype.h:268:12: note: expanded from macro 'Q_DECLARE_METATYPE'
struct QMetaTypeId< TYPE > \
^~~~~~~
/Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.h:94:1: note: previous definition is here
Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)
^
/Library/Frameworks/QtCore.framework/Headers/qmetatype.h:268:12: note: expanded from macro 'Q_DECLARE_METATYPE'
struct QMetaTypeId< TYPE > \
^
In file included from /Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerModelsDialog.cxx:26:
In file included from /Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerIOManager.h:15:
/Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.h:152:1: error: redefinition of 'QMetaTypeId<qSlicerFileDialog::IOAction>'
Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)
^~~~~~~~~~~
/Library/Frameworks/QtCore.framework/Headers/qmetatype.h:268:12: note: expanded from macro 'Q_DECLARE_METATYPE'
struct QMetaTypeId< TYPE > \
^~~~~~~
/Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.h:94:1: note: previous definition is here
Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)
^
/Library/Frameworks/QtCore.framework/Headers/qmetatype.h:268:12: note: expanded from macro 'Q_DECLARE_METATYPE'
struct QMetaTypeId< TYPE > \
^
1 error generated.
make[5]: [Base/QTGUI/CMakeFiles/qSlicerBaseQTGUI.dir/qSlicerFileDialog.cxx.o] Error 1
make[5]:
Waiting for unfinished jobs....

pieper

pieper

2013-04-29 07:19

administrator   ~0008535

Seems the line is duplicated - if I remove one it seems to work fine. Do you have a preference for removing the one before the class declaration or the one after?

$ grep META /Users/pieper/slicer4/latest/Slicer/Base/QTGUI/qSlicerFileDialog.h
//Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)
Q_DECLARE_METATYPE(qSlicerFileDialog::IOAction)

finetjul

finetjul

2013-04-29 07:31

administrator   ~0008536

Sorry about that. I've a slight preference for removing the second one. (I should have moved qSlicerStandardFileDialog into a separate file :-/ )

pieper

pieper

2013-04-29 07:36

administrator   ~0008537

No problem ;)

Fixed in r21953

I'll try to have a look at integrating this with the dicom module this afternoon and let you know if I have questions.

kikinis

kikinis

2013-08-06 07:19

developer   ~0009393

To slightly improve the user experience: If I drag a dicom directory into slicer, the popup defaults to "Any Data". That is potentially confusing. It should default to "Dicom", with any data as a pull down option

pieper

pieper

2013-08-06 09:02

administrator   ~0009406

@Julien - Is there an easy place to implement Ron's request?

finetjul

finetjul

2013-08-07 11:57

administrator   ~0009425

Load DICOM by default is fixed in r22267

Related Changesets

Slicer: 2145-support-for-installing-extension-from-file cbcecd95

2013-04-20 18:06:25

finetjul

Details Diff
ENH: Add drag&drop support for registered IO dialogs.

To support drag&drop, a qSlicerFileDialog derived class should reimplement:
* qSlicerFileDialog::dragEnterEvent()
* qSlicerFileDialog::dropEvent()

By default, qSlicerDataDialog supports drag&drop.

Issue 0003081

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21904 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTGUI/qSlicerDataDialog.cxx Diff File
mod - Base/QTGUI/qSlicerDataDialog.h Diff File
mod - Base/QTGUI/qSlicerDataDialog_p.h Diff File
mod - Base/QTGUI/qSlicerFileDialog.cxx Diff File
mod - Base/QTGUI/qSlicerFileDialog.h Diff File
mod - Base/QTGUI/qSlicerIOManager.cxx Diff File
mod - Base/QTGUI/qSlicerIOManager.h Diff File
mod - Base/QTGUI/qSlicerModelsDialog.h Diff File

Slicer: 2145-support-for-installing-extension-from-file 35b30817

2013-04-29 10:12:03

finetjul

Details Diff
ENH: Add qSlicerScriptedFileDialog

* Add qSlicerFileDialog::description
* Add input dialog to select reader when multiple readers accept the same mime data


How to create a FileDialog in python?

+class XYZFileDialog:
+ def __init__(self, parent):
+ self.parent = parent
+ parent.fileType = 'XYZ'
+ parent.description = 'XYZ'
+ parent.action = slicer.qSlicerFileDialog.Read
+ def isMimeDataAccepted(self):
+ accept = self.parent.mimeData().hasFormat("text/uri-list")
+ self.parent.acceptMimeData(accept)
+ def dropEvent(self):
+ self.parent.dropEvent().accept()
+ def execDialog(self):
+ print 'exec'

How to order the list (make the module reader by default):
Make the module depend on "Data" -> instantiated after "Data" module
def __init__(self, parent):
+ parent.dependencies = ["Data"]

Issue 0003081

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21951 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTCore/qSlicerCoreApplication.cxx Diff File
mod - Base/QTGUI/CMakeLists.txt Diff File
mod - Base/QTGUI/qSlicerDataDialog.cxx Diff File
mod - Base/QTGUI/qSlicerDataDialog.h Diff File
mod - Base/QTGUI/qSlicerFileDialog.cxx Diff File
mod - Base/QTGUI/qSlicerFileDialog.h Diff File
mod - Base/QTGUI/qSlicerIOManager.cxx Diff File
mod - Base/QTGUI/qSlicerModelsDialog.cxx Diff File
mod - Base/QTGUI/qSlicerModelsDialog.h Diff File
mod - Base/QTGUI/qSlicerSaveDataDialog.cxx Diff File
mod - Base/QTGUI/qSlicerSaveDataDialog.h Diff File
add - Base/QTGUI/qSlicerScriptedFileDialog.cxx Diff File
add - Base/QTGUI/qSlicerScriptedFileDialog.h Diff File
mod - Base/QTGUI/qSlicerScriptedLoadableModule.cxx Diff File
mod - Base/QTGUI/qSlicerScriptedLoadableModule.h Diff File

Slicer: 2145-support-for-installing-extension-from-file df58ed05

2013-04-29 11:35:13

pieper

Details Diff
COMP: fix duplicate metatype declaration (Issue 0003081)

See also r21951

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21953 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTGUI/qSlicerFileDialog.h Diff File

Slicer: 2145-support-for-installing-extension-from-file 50b9bcf3

2013-08-07 15:56:35

finetjul

Details Diff
ENH: Select DICOM reader by default on drag&drop

Issue 0003081

git-svn-id: http://svn.slicer.org/Slicer4/trunk@22267 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Base/QTGUI/qSlicerIOManager.cxx Diff File

Issue History

Date Modified Username Field Change
2013-04-20 02:39 kikinis New Issue
2013-04-20 02:39 kikinis Status new => assigned
2013-04-20 02:39 kikinis Assigned To => finetjul
2013-04-20 14:10 finetjul Note Added: 0008455
2013-04-20 14:11 finetjul Assigned To finetjul => pieper
2013-04-25 14:32 pieper Note Added: 0008501
2013-04-25 15:06 finetjul Note Added: 0008505
2013-04-25 15:23 pieper Note Added: 0008507
2013-04-25 19:41 kikinis Note Added: 0008509
2013-04-26 04:44 finetjul Note Added: 0008511
2013-04-26 06:17 pieper Note Added: 0008512
2013-04-26 06:38 finetjul Note Added: 0008513
2013-04-26 06:48 pieper Note Added: 0008514
2013-04-29 06:27 finetjul Note Added: 0008533
2013-04-29 06:55 pieper Note Added: 0008534
2013-04-29 07:19 pieper Note Added: 0008535
2013-04-29 07:31 finetjul Note Added: 0008536
2013-04-29 07:36 pieper Note Added: 0008537
2013-07-04 14:27 pieper Status assigned => resolved
2013-07-04 14:27 pieper Fixed in Version => Slicer 4.3.0
2013-07-04 14:27 pieper Resolution open => fixed
2013-08-06 07:19 kikinis Note Added: 0009393
2013-08-06 07:19 kikinis Status resolved => feedback
2013-08-06 07:19 kikinis Resolution fixed => reopened
2013-08-06 09:01 pieper Status feedback => assigned
2013-08-06 09:01 pieper Assigned To pieper => finetjul
2013-08-06 09:02 pieper Note Added: 0009406
2013-08-07 11:57 finetjul Note Added: 0009425
2013-08-07 11:57 finetjul Status assigned => resolved
2013-08-07 11:57 finetjul Resolution reopened => fixed
2013-08-31 04:45 kikinis Status resolved => closed
2015-11-02 05:47 jcfr Relationship added related to 0003291
2017-06-07 23:27 finetjul Changeset attached => Slicer 2145-support-for-installing-extension-from-file 50b9bcf3
2017-06-07 23:27 pieper Changeset attached => Slicer 2145-support-for-installing-extension-from-file df58ed05
2017-06-07 23:27 finetjul Changeset attached => Slicer 2145-support-for-installing-extension-from-file 35b30817
2017-06-07 23:27 finetjul Changeset attached => Slicer 2145-support-for-installing-extension-from-file cbcecd95