]> Creatis software - clitk.git/commitdiff
new multiple input selector for default vvToolWidget
authordsarrut <dsarrut>
Wed, 17 Mar 2010 11:22:18 +0000 (11:22 +0000)
committerdsarrut <dsarrut>
Wed, 17 Mar 2010 11:22:18 +0000 (11:22 +0000)
vv/CMakeLists.txt
vv/qt_ui/vvToolInputSelectorWidget.ui
vv/qt_ui/vvToolWidgetBase.ui
vv/vvToolBinarize.cxx
vv/vvToolBinarize.h
vv/vvToolCropImage.cxx
vv/vvToolInputSelectorWidget.cxx
vv/vvToolInputSelectorWidget.h
vv/vvToolWidgetBase.cxx
vv/vvToolWidgetBase.h

index 25b2770ce0408b7dc4227bdf45593f0a9514eb4b..b50d8892c0b6bae2ad926e5c29d624409657813f 100644 (file)
@@ -107,6 +107,7 @@ SET(vv_SRCS
 #  vvToolFooWithWidgetBase.cxx
   vvToolCropImage.cxx
   vvToolBinarize.cxx
+  vvToolSimpleInputSelectorWidget.cxx
   vvToolInputSelectorWidget.cxx
   vvImageContour.cxx
   )
@@ -134,6 +135,7 @@ QT4_WRAP_CPP(vv_SRCS
 #  vvToolFoo.h
 #  vvToolFooWithWidgetBase.h
   vvToolBinarize.h
+  vvToolSimpleInputSelectorWidget.h
   vvToolInputSelectorWidget.h
   vvToolWidgetBase.h
   vvToolCropImage.h
@@ -160,6 +162,7 @@ QT4_WRAP_UI(vv_UI_CXX
 #  qt_ui/vvToolFoo.ui
   qt_ui/vvToolCropImage.ui
   qt_ui/vvToolBinarize.ui
+  qt_ui/vvToolSimpleInputSelectorWidget.ui
   qt_ui/vvToolInputSelectorWidget.ui
   )
 
index 775591ab977142ec7e65252a0df91211b0cef79c..96ae5acfa24675edea9d15d2741dcbfbd5ad9b3c 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>276</width>
-    <height>98</height>
+    <width>676</width>
+    <height>381</height>
    </rect>
   </property>
   <property name="font">
   <property name="autoFillBackground">
    <bool>false</bool>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <property name="margin">
-    <number>2</number>
-   </property>
-   <item row="0" column="0">
-    <widget class="QGroupBox" name="groupBox">
-     <property name="title">
-      <string>Select input image</string>
-     </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <property name="margin">
-       <number>2</number>
-      </property>
-      <item row="0" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <item>
-         <widget class="QComboBox" name="mInputSequenceBox">
-          <property name="font">
-           <font>
-            <pointsize>11</pointsize>
-           </font>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-      <item row="1" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout_2">
-        <item>
-         <widget class="QLabel" name="mLabelInputInfo">
-          <property name="font">
-           <font>
-            <pointsize>11</pointsize>
-           </font>
-          </property>
-          <property name="frameShape">
-           <enum>QFrame::NoFrame</enum>
-          </property>
-          <property name="text">
-           <string>3D image
-Pixel type short
-bla bla</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QDialogButtonBox" name="mInputSelectionButtonBox">
-          <property name="standardButtons">
-           <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
-  </layout>
+  <layout class="QVBoxLayout" name="mVerticalLayout"/>
  </widget>
  <resources/>
  <connections/>
index 0effdb51a49cae534566ac6241d823e26493556e..567b595e258e1dad4faa07efbabba4fe66aa02c4 100644 (file)
@@ -25,6 +25,9 @@
    </item>
    <item>
     <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
   </layout>
-  <zorder>splitter</zorder>
-  <zorder>buttonBox</zorder>
-  <zorder>mToolInputSelectionWidget</zorder>
-  <zorder>groupBox</zorder>
  </widget>
  <customwidgets>
   <customwidget>
index 09016f080e8d045f4e272c75bac2fc97c882b2a6..343350ce2731a40dcf2c95ecabfbeff21c2566ea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBinarize.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/03/05 10:32:33 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.12 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -76,7 +76,10 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
   mBGSlider->SetText("Background value");
 
   // Main filter 
-  mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>; //DS PUT IN BASECLASS ?
+  mFilter = new clitk::BinarizeImageGenericFilter<args_info_clitkBinarizeImage>;
+
+  // Set how many inputs are needed for this tool
+  AddInputSelector(mFilter);
 }
 //------------------------------------------------------------------------------
 
@@ -96,7 +99,8 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) {
   else {
     for(unsigned int i=0; i<mImageContour.size(); i++) {
       mImageContour[i]->showActors();
-      mImageContourLower[i]->showActors();
+      if (mRadioButtonLowerThan->isChecked())
+        mImageContourLower[i]->showActors();
     }
     if (mCurrentSlicerManager)
       mCurrentSlicerManager->Render();
@@ -127,6 +131,7 @@ bool vvToolBinarize::close() {
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::reject() { 
+  DD("vvToolBinarize::reject");
   RemoveVTKObjects();
   return vvToolWidgetBase::reject(); 
 }
@@ -163,6 +168,10 @@ void vvToolBinarize::useFGBGtoggled(bool) {
 
 
 //------------------------------------------------------------------------------
+// void vvToolBinarize::InputIsSelected(std::vector<vvSlicerManager *> & m) {
+//   DD("vvToolBinarize::InputIsSelected vector in binarize");
+//   DD(m.size());
+// }
 void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
   mCurrentSlicerManager = m;
 
index 4b0721f1e8b5bf64280695b7e3a46e1922182f4b..fbc5a24ee5d841dec6b39e20cf02250bf2145d5f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolBinarize.h,v $
   Language:  C++
-  Date:      $Date: 2010/03/05 10:32:33 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.9 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -51,6 +51,8 @@ class vvToolBinarize:
   static void Initialize();
   void InputIsSet(bool b);
   void GetArgsInfoFromGUI();
+  virtual void InputIsSelected(vvSlicerManager * m);
+  //  virtual void InputIsSelected(std::vector<vvSlicerManager *> & m);
 
   //-----------------------------------------------------
   public slots:
@@ -60,7 +62,6 @@ class vvToolBinarize:
   void valueChangedT1(double v);
   void valueChangedT2(double v);
   void UpdateSlice(int slicer,int slices);
-  void InputIsSelected(vvSlicerManager * m);
   void enableLowerThan(bool b);
   void useFGBGtoggled(bool);
   void InteractiveDisplayToggled(bool b);
index ba97489b8da372479c7c35aa9a8c755e5ab8331f..b50e332c6cfc1bf1e9156ace449fd9eb7c7fe36b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolCropImage.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/03/01 15:38:09 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.4 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -51,6 +51,8 @@ vvToolCropImage::vvToolCropImage(vvMainWindowBase * parent, Qt::WindowFlags f):
   // GUI Initialization
   Ui_vvToolCropImage::setupUi(mToolWidget);
 
+  // Set how many inputs are needed for this tool
+  AddInputSelector();
 }
 //------------------------------------------------------------------------------
 
@@ -191,6 +193,9 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) {
   mReducedExtent = mCurrentSlicerManager->GetImage()->GetFirstVTKImageData()->GetWholeExtent();
   for(int i=0; i<6; i++) mInitialExtent[i] = mReducedExtent[i];
   for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+    DD(i);
+    DD(mReducedExtent[i]);
+    DD(mInitialExtent[i]);
     mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(true);
   }
   
@@ -251,6 +256,7 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) {
   // connect(tmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMaxValueChanged(int)));
   
   //  connect(mIntensitySlider, SIGNAL(valueChanged(double)), this, SLOT(autoCropValueChanged(double)));
+  UpdateExtent();
 }
 //------------------------------------------------------------------------------
 
index 482c2410909d906ef230cd88de57b1a93a5e3133..257966013c7fdb011685f108f9fa2d2ba245bbdb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolInputSelectorWidget.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/03/01 15:38:09 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.4 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -28,6 +28,7 @@
 #ifndef VVTOOLINPUTSELECTORWIDGET_CXX
 #define VVTOOLINPUTSELECTORWIDGET_CXX
 
+#include "vvToolSimpleInputSelectorWidget.h"
 #include "vvToolInputSelectorWidget.h"
 #include "vvSlicerManager.h"
 
 vvToolInputSelectorWidget::vvToolInputSelectorWidget(QWidget * parent, Qt::WindowFlags f):
   QWidget(parent, f) {
   setupUi(this);  
-
   setEnabled(true);
+  mNumberOfAcceptedInputs = 0;
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+int vvToolInputSelectorWidget::GetNumberOfInput() {
+  return mListOfSimpleInputWidget.size();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::AddInputSelector(const std::vector<vvSlicerManager*> & l, int index) {
+  DD("ICICICICICICICIC AddInputSelector ADD layout");
+  DD(index);
+  DD(l.size());
+  vvToolSimpleInputSelectorWidget * input = new vvToolSimpleInputSelectorWidget;
+  mListOfSimpleInputWidget.push_back(input);
+
+  // copy list
+  std::vector<vvSlicerManager*> * ll = new std::vector<vvSlicerManager*>;
+  for(unsigned int i=0; i<l.size(); i++)
+    ll->push_back(l[i]);
+
+  // add
+  input->SetInputList(*ll, index);
+  input->setObjectName(QString::fromUtf8("TOTO"));
+  mVerticalLayout->addWidget(input);
+
+  // Enable or disable
+  if (GetNumberOfInput() == 1) input->setEnabled(true);
+  else input->setEnabled(false);
+  DD(GetNumberOfInput());
 
   // Connect signals & slots  
-  connect(mInputSelectionButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
-  connect(mInputSelectionButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
-  connect(mInputSequenceBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeInput(int)));  
+  connect(input, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(input, SIGNAL(rejected()), this, SLOT(reject()));  
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolInputSelectorWidget::Initialize(std::vector<vvSlicerManager*> l, int index) {
-  mInputSequenceBox->clear();
-  mSlicerManagerList = l;
-  mCurrentIndex = index;
-  for (unsigned int i = 0; i < mSlicerManagerList.size(); i++) {
-    mInputSequenceBox->addItem(mSlicerManagerList[i]->GetFileName().c_str());
-  }
-  mInputSequenceBox->setCurrentIndex(mCurrentIndex);
-  if (mSlicerManagerList.size() == 0) {
-    // TODO !!!
-    DD("no input > error message");
-    reject();
-  }
-  if (mSlicerManagerList.size() == 1) {
-    accept();
-  }
+void vvToolInputSelectorWidget::Initialize() {
+  for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
+    mListOfSimpleInputWidget[i]->Initialize();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolInputSelectorWidget::accept() {
-  mInputSelectionButtonBox->setEnabled(false);
-  mInputSequenceBox->setEnabled(false);
-  emit accepted();
+  DD("vvToolInputSelectorWidget::accept");
+  DD(mNumberOfAcceptedInputs);
+  mNumberOfAcceptedInputs++;
+  if (mNumberOfAcceptedInputs == GetNumberOfInput()) {
+    setEnabled(false);
+    emit accepted();
+  }
+  else {
+    DD("accepted");
+    //    for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
+      //      mListOfSimpleInputWidget[i]->Initialize();
+      mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(true);
+      //}
+  }
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolInputSelectorWidget::reject() {
-  emit rejected();
+  DD("vvToolInputSelectorWidget::reject");
+  if (mNumberOfAcceptedInputs != 0)  {
+    //    for(unsigned int i=mNumberOfAcceptedInputs; i<mListOfSimpleInputWidget.size(); i++) {
+    //      mListOfSimpleInputWidget[i]->Initialize();
+    DD(mNumberOfAcceptedInputs);
+    mListOfSimpleInputWidget[mNumberOfAcceptedInputs]->setEnabled(false);
+    mListOfSimpleInputWidget[mNumberOfAcceptedInputs-1]->setEnabled(true);
+    mNumberOfAcceptedInputs--;
+    //}
+  }
+  else {
+    emit rejected();
+  }
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolInputSelectorWidget::changeInput(int index) {
-  mCurrentIndex = index;
-  vvImage * mCurrentImage = mSlicerManagerList[index]->GetImage();
-  unsigned int d = mCurrentImage->GetNumberOfDimensions();
-  QString size;
-  QString spacing;
-  for(unsigned int i=0; i<d-1; i++) {
-    size.append(QString("%1").arg(mCurrentImage->GetSize()[i]));
-    size.append("x");
-    spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[i]));
-    spacing.append("x");
-  }
-  size.append(QString("%1").arg(mCurrentImage->GetSize()[d-1]));
-  spacing.append(QString("%1").arg(mCurrentImage->GetSpacing()[d-1]));
-  mLabelInputInfo->setText(QString("Image: %1D %2   %3    %4")
-                           .arg(d)
-                           .arg(mCurrentImage->GetScalarTypeAsString().c_str())
-                           .arg(size)
-                           .arg(spacing));
+std::vector<vvSlicerManager*> & vvToolInputSelectorWidget::GetSelectedInputs() {
+  std::vector<vvSlicerManager*> * l = new std::vector<vvSlicerManager*>;
+  for(unsigned int i=0; i<mListOfSimpleInputWidget.size(); i++)
+    l->push_back(mListOfSimpleInputWidget[i]->GetSelectedInput());
+  return *l;
 }
 //------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
+void vvToolInputSelectorWidget::AnImageIsBeingClosed(vvSlicerManager * m) {
+  DD("TODO : verify that the image still exist !!");
+  //  for(int i=0; i<
+}
+//------------------------------------------------------------------------------
+
+
 #endif
 
index 80a6bde6d49875deacf733ad711b98b94c75e1c4..8aef39d188ed3d40c53f7561574ce2dd61b60e68 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolInputSelectorWidget.h,v $
   Language:  C++
-  Date:      $Date: 2010/03/01 15:38:09 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.5 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -31,9 +31,9 @@
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 #include "ui_vvToolInputSelectorWidget.h"
-#include "vvImage.h"
 
 class vvSlicerManager;
+class vvToolSimpleInputSelectorWidget;
 
 //------------------------------------------------------------------------------
 class vvToolInputSelectorWidget: public QWidget, private Ui::vvToolInputSelectorWidget 
@@ -43,24 +43,29 @@ class vvToolInputSelectorWidget: public QWidget, private Ui::vvToolInputSelector
   vvToolInputSelectorWidget(QWidget * parent=0, Qt::WindowFlags f=0);
   ~vvToolInputSelectorWidget() {}
   
-  void Initialize(std::vector<vvSlicerManager*> l, int index);
-  int GetSelectedInputIndex() { return mCurrentIndex; }
+  void AddInputSelector(const std::vector<vvSlicerManager*> & l, int index);  
+  void Initialize();
+  std::vector<vvSlicerManager*> & GetSelectedInputs();
+  void AnImageIsBeingClosed(vvSlicerManager * m);
+  int GetNumberOfInput();
 
  public slots:
-  void accept();
+  void accept(); // to change ! in something like acceptOneMoreInput
   void reject();
-  void changeInput(int i);
 
  signals:
   void accepted();
   void rejected();
 
  protected:
+  void AddInputSelector(vvToolSimpleInputSelectorWidget * input, 
+                       std::vector<vvSlicerManager*> l, int index);
   Ui::vvToolInputSelectorWidget ui;
   std::vector<vvSlicerManager*> mSlicerManagerList;
   int mCurrentIndex;
   vvSlicerManager * mCurrentSliceManager;
-
+  int mNumberOfAcceptedInputs;
+  std::vector<vvToolSimpleInputSelectorWidget *> mListOfSimpleInputWidget;
 }; // end class vvToolInputSelectorWidget
 //------------------------------------------------------------------------------
 
index 080e29857e45e999aedd82a415f9c30c0aee7323..e08d54f9b3b6ef85a1cb38f497b84d2caefe38a3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolWidgetBase.cxx,v $
   Language:  C++
-  Date:      $Date: 2010/03/01 15:38:09 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2008
@@ -41,6 +41,7 @@ vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f)
   mMainWindowBase = parent;
   setModal(false);
   setAttribute(Qt::WA_DeleteOnClose);
+  mCurrentSlicerManager = 0;
   
   // GUI Initialization
   setupUi(this);
@@ -66,10 +67,59 @@ vvToolWidgetBase::~vvToolWidgetBase() {
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+// void vvToolWidgetBase::SetNumberOfNeededInputs(int nb) {
+//   mNumberOfInputs = nb;
+//   mListOfFilters.resize(nb);
+//   for(int i=0; i<mNumberOfInputs; i++) mListOfFilters[i] = 0;
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AddInputSelector(clitk::ImageToImageGenericFilterBase * f) {
+  DD("AddInputSelector with filter");
+  DD(mMainWindowBase->GetSlicerManagers().size());
+  int j=0;
+  mFilter = f;
+  mSlicerManagersCompatible.clear();
+  //  mToolInputSelectionWidget->setToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
+  for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+    DD(i);
+    vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
+    if (mFilter->CheckImageType(s->GetNumberOfDimensions(), 
+                               s->GetNumberOfScalarComponents(), 
+                               s->GetScalarTypeAsString())) {
+      mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+      if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+      j++;
+    }
+  }
+  mToolInputSelectionWidget->AddInputSelector(mSlicerManagersCompatible, mCurrentCompatibleIndex);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::AddInputSelector() {
+  DD("AddInput without filter");
+  DD(mMainWindowBase->GetSlicerManagers().size());
+  mSlicerManagersCompatible.clear();
+  for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
+    mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+  }
+  mToolInputSelectionWidget->AddInputSelector(mMainWindowBase->GetSlicerManagers(),
+                                             mMainWindowBase->GetSlicerManagerCurrentIndex());
+}
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::show() {
  if (!mIsInitialized) {
-   InitializeInputs();
+   DD("show -> init");
+   mToolInputSelectionWidget->Initialize();
+   mIsInitialized = true;
  }
  QDialog::show();
 }
@@ -78,6 +128,7 @@ void vvToolWidgetBase::show() {
 
 //------------------------------------------------------------------------------
 bool vvToolWidgetBase::close() {
+  DD("vvToolWidgetBase::close()");
   return QDialog::close();
 }
 //------------------------------------------------------------------------------
@@ -85,6 +136,7 @@ bool vvToolWidgetBase::close() {
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) {
+   mToolInputSelectionWidget->AnImageIsBeingClosed(m);
   if (m == mCurrentSlicerManager) {
     close();
   }
@@ -94,17 +146,18 @@ void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m) {
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InitializeInputs() {
+  /*
   if (mFilter) {
     int j=0;
     mToolInputSelectionWidget->setToolTip(QString("%1").arg(mFilter->GetAvailableImageTypes().c_str()));
     for(unsigned int i=0; i<mMainWindowBase->GetSlicerManagers().size(); i++) {
       vvImage * s = mMainWindowBase->GetSlicerManagers()[i]->GetImage();
       if (mFilter->CheckImageType(s->GetNumberOfDimensions(), 
-                                  s->GetNumberOfScalarComponents(), 
-                                  s->GetScalarTypeAsString())) {
-        mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
-        if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
-        j++;
+                                 s->GetNumberOfScalarComponents(), 
+                                 s->GetScalarTypeAsString())) {
+       mSlicerManagersCompatible.push_back(mMainWindowBase->GetSlicerManagers()[i]);
+       if ((int)i == mMainWindowBase->GetSlicerManagerCurrentIndex()) mCurrentCompatibleIndex = j;
+       j++;
       }
     }
   }
@@ -113,21 +166,53 @@ void vvToolWidgetBase::InitializeInputs() {
     mCurrentCompatibleIndex = mMainWindowBase->GetSlicerManagerCurrentIndex();
   }
   mToolInputSelectionWidget->Initialize(mSlicerManagersCompatible, 
-                                        mCurrentCompatibleIndex);
+                                       mCurrentCompatibleIndex);
   mIsInitialized = true;
+  */
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+// void vvToolWidgetBase::SetNumberOfNeededInputs(int i) {
+//   DD("SetNumberOfNeededInputs");
+//   DD(i);
+// }
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InputIsSelected() {
-  // Common
-  int index = mToolInputSelectionWidget->GetSelectedInputIndex();
-  mCurrentSlicerManager = mSlicerManagersCompatible[index];
+  DD("InputIsSelected");
+  buttonBox->setEnabled(true);
+  std::vector<vvSlicerManager*> & l = mToolInputSelectionWidget->GetSelectedInputs();
+  mCurrentSlicerManager = l[0];
   mCurrentImage = mCurrentSlicerManager->GetImage();
   mToolWidget->setEnabled(true);
   if (!mCurrentSlicerManager) close();
-  InputIsSelected(mCurrentSlicerManager);
+  if (l.size() == 1) InputIsSelected(mCurrentSlicerManager);
+  else InputIsSelected(l);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) {
+  std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) if you use one single input" << std::endl;
+  exit(0);
 }
 //------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
+void vvToolWidgetBase::InputIsSelected(std::vector<vvSlicerManager*> & l) {
+  buttonBox->setEnabled(true);
+  DD("InputIsSelected(vector)");
+  DD(l.size());
+  if (l.size() == 1) InputIsSelected(l[0]);
+  else {
+  std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vector<vvSlicerManager *> m) if you use several input" << std::endl;
+  exit(0);
+  }
+}
+//------------------------------------------------------------------------------
index 4c5ca4d96f3149f1238a60cf5d8a4536238dda8f..6f8e23fa92324f1c9a7b20ffb6ebb9000b85fb41 100644 (file)
@@ -3,8 +3,8 @@
   Program:   vv
   Module:    $RCSfile: vvToolWidgetBase.h,v $
   Language:  C++
-  Date:      $Date: 2010/03/01 07:37:25 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2010/03/17 11:22:18 $
+  Version:   $Revision: 1.3 $
   Author :   David Sarrut (david.sarrut@creatis.insa-lyon.fr)
 
   Copyright (C) 2010
@@ -44,7 +44,10 @@ class vvToolWidgetBase:
   vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
   ~vvToolWidgetBase();
 
-  virtual void InputIsSelected(vvSlicerManager *m) = 0;
+  virtual void InputIsSelected(vvSlicerManager *m);
+  virtual void InputIsSelected(std::vector<vvSlicerManager*> & l);
+  void AddInputSelector(clitk::ImageToImageGenericFilterBase * f);
+  void AddInputSelector();
 
 public slots:
   virtual void apply() = 0;