From: tbaudier Date: Mon, 25 Jul 2016 13:16:23 +0000 (+0200) Subject: Add wipe tools (1) X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8ff203b82a71124d7a6cf996d07dc6a59f57cbc5;p=clitk.git Add wipe tools (1) --- diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index a0a227f..d15070b 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -70,6 +70,7 @@ set(vv_COMMON_WITH_UI vvToolSimpleInputSelectorWidget vvToolInputSelectorWidget vvRegisterForm + vvWipeImage ) # All others sources diff --git a/vv/icons/wipe.png b/vv/icons/wipe.png new file mode 100644 index 0000000..6944f39 Binary files /dev/null and b/vv/icons/wipe.png differ diff --git a/vv/qt_ui/vvMainWindow.ui b/vv/qt_ui/vvMainWindow.ui index cf2371c..91774e8 100644 --- a/vv/qt_ui/vvMainWindow.ui +++ b/vv/qt_ui/vvMainWindow.ui @@ -832,6 +832,7 @@ + @@ -1276,6 +1277,18 @@ true + + + + :/common/icons/wipe.png:/common/icons/wipe.png + + + Add wipe Image + + + true + + diff --git a/vv/qt_ui/vvWipeImage.ui b/vv/qt_ui/vvWipeImage.ui new file mode 100644 index 0000000..856bbc8 --- /dev/null +++ b/vv/qt_ui/vvWipeImage.ui @@ -0,0 +1,189 @@ + + + vvWipeImage + + + + 0 + 0 + 314 + 197 + + + + Wipe image + + + + + + + + + + false + + + + + + + Foreground (FG) is greater than : + + + + + + + + + + and lower than + + + false + + + + + + + + + + + + + Qt::Horizontal + + + + + + + Resulting wipe image: + + + + + + + + + Use FG + + + false + + + + + + + false + + + + + + + + + + + Use BG + + + true + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + true + + + Interactive (unchek to disable on the fly contours drawing) + + + true + + + + + + + + vvIntensityValueSlider + QWidget +
vvIntensityValueSlider.h
+ 1 +
+
+ + + + mRadioButtonLowerThan + toggled(bool) + mThresholdSlider2 + setEnabled(bool) + + + 85 + 129 + + + 305 + 129 + + + + + mCheckBoxUseBG + toggled(bool) + mBGSlider + setEnabled(bool) + + + 79 + 203 + + + 395 + 225 + + + + + mCheckBoxUseFG + toggled(bool) + mFGSlider + setEnabled(bool) + + + 63 + 177 + + + 242 + 177 + + + + +
diff --git a/vv/vvIcons.qrc b/vv/vvIcons.qrc index e160460..8c8d0a5 100644 --- a/vv/vvIcons.qrc +++ b/vv/vvIcons.qrc @@ -41,5 +41,6 @@ icons/standardbutton-apply-16.png icons/standardbutton-cancel-16.png icons/identity.png + icons/wipe.png diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 1bc0759..0075d46 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -197,6 +197,9 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() contextActions.push_back(actionAdd_USSequence_toCT); #endif + contextMenu.addAction(actionAdd_wipe_image); + contextActions.push_back(actionAdd_wipe_image); + contextMenu.addSeparator(); QAction* actionResetMatrix = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/identity.png")), @@ -237,6 +240,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() actionAdd_VF_to_current_Image->setEnabled(0); actionAdd_fusion_image->setEnabled(0); actionAdd_USSequence_toCT->setEnabled(0); + actionAdd_wipe_image->setEnabled(0); //init the sliders verticalSliders.push_back(NOVerticalSlider); @@ -283,6 +287,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(actionRead_saved_state,SIGNAL(triggered()),this,SLOT(ReadSavedState())); connect(actionExit,SIGNAL(triggered()),this,SLOT(close())); connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField())); + connect(actionAdd_wipe_image,SIGNAL(triggered()),this,SLOT(SelectWipeImage())); connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage())); connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage())); connect(actionAdd_USSequence_toCT,SIGNAL(triggered()), this,SLOT(SelectFusionSequence())); @@ -1052,6 +1057,7 @@ void vvMainWindow::ImageInfoChanged() actionSave_As->setEnabled(1); actionAdd_VF_to_current_Image->setEnabled(1); actionAdd_fusion_image->setEnabled(1); + actionAdd_wipe_image->setEnabled(1); actionAdd_overlay_image_to_current_image->setEnabled(1); actionAdd_USSequence_toCT->setEnabled(1); actionNorth_East_Window->setEnabled(1); @@ -2138,6 +2144,30 @@ void vvMainWindow::AddROI(int index, QString file) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::SelectWipeImage() +{ + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + + if (!(CheckAddedImage(index, "wipe"))) + return; + + QString Extensions = EXTENSIONS; + Extensions += ";;All Files (*)"; + QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Wipe image"),mInputPathName,Extensions); + if (files.isEmpty()) + return; + + std::vector vecFileNames; + for (int i = 0; i < files.size(); i++) { + vecFileNames.push_back(files[i].toStdString()); + } + + //AddWipeImage(index,vecFileNames,vvImageReader::IMAGE); +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvMainWindow::SelectFusionImage() { diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 9253fa0..1e0ad6f 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -158,6 +158,7 @@ public slots: void ReloadImage(); void OpenField(); void SelectOverlayImage(); + void SelectWipeImage(); void SelectFusionImage(); //select the file(s) from the disk containing the image sequence to fuse void SelectFusionSequence(); diff --git a/vv/vvWipeImage.cxx b/vv/vvWipeImage.cxx index 967c301..7c7cc00 100644 --- a/vv/vvWipeImage.cxx +++ b/vv/vvWipeImage.cxx @@ -38,7 +38,6 @@ #include #include #include -#include //------------------------------------------------------------------------------ // Create the tool and automagically (I like this word) insert it in @@ -53,6 +52,8 @@ vvWipeImage::vvWipeImage(vvMainWindowBase * parent, Qt::WindowFlags f): Ui::vvWipeImage() { vtkSmartPointer mWipe = vtkSmartPointer::New(); + mWipe->SetWipe(0); + mWipe->SetPosition(256,256); } //------------------------------------------------------------------------------ @@ -60,29 +61,22 @@ vvWipeImage::vvWipeImage(vvMainWindowBase * parent, Qt::WindowFlags f): //------------------------------------------------------------------------------ vvWipeImage::~vvWipeImage() { - delete [] mReducedExtent; - delete [] mInitialExtent; } //------------------------------------------------------------------------------ -void vvWipeImage::setInput(int number, ) +//------------------------------------------------------------------------------ +void vvWipeImage::setInput(int number, vvImage::Pointer image) { - mWipe->SetInputConnection(0,reader1->GetOutputPort()); + if (image->GetVTKImages().size()) { + mImage = image; + mWipe->SetInputData(number, mImage->GetVTKImages()[0]); //[0] pour du 4D ? + } } - wipe->SetInputConnection(0,reader1->GetOutputPort()); - wipe->SetInputConnection(1,reader2->GetOutputPort()); +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvWipeImage::closeEvent(QCloseEvent *event) { - if(mCurrentSlicerManager){ -// Reset extends - for(int i=0; i<6; i++){ - mReducedExtent[i] = mInitialExtent[i]; - } - for(int i=0; iGetNumberOfSlicers(); i++) - mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false); - UpdateExtent(); - } mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(mConcatenedTransform); for (int i=0; iGetNumberOfSlicers(); i++) { mCurrentSlicerManager->GetSlicer(i)->ResetCamera(); @@ -105,11 +99,6 @@ bool vvWipeImage::close() //------------------------------------------------------------------------------ void vvWipeImage::reject() { - for(int i=0; iGetNumberOfSlicers(); i++) - mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false); - UpdateExtent(); return vvToolWidgetBase::reject(); } //------------------------------------------------------------------------------ @@ -118,13 +107,7 @@ void vvWipeImage::reject() //------------------------------------------------------------------------------ void vvWipeImage::crossPointerChanged() { - int dimMin = dim; - if(dim%2==0){//case we are minimum - mSliders[dim+1]->setMinimum(mSliders[dim]->value()); - }else { - mSliders[--dimMin]->setMaximum(mSliders[dim]->value()); - } - mReducedExtent[dim] = mSliders[dim]->value() + mInitialExtent[dimMin]; + mWipe->SetPosition(256,256); UpdateWipe(); } //------------------------------------------------------------------------------ @@ -134,7 +117,7 @@ void vvWipeImage::crossPointerChanged() void vvWipeImage::UpdateWipe() { for(int i=0; iGetNumberOfSlicers(); i++) { - mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent); + //mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mReducedExtent); mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent(); mCurrentSlicerManager->GetSlicer(i)->Render(); } @@ -158,74 +141,18 @@ void vvWipeImage::InputIsSelected(vvSlicerManager * slicer) } // Change interface according to number of dimension - mExtentSize = 2*slicer->GetDimension(); - if (slicer->GetDimension()<4) { - mTLabel1->setHidden(true); - mTLabel2->setHidden(true); - tminSlider->setHidden(true); - tmaxSlider->setHidden(true); - spin_tmin->setHidden(true); - spin_tmax->setHidden(true); - mLabelTimeCropping->setHidden(true); - } - if (slicer->GetDimension()<3) { - mZLabel1->setHidden(true); - mZLabel2->setHidden(true); - zminSlider->setHidden(true); - zmaxSlider->setHidden(true); - spin_zmin->setHidden(true); - spin_zmax->setHidden(true); - } #if VTK_MAJOR_VERSION <= 5 int *a = mCurrentImage->GetFirstVTKImageData()->GetWholeExtent(); #else int *a = mCurrentImage->GetFirstVTKImageData()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()); #endif - for(int i=0; i<6; i++){ - mInitialExtent[i] = a[i]; - mReducedExtent[i] = a[i]; - } - for(int i=0; iGetNumberOfSlicers(); i++) { - mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true); - mCurrentSlicerManager->GetSlicer(i)->SetReducedExtent(mInitialExtent); - } // Set initial sliders values int w_ext[6], imsize[3]; mCurrentSlicerManager->GetSlicer(0)->GetRegisterExtent(w_ext); - for(int dim=0; dimGetDimension() && dim<3; ++dim){ - imsize[dim] = w_ext[2*dim+1] - w_ext[2*dim] +1; - mSliders[dim*2]->setMaximum(imsize[dim]-1); - mSliders[dim*2+1]->setMaximum(imsize[dim]-1); - mSliders[dim*2+1]->setValue(imsize[dim]-1); - } - spin_xmin->setMaximum(imsize[0]-1); - spin_xmax->setMaximum(imsize[0]-1); - spin_xmax->setValue(imsize[0]-1); - - spin_ymin->setMaximum(imsize[1]-1); - spin_ymax->setMaximum(imsize[1]-1); - spin_ymax->setValue(imsize[1]-1); - - if (slicer->GetDimension() >2) { - spin_zmin->setMaximum(imsize[2]-1); - spin_zmax->setMaximum(imsize[2]-1); - spin_zmax->setValue(imsize[2]-1); - } - - if (slicer->GetDimension() >3) { - spin_tmin->setMaximum(imsize[3]-1); - spin_tmax->setMaximum(imsize[3]-1); - spin_tmax->setValue(imsize[3]-1); - } QSignalMapper* signalMapper = new QSignalMapper(this); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(sliderValueChanged(int))); - for(unsigned int i=0; isetMapping(mSliders[i], i); - connect(mSliders[i], SIGNAL(valueChanged(int)), signalMapper, SLOT(map())); - } - UpdateExtent(); } //------------------------------------------------------------------------------ @@ -247,21 +174,8 @@ void vvWipeImage::apply() mArgsInfo.boundingBox_given = n; mArgsInfo.boundingBox_arg = new int[n]; - for(int dim=0; dimGetDimension() && dim<3; ++dim){ - mArgsInfo.boundingBox_arg[dim*2] = mSliders[dim*2]->value(); - mArgsInfo.boundingBox_arg[dim*2+1] = mSliders[dim*2+1]->value(); - } - if (n>6) { // 4D - mArgsInfo.boundingBox_arg[6] = 0; - mArgsInfo.boundingBox_arg[7] = mCurrentImage->GetSize()[3]-1; - } // We MUST reset initial extend to input image before using the - // filter to retrieve the correct image size - for(int i=0; i<6; i++) { - mReducedExtent[i] = mInitialExtent[i]; - } - - UpdateExtent(); + // filter to retrieve the correct image size ; // Main filter CropFilterType::Pointer filter = CropFilterType::New(); filter->SetInputVVImage(mCurrentImage); diff --git a/vv/vvWipeImage.h b/vv/vvWipeImage.h index f44de56..9b39708 100644 --- a/vv/vvWipeImage.h +++ b/vv/vvWipeImage.h @@ -27,9 +27,10 @@ #include "vvToolBase.h" #include "vvToolWidgetBase.h" #include "vvMainWindowBase.h" -//#include "ui_vvWipeImage.h" +#include "ui_vvWipeImage.h" //vtk #include +#include //------------------------------------------------------------------------------ class vvWipeImage: @@ -43,6 +44,7 @@ class vvWipeImage: ~vvWipeImage(); virtual void InputIsSelected(vvSlicerManager *m); + void setInput(int number, vvImage::Pointer image); public slots: virtual void apply(); @@ -63,6 +65,8 @@ public slots: vtkSmartPointer mWipe; void UpdateWipe(); virtual void closeEvent(QCloseEvent *event); + vtkSmartPointer mConcatenedTransform; + vvImage::Pointer mImage; }; // end class vvWipeImage //------------------------------------------------------------------------------