19 #include "internal/QmitkCommonExtPlugin.h"
21 #include <QFileDialog>
22 #include <QMessageBox>
23 #include <QApplication>
58 this->setText(
"&Save Project...");
59 this->setToolTip(
"Save content of Data Manager as a .mitk project file");
61 this->connect(
this, SIGNAL(triggered(
bool)),
this, SLOT(
Run()));
72 static QString m_LastPath;
77 ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
87 QString msg =
"IDataStorageService service not available. Unable to open files.";
89 QMessageBox::warning(QApplication::activeWindow(),
"Unable to open files", msg);
95 context->ungetService(dsServiceRef);
100 QString dialogTitle =
"Save MITK Scene (%1)";
101 QString fileName = QFileDialog::getSaveFileName(NULL,
102 dialogTitle.arg(dsRef->GetLabel()),
104 "MITK scene files (*.mitk)",
107 if (fileName.isEmpty() )
111 m_LastPath = fileName;
113 if ( fileName.right(5) !=
".mitk" )
125 if ( !sceneIO->SaveScene( nodesToBeSaved, storage, fileName.toStdString() ) )
127 QMessageBox::information(NULL,
129 "Scene could not be written completely. Please check the log.",
136 if (!failedNodes->empty())
138 std::stringstream ss;
139 ss <<
"The following nodes could not be serialized:" << std::endl;
140 for ( mitk::SceneIO::FailedBaseDataListType::const_iterator iter = failedNodes->begin();
141 iter != failedNodes->end();
147 ss << data->GetNameOfClass();
154 ss <<
" contained in node '" << (*iter)->GetName() <<
"'" << std::endl;
161 if (!failedProperties->GetMap()->empty())
163 std::stringstream ss;
164 ss <<
"The following properties could not be serialized:" << std::endl;
166 for ( mitk::PropertyList::PropertyMap::const_iterator iter = propmap->begin();
167 iter != propmap->end();
170 ss <<
" - " << iter->second->GetNameOfClass() <<
" associated to key '" << iter->first <<
"'" << std::endl;
176 catch (std::exception& e)
178 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.
itk::SmartPointer< Self > Pointer
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...
itk::SmartPointer< const Self > ConstPointer
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