diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexample/src/internal/QmitkIGTRecorderView.cpp b/Modules/Bundles/org.mitk.gui.qt.igtexample/src/internal/QmitkIGTRecorderView.cpp index 27cbf18f93..465a13e3f8 100644 --- a/Modules/Bundles/org.mitk.gui.qt.igtexample/src/internal/QmitkIGTRecorderView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.igtexample/src/internal/QmitkIGTRecorderView.cpp @@ -1,367 +1,369 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-06 16:03:09 +0200 (Mi, 06 Mai 2009) $ Version: $Revision: 17113 $ 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 "QmitkIGTRecorderView.h" //#include "resources/icon.xpm" #include "QmitkStdMultiWidget.h" #include "mitkCone.h" #include "mitkInternalTrackingTool.h" #include "mitkNDIPassiveTool.h" #include "mitkNDITrackingDevice.h" #include "mitkTrackingVolumeGenerator.h" #include "mitkProperties.h" #include "QmitkNDIConfigurationWidget.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateAnd.h" #include "mitkNodePredicateNot.h" #include "mitkGroupTagProperty.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkStatusBar.h" QmitkIGTRecorderView::QmitkIGTRecorderView(QObject * /*parent*/, const char * /*name*/) : QmitkFunctionality() { m_Timer = new QTimer(this); m_RecordingTimer = new QTimer(this); m_PlayingTimer = new QTimer(this); //m_XValues.clear(); //m_YValues.clear(); m_Controls = NULL; } QmitkIGTRecorderView::~QmitkIGTRecorderView() { this->OnStopRecording(); // cleanup IGT pipeline, if tracking is in progress m_RecordingTimer->stop(); m_PlayingTimer->stop(); m_Recorder = NULL; //m_Player = NULL; m_RecordingTimer = NULL; m_PlayingTimer = NULL; } void QmitkIGTRecorderView::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { m_Controls = new Ui::QmitkIGTRecorderControls; m_Controls->setupUi(parent); m_ConfigWidget = new QmitkNDIConfigurationWidget(parent); mitk::NodePredicateAnd::Pointer pred = mitk::NodePredicateAnd::New( mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("already Assigned")), mitk::NodePredicateDataType::New("Surface")); // does not have assigned tag and is surface m_ConfigWidget->SetDataStorage(this->GetDefaultDataStorage()); m_ConfigWidget->SetPredicate(pred.GetPointer()); m_ConfigWidget->SetTagPropertyName("already Assigned"); m_ConfigWidget->SetTagProperty(mitk::GroupTagProperty::New().GetPointer()); // m_ConfigWidget->SetToolTypes(QStringList() << "Instrument"); m_Controls->m_DeviceConfigGroup->layout()->addWidget(m_ConfigWidget); // add ndi config widget this->CreateConnections(); } } void QmitkIGTRecorderView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkIGTRecorderView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkIGTRecorderView::CreateConnections() { if ( m_Controls ) { connect((QObject*)(m_Controls->m_StartRecording), SIGNAL(clicked()), (QObject*) this, SLOT(OnStartRecording())); connect((QObject*)(m_Controls->m_PauseRecording), SIGNAL(toggled (bool)), (QObject*) this, SLOT(OnPauseRecording(bool))); connect((QObject*)(m_Controls->m_StopRecording), SIGNAL(clicked()), (QObject*) this, SLOT(OnStopRecording())); connect((QObject*)(m_Controls->m_StartReplay), SIGNAL(clicked()), (QObject*) this, SLOT(OnStartReplaying())); connect((QObject*)(m_Controls->m_StopReplay), SIGNAL(clicked()), (QObject*) this, SLOT(OnStopReplaying())); connect((QObject*)(m_RecordingTimer), SIGNAL(timeout()), (QObject*) this, SLOT(RecordFrame())); connect((QObject*)(m_ConfigWidget), SIGNAL(Connected()), this, SLOT(OnConnect())); connect((QObject*)(m_ConfigWidget), SIGNAL(Disconnected()), this, SLOT(OnDisconnect())); } } void QmitkIGTRecorderView::OnStartRecording() { if (m_Source.IsNotNull()) if (m_Source->IsTracking()) return; if ((m_ConfigWidget == NULL)) return; mitk::TrackingDevice::Pointer tracker = m_ConfigWidget->GetTracker(); QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save tracking data to"),"D:/home/jochen/Versuche/2010.01.25 EM Messungen in der Speiseröhre" /*QDir::homePath()*/, tr("MITK Navigation Data XML logfile(*.xml)")); if (fileName.isEmpty()) return; // recorder! if (this->GetDefaultDataStorage()->GetNamedNode("Tracking Volume") == NULL) // add tracking volume node { mitk::TrackingVolumeGenerator::Pointer tvGenerator = mitk::TrackingVolumeGenerator::New(); tvGenerator->SetTrackingDeviceType(tracker->GetType()); + tvGenerator->Update(); mitk::Surface::Pointer tv = tvGenerator->GetOutput(); + mitk::DataNode::Pointer n = mitk::DataNode::New(); n->SetData(tv); n->SetName("Tracking Volume"); n->SetOpacity(0.1); n->SetColor(0.4, 0.4, 1.0); this->GetDefaultDataStorage()->Add(n); this->GetActiveStdMultiWidget()->SetWidgetPlanesVisibility(false); mitk::RenderingManager::GetInstance()->InitializeViews(this->GetDefaultDataStorage()->ComputeBoundingGeometry3D(this->GetDefaultDataStorage()->GetAll())); // reset render window geometry to include all objects } try { this->SetupIGTPipeline(tracker, fileName); //m_Source->Connect(); m_Source->StartTracking(); m_RecordingTimer->start(50); } catch (std::exception& e) { mitk::StatusBar::GetInstance()->DisplayText(QString("Error during navigation pipeline setup: %1").arg(e.what()).toLatin1(), 4000); m_RecordingTimer->stop(); } } void QmitkIGTRecorderView::OnStopRecording() { if (m_RecordingTimer != NULL) m_RecordingTimer->stop(); if (m_Recorder.IsNotNull()) m_Recorder->StopRecording(); if (m_Source.IsNotNull()) { m_Source->StopTracking(); //m_Source->Disconnect(); } m_MessageFilter = NULL; m_PointSetFilter = NULL; m_Recorder = NULL; m_Visualizer = NULL; //m_Source = NULL; } void QmitkIGTRecorderView::OnPauseRecording( bool pause ) { if (pause == true) m_RecordingTimer->stop(); else m_RecordingTimer->start(50); } void QmitkIGTRecorderView::RecordFrame() { try { bool updated = false; if ((m_Controls->m_UpdateTrajectory->checkState() == Qt::Checked) && (m_PointSetFilter.IsNotNull())) m_PointSetFilter->Update(); // update pipeline else updated |= false; if ((m_Controls->m_UpdateRecorder->checkState() == Qt::Checked) && (m_Recorder.IsNotNull())) m_Recorder->Update(); // record data to file else updated |= false; if ((updated == false) && (m_Recorder.IsNotNull())) m_Visualizer->Update(); mitk::RenderingManager::GetInstance()->RequestUpdate(this->GetActiveStdMultiWidget()->GetRenderWindow4()->GetRenderWindow()); // render 3D scene } catch (...) { mitk::StatusBar::GetInstance()->DisplayText("Error during navigation pipeline update", 1000); } } void QmitkIGTRecorderView::OnStartReplaying() { } void QmitkIGTRecorderView::OnStopReplaying() { } void QmitkIGTRecorderView::SetupIGTPipeline(mitk::TrackingDevice::Pointer tracker, QString fileName) { mitk::DataStorage* ds = this->GetDefaultDataStorage(); if (ds == NULL) throw std::invalid_argument("DataStorage not available"); if (tracker.IsNull()) throw std::invalid_argument("invalid tracking device provided."); if (m_ConfigWidget->GetToolsByToolType("Instrument").isEmpty()) throw std::invalid_argument("insufficient tool assignments for instrument"); /* build pipeline filters */ if (m_Source.IsNull()) { m_Source = mitk::TrackingDeviceSource::New(); m_Source->SetTrackingDevice(tracker); } m_Visualizer = mitk::NavigationDataObjectVisualizationFilter::New(); m_MessageFilter = mitk::NavigationDataToMessageFilter::New(); m_PointSetFilter = mitk::NavigationDataToPointSetFilter::New(); m_PointSetFilter->SetOperationMode(mitk::NavigationDataToPointSetFilter::Mode3D); m_Recorder = mitk::NavigationDataRecorder::New(); m_Recorder->SetFileName(fileName.toLatin1()); /* connect inputs and outputs of filters */ for (unsigned int i = 0; i < m_Source->GetNumberOfOutputs(); ++i) // source --> visualizer --> messager --> pointset { /* visualization filter */ m_Visualizer->SetInput(i, m_Source->GetOutput(i)); /* message filter */ m_MessageFilter->SetInput(i, m_Visualizer->GetOutput(i)); /* landmark transform filter */ m_PointSetFilter->SetInput(i, m_MessageFilter->GetOutput(i)); m_Recorder->AddNavigationData(m_MessageFilter->GetOutput(i)); } m_Recorder->StartRecording(); /* set filter parameters */ /* instrument visualization */ const QList instruments = m_ConfigWidget->GetToolsByToolType("Instrument"); foreach (const unsigned int& index, instruments) { mitk::DataNode::Pointer node = this->CreateInstrumentVisualization(m_Source->GetOutput(index)->GetName()); ds->Add(node); m_Visualizer->SetRepresentationObject(index, node->GetData()); } for (unsigned int i = 0; i < m_PointSetFilter->GetNumberOfOutputs(); i++) { mitk::PointSet* p = m_PointSetFilter->GetOutput(i); assert(p); mitk::DataNode::Pointer pointSetNode = mitk::DataNode::New(); pointSetNode->SetData(p); pointSetNode->SetName(QString("Trajectory of Tool #%1 (%2)").arg(i).arg(QTime::currentTime().toString()).toLatin1()); mitk::Color color; color.Set(0.2, 0.3 * i ,0.9 - 0.2 * i); pointSetNode->SetColor(color); //change color of points pointSetNode->SetProperty("contourcolor", mitk::ColorProperty::New(color)); // change color of trajectory line pointSetNode->SetProperty("pointsize", mitk::FloatProperty::New(1.0)); // enlarge visualization of points pointSetNode->SetProperty("contoursize", mitk::FloatProperty::New(0.5)); // enlarge visualization of trajectory line pointSetNode->SetBoolProperty("show contour", true); pointSetNode->SetBoolProperty("updateDataOnRender", false); // do not call Update() on the pointset during render (this would cause a execution of the pipeline that is still connected to the pointset) this->GetDefaultDataStorage()->Add(pointSetNode); //add it to the DataStorage } } mitk::DataNode::Pointer QmitkIGTRecorderView::CreateInstrumentVisualization(const char* label) { vtkAxes* axes = vtkAxes::New(); axes->SymmetricOn(); axes->SetScaleFactor(10.0); vtkTubeFilter* tuber = vtkTubeFilter::New(); tuber->SetRadius(0.02); tuber->SetNumberOfSides(6); tuber->SetInputConnection(axes->GetOutputPort()); vtkTextSource* tss = vtkTextSource::New(); tss->SetText(label); tss->BackingOff(); vtkConeSource* cone = vtkConeSource::New(); cone->SetDirection(0.0, 0.0, -1.0); // direction: along z-axis, facing towards -z direction cone->SetCenter(0.0, 0.0, 100.0); cone->SetHeight(200.0); // center at 100, height 200 should set the tip of the cone to the origin cone->SetRadius(10.0); vtkAppendPolyData* ap = vtkAppendPolyData::New(); //ap->AddInput(tss->GetOutput()); ap->AddInput(tuber->GetOutput()); //ap->AddInput(cone->GetOutput()); ap->GetOutput()->Update(); mitk::Surface::Pointer dummy = mitk::Surface::New(); dummy->SetVtkPolyData(ap->GetOutput()); ap->Delete(); cone->Delete(); tss->Delete(); tuber->Delete(); axes->Delete(); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(dummy); node->SetName(label); node->SetColor(0.2, 0.9, 0.2); //node->SetBoolProperty("helperObject", true); return node; } void QmitkIGTRecorderView::OnConnect() { m_Controls->m_StartRecording->setEnabled(true); m_Controls->m_StopRecording->setEnabled(true); m_Controls->m_PauseRecording->setEnabled(true); //m_Controls->m_StartReplay->setEnabled(true); //m_Controls->m_StopReplay->setEnabled(true); } void QmitkIGTRecorderView::OnDisconnect() { this->OnStopRecording(); m_Controls->m_StartRecording->setEnabled(false); m_Controls->m_StopRecording->setEnabled(false); m_Controls->m_PauseRecording->setEnabled(false); } 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 0023c9c907..51f20034a9 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,284 +1,285 @@ /*========================================================================= 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 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() { } 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())); //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 TrackingVolumeNode = mitk::DataNode::New(); TrackingVolumeNode->SetName("TrackingVolume"); this->GetDataStorage()->Add(TrackingVolumeNode); //initialize buttons m_Controls->m_StopTracking->setEnabled(false); } } 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; //initialize tool storage m_toolStorage = mitk::NavigationToolStorage::New(); //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::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::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory = mitk::TrackingDeviceSourceConfigurator::New(this->m_toolStorage,this->m_Controls->m_configurationWidget->GetTrackingDevice()); m_TrackingDeviceSource = myTrackingDeviceSourceFactory->CreateTrackingDeviceSource(this->m_ToolVisualizationFilter); if (m_TrackingDeviceSource.IsNull()) { MessageBox(myTrackingDeviceSourceFactory->GetErrorMessage()); return; } //initialize tracking try { m_TrackingDeviceSource->Connect(); m_TrackingDeviceSource->StartTracking(); } catch (...) { MessageBox("Error while starting the tracking device!"); 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(); //disable loading new tools this->m_Controls->m_LoadTools->setEnabled(false); //set configuration finished this->m_Controls->m_configurationWidget->ConfigurationFinished(); //show tracking volume if (m_Controls->m_ShowTrackingVolume->isChecked()) { mitk::TrackingVolumeGenerator::Pointer volumeGenerator= mitk::TrackingVolumeGenerator::New(); volumeGenerator->SetTrackingDeviceType(m_TrackingDeviceSource->GetTrackingDevice()->GetType()); + volumeGenerator->Update(); mitk::Surface::Pointer volumeSurface = volumeGenerator->GetOutput(); TrackingVolumeNode->SetData(volumeSurface); TrackingVolumeNode->SetOpacity(0.25); mitk::Color red; red.SetRed(1); TrackingVolumeNode->SetColor(red); } m_tracking = true; m_Controls->m_StopTracking->setEnabled(true); m_Controls->m_StartTracking->setEnabled(false); } 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); m_Controls->m_TrackingToolsStatusWidget->RemoveStatusLabels(); m_Controls->m_TrackingToolsStatusWidget->PreShowTools(m_toolStorage); TrackingVolumeNode->SetData(NULL); m_tracking = false; m_Controls->m_StopTracking->setEnabled(false); m_Controls->m_StartTracking->setEnabled(true); } 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())) { m_Controls->m_LoggingLabel->setText("Logging OFF"); m_logging = false; } } 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() { //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; } void QmitkMITKIGTTrackingToolboxView::StopLogging() { //update label this->m_Controls->m_LoggingLabel->setText("Logging OFF"); m_loggingFilter->StopRecording(); m_logging = false; } diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp index 3a02ca52c7..3a59f94d5e 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.cpp @@ -1,98 +1,104 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2011-01-18 13:22:38 +0100 (Di, 18 Jan 2011) $ Version: $Revision: 28959 $ 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. =========================================================================*/ -//TODO unnötige importe entfernen #include "mitkTrackingVolumeGenerator.h" #include "mitkSTLFileReader.h" #include "mitkStandardFileLocations.h" #include "mitkConfig.h" #include #include #include #include #include +#include mitk::TrackingVolumeGenerator::TrackingVolumeGenerator() { std::string volumeDir = MITK_ROOT; volumeDir += "Modules/IGT/IGTTrackingDevices/TrackingVolumeData"; //folder which contains the trackingdevices configs mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch( volumeDir.c_str(), false ); //add this directory to StdFileLocations for the search m_TrackingDeviceType ; } void mitk::TrackingVolumeGenerator::SetTrackingDevice (mitk::TrackingDevice::Pointer tracker) { this->m_TrackingDeviceType = tracker->GetType(); } void mitk::TrackingVolumeGenerator::GenerateData() { - mitk::Surface::Pointer output = this->GetOutput(); + mitk::Surface::Pointer output = this->GetOutput();//the surface wich represents the tracking volume std::string filename = ""; switch(m_TrackingDeviceType) { case mitk::ClaronMicron: filename = mitk::StandardFileLocations::GetInstance()->FindFile("ClaronMicron.stl"); break; case mitk::IntuitiveDaVinci: filename = mitk::StandardFileLocations::GetInstance()->FindFile("IntuitiveDaVinci.stl"); break; case mitk::NDIPolaris: filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIPolaris.stl"); break; case mitk::NDIAurora: filename = mitk::StandardFileLocations::GetInstance()->FindFile("NDIAurora.stl"); break; case mitk::VirtualTracker: { vtkSmartPointer cubeSource = vtkSmartPointer::New(); double bounds[6]; bounds[0] = bounds[2] = bounds[4] = -400.0; // initialize bounds to -400 ... +400 cube. This is the default value of the bounds[1] = bounds[3] = bounds[5] = 400.0; // virtual tracking device, but it can be changed. In that case, // the tracking volume polydata has be updated manually cubeSource->SetBounds(bounds); cubeSource->GetOutput()->Update(); output->SetVtkPolyData(cubeSource->GetOutput()); //set the vtkCubeSource as polyData of the surface return; } default: - return; + { + MITK_INFO<< "No STL to given TrackingDevice found"; + return; + } + } if (filename.empty()) { MITK_ERROR << "Filename is empty"; return; } mitk::STLFileReader::Pointer stlReader = mitk::STLFileReader::New(); stlReader->SetFileName( filename.c_str() ); stlReader->Update(); if ( stlReader->GetOutput() == NULL) + { + MITK_ERROR << "Error while reading file"; return ; - + } output->SetVtkPolyData( stlReader->GetOutput()->GetVtkPolyData());//set the visible trackingvolume } diff --git a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h index 0eae95f2a4..e0417af129 100644 --- a/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h +++ b/Modules/IGT/IGTFilters/mitkTrackingVolumeGenerator.h @@ -1,89 +1,85 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2011-01-18 13:22:38 +0100 (Di, 18 Jan 2011) $ Version: $Revision: 28959 $ 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 MITKTRACKINGVOLUMEGENERATOR_H #define MITKTRACKINGVOLUMEGENERATOR_H #include "MitkIGTExports.h" #include -#include -//#include #include "mitkTrackingTypes.h" #include "mitkTrackingDevice.h" class vtkPolyData; namespace mitk { /**Documentation * \brief An instance of this class represents a generator wich generates the tracking volume of a * given tracking device as a mitk:Surface. * * As it inherits from mitk::Surface it can be * displayed in the 3D-window of MITK. The coordinate system is the same * as the coordination system of the tracking device. * To generate the specific dimensions of the tracking volume of a tracking device * the methods SetTrackingDeviceType() or SetTrackingDevice ()needs to be called first. - * After the method GetOutPut(), delivers the generatet TrackingVolume as mitk:Surface + * After the method GetOutput(), delivers the generatet TrackingVolume as mitk:Surface * * For tracking devices that have a modifiable tracking volume (e.g. VirtualTrackingDevice, - * this class produces a tracking volume with default values (e.g. that are set in the class' - * constructor + * this class produces a tracking volume with default values * * \ingroup IGT */ class MitkIGT_EXPORT TrackingVolumeGenerator : public mitk::SurfaceSource { public: mitkClassMacro(TrackingVolumeGenerator, mitk::SurfaceSource) itkNewMacro(Self); /** - * \brief Sets the tracking device of the volume. After doing this + * \brief Sets the tracking device type of the volume. After doing this * the tracking volume gets generatet and set to the correct dimensions in the correct - * coordinate system. + * coordinate system. The TV of a VirtualTrackingDevice is always a 400*400 cube. * \param type The type of the tracking device (currently supported:NDIAurora, NDIPolaris, ClaronMicron, IntuitiveDaVinci and the VirtualTracker). - * \return Returns true if the type was set successfull, false if not. */ itkSetMacro(TrackingDeviceType, mitk::TrackingDeviceType); itkGetMacro(TrackingDeviceType, mitk::TrackingDeviceType); /** * \brief Sets the tracking device of the volume. After doing this * the tracking volume gets generatet and is set to the correct dimensions in the correct * coordinate system. - * \param tracker The tracking device the tracking volume has to be created for - * \return Returns true if the type was set successfull, false if not. + * \param tracker The tracking device the tracking volume has to be created for (currently supported:NDIAurora, NDIPolaris, ClaronMicron, IntuitiveDaVinci and the VirtualTracker). */ void SetTrackingDevice(mitk::TrackingDevice::Pointer tracker); - void GenerateData(); protected: TrackingVolumeGenerator(); mitk::TrackingDeviceType m_TrackingDeviceType; + + void GenerateData(); }; } #endif // MITKTRACKINGVOLUMEGENERATOR_H