MCPcopy Create free account
hub / github.com/MITK/MITK / Run

Method Run

Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp:57–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56
57void QmitkExtFileSaveProjectAction::Run()
58{
59 try
60 {
61 /**
62 * @brief stores the last path of last saved file
63 */
64 static QString m_LastPath;
65
66 mitk::CoreServicePointer<mitk::IDataStorageService> dsService(mitk::CoreServices::GetDataStorageService());
67
68 if (!dsService)
69 {
70 QString msg = "IDataStorageService service not available. Unable to save project.";
71 MITK_WARN << msg.toStdString();
72 QMessageBox::warning(QApplication::activeWindow(), "Unable to save project", msg);
73 return;
74 }
75
76 // Get the active data storage info (or the default one, if none is active)
77 mitk::DataStorageReference dsRef = dsService->GetActiveDataStorageReference();
78 mitk::DataStorage::Pointer storage = dsRef.GetStorage();
79
80 QString dialogTitle = "Save MITK Scene (%1)";
81 QString fileName = QFileDialog::getSaveFileName(nullptr,
82 dialogTitle.arg(QString::fromStdString(dsRef.GetLabel())),
83 m_LastPath,
84 "MITK scene files (*.mitk)",
85 nullptr );
86
87 if (fileName.isEmpty() )
88 return;
89
90 // remember the location
91 m_LastPath = fileName;
92
93 if ( fileName.right(5) != ".mitk" )
94 fileName += ".mitk";
95
96 mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New();
97
98 mitk::ProgressBar::GetInstance()->AddStepsToDo(2);
99
100 /* Build list of nodes that should be saved */
101 mitk::NodePredicateNot::Pointer isNotHelperObject =
102 mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true)));
103 mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = storage->GetSubset(isNotHelperObject);
104
105 if ( !sceneIO->SaveScene( nodesToBeSaved, storage, fileName.toStdString() ) )
106 {
107 QMessageBox::information(nullptr,
108 "Scene saving",
109 "Scene could not be written completely. Please check the log.",
110 QMessageBox::Ok);
111
112 }
113 mitk::ProgressBar::GetInstance()->Progress(2);
114

Callers

nothing calls this directly

Calls 15

GetSubsetMethod · 0.80
SaveSceneMethod · 0.80
GetFailedNodesMethod · 0.80
whatMethod · 0.80
NewFunction · 0.50
GetStorageMethod · 0.45
GetLabelMethod · 0.45
AddStepsToDoMethod · 0.45
ProgressMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected