]> Creatis software - clitk.git/commitdiff
Add wipe tools (1)
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 25 Jul 2016 13:16:23 +0000 (15:16 +0200)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 25 Jul 2016 13:16:23 +0000 (15:16 +0200)
vv/CMakeLists.txt
vv/icons/wipe.png [new file with mode: 0644]
vv/qt_ui/vvMainWindow.ui
vv/qt_ui/vvWipeImage.ui [new file with mode: 0644]
vv/vvIcons.qrc
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvWipeImage.cxx
vv/vvWipeImage.h

index a0a227fc848cf71fe9cd9b9c55c3c758f29c7993..d15070bca32a96a5436de56fad57c12bfc8f6c37 100644 (file)
@@ -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 (file)
index 0000000..6944f39
Binary files /dev/null and b/vv/icons/wipe.png differ
index cf2371ca5314d1901dc9eda84b046615492db43b..91774e8c075a810b1bcd22b3245aef50229b1ecc 100644 (file)
     <addaction name="actionAdd_overlay_image_to_current_image"/>
     <addaction name="actionAdd_fusion_image"/>
     <addaction name="actionAdd_USSequence_toCT"/>
+    <addaction name="actionAdd_wipe_image"/>
    </widget>
    <widget class="QMenu" name="menuScreenshots">
     <property name="title">
     <bool>true</bool>
    </property>
   </action>
+  <action name="actionAdd_wipe_image">
+   <property name="icon">
+    <iconset resource="../vvIcons.qrc">
+     <normaloff>:/common/icons/wipe.png</normaloff>:/common/icons/wipe.png</iconset>
+   </property>
+   <property name="text">
+    <string>Add wipe Image</string>
+   </property>
+   <property name="iconVisibleInMenu">
+    <bool>true</bool>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>
diff --git a/vv/qt_ui/vvWipeImage.ui b/vv/qt_ui/vvWipeImage.ui
new file mode 100644 (file)
index 0000000..856bbc8
--- /dev/null
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvWipeImage</class>
+ <widget class="QWidget" name="vvWipeImage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>314</width>
+    <height>197</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Wipe image</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_3">
+     <item>
+      <layout class="QGridLayout" name="gridLayout_2">
+       <item row="2" column="2">
+        <widget class="vvIntensityValueSlider" name="mThresholdSlider2" native="true">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Foreground (FG) is greater than : </string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="2">
+        <widget class="vvIntensityValueSlider" name="mThresholdSlider1" native="true"/>
+       </item>
+       <item row="2" column="1">
+        <widget class="QRadioButton" name="mRadioButtonLowerThan">
+         <property name="text">
+          <string>and lower than</string>
+         </property>
+         <property name="autoExclusive">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="Line" name="line_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Resulting wipe image:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_4">
+       <item>
+        <widget class="QCheckBox" name="mCheckBoxUseFG">
+         <property name="text">
+          <string>Use FG</string>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="vvIntensityValueSlider" name="mFGSlider" native="true">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_5">
+       <item>
+        <widget class="QCheckBox" name="mCheckBoxUseBG">
+         <property name="text">
+          <string>Use BG</string>
+         </property>
+         <property name="checked">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="vvIntensityValueSlider" name="mBGSlider" native="true"/>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="Line" name="line_3">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="mCheckBoxInteractiveDisplay">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="text">
+      <string>Interactive (unchek to disable on the fly contours drawing)</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>vvIntensityValueSlider</class>
+   <extends>QWidget</extends>
+   <header>vvIntensityValueSlider.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>mRadioButtonLowerThan</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mThresholdSlider2</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>85</x>
+     <y>129</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>305</x>
+     <y>129</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>mCheckBoxUseBG</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mBGSlider</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>79</x>
+     <y>203</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>395</x>
+     <y>225</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>mCheckBoxUseFG</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>mFGSlider</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>63</x>
+     <y>177</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>242</x>
+     <y>177</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index e1604607aa8af0e2f57effbd728d23a04408047c..8c8d0a5fbdd40441a3f447fcb16eb3dd8b792e82 100644 (file)
@@ -41,5 +41,6 @@
     <file>icons/standardbutton-apply-16.png</file>
     <file>icons/standardbutton-cancel-16.png</file>
     <file>icons/identity.png</file>
+    <file>icons/wipe.png</file>
   </qresource>
 </RCC>
index 1bc0759e8ee14671f60a29dcc493623f2f0293b0..0075d46aa76718d59321c792adbd0045465602b2 100644 (file)
@@ -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<std::string> vecFileNames;
+  for (int i = 0; i < files.size(); i++) {
+    vecFileNames.push_back(files[i].toStdString());
+  }
+
+  //AddWipeImage(index,vecFileNames,vvImageReader::IMAGE);
+}
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionImage()
 { 
index 9253fa07a21a0f41853300b869d34c393fa5ed3f..1e0ad6fdfc61cfc10607cd3d16f1284d2db1defa 100644 (file)
@@ -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();
index 967c3015a14bca405552587b17d8868f586f8605..7c7cc00c0888b73a16b4ad572bbba435663aa220 100644 (file)
@@ -38,7 +38,6 @@
 #include <vtkInformation.h>
 #include <vtkImageData.h>
 #include <vtkSmartPointer.h>
-#include <vtkImageRectilinearWipe.h>
 
 //------------------------------------------------------------------------------
 // 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<vtkImageRectilinearWipe> mWipe = vtkSmartPointer<vtkImageRectilinearWipe>::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; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++)
-      mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false);
-    UpdateExtent();
-  }
   mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(mConcatenedTransform);
   for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
     mCurrentSlicerManager->GetSlicer(i)->ResetCamera();
@@ -105,11 +99,6 @@ bool vvWipeImage::close()
 //------------------------------------------------------------------------------
 void vvWipeImage::reject()
 {
-  for(int i=0; i<mExtentSize; i++)
-    mReducedExtent[i] = mInitialExtent[i];
-  for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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; dim<slicer->GetDimension() && 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; i<mSliders.size(); ++i){
-    signalMapper->setMapping(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; dim<mCurrentSlicerManager->GetDimension() && 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);
index f44de564881e267d0be96bd0d0e1176d9534d117..9b3970883865813f97748fc4a7856b5231f80e76 100644 (file)
 #include "vvToolBase.h"
 #include "vvToolWidgetBase.h"
 #include "vvMainWindowBase.h"
-//#include "ui_vvWipeImage.h"
+#include "ui_vvWipeImage.h"
 //vtk
 #include <vtkTransform.h>
+#include <vtkImageRectilinearWipe.h>
 
 //------------------------------------------------------------------------------
 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<vtkImageRectilinearWipe> mWipe;
   void UpdateWipe();
   virtual void closeEvent(QCloseEvent *event);
+  vtkSmartPointer<vtkMatrix4x4> mConcatenedTransform;
+  vvImage::Pointer mImage;
 
 }; // end class vvWipeImage
 //------------------------------------------------------------------------------