]> Creatis software - clitk.git/blob - vv/vvToolROIManager.cxx
First version of new ROI tool (the goal is to put it into the main tab and allow...
[clitk.git] / vv / vvToolROIManager.cxx
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 // vv
20 #include "vvToolROIManager.h"
21 #include "vvImageReader.h"
22 #include "vvROIActor.h"
23 #include "vvSlicer.h"
24 #include "vvROIActor.h"
25
26 // Qt
27 #include <QFileDialog>
28 #include <QMessageBox>
29 #include <QColorDialog>
30 #include <QAbstractEventDispatcher>
31  
32 // vtk
33 #include <vtkLookupTable.h>
34 #include <vtkRenderWindow.h>
35
36 //------------------------------------------------------------------------------
37 // Create the tool and automagically (I like this word) insert it in
38 // the main window menu.
39 ADD_TOOL(vvToolROIManager);
40 //------------------------------------------------------------------------------
41
42 //------------------------------------------------------------------------------
43 vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f):
44   // vvToolWidgetBase(parent, f), 
45   // if Qt::Widget -> No dialog in this case (in tab) ; PB = "invisible widget on menu" !
46   // if "f" normal widget
47   QWidget(parent->GetTab()->widget(4)), 
48   vvToolBase<vvToolROIManager>(parent),
49   Ui::vvToolROIManager()
50 {
51   //  Insert the current QWidget into the tab layout (required)
52   QWidget * mother = qFindChild<QWidget*>(parent->GetTab(), "ROItab");
53   mother->layout()->addWidget(this);
54   
55   // Build the UI
56   Ui_vvToolROIManager::setupUi(this);
57   setAttribute(Qt::WA_DeleteOnClose);
58
59   // Select the current image as the target
60   int i = parent->GetSlicerManagerCurrentIndex();
61   InputIsSelected(parent->GetSlicerManagers()[i]);
62
63   // Connect event from mainwindow to this widget
64   connect(parent, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)), 
65           this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
66   connect(parent, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
67           this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
68
69   // mMainWindowBase->GetTab()->setTabIcon(mTabNumber, GetToolIcon());
70 }
71 //------------------------------------------------------------------------------
72
73
74 //------------------------------------------------------------------------------
75 vvToolROIManager::~vvToolROIManager()
76 {
77   std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl;
78 }
79 //------------------------------------------------------------------------------
80
81
82 //------------------------------------------------------------------------------
83 // STATIC
84 void vvToolROIManager::Initialize() {
85   SetToolName("ROIManager");
86   SetToolMenuName("Display ROI (binary image)");
87   SetToolIconFilename(":/common/icons/tool-roi.png");
88   SetToolTip("Display ROI from a binary image.");
89   SetToolExperimental(true);
90 }
91 //------------------------------------------------------------------------------
92
93
94 //------------------------------------------------------------------------------
95 void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
96 {
97   std::cout << "vvToolROIManager::InputIsSelected()" << std::endl;
98   mSlicerManager = m;
99
100   // Signal/slot
101   connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
102
103   // Initialization
104
105 }
106 //------------------------------------------------------------------------------
107
108
109 //------------------------------------------------------------------------------
110 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
111 {
112   if (m == mSlicerManager) close();
113 }
114 //------------------------------------------------------------------------------
115
116
117 //------------------------------------------------------------------------------
118 void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
119   if (m != mSlicerManager) hide();
120   else show();
121 }
122 //------------------------------------------------------------------------------