]> Creatis software - clitk.git/blob - vv/vvToolSegmentation.h
Ensure the compilation with Qt4 and Qt5
[clitk.git] / vv / vvToolSegmentation.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 #ifndef VVTOOLSEGMENTATION_H
19 #define VVTOOLSEGMENTATION_H
20
21 #if QT_VERSION < 0x050000
22 #include <QtDesigner/QDesignerExportWidget>
23 #else
24 #include <QtUiPlugin/QDesignerExportWidget>
25 #endif
26
27 #include "vvToolBase.h"
28 #include "vvToolWidgetBase.h"
29 #include "vvROIActor.h"
30 #include "ui_vvToolSegmentation.h"
31
32 #include "vtkLookupTable.h"
33
34 //------------------------------------------------------------------------------
35 class vvToolSegmentation:
36   public vvToolWidgetBase,
37   public vvToolBase<vvToolSegmentation>, 
38   private Ui::vvToolSegmentation 
39 {
40   Q_OBJECT
41     public:
42   vvToolSegmentation(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
43   ~vvToolSegmentation();
44
45   //-----------------------------------------------------
46   static void Initialize();
47   virtual void InputIsSelected(vvSlicerManager * m);
48   void OpenBinaryImage();
49   void RegionGrowing();
50   void Erode();
51   void Dilate();
52   void Labelize();
53   void Merge();
54   void RemoveLabel();
55   void UpdateAndRenderNewMask();
56
57   //-----------------------------------------------------
58   public slots:
59   virtual void apply();
60   void KeyPressed(std::string KeyPress);
61   virtual bool close();
62   virtual void MousePositionChanged(int slicer);
63
64  protected:
65   Ui::vvToolSegmentation ui;
66   QSharedPointer<vvROIActor> mRefMaskActor;
67   QSharedPointer<vvROIActor> mCurrentMaskActor;
68   std::vector<QSharedPointer<vvROIActor> > mCurrentCCLActors;
69   vvImage::Pointer mRefMaskImage;
70   vvImage::Pointer mCurrentMaskImage;
71   vvImage::Pointer mCurrentCCLImage;
72   int mKernelValue;
73   vtkSmartPointer<vtkLookupTable> mDefaultLUTColor;
74   enum { State_Default, State_CCL};
75   int mCurrentState;
76
77   QSharedPointer<vvROIActor> CreateMaskActor(vvImage::Pointer image, int i, int colorID, bool BGMode=false);
78   
79   double mCurrentLabelUnderMousePointer;
80   std::vector<double> mCurrentMousePositionInMM;
81   //std::vector<double> mCurrentMousePositionInPixel;
82   double GetBackgroundValue() { return 0; }
83   double GetForegroundValue() { return 1; }
84   long ComputeNumberOfPixels(vvImage::Pointer image, double value);
85
86   // Compute and store sizes of mask Foreground
87   void   UpdateMaskSize(vvImage::Pointer image, long & pix, double & cc);
88   void   UpdateMaskSizeLabels();
89   long   mRefMaskSizeInPixels;
90   double mRefMaskSizeInCC;
91   long   mCurrentMaskSizeInPixels;
92   double mCurrentMaskSizeInCC;
93
94 }; // end class vvToolSegmentation
95 //------------------------------------------------------------------------------
96
97 #endif