Page MenuHomePhabricator

Provide a DataStorage to DataTreeNodeFactory and FileReader subclasses
Closed, DuplicatePublic

Description

As part of implementing a scene file loader, I would like to add the possibility to load scene files using the normal "File/Open" menu of ExtApp.

A major difference of scene loading compared to other file loaders is that the scene file reader must also recreate the hierarchy of multiple objects in DataStroage. Plain file readers only output a vector of DataTreeNodes without hierarchy.

If scenes should be loadable via File/Open, we have to create a way to tell a class called SceneFileReader an instance of DataStorage. (As DataStorage is no longer a singleton, there is no other way).

The code part that is used for File/Open is found in mitk/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.cpp. This code instantiates a mitk::DataTreeNodeFactory, uses this instance to load DataTreeNodes and adds all loaded nodes to the "current editor's data storage".

My proposed solution is to provide SetDataStorage(..) methods to the following classes:

mitk::DataTreeNodeFactory (entry point for FileOpenAction)
mitk::BaseDataIO (handles file reader factories)
mitk::IOAdapterBase (wrapper for file readers)
mitk::FileReader (interface for file readers)

SetDataStorage() and a respective GetDataStorage() method should be setter/getter methods for a member m_DataStorage.

mitk::IOAdaper<T>::CreateIOProcessObject would be modified to call SetDataStorage(..) on the appropriate mitk::FileReader. In cases where this is mitk::SceneFileReader, we would have a way to add read nodes to a data storage and create a hierarchy for them.

Event Timeline

Ok, I discussed this with Marco and we found that we don't actualy want the implementation suggested above. The main reason for the descision againt this is that in future versions, scenes will probably contain information such as camera perspective, slice positions, render window layout etc. This would require more and more objects for the reader mechanism.

I'll now implement special handling of scene files in the file/open and the drag&drop actions.

Just in case we need something like in comment #1, I attach a nearly finished solution as a patch.

Hi, your bug is resolved, can you please remove the needs_core_modification request (set it to - or nothing)? Otherwise it clutters the list of open requests which is not filterable by status.

This will help granting the flag for open bugs much faster ;)