1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
20 #include "vvToolROIManager.h"
21 #include "vvImageReader.h"
22 #include "vvROIActor.h"
24 #include "vvROIActor.h"
27 #include <QFileDialog>
28 #include <QMessageBox>
29 #include <QColorDialog>
30 #include <QAbstractEventDispatcher>
33 #include <vtkLookupTable.h>
34 #include <vtkRenderWindow.h>
36 //------------------------------------------------------------------------------
37 // Create the tool and automagically (I like this word) insert it in
38 // the main window menu.
39 ADD_TOOL(vvToolROIManager);
40 //------------------------------------------------------------------------------
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()
51 // Insert the current QWidget into the tab layout (required)
52 QWidget * mother = qFindChild<QWidget*>(parent->GetTab(), "ROItab");
53 mother->layout()->addWidget(this);
56 Ui_vvToolROIManager::setupUi(this);
57 setAttribute(Qt::WA_DeleteOnClose);
59 // Select the current image as the target
60 int i = parent->GetSlicerManagerCurrentIndex();
61 InputIsSelected(parent->GetSlicerManagers()[i]);
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 *)));
69 // mMainWindowBase->GetTab()->setTabIcon(mTabNumber, GetToolIcon());
71 //------------------------------------------------------------------------------
74 //------------------------------------------------------------------------------
75 vvToolROIManager::~vvToolROIManager()
77 std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl;
79 //------------------------------------------------------------------------------
82 //------------------------------------------------------------------------------
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);
91 //------------------------------------------------------------------------------
94 //------------------------------------------------------------------------------
95 void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
97 std::cout << "vvToolROIManager::InputIsSelected()" << std::endl;
101 connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
106 //------------------------------------------------------------------------------
109 //------------------------------------------------------------------------------
110 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
112 if (m == mSlicerManager) close();
114 //------------------------------------------------------------------------------
117 //------------------------------------------------------------------------------
118 void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
119 if (m != mSlicerManager) hide();
122 //------------------------------------------------------------------------------