]> Creatis software - clitk.git/blob - vv/vvToolWidgetBase.h
915600e478b96e677f4038745ab2bbbcd341db45
[clitk.git] / vv / vvToolWidgetBase.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18
19 #ifndef VVTOOLWIDGETBASE_H
20 #define VVTOOLWIDGETBASE_H
21
22 #if QT_VERSION < 0x050000
23 #include <QtDesigner/QDesignerExportWidget>
24 #else
25 #include <QtUiPlugin/QDesignerExportWidget>
26 #endif
27 #include "ui_vvToolWidgetBase.h"
28 #include "clitkImageToImageGenericFilter.h"
29
30 // qt
31  #include <QCloseEvent>
32
33 class vvMainWindowBase;
34
35 //------------------------------------------------------------------------------
36 class vvToolWidgetBase:
37   public QWidget, 
38   public Ui::vvToolWidgetBase 
39 {
40   Q_OBJECT
41   public:
42
43   vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=Qt::Dialog, bool initialize=true); // default is a dialog
44   virtual ~vvToolWidgetBase();
45
46   virtual void InputIsSelected(vvSlicerManager *m);
47   virtual void InputIsSelected(std::vector<vvSlicerManager*> & l);
48   void AddInputSelector(QString s, clitk::ImageToImageGenericFilterBase * f, bool allowSkip=false);
49   void AddInputSelector(QString s, bool allowSkip=false);
50   void HideInputSelector();
51   void accept();
52   void reject();
53
54 public slots:
55   virtual void apply() = 0;
56   virtual bool close();
57   void InputIsSelected();
58   virtual void AnImageIsBeingClosed(vvSlicerManager * m);
59   virtual void SelectedImageHasChanged(vvSlicerManager * m);
60   void show();
61   virtual void keyPressEvent(QKeyEvent *event);
62
63 protected:
64   virtual void Initialization();
65   void InitializeInputs();
66   Ui::vvToolWidgetBase ui;
67   clitk::ImageToImageGenericFilterBase::Pointer mFilter;
68   vvMainWindowBase * mMainWindow;
69   std::vector<vvSlicerManager*> mSlicerManagersCompatible;
70   vvSlicerManager * mCurrentSlicerManager;
71   int mCurrentCompatibleIndex;
72   vvImage * mCurrentImage;
73   bool mIsInitialized;
74   QWidget * mWidgetForTab;
75   
76   // The static members manage all tool instances
77   static QWidget * mStaticWidgetForTab; // <-- MUST BE CHANGED IN VECTOR 
78   static int mTabNumber;
79   static QVBoxLayout * mStaticVerticalLayout;  // <-- MUST BE CHANGED IN VECTOR 
80   static bool mIsAnotherToolWaitInput;
81   virtual void CheckInputList(std::vector<vvSlicerManager*> & l, int & index) { }
82   virtual void closeEvent(QCloseEvent *event);
83   void SwapCurrentWidget();
84   bool mPreventToUseTwoToolsOnSameInput;
85
86 }; // end class vvToolWidgetBase
87 //------------------------------------------------------------------------------
88
89 #endif
90