From: dsarrut Date: Fri, 18 Mar 2011 12:49:55 +0000 (+0000) Subject: Check image size before performing operation X-Git-Tag: v1.2.0~150 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9dcfc70a568fda4cc6835eb55fc0e5f22b9e91d0;p=clitk.git Check image size before performing operation --- diff --git a/vv/vvToolImageArithm.cxx b/vv/vvToolImageArithm.cxx index 897e3d6..f4eb043 100644 --- a/vv/vvToolImageArithm.cxx +++ b/vv/vvToolImageArithm.cxx @@ -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; @@ -148,14 +146,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