23 #include <mitkIGTIOException.h> 27 #include <qfiledialog.h> 28 #include <qinputdialog.h> 29 #include <qmessagebox.h> 30 #include <qsettings.h> 33 #include <Poco/Path.h> 54 m_Controls =
new Ui::QmitkNavigationToolManagementWidgetControls;
66 MessageBox(
"Storage is locked, cannot modify it. Maybe the tracking device which uses this storage is connected. If you want to modify the storage please disconnect the device first.");
72 if (filename ==
"")
return;
73 mitk::NavigationTool::Pointer readTool = myReader->DoRead(filename);
74 if (readTool.IsNull())
MessageBox(
"Error: " + myReader->GetErrorMessage());
90 if (
m_Controls->m_ToolList->currentItem() ==
nullptr) {
MessageBox(
"Error: Please select tool first!");
return; }
95 if (filename ==
"")
return;
96 std::string fileExt = Poco::Path(filename).getExtension();
97 if (fileExt ==
"") { filename.append(
".IGTTool"); }
99 MessageBox(
"Error: "+ myWriter->GetErrorMessage());
122 connect((QObject*)(
m_Controls->m_ToolCreationWidget), SIGNAL(NavigationToolFinished()),
this, SLOT(
OnAddToolSave()));
134 if (storageToLoad.IsNotNull())
159 MessageBox(
"The storage is locked and it cannot be modified. Maybe the tracking device which " \
160 "uses this storage is connected. If you want to modify the storage please " \
161 "disconnect the device first.");
164 int toolIndex =
m_Controls->m_ToolList->currentIndex().row();
168 if (currentNavigationTool.IsNotNull())
170 std::string currentIdentifier = currentNavigationTool->GetIdentifier();
171 int NewNumber =
m_Controls->m_ToolList->currentIndex().row() - 1;
172 if (NewNumber < 0) {
MITK_WARN <<
"Cannot move tool up because it is on the top!"; }
187 MessageBox(
"The storage is locked and it cannot be modified. Maybe the tracking device which " \
188 "uses this storage is connected. If you want to modify the storage please " \
189 "disconnect the device first.");
192 int toolIndex =
m_Controls->m_ToolList->currentIndex().row();
196 if (currentNavigationTool.IsNotNull())
198 std::string currentIdentifier = currentNavigationTool->GetIdentifier();
199 unsigned int NewNumber =
m_Controls->m_ToolList->currentIndex().row() + 1;
212 MessageBox(
"Storage is locked, cannot modify it. Maybe the tracking device which uses this storage is connected. If you want to modify the storage please disconnect the device first.");
217 m_Controls->m_ToolCreationWidget->Initialize(
m_DataStorage, defaultIdentifier.toStdString(), defaultName.toStdString());
218 m_Controls->m_ToolCreationWidget->ShowToolPreview(
"Tool preview");
220 m_Controls->m_MainWidgets->setCurrentIndex(1);
228 MessageBox(
"Storage is locked, cannot modify it. Maybe the tracking device which uses this storage is connected. If you want to modify the storage please disconnect the device first.");
231 else if (
m_Controls->m_ToolList->currentItem() ==
nullptr)
233 MessageBox(
"Error: Please select tool first!");
246 MessageBox(
"Storage is locked, cannot modify it. Maybe the tracking device which uses this storage is connected. If you want to modify the storage please disconnect the device first.");
249 else if (
m_Controls->m_ToolList->currentItem() ==
nullptr)
251 MessageBox(
"Error: Please select tool first!");
256 m_Controls->m_ToolCreationWidget->SetDefaultData(selectedTool);
257 m_Controls->m_ToolCreationWidget->ShowToolPreview(
"Tool preview");
259 m_Controls->m_MainWidgets->setCurrentIndex(1);
264 QString storageName = QInputDialog::getText(
nullptr,
"Storage Name",
"Name of the new tool storage:");
265 if (storageName.isNull())
return;
275 mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(
m_DataStorage);
277 if (filename ==
"")
return;
281 mitk::NavigationToolStorage::Pointer tempStorage =
nullptr;
285 tempStorage = myDeserializer->Deserialize(filename);
292 if (tempStorage.IsNotNull())
294 Poco::Path myPath = Poco::Path(filename.c_str());
295 tempStorage->SetName(myPath.getFileName());
304 QFileDialog *fileDialog =
new QFileDialog;
305 fileDialog->setDefaultSuffix(
"IGTToolStorage");
306 QString suffix =
"IGT Tool Storage (*.IGTToolStorage)";
309 QString filename = fileDialog->getSaveFileName(
nullptr, tr(
"Save Navigation Tool Storage"), defaultFileName, suffix, &suffix);
311 if (filename.isEmpty())
return;
314 QFileInfo file(filename);
315 if(file.suffix().isEmpty()) filename +=
".IGTToolStorage";
326 MessageBox(
"Error: " + std::string(e.GetDescription()));
331 Poco::Path myPath = Poco::Path(filename.toStdString());
332 m_Controls->m_StorageName->setText(QString::fromStdString(myPath.getFileName()));
344 MessageBox(
"The storage is locked and it cannot be modified. Maybe the tracking device which " \
345 "uses this storage is connected. If you want to modify the storage please " \
346 "disconnect the device first.");
350 mitk::NavigationTool::Pointer newTool =
m_Controls->m_ToolCreationWidget->GetCreatedTool();
355 editedTool->Graft(newTool);
369 m_Controls->m_MainWidgets->setCurrentIndex(0);
376 m_Controls->m_MainWidgets->setCurrentIndex(0);
383 QString _label =
"Information for tool " +
m_Controls->m_ToolList->currentItem()->text() +
"\n";
385 m_Controls->m_ToolInformation->setText(_label);
397 QString currentTool =
"Tool" + QString::number(i) +
": " + QString(
m_NavigationToolStorage->GetTool(i)->GetToolName().c_str()) +
" ";
399 currentTool +=
"(" + QString::fromStdString(
m_NavigationToolStorage->GetTool(i)->GetTrackingDeviceType()) +
"/";
404 currentTool +=
"Instrument)";
break;
406 currentTool +=
"Fiducial)";
break;
408 currentTool +=
"Skinmarker)";
break;
410 currentTool +=
"Unknown)";
419 msgBox.setText(s.c_str());
429 m_Controls->m_MoveToolDown->setEnabled(
false);
430 m_Controls->m_selectedLabel->setEnabled(
false);
445 m_Controls->m_selectedLabel->setEnabled(
true);
static const QString GetLastFileLoadPath()
Data management class that handles 'was created by' relations.
static void SetLastFileSavePath(const QString &str)
static void SetLastFileLoadPathByFileName(const QString &str)
An object of this class represents an exception of the MITK-IGT module which are releated to the inpu...
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
static RenderingManager * GetInstance()
static void SetLastFileSavePathByFileName(const QString &str)
virtual void Remove(const DataNode *node)=0
Removes node from the DataStorage.
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
static const QString GetLastFileSavePath()
DataNode * GetNamedNode(const char *name) const
Convenience method to get the first node with a given name.