]> Creatis software - clitk.git/blobdiff - vv/vvToolImageArithm.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / vv / vvToolImageArithm.cxx
index 897e3d661a5f2aa28b581b6415037f810a8c1caf..7b62110d275ac4ab234b4baa36088653c6e10756 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 
 #include "vvToolImageArithm.h"
 #include "vvSlicer.h"
@@ -82,7 +82,6 @@ void vvToolImageArithm::InputIsSelected(vvSlicerManager * l)
 {
   mInput1 = l;
   mTwoInputs = false;
-  // DD("Single input");
   mGroupBoxTwoInputs->setEnabled(false);
   mGroupBoxOneInput->setEnabled(true);
 }
@@ -92,7 +91,6 @@ void vvToolImageArithm::InputIsSelected(vvSlicerManager * l)
 //------------------------------------------------------------------------------
 void vvToolImageArithm::GetArgsInfoFromGUI()
 {
-  //  DD("GetArgsInfoFromGUI");
   mArgsInfo.input1_given = false;
   if (mTwoInputs) {
     mArgsInfo.input2_given = true;
@@ -105,6 +103,8 @@ void vvToolImageArithm::GetArgsInfoFromGUI()
     if (radioButtonMin->isChecked()) mArgsInfo.operation_arg = 4;
     if (radioButtonAbsDiff->isChecked()) mArgsInfo.operation_arg = 5;
     if (radioButtonSquaredDiff->isChecked()) mArgsInfo.operation_arg = 6;
+    if (radioButtonDifference->isChecked()) mArgsInfo.operation_arg = 7;
+    if (radioButtonRelativeDiff->isChecked()) mArgsInfo.operation_arg = 8;
   } else {
     mArgsInfo.input2_given = false;
     mArgsInfo.scalar_given = true;
@@ -115,9 +115,12 @@ void vvToolImageArithm::GetArgsInfoFromGUI()
     if (radioButtonMinV->isChecked()) mArgsInfo.operation_arg = 4;
     if (radioButtonAbsDiffV->isChecked()) mArgsInfo.operation_arg = 5;
     if (radioButtonSquaredDiffV->isChecked()) mArgsInfo.operation_arg = 6;
-    if (radioButtonLogV->isChecked()) mArgsInfo.operation_arg = 7;
-    if (radioButtonExpV->isChecked()) mArgsInfo.operation_arg = 8;
+    if (radioButtonLogAlone->isChecked()) mArgsInfo.operation_arg = 7;
+    if (radioButtonExpAlone->isChecked()) mArgsInfo.operation_arg = 8;
     if (radioButtonSqrtV->isChecked()) mArgsInfo.operation_arg = 9;
+    if (radioButtonDivideV->isChecked()) mArgsInfo.operation_arg = 11;
+    if (radioButtonNormalize->isChecked()) mArgsInfo.operation_arg = 12;
+    if (radioButtonLogV->isChecked()) mArgsInfo.operation_arg = 13;
     mArgsInfo.scalar_given = true;
     mArgsInfo.scalar_arg = mValueSpinBox->value();
   }
@@ -148,14 +151,22 @@ void vvToolImageArithm::apply()
       std::cerr << "Input1 = " << inputs[0]->GetScalarTypeAsITKString() << std::endl;
       std::cerr << "Input2 = " << inputs[1]->GetScalarTypeAsITKString() << std::endl;
       QApplication::restoreOverrideCursor();
-      QMessageBox::information(this, "Wrong image type","Sorry, could not perform operation. Please select inputs with same pixe type.");
+      QMessageBox::information(this, "Wrong image type","Sorry, could not perform operation. Please select inputs with same pixel type.");
+      close();
+      return;
+    }
+    
+    // Check size
+    if (!mInput1->GetImage()->HaveSameSizeAndSpacingThan(mInput2->GetImage())) {
+      std::cerr << "Sorry inputs should have the same size and spacing." << std::endl;
+      QApplication::restoreOverrideCursor();
+      QMessageBox::information(this, "Wrong images size","Sorry, could not perform operation. Please select inputs with same size and spacing.");
       close();
       return;
     }
   } else {
     // Input
     inputs.push_back(mInput1->GetImage());
-    DD("Single input");
   }
 
   // Main filter