diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp b/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp index 752a530a64..9517e4c742 100644 --- a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp @@ -1,970 +1,970 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ 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. =========================================================================*/ // Qmitk #include "QmitkToFUtilView.h" #include // Qt #include #include // MITK #include #include #include #include #include #include // VTK #include const std::string QmitkToFUtilView::VIEW_ID = "org.mitk.views.tofutil"; QmitkToFUtilView::QmitkToFUtilView() : QmitkFunctionality() , m_Controls(NULL) , m_MultiWidget( NULL ) , m_DistanceImageNode(NULL) , m_AmplitudeImageNode(NULL) , m_IntensityImageNode(NULL) , m_SurfaceNode(NULL) , m_QmitkVideoBackground(NULL) , m_QmitkToFImageBackground1(NULL) , m_QmitkToFImageBackground2(NULL) , m_QmitkToFImageBackground3(NULL) { //this->m_FrameRate = 0; this->m_Frametimer = new QTimer(this); this->m_MitkDistanceImage = mitk::Image::New(); this->m_MitkAmplitudeImage = mitk::Image::New(); this->m_MitkIntensityImage = mitk::Image::New(); this->m_MitkAllImage = mitk::Image::New(); this->m_MitkRawImage = mitk::Image::New(); this->m_SurfaceInputImage = mitk::Image::New(); this->m_SurfaceTextureImage = mitk::Image::New(); this->m_SurfaceIntensityImage = mitk::Image::New(); this->m_Surface = mitk::Surface::New(); // this->m_ToFSurfaceGenerationFilter = mitk::ToFSurfaceGenerationFilter::New(); this->m_ToFDistanceImageToSurfaceFilter = mitk::ToFDistanceImageToSurfaceFilter::New(); this->m_ToFImageGrabber = NULL; this->m_ToFImageRecorder = mitk::ToFImageRecorder::New(); CreateNode("ToF_Distance", this->m_DistanceImageNode); CreateNode("ToF_Amplitude", this->m_AmplitudeImageNode); CreateNode("ToF_Intensity", this->m_IntensityImageNode); CreateNode("ToF_Surface", this->m_SurfaceNode); this->m_DataNodesInitilized = false; this->m_TransferFunctionInitialized = false; this->m_SurfaceInitialized = false; this->m_ImageSequence = 0; //this->m_DistLut = vtkLookupTable::New(); //this->m_AmplLut = vtkLookupTable::New(); //this->m_IntenLut = vtkLookupTable::New(); //PrepareColorLut(this->m_DistLut, 300.0, 1000.0); //PrepareBinaryLut(this->m_AmplLut, 0.0, 100.0); //PrepareBinaryLut(this->m_IntenLut, 0.0, 100.0); this->m_DataBuffer = NULL; this->m_DataBufferCurrentIndex = 0; this->m_DataBufferMaxSize = 0; this->m_IndexBuffer = NULL; this->m_VideoEnabled = false; this->m_ToFSurfaceVtkMapper3D = mitk::ToFSurfaceVtkMapper3D::New(); this->m_ToFCompositeFilter = mitk::ToFCompositeFilter::New(); this->m_ToFVisualizationFilter = mitk::ToFVisualizationFilter::New(); } QmitkToFUtilView::~QmitkToFUtilView() { RemoveNode("ToF_Distance", this->m_DistanceImageNode); RemoveNode("ToF_Amplitude", this->m_AmplitudeImageNode); RemoveNode("ToF_Intensity", this->m_IntensityImageNode); RemoveNode("ToF_Surface", this->m_SurfaceNode); //RemoveBackground(); } void QmitkToFUtilView::RemoveNode(const char* nodename, mitk::DataNode::Pointer node) { if(this->GetDataStorage()->GetNamedNode(nodename) != NULL) { this->GetDataStorage()->Remove(node); } } void QmitkToFUtilView::CreateNode(const char* nodename, mitk::DataNode::Pointer& node) { node = mitk::DataNode::New(); node->SetProperty( "name", mitk::StringProperty::New(nodename)); } void QmitkToFUtilView::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::QmitkToFUtilViewControls; m_Controls->setupUi( parent ); connect(m_Frametimer, SIGNAL(timeout()), this, SLOT(OnUpdateCamera())); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraConnected()), this, SLOT(OnToFCameraConnected()) ); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraDisconnected()), this, SLOT(OnToFCameraDisconnected()) ); connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraStop()), this, SLOT(OnToFCameraStop()) ); - connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraSelected(int)), this, SLOT(OnToFCameraSelected(int)) ); + connect( (QObject*)(m_Controls->m_ToFConnectionWidget), SIGNAL(ToFCameraSelected(const QString)), this, SLOT(OnToFCameraSelected(const QString)) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(ToFCameraStarted()), this, SLOT(OnToFCameraStarted()) ); connect( (QObject*)(m_Controls->m_ToFRecorderWidget), SIGNAL(ToFCameraStopped()), this, SLOT(OnToFCameraStopped()) ); connect( (QObject*)(m_Controls->m_SurfaceCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnSurfaceCheckBoxChecked(bool)) ); connect( (QObject*)(m_Controls->m_TextureCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnTextureCheckBoxChecked(bool)) ); connect( (QObject*)(m_Controls->m_VideoTextureCheckBox), SIGNAL(toggled(bool)), this, SLOT(OnVideoTextureCheckBoxChecked(bool)) ); } } void QmitkToFUtilView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkToFUtilView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkToFUtilView::Activated() { QmitkFunctionality::Activated(); m_MultiWidget->SetWidgetPlanesVisibility(false); m_MultiWidget->mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Transversal); m_MultiWidget->mitkWidget1->GetSliceNavigationController()->SliceLockedOn(); m_MultiWidget->mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Transversal); m_MultiWidget->mitkWidget2->GetSliceNavigationController()->SliceLockedOn(); m_MultiWidget->mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Transversal); m_MultiWidget->mitkWidget3->GetSliceNavigationController()->SliceLockedOn(); //m_Controls->m_ToFImageConverterWidget->Initialize(this->GetDefaultDataStorage(), m_MultiWidget); m_Controls->m_ToFVisualisationSettingsWidget->Initialize(this->GetDefaultDataStorage(), m_MultiWidget); m_Controls->m_ToFVisualisationSettingsWidget->SetParameter(this->m_ToFVisualizationFilter); m_Controls->m_ToFCompositeFilterWidget->SetToFCompositeFilter(this->m_ToFCompositeFilter); if (this->m_ToFImageGrabber == NULL) { m_Controls->m_ToFRecorderWidget->setEnabled(false); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); } } void QmitkToFUtilView::Deactivated() { m_MultiWidget->SetWidgetPlanesVisibility(true); m_MultiWidget->mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Transversal); m_MultiWidget->mitkWidget1->GetSliceNavigationController()->SliceLockedOff(); m_MultiWidget->mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); m_MultiWidget->mitkWidget2->GetSliceNavigationController()->SliceLockedOff(); m_MultiWidget->mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Frontal); m_MultiWidget->mitkWidget3->GetSliceNavigationController()->SliceLockedOff(); mitk::RenderingManager::GetInstance()->InitializeViews(); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); QmitkFunctionality::Deactivated(); } void QmitkToFUtilView::OnToFCameraConnected() { RemoveNode("ToF_Distance", this->m_DistanceImageNode); RemoveNode("ToF_Amplitude", this->m_AmplitudeImageNode); RemoveNode("ToF_Intensity", this->m_IntensityImageNode); RemoveNode("ToF_Surface", this->m_SurfaceNode); CreateNode("ToF_Distance", this->m_DistanceImageNode); CreateNode("ToF_Amplitude", this->m_AmplitudeImageNode); CreateNode("ToF_Intensity", this->m_IntensityImageNode); CreateNode("ToF_Surface", this->m_SurfaceNode); this->m_DistanceImageNode->SetData( NULL ); this->m_AmplitudeImageNode->SetData( NULL ); this->m_IntensityImageNode->SetData( NULL ); this->m_SurfaceNode->SetData( NULL ); this->m_DataNodesInitilized = false; this->m_TransferFunctionInitialized = false; this->m_SurfaceInitialized = false; this->m_ImageSequence = 0; //this->m_ToFImageGrabber = dynamic_cast(m_Controls->m_ToFConnectionWidget->GetToFImageGrabber()); this->m_ToFImageGrabber = m_Controls->m_ToFConnectionWidget->GetToFImageGrabber(); this->m_ToFCaptureWidth = this->m_ToFImageGrabber->GetCaptureWidth(); this->m_ToFCaptureHeight = this->m_ToFImageGrabber->GetCaptureHeight(); this->m_ToFImageRecorder->SetCameraDevice(this->m_ToFImageGrabber->GetCameraDevice()); //this->m_MitkDistanceImage->ReleaseData(); //this->m_MitkAmplitudeImage->ReleaseData(); //this->m_MitkIntensityImage->ReleaseData(); //this->m_MitkAllImage->ReleaseData(); this->m_MitkDistanceImage = mitk::Image::New(); this->m_MitkAmplitudeImage = mitk::Image::New(); this->m_MitkIntensityImage = mitk::Image::New(); this->m_MitkAllImage = mitk::Image::New(); InitImage(this->m_MitkDistanceImage, 1); InitImage(this->m_MitkAmplitudeImage, 1); InitImage(this->m_MitkIntensityImage, 1); InitImage(this->m_MitkAllImage, 3); InitImage(this->m_SurfaceInputImage, 1); InitImage(this->m_SurfaceIntensityImage, 1); this->m_SurfaceDisplayCount = 0; this->m_2DDisplayCount = 0; this->m_IplDistanceImage = cvCreateImageHeader(cvSize(this->m_ToFCaptureWidth, this->m_ToFCaptureHeight), IPL_DEPTH_32F, 1); // no allocation this->m_IplIntensityImage = cvCreateImageHeader(cvSize(this->m_ToFCaptureWidth, this->m_ToFCaptureHeight), IPL_DEPTH_32F, 1); // no allocation this->m_OutputIplImage = cvCreateImage(cvSize(this->m_ToFCaptureWidth, this->m_ToFCaptureHeight), IPL_DEPTH_32F, 1); this->m_ItkInputImage = ItkImageType2D::New(); ItkImageType2D::IndexType startIndex; startIndex[0] = 0; // first index on X startIndex[1] = 0; // first index on Y ItkImageType2D::SizeType size; size[0] = this->m_ToFCaptureWidth; // size along X size[1] = this->m_ToFCaptureHeight; // size along Y ItkImageType2D::RegionType region; region.SetSize( size ); region.SetIndex( startIndex ); this->m_ItkInputImage->SetRegions( region ); this->m_ItkInputImage->Allocate(); if ( this->m_SurfaceNode.IsNotNull() ) { this->m_SurfaceNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); this->m_SurfaceNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget1->GetRenderWindow() ) ); this->m_SurfaceNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget2->GetRenderWindow() ) ); this->m_SurfaceNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget3->GetRenderWindow() ) ); this->m_SurfaceNode->SetProperty( "inRenWin4" , mitk::BoolProperty::New( true )); this->m_SurfaceNode->SetProperty( "material.representation", mitk::VtkRepresentationProperty::New("Surface")); this->m_SurfaceNode->SetIntProperty("layer", 10); this->m_SurfaceNode->SetBoolProperty("scalar visibility", false); this->m_SurfaceNode->SetFloatProperty("ScalarsRangeMaximum", 20000); this->m_SurfaceNode->SetFloatProperty("color_coefficient", 0); this->m_SurfaceNode->SetBoolProperty("color mode", true); this->m_SurfaceNode->SetData(mitk::Surface::New()); this->m_SurfaceNode->SetMapper(mitk::BaseRenderer::Standard3D, this->m_ToFSurfaceVtkMapper3D); this->GetDefaultDataStorage()->Add( this->m_SurfaceNode ); } if(this->GetDataStorage()->GetNamedNode("ToF_Distance") == NULL) { this->m_DistanceImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); this->m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget1->GetRenderWindow() ) ); this->m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget3->GetRenderWindow() ) ); this->m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget4->GetRenderWindow() ) ); this->m_DistanceImageNode->SetProperty( "inRenWin2" , mitk::BoolProperty::New( true )); //m_DistanceImageNode->SetProperty( "use color", mitk::BoolProperty::New( false )); this->m_DistanceImageNode->SetProperty( "use color", mitk::BoolProperty::New( true )); this->m_DistanceImageNode->SetProperty( "binary", mitk::BoolProperty::New( false )); //m_DistanceImageNode->SetIntProperty( "layer", 10); //this->m_DistanceImageNode->SetData( this->m_MitkDistanceImage ); mitk::Image::Pointer myImage = mitk::Image::New(); unsigned int dimensions[2]; dimensions[0] = this->m_ToFImageGrabber->GetCaptureWidth(); dimensions[1] = this->m_ToFImageGrabber->GetCaptureHeight(); myImage->Initialize(mitk::PixelType(mitkIpPicUInt, 24, 3), 2, dimensions); //unsigned char RGB this->m_DistanceImageNode->SetData( myImage ); this->GetDataStorage()->Add( this->m_DistanceImageNode ); } m_Controls->m_ToFRecorderWidget->SetParameter(dynamic_cast(this->m_ToFImageGrabber), this->m_ToFImageRecorder); //TODO this->m_RealTimeClock = mitk::RealTimeClock::New(); this->m_StepsForFramerate = 100; this->m_TimeBefore = this->m_RealTimeClock->GetCurrentStamp(); this->m_2DTimeBefore = this->m_RealTimeClock->GetCurrentStamp(); this->m_SurfaceTimeBefore = this->m_RealTimeClock->GetCurrentStamp(); try { this->m_VideoSource = mitk::OpenCVVideoSource::New(); this->m_VideoSource->SetVideoCameraInput(0, false); this->m_VideoSource->StartCapturing(); if(!this->m_VideoSource->IsCapturingEnabled()) { MITK_INFO << "unable to initialize video grabbing/playback"; this->m_VideoEnabled = false; m_Controls->m_VideoTextureCheckBox->setEnabled(false); } else { this->m_VideoEnabled = true; m_Controls->m_VideoTextureCheckBox->setEnabled(true); } if (this->m_VideoEnabled) { this->m_VideoSource->FetchFrame(); this->m_VideoCaptureHeight = this->m_VideoSource->GetImageHeight(); this->m_VideoCaptureWidth = this->m_VideoSource->GetImageWidth(); int videoTexSize = this->m_VideoCaptureWidth * this->m_VideoCaptureHeight * 3; // for each pixel three values for rgb are needed!! this->m_VideoTexture = this->m_VideoSource->GetVideoTexture(); unsigned int dimensions[2]; dimensions[0] = this->m_VideoCaptureWidth; dimensions[1] = this->m_VideoCaptureHeight; this->m_SurfaceTextureImage->Initialize(mitk::PixelType(typeid(unsigned char), 3), 2, dimensions, 1); //this->m_SurfaceWorkerThread.SetTextureImageWidth(this->m_VideoCaptureWidth); //this->m_SurfaceWorkerThread.SetTextureImageHeight(this->m_VideoCaptureHeight); this->m_ToFDistanceImageToSurfaceFilter->SetTextureImageWidth(this->m_VideoCaptureWidth); this->m_ToFDistanceImageToSurfaceFilter->SetTextureImageHeight(this->m_VideoCaptureHeight); this->m_ToFSurfaceVtkMapper3D->SetTextureWidth(this->m_VideoCaptureWidth); this->m_ToFSurfaceVtkMapper3D->SetTextureHeight(this->m_VideoCaptureHeight); } m_MultiWidget->DisableGradientBackground(); InitTexture(this->m_Widget1Texture, this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); InitTexture(this->m_Widget2Texture, this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); InitTexture(this->m_Widget3Texture, this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); this->m_QmitkToFImageBackground1 = new QmitkToFImageBackground(); this->m_QmitkToFImageBackground1->AddRenderWindow(m_MultiWidget->mitkWidget1->GetRenderWindow(), this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); this->m_QmitkToFImageBackground1->UpdateBackground(this->m_Widget1Texture); this->m_Widget1ImageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget1ImageType(); this->m_QmitkToFImageBackground2 = new QmitkToFImageBackground(); this->m_QmitkToFImageBackground2->AddRenderWindow(m_MultiWidget->mitkWidget2->GetRenderWindow(), this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); this->m_QmitkToFImageBackground2->UpdateBackground(this->m_Widget2Texture); this->m_Widget2ImageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget2ImageType(); this->m_QmitkToFImageBackground3 = new QmitkToFImageBackground(); this->m_QmitkToFImageBackground3->AddRenderWindow(m_MultiWidget->mitkWidget3->GetRenderWindow(), this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); this->m_QmitkToFImageBackground3->UpdateBackground(this->m_Widget3Texture); this->m_Widget3ImageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget3ImageType(); } catch (std::logic_error& e) { QMessageBox::warning(NULL, "Warning", QString(e.what())); MITK_ERROR << e.what(); return; } //this->m_SurfaceWorkerThread.SetAbort(false); //this->m_SurfaceWorkerThread.SetFilterThread(&(this->m_FilterWorkerThread)); //this->m_FilterWorkerThread.SetAbort(false); m_Controls->m_ToFRecorderWidget->setEnabled(true); m_Controls->m_ToFRecorderWidget->ResetGUIToInitial(); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(true); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } void QmitkToFUtilView::OnToFCameraDisconnected() { //this->m_SurfaceWorkerThread.SetAbort(true); //this->m_SurfaceWorkerThread.quit(); //this->m_FilterWorkerThread.SetAbort(true); m_Controls->m_ToFRecorderWidget->setEnabled(false); m_Controls->m_ToFVisualisationSettingsWidget->setEnabled(false); if(this->m_VideoSource) { this->m_VideoSource->StopCapturing(); this->m_VideoSource = NULL; } RemoveBackground(); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); cvReleaseImage(&(this->m_IplDistanceImage)); cvReleaseImage(&(this->m_IplIntensityImage)); cvReleaseImage(&(this->m_OutputIplImage)); delete[] this->m_Widget1Texture; delete[] this->m_Widget2Texture; delete[] this->m_Widget3Texture; //mitk::ToFImageGrabber* aToFImageGrabber = dynamic_cast(m_ToFImageGrabber); //aToFImageGrabber->Delete(); } void QmitkToFUtilView::OnToFCameraStarted() { //this->m_FilterWorkerThread.SetAbort(false); //this->m_FilterWorkerThread.StartProcessing(this->m_ToFImageGrabber, this->m_MitkAllImage); //this->m_SurfaceWorkerThread.SetAbort(false); // initial update of image grabber this->m_ToFImageGrabber->Update(); this->m_ToFCompositeFilter->SetInput(0,this->m_ToFImageGrabber->GetOutput(0)); this->m_ToFCompositeFilter->SetInput(1,this->m_ToFImageGrabber->GetOutput(1)); this->m_ToFCompositeFilter->SetInput(2,this->m_ToFImageGrabber->GetOutput(2)); // initial update of composite filter this->m_ToFCompositeFilter->Update(); this->m_ToFVisualizationFilter->SetInput(0,this->m_ToFCompositeFilter->GetOutput(0)); this->m_ToFVisualizationFilter->SetInput(1,this->m_ToFCompositeFilter->GetOutput(1)); this->m_ToFVisualizationFilter->SetInput(2,this->m_ToFCompositeFilter->GetOutput(2)); // initial update of visualization filter this->m_ToFVisualizationFilter->Update(); //this->m_MitkDistanceImage = m_ToFVisualizationFilter->GetOutput(0); //this->m_MitkAmplitudeImage = m_ToFVisualizationFilter->GetOutput(1); //this->m_MitkIntensityImage = m_ToFVisualizationFilter->GetOutput(2); this->m_MitkDistanceImage = m_ToFCompositeFilter->GetOutput(0); this->m_MitkAmplitudeImage = m_ToFCompositeFilter->GetOutput(1); this->m_MitkIntensityImage = m_ToFCompositeFilter->GetOutput(2); this->m_ToFDistanceImageToSurfaceFilter->SetInput(0,this->m_ToFCompositeFilter->GetOutput(0)); this->m_ToFDistanceImageToSurfaceFilter->SetInput(1,this->m_ToFCompositeFilter->GetOutput(1)); this->m_ToFDistanceImageToSurfaceFilter->SetInput(2,this->m_ToFCompositeFilter->GetOutput(2)); this->m_Surface = this->m_ToFDistanceImageToSurfaceFilter->GetOutput(0); this->m_Frametimer->start(0); //if (m_Controls->m_AveragingFilterCheckBox->isChecked()) //{ // OnAveragingFilterCheckBoxChecked(true); //} //if (m_Controls->m_ThresholdFilterCheckBox->isChecked()) //{ // OnThresholdFilterCheckBoxChecked(true); //} //if (m_Controls->m_BilateralFilterCheckBox->isChecked()) //{ // OnBilateralFilterCheckBoxChecked(true); //} m_Controls->m_ToFCompositeFilterWidget->UpdateFilterParameter(); if (m_Controls->m_SurfaceCheckBox->isChecked()) { OnSurfaceCheckBoxChecked(true); } if (m_Controls->m_TextureCheckBox->isChecked()) { OnTextureCheckBoxChecked(true); } if (m_Controls->m_VideoTextureCheckBox->isChecked()) { OnVideoTextureCheckBoxChecked(true); } } void QmitkToFUtilView::OnToFCameraStop() { //this->m_Frametimer->stop(); //this->m_SurfaceWorkerThread.SetAbort(true); //this->m_FilterWorkerThread.SetAbort(true); m_Controls->m_ToFRecorderWidget->OnStop(); } void QmitkToFUtilView::OnToFCameraStopped() { this->m_Frametimer->stop(); //this->m_SurfaceWorkerThread.SetAbort(true); //this->m_FilterWorkerThread.SetAbort(true); } -void QmitkToFUtilView::OnToFCameraSelected(int index) +void QmitkToFUtilView::OnToFCameraSelected(const QString selected) { - if ((index==1)||(index==2)) + if ((selected=="PMD CamBoard")||(selected=="PMD O3D")) { MITK_INFO<<"Surface representation currently not available for CamBoard and O3. Intrinsic parameters missing."; this->m_Controls->m_SurfaceCheckBox->setEnabled(false); this->m_Controls->m_TextureCheckBox->setEnabled(false); this->m_Controls->m_VideoTextureCheckBox->setEnabled(false); this->m_Controls->m_SurfaceCheckBox->setChecked(false); this->m_Controls->m_TextureCheckBox->setChecked(false); this->m_Controls->m_VideoTextureCheckBox->setChecked(false); } else { this->m_Controls->m_SurfaceCheckBox->setEnabled(true); this->m_Controls->m_TextureCheckBox->setEnabled(true); // TODO enable when bug 8106 is solved this->m_Controls->m_VideoTextureCheckBox->setEnabled(true); } } void QmitkToFUtilView::InitImage(mitk::Image::Pointer image, int numOfChannel) { unsigned int dimensions[4]; dimensions[0] = this->m_ToFImageGrabber->GetCaptureWidth(); dimensions[1] = this->m_ToFImageGrabber->GetCaptureHeight(); dimensions[2] = 1; dimensions[3] = 1; image->Initialize(mitk::PixelType(typeid(float)), 2, dimensions, numOfChannel); } void QmitkToFUtilView::InitTexture(unsigned char* &image, int width, int height) { int texSize = width * height * 3; image = new unsigned char[ texSize ]; for(int i=0; iGetDataStorage()->GetNamedNode("ToF_Distance") == NULL) { //m_DistanceImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); //m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget1->GetRenderWindow() ) ); //m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget3->GetRenderWindow() ) ); //m_DistanceImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget4->GetRenderWindow() ) ); //m_DistanceImageNode->SetProperty( "inRenWin2" , mitk::BoolProperty::New( true )); ////m_DistanceImageNode->SetProperty( "use color", mitk::BoolProperty::New( false )); //m_DistanceImageNode->SetProperty( "use color", mitk::BoolProperty::New( true )); //m_DistanceImageNode->SetProperty( "binary", mitk::BoolProperty::New( false )); //m_DistanceImageNode->SetIntProperty( "layer", 10); //this->GetDataStorage()->Add( this->m_DistanceImageNode ); } if(this->GetDataStorage()->GetNamedNode("ToF_Amplitude") == NULL) { //m_AmplitudeImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); //m_AmplitudeImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget2->GetRenderWindow() ) ); //m_AmplitudeImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget3->GetRenderWindow() ) ); //m_AmplitudeImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget4->GetRenderWindow() ) ); //m_AmplitudeImageNode->SetProperty( "inRenWin1" , mitk::BoolProperty::New( true )); //m_AmplitudeImageNode->SetProperty( "use color", mitk::BoolProperty::New( true )); //m_AmplitudeImageNode->SetProperty( "binary", mitk::BoolProperty::New( false )); //m_AmplitudeImageNode->SetIntProperty( "layer", 10); //this->GetDataStorage()->Add( this->m_AmplitudeImageNode ); } if(this->GetDataStorage()->GetNamedNode("ToF_Intensity") == NULL) { //m_IntensityImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); //m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget1->GetRenderWindow() ) ); //m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget2->GetRenderWindow() ) ); //m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget4->GetRenderWindow() ) ); //m_IntensityImageNode->SetProperty( "inRenWin3" , mitk::BoolProperty::New( true )); //m_IntensityImageNode->SetProperty( "use color", mitk::BoolProperty::New( true )); //m_IntensityImageNode->SetProperty( "binary", mitk::BoolProperty::New( false )); //m_IntensityImageNode->SetIntProperty( "layer", 10); //this->GetDataStorage()->Add( this->m_IntensityImageNode ); } if(this->GetDataStorage()->GetNamedNode("ToF_All") == NULL) { //m_AllImageNode->SetProperty( "visible" , mitk::BoolProperty::New( true )); /* m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget1->GetRenderWindow() ) ); m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget2->GetRenderWindow() ) ); m_IntensityImageNode->SetVisibility( false, mitk::BaseRenderer::GetInstance(GetActiveStdMultiWidget()->mitkWidget4->GetRenderWindow() ) ); m_IntensityImageNode->SetProperty( "inRenWin3" , mitk::BoolProperty::New( true )); m_IntensityImageNode->SetProperty( "use color", mitk::BoolProperty::New( true )); m_IntensityImageNode->SetProperty( "binary", mitk::BoolProperty::New( false )); m_IntensityImageNode->SetIntProperty( "layer", 10); */ //mitk::Mapper::Pointer aMapper = mitk::ToFImageMapper::New(); //m_AllImageNode->SetMapper(mitk::BaseRenderer::Standard2D, aMapper); //this->GetDataStorage()->Add( this->m_AllImageNode ); } } void* QmitkToFUtilView::GetDataFromImage(std::string imageType) { void* data; if (imageType.compare("Distance")==0) { data = this->m_MitkDistanceImage->GetData(); //data = this->m_MitkAllImage->GetSliceData(0, 0, 0)->GetData(); } else if (imageType.compare("Amplitude")==0) { data = this->m_MitkAmplitudeImage->GetData(); //data = this->m_MitkAllImage->GetSliceData(0, 0, 1)->GetData(); } if (imageType.compare("Intensity")==0) { data = this->m_MitkIntensityImage->GetData(); //data = this->m_MitkAllImage->GetSliceData(0, 0, 2)->GetData(); } return data; } void QmitkToFUtilView::OnUpdateCamera() { int currentImageSequence = 0; // update pipeline this->m_MitkDistanceImage->Update(); // update distance image node this->m_DistanceImageNode->SetData(this->m_MitkDistanceImage); if (!this->m_TransferFunctionInitialized) { m_Controls->m_ToFVisualisationSettingsWidget->InitializeTransferFunction(this->m_MitkDistanceImage, this->m_MitkAmplitudeImage, this->m_MitkIntensityImage); this->m_TransferFunctionInitialized = true; } if (m_Controls->m_VideoTextureCheckBox->isChecked() && this->m_VideoEnabled && this->m_VideoSource) { this->m_VideoTexture = this->m_VideoSource->GetVideoTexture(); ProcessVideoTransform(); } vtkColorTransferFunction* colorTransferFunction; std::string imageType; colorTransferFunction = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget1ColorTransferFunction(); imageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget1ImageType(); RenderWidget(m_MultiWidget->mitkWidget1, this->m_QmitkToFImageBackground1, this->m_Widget1ImageType, imageType, colorTransferFunction, this->m_VideoTexture, this->m_Widget1Texture ); colorTransferFunction = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget2ColorTransferFunction(); imageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget2ImageType(); RenderWidget(m_MultiWidget->mitkWidget2, this->m_QmitkToFImageBackground2, this->m_Widget2ImageType, imageType, colorTransferFunction, this->m_VideoTexture, this->m_Widget2Texture ); colorTransferFunction = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget3ColorTransferFunction(); imageType = m_Controls->m_ToFVisualisationSettingsWidget->GetWidget3ImageType(); RenderWidget(m_MultiWidget->mitkWidget3, this->m_QmitkToFImageBackground3, this->m_Widget3ImageType, imageType, colorTransferFunction, this->m_VideoTexture, this->m_Widget3Texture ); if (m_Controls->m_SurfaceCheckBox->isChecked()) { // update surface this->m_Surface->Update(); colorTransferFunction = m_Controls->m_ToFVisualisationSettingsWidget->GetColorTransferFunctionByImageType("Intensity"); this->m_ToFSurfaceVtkMapper3D->SetVtkScalarsToColors(colorTransferFunction); if (this->m_SurfaceDisplayCount < 2) { this->m_SurfaceNode->SetData(this->m_Surface); this->m_SurfaceNode->SetMapper(mitk::BaseRenderer::Standard3D, m_ToFSurfaceVtkMapper3D); mitk::RenderingManager::GetInstance()->InitializeViews( this->m_Surface->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS, true); mitk::Point3D surfaceCenter= this->m_Surface->GetGeometry()->GetCenter(); m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetPosition(0,0,-50); m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetViewUp(0,-1,0); m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetFocalPoint(0,0,surfaceCenter[2]); m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetViewAngle(40); m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetClippingRange(1, 10000); } this->m_SurfaceDisplayCount++; } mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); this->m_2DDisplayCount++; if ((this->m_2DDisplayCount % this->m_StepsForFramerate) == 0) { this->m_2DTimeAfter = this->m_RealTimeClock->GetCurrentStamp() - this->m_2DTimeBefore; MITK_INFO << " 2D-Display-framerate (fps): " << this->m_StepsForFramerate / (this->m_2DTimeAfter/1000) << " Sequence: " << this->m_ImageSequence; this->m_2DTimeBefore = this->m_RealTimeClock->GetCurrentStamp(); } } void QmitkToFUtilView::ProcessVideoTransform() { /* this->m_VideoTexture this->m_IplIntensityImage->imageData = (char*)intensityFloatData; this->m_IplIntensityImage = cvCreateImageHeader(cvSize(this->m_ToFCaptureWidth, this->m_ToFCaptureHeight), IPL_DEPTH_32F, 1); // no allocation this->m_OutputIplImage = cvCreateImage(cvSize(this->m_ToFCaptureWidth, this->m_ToFCaptureHeight), IPL_DEPTH_32F, 1); */ IplImage *src, *dst; src = cvCreateImageHeader(cvSize(this->m_VideoCaptureWidth, this->m_VideoCaptureHeight), IPL_DEPTH_8U, 3); src->imageData = (char*)this->m_VideoTexture; CvPoint2D32f srcTri[3], dstTri[3]; CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1); CvMat* warp_mat = cvCreateMat(2,3,CV_32FC1); dst = cvCloneImage(src); dst->origin = src->origin; cvZero( dst ); // Create angle and scale double angle = 0.0; double scale = 1.0; int xOffset = 0;//m_Controls->m_XOffsetSpinBox->value(); int yOffset = 0;//m_Controls->m_YOffsetSpinBox->value(); int zoom = 0;//m_Controls->m_ZoomSpinBox->value(); // Compute warp matrix srcTri[0].x = 0 + zoom; srcTri[0].y = 0 + zoom; srcTri[1].x = src->width - 1 - zoom; srcTri[1].y = 0 + zoom; srcTri[2].x = 0 + zoom; srcTri[2].y = src->height - 1 - zoom; dstTri[0].x = 0; dstTri[0].y = 0; dstTri[1].x = src->width - 1; dstTri[1].y = 0; dstTri[2].x = 0; dstTri[2].y = src->height - 1; cvGetAffineTransform( srcTri, dstTri, warp_mat ); cvWarpAffine( src, dst, warp_mat ); cvCopy ( dst, src ); // Compute warp matrix srcTri[0].x = 0; srcTri[0].y = 0; srcTri[1].x = src->width - 1; srcTri[1].y = 0; srcTri[2].x = 0; srcTri[2].y = src->height - 1; dstTri[0].x = srcTri[0].x + xOffset; dstTri[0].y = srcTri[0].y + yOffset; dstTri[1].x = srcTri[1].x + xOffset; dstTri[1].y = srcTri[1].y + yOffset; dstTri[2].x = srcTri[2].x + xOffset; dstTri[2].y = srcTri[2].y + yOffset; cvGetAffineTransform( srcTri, dstTri, warp_mat ); cvWarpAffine( src, dst, warp_mat ); cvCopy ( dst, src ); src->imageData = NULL; cvReleaseImage( &src ); cvReleaseImage( &dst ); cvReleaseMat( &rot_mat ); cvReleaseMat( &warp_mat ); } void QmitkToFUtilView::RenderWidget(QmitkRenderWindow* mitkWidget, QmitkToFImageBackground* imageBackground, std::string& oldImageType, std::string newImageType, vtkColorTransferFunction* colorTransferFunction, unsigned char* videoTexture, unsigned char* tofTexture ) { if (newImageType.compare("Video") == 0) { if (this->m_VideoEnabled) { if (oldImageType.compare(newImageType)!=0) { imageBackground->AddRenderWindow(mitkWidget->GetRenderWindow(), this->m_VideoCaptureWidth, this->m_VideoCaptureHeight); oldImageType = newImageType; } imageBackground->UpdateBackground(videoTexture); } } else { if (oldImageType.compare(newImageType)!=0) { imageBackground->AddRenderWindow(mitkWidget->GetRenderWindow(), this->m_ToFCaptureWidth, this->m_ToFCaptureHeight); oldImageType = newImageType; } void* data = GetDataFromImage(newImageType); PrepareImageForBackground(colorTransferFunction, (float*)data, tofTexture); imageBackground->UpdateBackground(tofTexture); } } //void QmitkToFUtilView::CreateSurface() //{ // static int count = 0; // //this->m_ToFSurfaceGenerationFilter = mitk::ToFSurfaceGenerationFilter::New(); // this->m_ToFSurfaceGenerationFilter->SetInput(this->m_MitkDistanceImage); // this->m_ToFSurfaceGenerationFilter->Modified(); // this->m_ToFSurfaceGenerationFilter->Update(); // this->m_Surface->ReleaseData(); // vtkPolyData* polydata = this->m_ToFSurfaceGenerationFilter->GetOutput()->GetVtkPolyData(); // //this->m_Surface->GetVtkPolyData()->ReleaseData(); // this->m_Surface->SetVtkPolyData(polydata); // //this->m_Surface = this->m_ToFSurfaceGenerationFilter->GetOutput(); // this->m_SurfaceNode->SetData(this->m_Surface); // //if(!this->m_SurfaceInitialized) // if (count < 1) // { // //mitk::RenderingManager::GetInstance()->InitializeViews( // // this->m_Surface->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS, true); // m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->ResetCamera(); // m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetPosition(-500,-120,-6000); // m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetViewUp(0,-1,0); // m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetFocalPoint(-130,0,2300); // m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer()->GetActiveCamera()->SetViewAngle(40); // //this->m_SurfaceInitialized = true; // count++; // } //} void QmitkToFUtilView::OnTextureCheckBoxChecked(bool checked) { if (checked) { this->m_SurfaceNode->SetBoolProperty("scalar visibility", true); } else { this->m_SurfaceNode->SetBoolProperty("scalar visibility", false); } } void QmitkToFUtilView::OnVideoTextureCheckBoxChecked(bool checked) { if (checked) { if (this->m_VideoEnabled) { this->m_SurfaceTextureImage->SetSlice(this->m_VideoTexture, 0, 0, 0); this->m_ToFSurfaceVtkMapper3D->SetTexture(this->m_VideoTexture); } else { this->m_ToFSurfaceVtkMapper3D->SetTexture(NULL); } } else { this->m_ToFSurfaceVtkMapper3D->SetTexture(NULL); } } void QmitkToFUtilView::OnSurfaceCheckBoxChecked(bool checked) { //if (checked) //{ // void* surfaceInputdata = this->m_MitkAllImage->GetSliceData(0, 0, 0)->GetData(); // this->m_SurfaceInputImage->SetSlice(surfaceInputdata, 0, 0, 0); // void* surfaceIntensitydata = this->m_MitkAllImage->GetSliceData(0, 0, 2)->GetData(); // this->m_SurfaceIntensityImage->SetSlice(surfaceIntensitydata, 0, 0, 0); // if (m_Controls->m_VideoTextureCheckBox->isChecked()) // { // OnVideoTextureCheckBoxChecked(true); // } // else // { // OnVideoTextureCheckBoxChecked(false); // } // if (m_Controls->m_TextureCheckBox->isChecked()) // { // OnTextureCheckBoxChecked(true); // } // else // { // OnTextureCheckBoxChecked(false); // } // //this->m_SurfaceWorkerThread.SetAbort(false); // //this->m_SurfaceDisplayCount = 0; // //this->m_SurfaceWorkerThread.CreateSurface(this->m_SurfaceInputImage, this->m_SurfaceIntensityImage, this->m_SurfaceTextureImage, this->m_Surface); //} //else //{ // //this->m_SurfaceWorkerThread.SetAbort(true); //} } void QmitkToFUtilView::PrepareImageForBackground(vtkLookupTable* lut, float* floatData, unsigned char* image) { vtkSmartPointer floatArrayDist = vtkFloatArray::New(); floatArrayDist->Initialize(); int numOfPixel = this->m_ToFCaptureWidth * this->m_ToFCaptureHeight; float* flippedFloatData = new float[numOfPixel]; for (int i=0; im_ToFCaptureHeight; i++) { for (int j=0; jm_ToFCaptureWidth; j++) { flippedFloatData[i*this->m_ToFCaptureWidth+j] = floatData[((this->m_ToFCaptureHeight-1-i)*this->m_ToFCaptureWidth)+j]; } } floatArrayDist->SetArray(flippedFloatData, numOfPixel, 0); lut->MapScalarsThroughTable(floatArrayDist, image, VTK_RGB); delete[] flippedFloatData; } void QmitkToFUtilView::PrepareImageForBackground(vtkColorTransferFunction* colorTransferFunction, float* floatData, unsigned char* image) { vtkSmartPointer floatArrayDist = vtkFloatArray::New(); floatArrayDist->Initialize(); int numOfPixel = this->m_ToFCaptureWidth * this->m_ToFCaptureHeight; float* flippedFloatData = new float[numOfPixel]; for (int i=0; im_ToFCaptureHeight; i++) { for (int j=0; jm_ToFCaptureWidth; j++) { flippedFloatData[i*this->m_ToFCaptureWidth+j] = floatData[((this->m_ToFCaptureHeight-1-i)*this->m_ToFCaptureWidth)+j]; } } floatArrayDist->SetArray(flippedFloatData, numOfPixel, 0); colorTransferFunction->MapScalarsThroughTable(floatArrayDist, image, VTK_RGB); delete[] flippedFloatData; } void QmitkToFUtilView::RemoveBackground() { if(this->m_QmitkToFImageBackground1) { this->m_QmitkToFImageBackground1->RemoveRenderWindow(m_MultiWidget->mitkWidget1->GetRenderWindow()); } if(this->m_QmitkToFImageBackground2) { this->m_QmitkToFImageBackground2->RemoveRenderWindow(m_MultiWidget->mitkWidget2->GetRenderWindow()); } if(this->m_QmitkToFImageBackground3) { this->m_QmitkToFImageBackground3->RemoveRenderWindow(m_MultiWidget->mitkWidget3->GetRenderWindow()); } } diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h b/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h index a49d43806f..ee8165a49e 100644 --- a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h +++ b/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h @@ -1,276 +1,276 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ 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 QmitkToFUtilView_h #define QmitkToFUtilView_h #include #include "QmitkToFImageBackground.h" #include #include #include #include #include #include #include #include #include #include #include #include typedef itk::Image ItkImageType2D; /*! \brief QmitkToFUtilView \warning This application is still under active development. Complete documentation will be added when class is finished. \sa QmitkFunctionality \ingroup Functionalities */ class QmitkToFUtilView : 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; QmitkToFUtilView(); QmitkToFUtilView(const QmitkToFUtilView& other) { Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } ~QmitkToFUtilView(); virtual void CreateQtPartControl(QWidget *parent); /// \brief Called when the functionality is activated virtual void Activated(); virtual void Deactivated(); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); protected slots: /// \brief Called when the user clicks the GUI button void OnUpdateCamera(); /*! \This method is automatically called by the connection widgets when the configuration is completed */ void OnToFCameraConnected(); void OnToFCameraDisconnected(); void OnToFCameraStarted(); void OnToFCameraStopped(); void OnToFCameraStop(); - void OnToFCameraSelected(int index); + void OnToFCameraSelected(const QString selected); void OnSurfaceCheckBoxChecked(bool checked); void OnTextureCheckBoxChecked(bool checked); void OnVideoTextureCheckBoxChecked(bool checked); protected: static ITK_THREAD_RETURN_TYPE OnUpdateCameraITKThread(void* pInfoStruct); static void UpdateCamera(); void InitImage(mitk::Image::Pointer image, int numOfChannel); void InitTexture(unsigned char* &image, int width, int height); //void PrepareBinaryLut(vtkLookupTable* lut, double minRange, double maxRange); //void PrepareColorLut(vtkLookupTable* lut, double minRange, double maxRange); void PrepareImageForBackground(vtkLookupTable* lut, float* floadData, unsigned char* image); void PrepareImageForBackground(vtkColorTransferFunction* colorTransferFunction, float* floatData, unsigned char* image); void RemoveBackground(); // void CreateSurface(); Ui::QmitkToFUtilViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; QTimer* m_Frametimer; //int m_FrameRate; mitk::ToFImageGrabber* m_ToFImageGrabber; //mitk::ToFImageGrabber* m_ToFImageGrabber; mitk::Image::Pointer m_MitkInDistanceImage; ///< object to hold the distance image mitk::Image::Pointer m_MitkDistanceImage; ///< object to hold the distance image mitk::Image::Pointer m_MitkAmplitudeImage; ///< object to hold the amplitude image mitk::Image::Pointer m_MitkIntensityImage; ///< object to hold the amplitude image mitk::Image::Pointer m_MitkAllImage; ///< object to hold all image mitk::Image::Pointer m_MitkRawImage; ///< object to hold the raw image mitk::Image::Pointer m_SurfaceInputImage; mitk::Image::Pointer m_SurfaceTextureImage; mitk::Image::Pointer m_SurfaceIntensityImage; mitk::Surface::Pointer m_Surface; mitk::DataNode::Pointer m_DistanceImageNode; ///< DataNode to get the distance image into the DataStorage mitk::DataNode::Pointer m_AmplitudeImageNode; ///< DataNode to get the amplitude image into the DataStorage mitk::DataNode::Pointer m_IntensityImageNode; ///< DataNode to get the intensity image into the DataStorage mitk::DataNode::Pointer m_AllImageNode; ///< DataNode to get all images into the DataStorage mitk::DataNode::Pointer m_SurfaceNode; mitk::ToFImageRecorder::Pointer m_ToFImageRecorder; int m_ImageSequence; mitk::RealTimeClock::Pointer m_RealTimeClock; int m_StepsForFramerate; double m_TimeBefore, m_TimeAfter; double m_SurfaceTimeBefore, m_SurfaceTimeAfter; double m_2DTimeBefore, m_2DTimeAfter; double m_2DTimeSum; QmitkVideoBackground* m_QmitkVideoBackground; QmitkToFImageBackground* m_QmitkToFImageBackground1; QmitkToFImageBackground* m_QmitkToFImageBackground2; QmitkToFImageBackground* m_QmitkToFImageBackground3; mitk::OpenCVVideoSource::Pointer m_VideoSource; unsigned char* m_VideoTexture; unsigned char* m_Widget1Texture; unsigned char* m_Widget2Texture; unsigned char* m_Widget3Texture; vtkLookupTable* m_DistLut; vtkLookupTable* m_AmplLut; vtkLookupTable* m_IntenLut; int m_ToFCaptureWidth; int m_ToFCaptureHeight; int m_VideoCaptureWidth; int m_VideoCaptureHeight; // mitk::ToFSurfaceGenerationFilter::Pointer m_ToFSurfaceGenerationFilter; mitk::ToFDistanceImageToSurfaceFilter::Pointer m_ToFDistanceImageToSurfaceFilter; mitk::ToFCompositeFilter::Pointer m_ToFCompositeFilter; mitk::ToFVisualizationFilter::Pointer m_ToFVisualizationFilter; private: void RemoveNode(const char* nodename, mitk::DataNode::Pointer node); void CreateNode(const char* nodename, mitk::DataNode::Pointer& node); void* GetDataFromImage(std::string imageType); ItkImageType2D::Pointer ProcessThresholdFilter(ItkImageType2D::Pointer inputItkImage, int min, int max); void ProcessCVThresholdFilter(IplImage* inputIplImage, int min, int max); void ProcessCVEdgeFilter(IplImage* inputIplImage, float threshold); ItkImageType2D::Pointer ProcessItkBilateralFilter(ItkImageType2D::Pointer inputItkImage, int domainSigma, int rangeSigma, int kernelRadius); void ProcessCVBilateralFilter(IplImage* inputIplImage, IplImage* outputIplImage, int domainSigma, int rangeSigma, int kernelRadius); void ProcessCVMedianFilter(IplImage* inputIplImage, IplImage* outputIplImage, int radius = 3); void ProcessStreamedAverageImageFilter(float* data, int numOfImages); void ProcessStreamedMedianImageFilter(float* data, int numOfImages); void ProcessStreamedQuickSelectMedianImageFilter(IplImage* inputIplImage, int numOfImages); float quick_select(float arr[], int n); void AddNodesToDataStorage(); void RenderWidget(QmitkRenderWindow* mitkWidget, QmitkToFImageBackground* imageBackground, std::string& oldImageType, std::string newImageType, vtkColorTransferFunction* colorTransferFunction, unsigned char* videoTexture, unsigned char* tofTexture ); void SetBilateralFilterParameter(); void SetThresholdFilterParameter(); void ProcessVideoTransform(); bool m_DataNodesInitilized; bool m_TransferFunctionInitialized; bool m_SurfaceInitialized; float** m_DataBuffer; int m_DataBufferCurrentIndex; int m_DataBufferMaxSize; int** m_IndexBuffer; int m_SurfaceDisplayCount; int m_2DDisplayCount; bool m_VideoEnabled; IplImage* m_IplDistanceImage; IplImage* m_IplIntensityImage; IplImage* m_OutputIplImage; std::string m_Widget1ImageType; std::string m_Widget2ImageType; std::string m_Widget3ImageType; mitk::ToFSurfaceVtkMapper3D::Pointer m_ToFSurfaceVtkMapper3D; ItkImageType2D::Pointer m_ItkInputImage; ItkImageType2D::Pointer m_ItkOutputImage; }; #endif // _QMITKTOFUTILVIEW_H_INCLUDED diff --git a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp index fc8ff0b450..f95f3ac3e1 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFConnectionWidget.cpp @@ -1,432 +1,432 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ 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. =========================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include //mitk headers #include "mitkToFConfig.h" #include //itk headers #include const std::string QmitkToFConnectionWidget::VIEW_ID = "org.mitk.views.qmitktofconnectionwidget"; QmitkToFConnectionWidget::QmitkToFConnectionWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; this->m_ToFImageGrabber = NULL; m_Controls = NULL; CreateQtPartControl(this); } QmitkToFConnectionWidget::~QmitkToFConnectionWidget() { } void QmitkToFConnectionWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToFConnectionWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); // set available cameras to combo box QString string(MITK_TOF_CAMERAS); string.replace(";"," "); QStringList list = string.split(","); m_Controls->m_SelectCameraCombobox->addItems(list); ShowParameterWidget(); } } void QmitkToFConnectionWidget::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->m_ConnectCameraButton), SIGNAL(clicked()),(QObject*) this, SLOT(OnConnectCamera()) ); connect( m_Controls->m_SelectCameraCombobox, SIGNAL(currentIndexChanged(const QString)), this, SLOT(OnSelectCamera(const QString)) ); - connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(int)), this, SLOT(OnSelectCamera(int)) ); - connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(int)), this, SIGNAL(ToFCameraSelected(int)) ); + connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(const QString)), this, SLOT(OnSelectCamera(const QString)) ); + connect( m_Controls->m_SelectCameraCombobox, SIGNAL(activated(const QString)), this, SIGNAL(ToFCameraSelected(const QString)) ); //connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) ); //connect( m_Controls->m_ModulationFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeModulationFrequencySpinBox(int)) ); } } void QmitkToFConnectionWidget::ShowParameterWidget() { QString selectedCamera = m_Controls->m_SelectCameraCombobox->currentText(); if ((selectedCamera == "PMD CamCube 2.0/3.0")||(selectedCamera == "PMD CamBoard")||(selectedCamera=="PMD O3D")) { ShowPMDParameterWidget(); } else if (selectedCamera=="MESA Swissranger 4000") { ShowMESAParameterWidget(); } else { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->hide(); } } void QmitkToFConnectionWidget::ShowPMDParameterWidget() { this->m_Controls->m_PMDParameterWidget->show(); this->m_Controls->m_MESAParameterWidget->hide(); } void QmitkToFConnectionWidget::ShowMESAParameterWidget() { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->show(); } void QmitkToFConnectionWidget::ShowPlayerParameterWidget() { this->m_Controls->m_PMDParameterWidget->hide(); this->m_Controls->m_MESAParameterWidget->hide(); } mitk::ToFImageGrabber* QmitkToFConnectionWidget::GetToFImageGrabber() { return m_ToFImageGrabber; } void QmitkToFConnectionWidget::OnSelectCamera(const QString selectedText) { if (selectedText == "PMD CamCube 2.0/3.0") // PMD camcube 2 { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(true); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(true); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(true); ShowPMDParameterWidget(); } else if (selectedText == "PMD CamBoard") // pmd camboard { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(true); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(true); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); ShowPMDParameterWidget(); } else if (selectedText == "PMD O3D") // pmd O3d { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(true); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(true); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); ShowPMDParameterWidget(); } else if (selectedText == "MESA Swissranger 4000") // MESA 4000 { ShowMESAParameterWidget(); } else if (selectedText == "PMD Player") // pmd file player { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(false); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(false); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); ShowPlayerParameterWidget(); } else if (selectedText == "PMD Raw Data Player") // pmd raw data player { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(false); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(false); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); ShowPlayerParameterWidget(); } else if (selectedText == "MITK Player") // mitk player { //m_Controls->m_IntegrationTimeSpinBox->setEnabled(false); //m_Controls->m_ModulationFrequencySpinBox->setEnabled(false); //m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); ShowPlayerParameterWidget(); } } void QmitkToFConnectionWidget::OnConnectCamera() { bool playerMode = false; if (m_Controls->m_ConnectCameraButton->text()=="Connect") { //reset the status of the GUI buttons m_Controls->m_ConnectCameraButton->setEnabled(false); m_Controls->m_SelectCameraCombobox->setEnabled(false); // m_Controls->m_CalibrationParameterGroupBox->setEnabled(false); //repaint the widget this->repaint(); QString tmpFileName(""); QString fileFilter(""); //select the camera to connect with QString selectedCamera = m_Controls->m_SelectCameraCombobox->currentText(); if (selectedCamera == "PMD CamCube 2.0/3.0") { //PMD CamCube this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamCubeImageGrabber(); } else if (selectedCamera == "PMD CamBoard") { //PMD CamBoard this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDCamBoardImageGrabber(); } else if (selectedCamera == "PMD O3D") {//PMD O3 this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDO3ImageGrabber(); } else if (selectedCamera == "MESA Swissranger 4000") {//MESA SR4000 this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMESASR4000ImageGrabber(); } else if (selectedCamera == "PMD Player") {//PMD player playerMode = true; fileFilter.append("PMD Files (*.pmd)"); this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDPlayerImageGrabber(); } else if (selectedCamera == "PMD Raw Data Player") {//PMD MITK player playerMode = true; fileFilter.append("MITK Images (*.pic)"); this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetPMDMITKPlayerImageGrabber(); } else if (selectedCamera == "MITK Player") {//MITK player playerMode = true; fileFilter.append("MITK Images (*.pic)"); this->m_ToFImageGrabber = mitk::ToFImageGrabberCreator::GetInstance()->GetMITKPlayerImageGrabber(); } // if a player was selected ... if (playerMode) { //... open a QFileDialog to chose the corresponding file from the disc tmpFileName = QFileDialog::getOpenFileName(NULL, "Play Image From...", "", fileFilter); if (tmpFileName.isEmpty()) { m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_SelectCameraCombobox->setEnabled(true); // m_Controls->m_CalibrationParameterGroupBox->setEnabled(true); OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); QMessageBox::information( this, "Template functionality", "Please select a valid image before starting some action."); return; } if(selectedCamera == "PMD Player") { //set the PMD file name this->m_ToFImageGrabber->SetStringProperty("PMDFileName", tmpFileName.toStdString().c_str() ); } if (selectedCamera == "PMD Raw Data Player" || selectedCamera == "MITK Player") { std::string msg = ""; try { //get 3 corresponding file names std::string dir = itksys::SystemTools::GetFilenamePath( tmpFileName.toStdString() ); std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( tmpFileName.toStdString() ); std::string extension = itksys::SystemTools::GetFilenameLastExtension( tmpFileName.toStdString() ); if (extension != ".pic") { msg = msg + "Invalid file format, please select a \".pic\"-file"; throw std::logic_error(msg.c_str()); } int found = baseFilename.rfind("_DistanceImage"); if (found == std::string::npos) { found = baseFilename.rfind("_AmplitudeImage"); } if (found == std::string::npos) { found = baseFilename.rfind("_IntensityImage"); } if (found == std::string::npos) { msg = msg + "Input file name must end with \"_DistanceImage.pic\", \"_AmplitudeImage.pic\" or \"_IntensityImage.pic\"!"; throw std::logic_error(msg.c_str()); } std::string baseFilenamePrefix = baseFilename.substr(0,found); std::string distanceImageFileName = dir + "/" + baseFilenamePrefix + "_DistanceImage" + extension; std::string amplitudeImageFileName = dir + "/" + baseFilenamePrefix + "_AmplitudeImage" + extension; std::string intensityImageFileName = dir + "/" + baseFilenamePrefix + "_IntensityImage" + extension; if (!itksys::SystemTools::FileExists(distanceImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + distanceImageFileName; throw std::logic_error(msg.c_str()); } if (!itksys::SystemTools::FileExists(amplitudeImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + amplitudeImageFileName; throw std::logic_error(msg.c_str()); } if (!itksys::SystemTools::FileExists(intensityImageFileName.c_str(), true)) { msg = msg + "Inputfile not exist! " + intensityImageFileName; throw std::logic_error(msg.c_str()); } //set the file names this->m_ToFImageGrabber->SetStringProperty("DistanceImageFileName", distanceImageFileName.c_str()); this->m_ToFImageGrabber->SetStringProperty("AmplitudeImageFileName", amplitudeImageFileName.c_str()); this->m_ToFImageGrabber->SetStringProperty("IntensityImageFileName", intensityImageFileName.c_str()); } catch (std::exception &e) { MITK_ERROR << e.what(); QMessageBox::critical( this, "Error", e.what() ); m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_SelectCameraCombobox->setEnabled(true); // m_Controls->m_CalibrationParameterGroupBox->setEnabled(true); OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); return; } } } //if a connection could be established if (this->m_ToFImageGrabber->ConnectCamera()) { this->m_Controls->m_PMDParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); this->m_Controls->m_MESAParameterWidget->SetToFImageGrabber(this->m_ToFImageGrabber); if ((selectedCamera == "PMD CamCube 2.0/3.0")||(selectedCamera == "PMD CamBoard")||(selectedCamera=="PMD O3D")) { this->m_Controls->m_PMDParameterWidget->ActivateAllParameters(); } else if (selectedCamera=="MESA Swissranger 4000") { this->m_Controls->m_MESAParameterWidget->ActivateAllParameters(); } /* //get the integration time and modulation frequency this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value(); //set the integration time and modulation frequency in the grabber this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); //set the PMD calibration according to the check boxes bool boolValue = false; boolValue = m_Controls->m_FPNCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPNCalibration", boolValue); boolValue = m_Controls->m_FPPNCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPPNCalibration", boolValue); boolValue = m_Controls->m_LinearityCalibCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetLinearityCalibration", boolValue); boolValue = m_Controls->m_LensCorrection->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetLensCalibration", boolValue); boolValue = m_Controls->m_ExposureModeCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetExposureMode", boolValue); //reset the GUI elements m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_IntegrationTime); m_Controls->m_ModulationFrequencySpinBox->setValue(this->m_ModulationFrequency); */ m_Controls->m_ConnectCameraButton->setText("Disconnect"); // send connect signal to the caller functionality emit ToFCameraConnected(); } else { QMessageBox::critical( this, "Error", "Connection failed. Check if you have installed the latest driver for your system." ); m_Controls->m_ConnectCameraButton->setChecked(false); m_Controls->m_ConnectCameraButton->setEnabled(true); m_Controls->m_SelectCameraCombobox->setEnabled(true); // m_Controls->m_CalibrationParameterGroupBox->setEnabled(true); OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); return; } m_Controls->m_ConnectCameraButton->setEnabled(true); } else if (m_Controls->m_ConnectCameraButton->text()=="Disconnect") { //send camera stop to the caller functionality emit ToFCameraStop(); this->m_ToFImageGrabber->StopCamera(); this->m_ToFImageGrabber->DisconnectCamera(); m_Controls->m_ConnectCameraButton->setText("Connect"); m_Controls->m_SelectCameraCombobox->setEnabled(true); // m_Controls->m_CalibrationParameterGroupBox->setEnabled(true); OnSelectCamera(m_Controls->m_SelectCameraCombobox->currentText()); this->m_ToFImageGrabber = NULL; // send disconnect signal to the caller functionality emit ToFCameraDisconnected(); } } /* void QmitkToFConnectionWidget::OnChangeIntegrationTimeSpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); if (active) { m_ToFImageGrabber->StartCamera(); } } } void QmitkToFConnectionWidget::OnChangeModulationFrequencySpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_ModulationFrequency = m_Controls->m_ModulationFrequencySpinBox->value(); this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); if (active) { m_ToFImageGrabber->StartCamera(); } } } */ diff --git a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp index 6c3f9e2ac0..2f21b1a895 100644 --- a/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp +++ b/Modules/ToFUI/Qmitk/QmitkToFMESAParameterWidget.cpp @@ -1,176 +1,176 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date: 2009-05-20 13:35:09 +0200 (Mi, 20 Mai 2009) $ Version: $Revision: 17332 $ 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. =========================================================================*/ //#define _USE_MATH_DEFINES #include //QT headers #include #include #include //mitk headers #include //itk headers #include const std::string QmitkToFMESAParameterWidget::VIEW_ID = "org.mitk.views.qmitktofpmdparameterwidget"; QmitkToFMESAParameterWidget::QmitkToFMESAParameterWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f) { this->m_IntegrationTime = 0; this->m_ModulationFrequency = 0; this->m_ToFImageGrabber = NULL; m_Controls = NULL; CreateQtPartControl(this); } QmitkToFMESAParameterWidget::~QmitkToFMESAParameterWidget() { } void QmitkToFMESAParameterWidget::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkToFMESAParameterWidgetControls; m_Controls->setupUi(parent); this->CreateConnections(); } } void QmitkToFMESAParameterWidget::CreateConnections() { if ( m_Controls ) { connect( m_Controls->m_IntegrationTimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeIntegrationTimeSpinBox(int)) ); - connect( m_Controls->m_ModulationFrequencyComboBox, SIGNAL(valueChanged(int)), this, SLOT(OnChangeModulationFrequencyComboBox(int)) ); + connect( m_Controls->m_ModulationFrequencyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChangeModulationFrequencyComboBox(int)) ); connect( m_Controls->m_FPNCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeFPNCheckBox(bool)) ); connect( m_Controls->m_ConvGrayCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeConvGrayCheckBox(bool)) ); connect( m_Controls->m_MedianCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeMedianCheckBox(bool)) ); connect( m_Controls->m_ANFCB, SIGNAL(toggled(bool)), this, SLOT(OnChangeANFCheckBox(bool)) ); } } mitk::ToFImageGrabber* QmitkToFMESAParameterWidget::GetToFImageGrabber() { return this->m_ToFImageGrabber; } void QmitkToFMESAParameterWidget::SetToFImageGrabber(mitk::ToFImageGrabber* aToFImageGrabber) { this->m_ToFImageGrabber = aToFImageGrabber; } void QmitkToFMESAParameterWidget::ActivateAllParameters() { this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); switch(m_Controls->m_ModulationFrequencyComboBox->currentIndex()) { case 0: this->m_ModulationFrequency = 29; break; case 1: this->m_ModulationFrequency = 30; break; case 2: this->m_ModulationFrequency = 31; break; default: this->m_ModulationFrequency = 30; break; } this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); //set the MESA acquire mode according to the check boxes bool boolValue = false; boolValue = m_Controls->m_FPNCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetFPN", boolValue); boolValue = m_Controls->m_ConvGrayCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetConvGray", boolValue); boolValue = m_Controls->m_MedianCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetMedian", boolValue); boolValue = m_Controls->m_ANFCB->isChecked(); this->m_ToFImageGrabber->SetBoolProperty("SetANF", boolValue); //reset the GUI elements m_Controls->m_IntegrationTimeSpinBox->setValue(this->m_IntegrationTime); //m_Controls->m_ModulationFrequencyComboBox->setValue(this->m_ModulationFrequency); } void QmitkToFMESAParameterWidget::OnChangeFPNCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetFPN", checked); } void QmitkToFMESAParameterWidget::OnChangeConvGrayCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetConvGray", checked); } void QmitkToFMESAParameterWidget::OnChangeMedianCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetMedian", checked); } void QmitkToFMESAParameterWidget::OnChangeANFCheckBox(bool checked) { this->m_ToFImageGrabber->SetBoolProperty("SetANF", checked); } void QmitkToFMESAParameterWidget::OnChangeIntegrationTimeSpinBox(int value) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } this->m_IntegrationTime = m_Controls->m_IntegrationTimeSpinBox->value(); this->m_IntegrationTime = this->m_ToFImageGrabber->SetIntegrationTime(this->m_IntegrationTime); if (active) { m_ToFImageGrabber->StartCamera(); } } } void QmitkToFMESAParameterWidget::OnChangeModulationFrequencyComboBox(int index) { if (this->m_ToFImageGrabber != NULL) { // stop camera if active bool active = m_ToFImageGrabber->IsCameraActive(); if (active) { m_ToFImageGrabber->StopCamera(); } switch(index) { case 0: this->m_ModulationFrequency = 29; break; case 1: this->m_ModulationFrequency = 30; break; case 2: this->m_ModulationFrequency = 31; break; default: this->m_ModulationFrequency = 30; break; } this->m_ModulationFrequency = this->m_ToFImageGrabber->SetModulationFrequency(this->m_ModulationFrequency); if (active) { m_ToFImageGrabber->StartCamera(); } } }