]> Creatis software - clitk.git/blob - vv/vvToolWidgetBase.h
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[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 #include <QtGlobal>
23 #include <QtDesigner/QDesignerExportWidget>
24 #include "ui_vvToolWidgetBase.h"
25 #include "clitkImageToImageGenericFilter.h"
26
27 // qt
28  #include <QCloseEvent>
29
30 class vvMainWindowBase;
31
32 //------------------------------------------------------------------------------
33 class vvToolWidgetBase:
34   public QWidget, 
35   public Ui::vvToolWidgetBase 
36 {
37   Q_OBJECT
38   public:
39
40   vvToolWidgetBase(vvMainWindowBase * parent=0, Qt::WindowFlags f=Qt::Dialog, bool initialize=true); // default is a dialog
41   virtual ~vvToolWidgetBase();
42
43   virtual void InputIsSelected(vvSlicerManager *m);
44   virtual void InputIsSelected(std::vector<vvSlicerManager*> & l);
45   void AddInputSelector(QString s, clitk::ImageToImageGenericFilterBase * f, bool allowSkip=false);
46   void AddInputSelector(QString s, bool allowSkip=false);
47   void HideInputSelector();
48   void accept();
49   void reject();
50
51 public slots:
52   virtual void apply() = 0;
53   virtual bool close();
54   void InputIsSelected();
55   virtual void AnImageIsBeingClosed(vvSlicerManager * m);
56   virtual void SelectedImageHasChanged(vvSlicerManager * m);
57   void show();
58   virtual void keyPressEvent(QKeyEvent *event);
59
60 protected:
61   virtual void Initialization();
62   void InitializeInputs();
63   Ui::vvToolWidgetBase ui;
64   clitk::ImageToImageGenericFilterBase::Pointer mFilter;
65   vvMainWindowBase * mMainWindow;
66   std::vector<vvSlicerManager*> mSlicerManagersCompatible;
67   vvSlicerManager * mCurrentSlicerManager;
68   int mCurrentCompatibleIndex;
69   vvImage * mCurrentImage;
70   bool mIsInitialized;
71   QWidget * mWidgetForTab;
72   
73   // The static members manage all tool instances
74   static QWidget * mStaticWidgetForTab; // <-- MUST BE CHANGED IN VECTOR 
75   static int mTabNumber;
76   static QVBoxLayout * mStaticVerticalLayout;  // <-- MUST BE CHANGED IN VECTOR 
77   static bool mIsAnotherToolWaitInput;
78   virtual void CheckInputList(std::vector<vvSlicerManager*> & l, int & index) { }
79   virtual void closeEvent(QCloseEvent *event);
80   void SwapCurrentWidget();
81   bool mPreventToUseTwoToolsOnSameInput;
82
83 }; // end class vvToolWidgetBase
84 //------------------------------------------------------------------------------
85
86 #endif
87