diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp index e7639abda2..9d2fa1892a 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.cpp @@ -1,502 +1,563 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkMITKIGTTrackingToolboxView.h" #include "QmitkStdMultiWidget.h" // Qt #include #include // MITK #include #include #include #include #include #include #include // vtk #include const std::string QmitkMITKIGTTrackingToolboxView::VIEW_ID = "org.mitk.views.mitkigttrackingtoolbox"; QmitkMITKIGTTrackingToolboxView::QmitkMITKIGTTrackingToolboxView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) { m_TrackingTimer = new QTimer(this); m_tracking = false; m_logging = false; m_loggedFrames = 0; } QmitkMITKIGTTrackingToolboxView::~QmitkMITKIGTTrackingToolboxView() { //remove the tracking volume this->GetDataStorage()->Remove(m_TrackingVolumeNode); this->GlobalReinit(); } void QmitkMITKIGTTrackingToolboxView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkMITKIGTTrackingToolboxViewControls; m_Controls->setupUi( parent ); //create connections connect( m_Controls->m_LoadTools, SIGNAL(clicked()), this, SLOT(OnLoadTools()) ); connect( m_Controls->m_StartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking()) ); connect( m_Controls->m_StopTracking, SIGNAL(clicked()), this, SLOT(OnStopTracking()) ); connect( m_TrackingTimer, SIGNAL(timeout()), this, SLOT(UpdateTrackingTimer())); connect( m_Controls->m_ChooseFile, SIGNAL(clicked()), this, SLOT(OnChooseFileClicked())); connect( m_Controls->m_StartLogging, SIGNAL(clicked()), this, SLOT(StartLogging())); connect( m_Controls->m_StopLogging, SIGNAL(clicked()), this, SLOT(StopLogging())); connect( m_Controls->m_configurationWidget, SIGNAL(TrackingDeviceSelectionChanged()), this, SLOT(OnTrackingDeviceChanged())); connect( m_Controls->m_VolumeSelectionBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(OnTrackingVolumeChanged(QString))); connect( m_Controls->m_ShowTrackingVolume, SIGNAL(clicked()), this, SLOT(OnShowTrackingVolumeChanged())); connect( m_Controls->m_AutoDetectTools, SIGNAL(clicked()), this, SLOT(OnAutoDetectTools())); + connect( m_Controls->m_ResetTools, SIGNAL(clicked()), this, SLOT(OnResetTools())); + + connect( m_Controls->m_AddSingleTool, SIGNAL(clicked()), this, SLOT(OnAddSingleTool())); + connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(NavigationToolFinished()), this, SLOT(OnAddSingleToolFinished())); + connect( m_Controls->m_NavigationToolCreationWidget, SIGNAL(Canceled()), this, SLOT(OnAddSingleToolCanceled())); //initialize widgets m_Controls->m_configurationWidget->EnableAdvancedUserControl(false); m_Controls->m_TrackingToolsStatusWidget->SetShowPositions(true); m_Controls->m_TrackingToolsStatusWidget->SetTextAlignment(Qt::AlignLeft); //initialize tracking volume node m_TrackingVolumeNode = mitk::DataNode::New(); m_TrackingVolumeNode->SetName("TrackingVolume"); m_TrackingVolumeNode->SetOpacity(0.25); mitk::Color red; red.SetRed(1); m_TrackingVolumeNode->SetColor(red); GetDataStorage()->Add(m_TrackingVolumeNode); //initialize buttons m_Controls->m_StopTracking->setEnabled(false); m_Controls->m_StopLogging->setEnabled(false); m_Controls->m_AutoDetectTools->setVisible(false); //only visible if tracking device is Aurora //Update List of available models for selected tool. std::vector Compatibles = mitk::GetDeviceDataForLine( m_Controls->m_configurationWidget->GetTrackingDevice()->GetType()); m_Controls->m_VolumeSelectionBox->clear(); for(int i = 0; i < Compatibles.size(); i++) { m_Controls->m_VolumeSelectionBox->addItem(Compatibles[i].Model.c_str()); } } } void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkMITKIGTTrackingToolboxView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkMITKIGTTrackingToolboxView::OnLoadTools() { //read in filename QString filename = QFileDialog::getOpenFileName(NULL,tr("Open Toolfile"), "/", tr("All Files (*.*)")); //later perhaps: tr("Toolfile (*.tfl)" if (filename.isNull()) return; //read tool storage from disk mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(GetDataStorage()); m_toolStorage = myDeserializer->Deserialize(filename.toStdString()); if (m_toolStorage.IsNull()) { MessageBox(myDeserializer->GetErrorMessage()); m_toolStorage = NULL; return; } //update label Poco::Path myPath = Poco::Path(filename.toStdString()); //use this to seperate filename from path QString toolLabel = QString("Loaded Tools: ") + QString::number(m_toolStorage->GetToolCount()) + " Tools from " + myPath.getFileName().c_str(); m_Controls->m_toolLabel->setText(toolLabel); //update tool preview m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); } +void QmitkMITKIGTTrackingToolboxView::OnResetTools() +{ + m_toolStorage = NULL; + m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); + QString toolLabel = QString("Loaded Tools: "); + m_Controls->m_toolLabel->setText(toolLabel); +} + void QmitkMITKIGTTrackingToolboxView::OnStartTracking() { //check if everything is ready to start tracking if (this->m_toolStorage.IsNull()) { MessageBox("Error: No Tools Loaded Yet!"); return; } else if (this->m_toolStorage->GetToolCount() == 0) { MessageBox("Error: No Way To Track Without Tools!"); return; } //build the IGT pipeline mitk::TrackingDevice::Pointer trackingDevice = this->m_Controls->m_configurationWidget->GetTrackingDevice(); - //Get Tracking Volume Data mitk::TrackingDeviceData data = mitk::DeviceDataUnspecified; QString qstr = m_Controls->m_VolumeSelectionBox->currentText(); if ( (! qstr.isNull()) || (! qstr.isEmpty()) ) { std::string str = qstr.toStdString(); data = mitk::GetDeviceDataByName(str); //Data will be set later, after device generation } - - - mitk::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory = mitk::TrackingDeviceSourceConfigurator::New(this->m_toolStorage,trackingDevice); m_TrackingDeviceSource = myTrackingDeviceSourceFactory->CreateTrackingDeviceSource(this->m_ToolVisualizationFilter); if (m_TrackingDeviceSource.IsNull()) { MessageBox(myTrackingDeviceSourceFactory->GetErrorMessage()); return; } +//disable Buttons +m_Controls->m_StopTracking->setEnabled(true); +m_Controls->m_StartTracking->setEnabled(false); +DisableOptionsButtons(); +DisableTrackingConfigurationButtons(); + //initialize tracking try { m_TrackingDeviceSource->Connect(); m_TrackingDeviceSource->StartTracking(); } catch (...) { MessageBox("Error while starting the tracking device!"); + //enable Buttons + m_Controls->m_StopTracking->setEnabled(false); + m_Controls->m_StartTracking->setEnabled(true); + EnableOptionsButtons(); + EnableTrackingConfigurationButtons(); return; } m_TrackingTimer->start(1000/(m_Controls->m_UpdateRate->value())); m_Controls->m_TrackingControlLabel->setText("Status: tracking"); //connect the tool visualization widget for(int i=0; iGetNumberOfOutputs(); i++) { m_Controls->m_TrackingToolsStatusWidget->AddNavigationData(m_TrackingDeviceSource->GetOutput(i)); } m_Controls->m_TrackingToolsStatusWidget->ShowStatusLabels(); if (m_Controls->m_ShowToolQuaternions->isChecked()) {m_Controls->m_TrackingToolsStatusWidget->SetShowQuaternions(true);} else {m_Controls->m_TrackingToolsStatusWidget->SetShowQuaternions(false);} -//disable loading new tools -this->m_Controls->m_LoadTools->setEnabled(false); -this->m_Controls->m_AutoDetectTools->setEnabled(false); - //set configuration finished this->m_Controls->m_configurationWidget->ConfigurationFinished(); //show tracking volume - this->OnTrackingVolumeChanged(m_Controls->m_VolumeSelectionBox->currentText()); - +this->OnTrackingVolumeChanged(m_Controls->m_VolumeSelectionBox->currentText()); m_tracking = true; -//disable Buttons -m_Controls->m_StopTracking->setEnabled(true); -m_Controls->m_StartTracking->setEnabled(false); -DisableOptionsButtons(); - this->GlobalReinit(); } void QmitkMITKIGTTrackingToolboxView::OnStopTracking() { if (!m_tracking) return; m_TrackingTimer->stop(); m_TrackingDeviceSource->StopTracking(); m_TrackingDeviceSource->Disconnect(); this->m_Controls->m_configurationWidget->Reset(); m_Controls->m_TrackingControlLabel->setText("Status: stopped"); if (m_logging) StopLogging(); -this->m_Controls->m_LoadTools->setEnabled(true); -this->m_Controls->m_AutoDetectTools->setEnabled(true); m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); m_tracking = false; //enable Buttons m_Controls->m_StopTracking->setEnabled(false); m_Controls->m_StartTracking->setEnabled(true); EnableOptionsButtons(); +EnableTrackingConfigurationButtons(); this->GlobalReinit(); } void QmitkMITKIGTTrackingToolboxView::OnTrackingDeviceChanged() { mitk::TrackingDeviceType Type = m_Controls->m_configurationWidget->GetTrackingDevice()->GetType(); - // Code to enable auto detection - if (Type == mitk::NDIAurora) - {m_Controls->m_AutoDetectTools->setVisible(true);} - else - {m_Controls->m_AutoDetectTools->setVisible(false);} + + // Code to enable/disable device specific buttons + if (Type == mitk::NDIAurora) //Aurora + { + m_Controls->m_AutoDetectTools->setVisible(true); + m_Controls->m_AddSingleTool->setEnabled(false); + } + else //Polaris or Microntracker + { + m_Controls->m_AutoDetectTools->setVisible(false); + m_Controls->m_AddSingleTool->setEnabled(true); + } -// Code to select appropriate tracking volumes + // Code to select appropriate tracking volume for current type std::vector Compatibles = mitk::GetDeviceDataForLine(Type); m_Controls->m_VolumeSelectionBox->clear(); for(int i = 0; i < Compatibles.size(); i++) { m_Controls->m_VolumeSelectionBox->addItem(Compatibles[i].Model.c_str()); } } void QmitkMITKIGTTrackingToolboxView::OnTrackingVolumeChanged(QString qstr) { if (qstr.isNull()) return; if (qstr.isEmpty()) return; if (m_Controls->m_ShowTrackingVolume->isChecked()) { mitk::TrackingVolumeGenerator::Pointer volumeGenerator = mitk::TrackingVolumeGenerator::New(); - std::string str = qstr.toStdString(); mitk::TrackingDeviceData data = mitk::GetDeviceDataByName(str); volumeGenerator->SetTrackingDeviceData(data); volumeGenerator->Update(); mitk::Surface::Pointer volumeSurface = volumeGenerator->GetOutput(); m_TrackingVolumeNode->SetData(volumeSurface); GlobalReinit(); } } void QmitkMITKIGTTrackingToolboxView::OnShowTrackingVolumeChanged() { if (m_Controls->m_ShowTrackingVolume->isChecked()) { OnTrackingVolumeChanged(m_Controls->m_VolumeSelectionBox->currentText()); GetDataStorage()->Add(m_TrackingVolumeNode); } else { GetDataStorage()->Remove(m_TrackingVolumeNode); GlobalReinit(); } } void QmitkMITKIGTTrackingToolboxView::OnAutoDetectTools() { if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() == mitk::NDIAurora) { + DisableTrackingConfigurationButtons(); mitk::NDITrackingDevice::Pointer currentDevice = dynamic_cast(m_Controls->m_configurationWidget->GetTrackingDevice().GetPointer()); currentDevice->OpenConnection(); currentDevice->StartTracking(); mitk::NavigationToolStorage::Pointer autoDetectedStorage = mitk::NavigationToolStorage::New(this->GetDataStorage()); for (int i=0; iGetToolCount(); i++) { //create a navigation tool with sphere as surface std::stringstream toolname; toolname << "AutoDetectedTool" << i; mitk::NavigationTool::Pointer newTool = mitk::NavigationTool::New(); newTool->SetSerialNumber(dynamic_cast(currentDevice->GetTool(i))->GetSerialNumber()); newTool->SetIdentifier(toolname.str()); newTool->SetTrackingDeviceType(mitk::NDIAurora); mitk::DataNode::Pointer newNode = mitk::DataNode::New(); mitk::Surface::Pointer mySphere = mitk::Surface::New(); vtkSphereSource *vtkData = vtkSphereSource::New(); vtkData->SetRadius(3.0f); vtkData->SetCenter(0.0, 0.0, 0.0); vtkData->Update(); mySphere->SetVtkPolyData(vtkData->GetOutput()); vtkData->Delete(); newNode->SetData(mySphere); newNode->SetName(toolname.str()); newTool->SetDataNode(newNode); autoDetectedStorage->AddTool(newTool); } //save detected tools m_toolStorage = autoDetectedStorage; //update label QString toolLabel = QString("Loaded Tools: ") + QString::number(m_toolStorage->GetToolCount()) + " Tools (Auto Detected)"; m_Controls->m_toolLabel->setText(toolLabel); //update tool preview m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); currentDevice->StopTracking(); currentDevice->CloseConnection(); + EnableTrackingConfigurationButtons(); + if (m_toolStorage->GetToolCount()>0) { //ask the user if he wants to save the detected tools QMessageBox msgBox; msgBox.setText("Found " + QString::number(m_toolStorage->GetToolCount()) + " tools!"); msgBox.setInformativeText("Do you want to save this tools as tool storage, so you can load them again?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); if (ret == 16384) //yes { //ask the user for a filename QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"),"",tr("*.*")); mitk::NavigationToolStorageSerializer::Pointer mySerializer = mitk::NavigationToolStorageSerializer::New(); if (!mySerializer->Serialize(fileName.toStdString(),m_toolStorage)) MessageBox(mySerializer->GetErrorMessage()); return; } else if (ret == 65536) //no { return; } } + } } void QmitkMITKIGTTrackingToolboxView::MessageBox(std::string s) { QMessageBox msgBox; msgBox.setText(s.c_str()); msgBox.exec(); } void QmitkMITKIGTTrackingToolboxView::UpdateTrackingTimer() { m_ToolVisualizationFilter->Update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); if (m_logging) { this->m_loggingFilter->Update(); m_loggedFrames = this->m_loggingFilter->GetRecordCounter(); this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: "+QString::number(m_loggedFrames)); //check if logging stopped automatically if((m_loggedFrames>1)&&(!m_loggingFilter->GetRecording())){StopLogging();} } m_Controls->m_TrackingToolsStatusWidget->Refresh(); } void QmitkMITKIGTTrackingToolboxView::OnChooseFileClicked() { QString filename = QFileDialog::getSaveFileName(NULL,tr("Choose Logging File"), "/", "*.*"); this->m_Controls->m_LoggingFileName->setText(filename); } void QmitkMITKIGTTrackingToolboxView::StartLogging() { if (!m_logging) { //initialize logging filter m_loggingFilter = mitk::NavigationDataRecorder::New(); m_loggingFilter->SetRecordingMode(mitk::NavigationDataRecorder::NormalFile); if (m_Controls->m_xmlFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::xml); else if (m_Controls->m_csvFormat->isChecked()) m_loggingFilter->SetOutputFormat(mitk::NavigationDataRecorder::csv); m_loggingFilter->SetFileName(m_Controls->m_LoggingFileName->text().toStdString().c_str()); if (m_Controls->m_LoggingLimit->isChecked()){m_loggingFilter->SetRecordCountLimit(m_Controls->m_LoggedFramesLimit->value());} //connect filter for(int i=0; iGetNumberOfOutputs(); i++){m_loggingFilter->AddNavigationData(m_ToolVisualizationFilter->GetOutput(i));} //start filter m_loggingFilter->StartRecording(); //update labels / logging variables this->m_Controls->m_LoggingLabel->setText("Logging ON"); this->m_Controls->m_LoggedFramesLabel->setText("Logged Frames: 0"); m_loggedFrames = 0; m_logging = true; DisableLoggingButtons(); } } void QmitkMITKIGTTrackingToolboxView::StopLogging() { if (m_logging) { //update label this->m_Controls->m_LoggingLabel->setText("Logging OFF"); m_loggingFilter->StopRecording(); m_logging = false; EnableLoggingButtons(); } } +void QmitkMITKIGTTrackingToolboxView::OnAddSingleTool() + { + QString Identifier = "Tool#"; + if (m_toolStorage.IsNotNull()) Identifier += QString::number(m_toolStorage->GetToolCount()); + else Identifier += "0"; + m_Controls->m_NavigationToolCreationWidget->Initialize(GetDataStorage(),Identifier.toStdString()); + m_Controls->m_NavigationToolCreationWidget->SetTrackingDeviceType(m_Controls->m_configurationWidget->GetTrackingDevice()->GetType(),false); + m_Controls->m_TrackingToolsWidget->setCurrentIndex(1); + + } + +void QmitkMITKIGTTrackingToolboxView::OnAddSingleToolFinished() + { + m_Controls->m_TrackingToolsWidget->setCurrentIndex(0); + if (this->m_toolStorage.IsNull()) m_toolStorage = mitk::NavigationToolStorage::New(GetDataStorage()); + m_toolStorage->AddTool(m_Controls->m_NavigationToolCreationWidget->GetCreatedTool()); + m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); + QString toolLabel = QString("Loaded Tools: "); + } + +void QmitkMITKIGTTrackingToolboxView::OnAddSingleToolCanceled() + { + m_Controls->m_TrackingToolsWidget->setCurrentIndex(0); + } + + void QmitkMITKIGTTrackingToolboxView::GlobalReinit() { // get all nodes that have not set "includeInBoundingBox" to false mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDataStorage()->GetSubset(pred); // calculate bounding geometry of these nodes mitk::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); // initialize the views to the bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(bounds); } void QmitkMITKIGTTrackingToolboxView::DisableLoggingButtons() { m_Controls->m_StartLogging->setEnabled(false); m_Controls->m_LoggingFileName->setEnabled(false); m_Controls->m_ChooseFile->setEnabled(false); m_Controls->m_LoggingLimit->setEnabled(false); m_Controls->m_LoggedFramesLimit->setEnabled(false); m_Controls->m_csvFormat->setEnabled(false); m_Controls->m_xmlFormat->setEnabled(false); m_Controls->m_StopLogging->setEnabled(true); } void QmitkMITKIGTTrackingToolboxView::EnableLoggingButtons() { m_Controls->m_StartLogging->setEnabled(true); m_Controls->m_LoggingFileName->setEnabled(true); m_Controls->m_ChooseFile->setEnabled(true); m_Controls->m_LoggingLimit->setEnabled(true); m_Controls->m_LoggedFramesLimit->setEnabled(true); m_Controls->m_csvFormat->setEnabled(true); m_Controls->m_xmlFormat->setEnabled(true); m_Controls->m_StopLogging->setEnabled(false); } void QmitkMITKIGTTrackingToolboxView::DisableOptionsButtons() { m_Controls->m_ShowTrackingVolume->setEnabled(false); m_Controls->m_UpdateRate->setEnabled(false); m_Controls->m_ShowToolQuaternions->setEnabled(false); m_Controls->m_OptionsUpdateRateLabel->setEnabled(false); } void QmitkMITKIGTTrackingToolboxView::EnableOptionsButtons() { m_Controls->m_ShowTrackingVolume->setEnabled(true); m_Controls->m_UpdateRate->setEnabled(true); m_Controls->m_ShowToolQuaternions->setEnabled(true); m_Controls->m_OptionsUpdateRateLabel->setEnabled(true); } +void QmitkMITKIGTTrackingToolboxView::EnableTrackingConfigurationButtons() +{ + m_Controls->m_AutoDetectTools->setEnabled(true); + if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() != mitk::NDIAurora) m_Controls->m_AddSingleTool->setEnabled(true); + m_Controls->m_LoadTools->setEnabled(true); + m_Controls->m_ResetTools->setEnabled(true); +} + +void QmitkMITKIGTTrackingToolboxView::DisableTrackingConfigurationButtons() +{ + m_Controls->m_AutoDetectTools->setEnabled(false); + if (m_Controls->m_configurationWidget->GetTrackingDevice()->GetType() != mitk::NDIAurora) m_Controls->m_AddSingleTool->setEnabled(false); + m_Controls->m_LoadTools->setEnabled(false); + m_Controls->m_ResetTools->setEnabled(false); +} + diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h index 0ff54294d2..378fd25e80 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxView.h @@ -1,149 +1,162 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkMITKIGTTrackingToolboxView_h #define QmitkMITKIGTTrackingToolboxView_h #include #include #include "ui_QmitkMITKIGTTrackingToolboxViewControls.h" //mitk headers #include #include #include #include //QT headers #include /*! \brief QmitkMITKIGTTrackingToolboxView This is the view of the bundle IGT Tracking Toolbox. The IGT Tracking Toolbox can be used to access tracking devices with MITK-IGT. The Tracking Toolbox can be used to log tracking data in XML or CSV format for measurement purposes. The Tracking Toolbox further allows for visualization of tools with given surfaces in combination with the NaviagtionToolManager. \sa QmitkFunctionality \ingroup Functionalities */ class QmitkMITKIGTTrackingToolboxView : public QmitkFunctionality { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkMITKIGTTrackingToolboxView(); QmitkMITKIGTTrackingToolboxView(const QmitkMITKIGTTrackingToolboxView& other) { Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } virtual ~QmitkMITKIGTTrackingToolboxView(); virtual void CreateQtPartControl(QWidget *parent); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); protected slots: /** @brief This slot is called if the user wants to load a new tool file. A new window opens where the user can choose a file. If the chosen file is corrupt or not valid the user gets an error message. If the file was loaded successfully the tools are show in the tool status widget. */ void OnLoadTools(); /** @brief This slot tries to start tracking with the current device. If start tracking fails the user gets an error message and tracking stays off.*/ void OnStartTracking(); /** @brief This slot stops tracking. If tracking is not strated it does nothing.*/ void OnStopTracking(); /** @brief This slot is called if the user want's to choose a file name for logging. A new windows to navigate through the file system and choose a file opens.*/ void OnChooseFileClicked(); /** @brief This slot starts logging. Logging is only possible if a device is tracking. If not the logging mechanism start when the start tracking is called.*/ void StartLogging(); /** @brief This slot stops logging. If logging is not running it does nothing.*/ void StopLogging(); /** @brief This slot enables / disables UI elements depending on the tracking device after a device is changed.*/ void OnTrackingDeviceChanged(); /** @brief This slot selects the Tracking Volume appropriate for a given model */ void OnTrackingVolumeChanged(QString qstr); /** @brief Shows or hides the tracking volume according to the checkboxe's state */ void OnShowTrackingVolumeChanged(); /** @brief This slot auto detects tools of a NDI Aurora tracking device. If tools where found they will be stored internally as a tool storage. The user is also asked if he wants to save this tool storage to load it later. Only call it if a Aurora device was configured because other devices don't support auto detection.*/ void OnAutoDetectTools(); /** @brief Slot for tracking timer. The timer updates the IGT pipline and also the logging filter if logging is activated.*/ void UpdateTrackingTimer(); + /** @brief Resets the Tracking Tools: this means all tools are removed. */ + void OnResetTools(); + + /** @brief Opens a dialog where a new navigation tool can be created. */ + void OnAddSingleTool(); + + /** @brief This slot is called if the user finishes the creation of a new tool. */ + void OnAddSingleToolFinished(); + + /** @brief This slot is called if the user cancels the creation of a new tool. */ + void OnAddSingleToolCanceled(); protected: Ui::QmitkMITKIGTTrackingToolboxViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; bool m_tracking; ///> bool which is true if tracking is running, false if not bool m_logging; ///> bool which is true if logging is running, false if not int m_loggedFrames; ///> stores the current number of logged frames if logging is on mitk::NavigationToolStorage::Pointer m_toolStorage; ///>stores the loaded tools mitk::DataNode::Pointer m_TrackingVolumeNode; ///>holds the data node of the tracking volume if volume is visualized /** @brief Shows a message box with the text given as parameter. */ void MessageBox(std::string s); /** @brief reinits the view globally. */ void GlobalReinit(); //members for the filter pipeline mitk::TrackingDeviceSource::Pointer m_TrackingDeviceSource; ///> member for the source of the IGT pipeline mitk::NavigationDataObjectVisualizationFilter::Pointer m_ToolVisualizationFilter; ///> holds the tool visualization filter (second filter of the IGT pipeline) mitk::NavigationDataRecorder::Pointer m_loggingFilter; ///> holds the logging filter if logging is on (third filter of the IGT pipeline) /** @brief This timer updates the IGT pipline and also the logging filter if logging is activated.*/ QTimer* m_TrackingTimer; //help methods for enable/disable buttons void DisableLoggingButtons(); void EnableLoggingButtons(); void DisableOptionsButtons(); void EnableOptionsButtons(); + void EnableTrackingConfigurationButtons(); + void DisableTrackingConfigurationButtons(); }; #endif // _QMITKMITKIGTTRACKINGTOOLBOXVIEW_H_INCLUDED \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui index eaa4286805..eeb8f20179 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui +++ b/Modules/Bundles/org.mitk.gui.qt.igttrackingtoolbox/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui @@ -1,544 +1,630 @@ QmitkMITKIGTTrackingToolboxViewControls 0 0 - 371 - 697 + 377 + 849 0 0 QmitkTemplate 0 Tracking - + 0 0 0 300 16777215 280 0 0 - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Tools</span></p></body></html> - - - - - Loaded Tools: <none> - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Auto Detection - - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + 0 + + + 0 + + + + + + + + + Loaded Tools: <none> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Auto Detection + + + + + + + + + + 200 + 150 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Add Single Tool + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">(only load tool storage files which can be created </span></p> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">with the bundle &quot;NavigationToolManager&quot;)</span></p></body></html> - - - Qt::AlignJustify|Qt::AlignVCenter - +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">(only load tool storage files created </span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-style:italic;">with </span><span style=" font-size:8pt; font-style:italic;">the &quot;NavigationToolManager&quot;)</span></p></body></html> + + + Qt::AlignJustify|Qt::AlignVCenter + + + + + + + + 110 + 0 + + + + Load Tool Storage + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + Reset + + + + + + + + + + + + + + - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Load Tools - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Tracking Control</span></p></body></html> Status: <not configured> Qt::Horizontal 40 20 + + + 110 + 0 + + Start Tracking Qt::Horizontal 40 20 + + + 110 + 0 + + Stop Tracking Qt::Vertical 20 40 Options true Show Tracking Volume true Select Model: - - - - Qt::Vertical - - - - 20 - 40 - - - - Qt::Horizontal - - - - Qt::Vertical - - - - 20 - 40 - - - - Update Rate (Times Per Second) Qt::Horizontal 40 20 999 10 Show Tool Quaternions Qt::Vertical 20 597 Logging Filename: C:/logfile.csv Choose File Limit Number Of Logged Frames: Qt::Horizontal 40 20 1 9999 300 CSV format true XML format Logging Status Logging OFF Logged Frames: 0 Qt::Horizontal 40 20 Start Logging Stop Logging Qt::Vertical 20 40 QmitkTrackingDeviceConfigurationWidget QWidget
QmitkTrackingDeviceConfigurationWidget.h
1
QmitkToolTrackingStatusWidget QWidget
QmitkToolTrackingStatusWidget.h
1
+ + QmitkNavigationToolCreationWidget + QWidget +
QmitkNavigationToolCreationWidget.h
+ 1 +
diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.cpp b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.cpp new file mode 100644 index 0000000000..4a41d52375 --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.cpp @@ -0,0 +1,234 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-12 19:14:45 +0200 (Di, 12 Mai 2009) $ +Version: $Revision: 1.12 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkNavigationToolCreationWidget.h" + +//mitk headers +#include "mitkTrackingTypes.h" +#include +#include + +//qt headers +#include +#include + +//poco headers +#include + +// vtk +#include + +const std::string QmitkNavigationToolCreationWidget::VIEW_ID = "org.mitk.views.navigationtoolcreationwizardwidget"; + +QmitkNavigationToolCreationWidget::QmitkNavigationToolCreationWidget(QWidget* parent, Qt::WindowFlags f) + : QWidget(parent, f) +{ + m_Controls = NULL; + CreateQtPartControl(this); + CreateConnections(); +} + + +QmitkNavigationToolCreationWidget::~QmitkNavigationToolCreationWidget() +{ +} + +void QmitkNavigationToolCreationWidget::CreateQtPartControl(QWidget *parent) + { + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkNavigationToolCreationWidgetControls; + m_Controls->setupUi(parent); + } + } + +void QmitkNavigationToolCreationWidget::CreateConnections() + { + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_cancel), SIGNAL(clicked()), this, SLOT(OnCancel()) ); + connect( (QObject*)(m_Controls->m_finished), SIGNAL(clicked()), this, SLOT(OnFinished()) ); + connect( (QObject*)(m_Controls->m_LoadSurface), SIGNAL(clicked()), this, SLOT(OnLoadSurface()) ); + connect( (QObject*)(m_Controls->m_LoadCalibrationFile), SIGNAL(clicked()), this, SLOT(OnLoadCalibrationFile()) ); + } + } + +void QmitkNavigationToolCreationWidget::Initialize(mitk::DataStorage* dataStorage, std::string supposedIdentifier) + { + m_DataStorage = dataStorage; + m_Controls->m_IdentifierEdit->setText(QString(supposedIdentifier.c_str())); + + //initialize UI components + m_Controls->m_SurfaceChooser->SetDataStorage(m_DataStorage); + m_Controls->m_SurfaceChooser->SetAutoSelectNewItems(true); + m_Controls->m_SurfaceChooser->SetPredicate(mitk::NodePredicateDataType::New("Surface")); + + //set default data + m_Controls->m_ToolNameEdit->setText("NewTool"); + m_Controls->m_CalibrationFileName->setText(""); + m_Controls->m_SerialNumberEdit->setText(""); + m_Controls->m_Surface_Use_Sphere->setChecked(true); + m_Controls->m_ToolTypeChooser->setCurrentIndex(0); + + } + +void QmitkNavigationToolCreationWidget::SetTrackingDeviceType(mitk::TrackingDeviceType type, bool changeable) + { + switch(type) + { + case mitk::NDIAurora: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(0);break; + case mitk::NDIPolaris: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(1);break; + case mitk::ClaronMicron: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(2);break; + default: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(0); + } + m_Controls->m_TrackingDeviceTypeChooser->setEnabled(changeable); + } + + + +//################################################################################## +//############################## slots ############################ +//################################################################################## + +void QmitkNavigationToolCreationWidget::OnFinished() + { + //here we create a new tool + m_CreatedTool = mitk::NavigationTool::New(); + + //create DataNode... + mitk::DataNode::Pointer newNode = mitk::DataNode::New(); + newNode->SetName(m_Controls->m_ToolNameEdit->text().toLatin1()); + if(m_Controls->m_Surface_Use_Sphere->isChecked()) + { + //create small sphere and use it as surface + mitk::Surface::Pointer mySphere = mitk::Surface::New(); + vtkSphereSource *vtkData = vtkSphereSource::New(); + vtkData->SetRadius(3.0f); + vtkData->SetCenter(0.0, 0.0, 0.0); + vtkData->Update(); + mySphere->SetVtkPolyData(vtkData->GetOutput()); + vtkData->Delete(); + newNode->SetData(mySphere); + } + else {newNode->SetData(m_Controls->m_SurfaceChooser->GetSelectedNode()->GetData());} + + m_CreatedTool->SetDataNode(newNode); + + //fill NavigationTool object + m_CreatedTool->SetCalibrationFile(m_Controls->m_CalibrationFileName->text().toAscii().data()); + m_CreatedTool->SetIdentifier(m_Controls->m_IdentifierEdit->text().toAscii().data()); + m_CreatedTool->SetSerialNumber(m_Controls->m_SerialNumberEdit->text().toAscii().data()); + + //Tracking Device + if (m_Controls->m_TrackingDeviceTypeChooser->currentText()=="NDI Aurora") m_CreatedTool->SetTrackingDeviceType(mitk::NDIAurora); + else if (m_Controls->m_TrackingDeviceTypeChooser->currentText()=="NDI Polaris") m_CreatedTool->SetTrackingDeviceType(mitk::NDIPolaris); + else if (m_Controls->m_TrackingDeviceTypeChooser->currentText()=="Claron Technology Micron Tracker") m_CreatedTool->SetTrackingDeviceType(mitk::ClaronMicron); + else m_CreatedTool->SetTrackingDeviceType(mitk::TrackingSystemNotSpecified); + + //ToolType + if (m_Controls->m_ToolTypeChooser->currentText()=="Instrument") m_CreatedTool->SetType(mitk::NavigationTool::Instrument); + else if (m_Controls->m_ToolTypeChooser->currentText()=="Fiducial") m_CreatedTool->SetType(mitk::NavigationTool::Fiducial); + else if (m_Controls->m_ToolTypeChooser->currentText()=="Skinmarker") m_CreatedTool->SetType(mitk::NavigationTool::Skinmarker); + else m_CreatedTool->SetType(mitk::NavigationTool::Unknown); + + emit NavigationToolFinished(); + } + +void QmitkNavigationToolCreationWidget::OnCancel() + { + m_CreatedTool = NULL; + emit Canceled(); + } + +void QmitkNavigationToolCreationWidget::OnLoadSurface() + { + std::string filename = QFileDialog::getOpenFileName(NULL,tr("Open Surface"), "/", "*.stl").toLatin1().data(); + mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); + try + { + stlReader->SetFileName( filename.c_str() ); + stlReader->Update(); + } + catch (...) + { + } + + if ( stlReader->GetOutput() == NULL ); + else + { + mitk::DataNode::Pointer newNode = mitk::DataNode::New(); + newNode->SetName(filename); + newNode->SetData(stlReader->GetOutput()); + m_DataStorage->Add(newNode); + } + } + +void QmitkNavigationToolCreationWidget::OnLoadCalibrationFile() + { + m_Controls->m_CalibrationFileName->setText(QFileDialog::getOpenFileName(NULL,tr("Open Calibration File"), "/", "*.*")); + } + +void QmitkNavigationToolCreationWidget::SetDefaultData(mitk::NavigationTool::Pointer DefaultTool) + { + m_Controls->m_ToolNameEdit->setText(QString(DefaultTool->GetDataNode()->GetName().c_str())); + m_Controls->m_IdentifierEdit->setText(QString(DefaultTool->GetIdentifier().c_str())); + m_Controls->m_SerialNumberEdit->setText(QString(DefaultTool->GetSerialNumber().c_str())); + switch(DefaultTool->GetTrackingDeviceType()) + { + case mitk::NDIAurora: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(0);break; + case mitk::NDIPolaris: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(1);break; + case mitk::ClaronMicron: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(2);break; + default: + m_Controls->m_TrackingDeviceTypeChooser->setCurrentIndex(0); + } + m_Controls->m_CalibrationFileName->setText(QString(DefaultTool->GetCalibrationFile().c_str())); + m_Controls->m_Surface_Use_Other->setChecked(true); + switch(DefaultTool->GetType()) + { + case mitk::NavigationTool::Instrument: + m_Controls->m_ToolTypeChooser->setCurrentIndex(0); break; + case mitk::NavigationTool::Fiducial: + m_Controls->m_ToolTypeChooser->setCurrentIndex(1); break; + case mitk::NavigationTool::Skinmarker: + m_Controls->m_ToolTypeChooser->setCurrentIndex(2); break; + case mitk::NavigationTool::Unknown: + m_Controls->m_ToolTypeChooser->setCurrentIndex(3); break; + } + + m_Controls->m_SurfaceChooser->SetSelectedNode(DefaultTool->GetDataNode()); + + } + + + +//################################################################################## +//############################## internal help methods ############################# +//################################################################################## +void QmitkNavigationToolCreationWidget::MessageBox(std::string s) + { + QMessageBox msgBox; + msgBox.setText(s.c_str()); + msgBox.exec(); + } \ No newline at end of file diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h new file mode 100644 index 0000000000..addfffb96b --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h @@ -0,0 +1,101 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-12 19:14:45 +0200 (Di, 12 Mai 2009) $ +Version: $Revision: 1.12 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkNavigationToolCreationWidget_H +#define QmitkNavigationToolCreationWidget_H + +//QT headers +#include + +//mitk headers +#include "MitkIGTUIExports.h" +#include +#include +#include + +//ui header +#include "ui_QmitkNavigationToolCreationWidget.h" + + /** Documentation: + * \brief An object of this class offers an UI to create new NavigationTools + * + * Be sure to call the Initialize-methode before you start the widget + * otherwise some errors might occure. + * + * \ingroup IGTUI + */ +class MitkIGTUI_EXPORT QmitkNavigationToolCreationWidget : public QWidget +{ + Q_OBJECT + + public: + static const std::string VIEW_ID; + + /** @brief Initializes the widget. + * @param dataStorage The data storage is needed to offer the possibility to choose surfaces from the data storage for tool visualization. + * @param supposedIdentifier This Identifier is supposed for the user. It is needed because every identifier in a navigation tool storage must be unique and we don't know the others. + */ + void Initialize(mitk::DataStorage* dataStorage, std::string supposedIdentifier); + + /** @brief Sets the default tracking device type. You may also define if it is changeable or not.*/ + void SetTrackingDeviceType(mitk::TrackingDeviceType type, bool changeable = true); + + /** @brief Sets the default data of all input fields. The default data is used from the default tool which is given as parameter. */ + void SetDefaultData(mitk::NavigationTool::Pointer DefaultTool); + + QmitkNavigationToolCreationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + ~QmitkNavigationToolCreationWidget(); + + /** @return Returns the created tool. Returns NULL if no tool was created yet. */ + itkGetConstMacro(CreatedTool,mitk::NavigationTool::Pointer); + + signals: + + /** @brief This signal is emited if the user finished the creation of the tool. */ + void NavigationToolFinished(); + + /** @brief This signal is emited if the user canceld the creation of the tool. */ + void Canceled(); + + protected slots: + + void OnCancel(); + void OnFinished(); + void OnLoadSurface(); + void OnLoadCalibrationFile(); + + + protected: + + /// \brief Creation of the connections + virtual void CreateConnections(); + + virtual void CreateQtPartControl(QWidget *parent); + + Ui::QmitkNavigationToolCreationWidgetControls* m_Controls; + + /** @brief holds the DataStorage */ + mitk::DataStorage* m_DataStorage; + + /** @brief this pointer holds the tool which is created */ + mitk::NavigationTool::Pointer m_CreatedTool; + + //############## private help methods ####################### + void MessageBox(std::string s); + +}; +#endif \ No newline at end of file diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.ui b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.ui new file mode 100644 index 0000000000..547a1a4e2c --- /dev/null +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.ui @@ -0,0 +1,414 @@ + + + QmitkNavigationToolCreationWidgetControls + + + + 0 + 0 + 321 + 272 + + + + Form + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; text-decoration: underline;">New Navigation Tool</span></p></body></html> + + + + + + + + + Device Type: + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + + NDI Aurora + + + + + NDI Polaris + + + + + Claron Technology Micron Tracker + + + + + + + + + + 0 + + + + + 0 + 0 + 303 + 83 + + + + Basic Information + + + + + + + + + 100 + 0 + + + + Name: + + + + + + + NewTool + + + + + + + + + + + + 100 + 0 + + + + Calibration File: + + + + + + + <not given> + + + + + + + + 40 + 16777215 + + + + Load + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + 0 + 307 + 72 + + + + Tool Visualization + + + + + + Use Simple Sphere + + + true + + + + + + + + + Use Surface: + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + + + + + + 40 + 16777215 + + + + Load + + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + Advanced + + + + + + + + + 100 + 0 + + + + Tool Type: + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + + Instrument + + + + + Fiducial + + + + + Skinmarker + + + + + Unkown + + + + + + + + + + + + + 100 + 0 + + + + Identifier: + + + + + + + <not given> + + + + + + + + + + + + 100 + 0 + + + + Serial Number: + + + + + + + <not given> + + + + + + + + + Qt::Vertical + + + + 20 + 7 + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Finished + + + + + + + + + + QmitkDataStorageComboBox + QComboBox +
QmitkDataStorageComboBox.h
+
+
+ + +
diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp index c012803294..546a94ced3 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.cpp @@ -1,225 +1,268 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ Version: $Revision: 16719 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkToolTrackingStatusWidget.h" QmitkToolTrackingStatusWidget::QmitkToolTrackingStatusWidget(QWidget* parent) : QWidget(parent), m_Controls(NULL), m_StatusLabels (NULL), m_NavigationDatas(NULL) { - this->CreateQtPartControl( this ); m_ShowPositions = false; m_ShowQuaternions = false; m_Alignment = Qt::AlignHCenter; m_Style = QmitkToolTrackingStatusWidget::VerticalUpperStyle; + + CreateQtPartControl( this ); + } void QmitkToolTrackingStatusWidget::SetStyle(QmitkToolTrackingStatusWidget::Style newStyle) { + //set new style m_Style = newStyle; + + //update current labels to show them in the new style + Refresh(); } void QmitkToolTrackingStatusWidget::SetShowPositions(bool enable) { m_ShowPositions = enable; + + //update current labels + Refresh(); } void QmitkToolTrackingStatusWidget::SetShowQuaternions(bool enable) { m_ShowQuaternions = enable; + + //update current labels + Refresh(); } void QmitkToolTrackingStatusWidget::SetTextAlignment(Qt::AlignmentFlag alignment) { m_Alignment = alignment; + + //update current labels + Refresh(); } QmitkToolTrackingStatusWidget::~QmitkToolTrackingStatusWidget() { //m_Controls = NULL; delete m_StatusLabels; delete m_NavigationDatas; } void QmitkToolTrackingStatusWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToolTrackingStatusWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); + + //add empty label + AddEmptyLabel(); } } void QmitkToolTrackingStatusWidget::CreateConnections() { } void QmitkToolTrackingStatusWidget::SetNavigationDatas(std::vector* navDatas) { m_NavigationDatas = navDatas; } void QmitkToolTrackingStatusWidget::AddNavigationData(mitk::NavigationData::Pointer nd) { if(m_NavigationDatas == NULL) m_NavigationDatas = new std::vector(); m_NavigationDatas->push_back(nd); } void QmitkToolTrackingStatusWidget::Refresh() { if(m_NavigationDatas == NULL || m_NavigationDatas->size() <= 0) + { + RemoveGuiLabels(); + AddEmptyLabel(); return; + } + mitk::NavigationData* navData; for(unsigned int i = 0; i < m_NavigationDatas->size(); i++) { navData = m_NavigationDatas->at(i).GetPointer(); QString name(navData->GetName()); QString pos = ""; QString quat = ""; if (m_ShowPositions) { mitk::Point3D position = navData->GetPosition(); pos = " [" + QString::number(position[0]) + ";" + QString::number(position[1]) + ";" + QString::number(position[2]) + "]"; } if (m_ShowQuaternions) { mitk::Quaternion quaternion = navData->GetOrientation(); quat = " / [qx:" + QString::number(quaternion.x()) + ";qy:" + QString::number(quaternion.y()) + ";qz:" + QString::number(quaternion.z()) + ";qr:" + QString::number(quaternion.r()) + "]"; } if(name.compare(m_StatusLabels->at(i)->objectName()) == 0) { m_StatusLabels->at(i)->setText(name+pos+quat); if(navData->IsDataValid()) m_StatusLabels->at(i)->setStyleSheet("QLabel{background-color: #8bff8b }"); else m_StatusLabels->at(i)->setStyleSheet("QLabel{background-color: #ff7878 }"); } } } void QmitkToolTrackingStatusWidget::ShowStatusLabels() { RemoveGuiLabels(); if(m_NavigationDatas == NULL || m_NavigationDatas->size() <= 0) + { + RemoveGuiLabels(); + AddEmptyLabel(); return; + } m_StatusLabels = new QVector(); mitk::NavigationData* navData; QLabel* label; for(unsigned int i = 0; i < m_NavigationDatas->size(); i++) { navData = m_NavigationDatas->at(i).GetPointer(); QString name(navData->GetName()); label = new QLabel(name, this); label->setObjectName(name); label->setAlignment(m_Alignment | Qt::AlignVCenter); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_StatusLabels->append(label); if (m_Style == QmitkToolTrackingStatusWidget::VerticalUpperStyle) m_Controls->m_VerticalLayout->addWidget(m_StatusLabels->at(i)); else m_Controls->m_GridLayout->addWidget(m_StatusLabels->at(i),0,i); } } void QmitkToolTrackingStatusWidget::PreShowTools(mitk::NavigationToolStorage::Pointer toolStorage) { + RemoveGuiLabels(); QLabel* label; for(unsigned int i = 0; i < toolStorage->GetToolCount(); i++) { QString name(toolStorage->GetTool(i)->GetToolName().c_str()); label = new QLabel(name, this); label->setObjectName(name); label->setAlignment(m_Alignment | Qt::AlignVCenter); label->setFrameStyle(QFrame::Panel | QFrame::Sunken); + label->setStyleSheet("QLabel{background-color: #dddddd }"); if (m_Style == QmitkToolTrackingStatusWidget::VerticalUpperStyle) m_Controls->m_VerticalLayout->addWidget(label); else m_Controls->m_GridLayout->addWidget(label); } } void QmitkToolTrackingStatusWidget::RemoveStatusLabels() { //remove GUI elements RemoveGuiLabels(); //clear members if(m_StatusLabels != NULL && m_StatusLabels->size() > 0) { delete m_StatusLabels; m_StatusLabels = new QVector< QLabel* >(); } if(m_NavigationDatas != NULL && m_NavigationDatas->size() > 0) { delete m_NavigationDatas; m_NavigationDatas = new std::vector(); } + //add empty label + AddEmptyLabel(); + } void QmitkToolTrackingStatusWidget::RemoveGuiLabels() { while(m_Controls->m_GridLayout->count() > 0 || m_Controls->m_VerticalLayout->count() > 0) { if (m_Controls->m_GridLayout->count() > 0) { QWidget* actWidget = m_Controls->m_GridLayout->itemAt(0)->widget(); m_Controls->m_GridLayout->removeWidget(actWidget); delete actWidget; } else if (m_Controls->m_VerticalLayout->count() > 0) { QWidget* actWidget = m_Controls->m_VerticalLayout->itemAt(0)->widget(); m_Controls->m_VerticalLayout->removeWidget(actWidget); delete actWidget; } } } +void QmitkToolTrackingStatusWidget::AddEmptyLabel() + { + //add a label which tells that no tools are loaded yet + QLabel* label = new QLabel("No tools loaded yet.", this); + label->setObjectName("No tools loaded yet."); + label->setAlignment(m_Alignment | Qt::AlignVCenter); + label->setFrameStyle(QFrame::Panel | QFrame::Sunken); + label->setStyleSheet("QLabel{background-color: #dddddd }"); + if (m_Style == QmitkToolTrackingStatusWidget::VerticalUpperStyle) m_Controls->m_VerticalLayout->addWidget(label); + else m_Controls->m_GridLayout->addWidget(label); + } diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h index f3272764e9..88673dc88a 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h @@ -1,133 +1,139 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-03-21 19:27:37 +0100 (Sa, 21 Mrz 2009) $ Version: $Revision: 16719 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _QmitkToolTrackingStatusWidget_H_INCLUDED #define _QmitkToolTrackingStatusWidget_H_INCLUDED #include "ui_QmitkToolTrackingStatusWidgetControls.h" #include "MitkIGTUIExports.h" #include #include #include #include /*! \brief QmitkToolTrackingStatusWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MitkIGTUI_EXPORT QmitkToolTrackingStatusWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: typedef std::vector< mitk::NavigationData::Pointer > NavigationDataPointerArray; enum Style { GridLowerStyle, VerticalUpperStyle }; /*! \brief default constructor */ QmitkToolTrackingStatusWidget( QWidget* parent ); /*! \brief default destructor */ virtual ~QmitkToolTrackingStatusWidget(); /*! \brief Sets up the labels in this widget's QGridLayout for showing the track status of the tracking tools */ void ShowStatusLabels(); /*! \brief Sets the ND for this widget */ void SetNavigationDatas(std::vector* navDatas); void AddNavigationData(mitk::NavigationData::Pointer nd); /*! \brief Changes background color of status labels (green or red) to show if actual navigation data of each tool is valid. */ void Refresh(); /*! \brief Removes all status labels. */ void RemoveStatusLabels(); /** @brief Enables / disables if the tool positions are shown. Default is off.*/ void SetShowPositions(bool enable); /** @brief Enables / disables if the tool quaternions are shown. Default is off.*/ void SetShowQuaternions(bool enable); /** @brief Sets the text alignment of the tool labels. Default is center. Example: Use Qt::AlignLeft for left alignment. */ void SetTextAlignment(Qt::AlignmentFlag alignment); /** @brief Sets the alignment style of this widget: * GridLowerStyle: Tool labels are at the lower side of the widget in grid alignment * VerticalUpperStyle: Tool labels are at the upper side in a vertical alignment (default) */ void SetStyle(QmitkToolTrackingStatusWidget::Style newStyle); /** @brief Shows tool labels for the tools in the tool storage. This method can be called BEFORE connecting the navigation data to * make a preview of the tools. */ void PreShowTools(mitk::NavigationToolStorage::Pointer toolStorage); + + protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkToolTrackingStatusWidgetControls* m_Controls; ///< gui widgets private: /*! \brief Vector for all tool tracking status labels. */ QVector< QLabel* >* m_StatusLabels; std::vector* m_NavigationDatas; bool m_ShowPositions; bool m_ShowQuaternions; Qt::AlignmentFlag m_Alignment; QmitkToolTrackingStatusWidget::Style m_Style; void RemoveGuiLabels(); + /** @brief Adds an empty label which tells the user that currently no tool is availiable. */ + void AddEmptyLabel(); + + }; #endif // _QmitkToolTrackingStatusWidget_H_INCLUDED diff --git a/Modules/IGTUI/files.cmake b/Modules/IGTUI/files.cmake index 3d14e93b40..79d9ea4c21 100644 --- a/Modules/IGTUI/files.cmake +++ b/Modules/IGTUI/files.cmake @@ -1,57 +1,59 @@ SET(CPP_FILES Qmitk/QmitkTrackingDeviceWidget.cpp Qmitk/QmitkTrackingDeviceConfigurationWidget.cpp Qmitk/QmitkNDIConfigurationWidget.cpp Qmitk/QmitkFiducialRegistrationWidget.cpp Qmitk/QmitkNDIToolDelegate.cpp Qmitk/QmitkNavigationToolManagementWidget.cpp Qmitk/QmitkIGTLoggerWidget.cpp Qmitk/QmitkUpdateTimerWidget.cpp Qmitk/QmitkToolDistanceWidget.cpp Qmitk/QmitkToolTrackingStatusWidget.cpp Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.cpp Qmitk/QmitkIGTPlayerWidget.cpp Qmitk/QmitkIGTConnectionWidget.cpp Qmitk/QmitkToolSelectionWidget.cpp + Qmitk/QmitkNavigationToolCreationWidget.cpp ) SET(UI_FILES Qmitk/QmitkNavigationToolManagementWidgetControls.ui Qmitk/QmitkTrackingDeviceConfigurationWidgetControls.ui Qmitk/QmitkNDIConfigurationWidget.ui Qmitk/QmitkFiducialRegistrationWidget.ui Qmitk/QmitkIGTLoggerWidgetControls.ui Qmitk/QmitkUpdateTimerWidgetControls.ui Qmitk/QmitkToolDistanceWidgetControls.ui Qmitk/QmitkToolTrackingStatusWidgetControls.ui Qmitk/QmitkTrackingSourcesCheckBoxPanelWidgetControls.ui Qmitk/QmitkIGTPlayerWidgetControls.ui Qmitk/QmitkIGTConnectionWidgetControls.ui Qmitk/QmitkToolSelectionWidgetControls.ui + Qmitk/QmitkNavigationToolCreationWidget.ui ) SET(MOC_H_FILES Qmitk/QmitkNavigationToolManagementWidget.h Qmitk/QmitkTrackingDeviceWidget.h Qmitk/QmitkTrackingDeviceConfigurationWidget.h Qmitk/QmitkNDIConfigurationWidget.h Qmitk/QmitkFiducialRegistrationWidget.h Qmitk/QmitkNDIToolDelegate.h Qmitk/QmitkIGTLoggerWidget.h Qmitk/QmitkUpdateTimerWidget.h Qmitk/QmitkToolDistanceWidget.h Qmitk/QmitkToolTrackingStatusWidget.h Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h Qmitk/QmitkIGTPlayerWidget.h Qmitk/QmitkIGTConnectionWidget.h Qmitk/QmitkToolSelectionWidget.h + Qmitk/QmitkNavigationToolCreationWidget.h ) SET(QRC_FILES resources/IGTUI.qrc ) -