15 #include "internal/QmitkCommonExtPlugin.h" 17 #include <QFileDialog> 18 #include <QMessageBox> 19 #include <QApplication> 54 this->setText(
"&Save Project...");
55 this->setToolTip(
"Save content of Data Manager as a .mitk project file");
57 this->connect(
this, SIGNAL(triggered(
bool)),
this, SLOT(
Run()));
68 static QString m_LastPath;
73 ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
83 QString msg =
"IDataStorageService service not available. Unable to open files.";
85 QMessageBox::warning(QApplication::activeWindow(),
"Unable to open files", msg);
91 context->ungetService(dsServiceRef);
96 QString dialogTitle =
"Save MITK Scene (%1)";
97 QString fileName = QFileDialog::getSaveFileName(
nullptr,
98 dialogTitle.arg(dsRef->GetLabel()),
100 "MITK scene files (*.mitk)",
103 if (fileName.isEmpty() )
107 m_LastPath = fileName;
109 if ( fileName.right(5) !=
".mitk" )
119 mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = storage->GetSubset(isNotHelperObject);
121 if ( !sceneIO->SaveScene( nodesToBeSaved, storage, fileName.toStdString() ) )
123 QMessageBox::information(
nullptr,
125 "Scene could not be written completely. Please check the log.",
131 mitk::SceneIO::FailedBaseDataListType::ConstPointer failedNodes = sceneIO->GetFailedNodes();
132 if (!failedNodes->empty())
134 std::stringstream ss;
135 ss <<
"The following nodes could not be serialized:" << std::endl;
136 for ( mitk::SceneIO::FailedBaseDataListType::const_iterator iter = failedNodes->begin();
137 iter != failedNodes->end();
143 ss << data->GetNameOfClass();
150 ss <<
" contained in node '" << (*iter)->GetName() <<
"'" << std::endl;
157 if (!failedProperties->GetMap()->empty())
159 std::stringstream ss;
160 ss <<
"The following properties could not be serialized:" << std::endl;
162 for ( mitk::PropertyList::PropertyMap::const_iterator iter = propmap->begin();
163 iter != propmap->end();
166 ss <<
" - " << iter->second->GetNameOfClass() <<
" associated to key '" << iter->first <<
"'" << std::endl;
172 catch (std::exception& e)
174 MITK_ERROR <<
"Exception caught during scene saving: " << e.what();
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
QmitkExtFileSaveProjectAction(berry::SmartPointer< berry::IWorkbenchWindow > window)
Base of all data objects.
virtual IDataStorageReference::Pointer GetDataStorage() const =0
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
std::map< std::string, BaseProperty::Pointer > PropertyMap
static Pointer New(const mitk::NodePredicateBase *_arg)
static Pointer New(const char *_arg)
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
ObjectType * GetPointer() const