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://oncora1.lyon.fnclcc.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 ======================================================================-====*/
19 #include "vvROIActor.h"
20 #include "vvImageContour.h"
21 #include "vvSlicerManager.h"
22 #include "vvBinaryImageOverlayActor.h"
23 #include <vtkImageActor.h>
24 #include <vtkCamera.h>
25 #include <vtkRenderer.h>
26 #include <vtkMarchingSquares.h>
27 #include <vtkImageClip.h>
28 #include <vtkImageData.h>
29 #include <vtkPolyDataMapper.h>
30 #include <vtkProperty.h>
32 //------------------------------------------------------------------------------
33 vvROIActor::vvROIActor() {
34 mImageContour.clear();
35 mOverlayActors.clear();
37 //------------------------------------------------------------------------------
40 //------------------------------------------------------------------------------
41 vvROIActor::~vvROIActor() {
43 //------------------------------------------------------------------------------
46 //------------------------------------------------------------------------------
47 void vvROIActor::SetROI(const clitk::DicomRT_ROI * s) {
50 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54 void vvROIActor::SetSlicerManager(vvSlicerManager * s) {
57 //------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------
61 void vvROIActor::Initialize() {
62 if (mROI->GetImage()) {
63 mImageContour.clear();
64 mOverlayActors.clear();
65 DD(mSlicerManager->NumberOfSlicers());
66 for(int i=0;i<mSlicerManager->NumberOfSlicers(); i++) {
67 mImageContour.push_back(new vvImageContour);
68 mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i));
69 mImageContour[i]->setImage(mROI->GetImage());
70 // mImageContour[i]->setColor(1.0, 0.0, 0.0);
71 mImageContour[i]->setColor(mROI->GetDisplayColor()[0],
72 mROI->GetDisplayColor()[1],
73 mROI->GetDisplayColor()[2]);
74 mImageContour[i]->setPreserveMemoryModeEnabled(false);
76 mOverlayActors.push_back(new vvBinaryImageOverlayActor);
77 mOverlayActors[i]->setImage(mROI->GetImage());
78 mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0],
79 mROI->GetDisplayColor()[1],
80 mROI->GetDisplayColor()[2]);
81 mOverlayActors[i]->setSlicer(mSlicerManager->GetSlicer(i));
82 mOverlayActors[i]->initialize();
85 connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
86 //connect(mSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
87 connect(mSlicerManager, SIGNAL(AVerticalSliderHasChanged(int, int)), SLOT(UpdateSlice(int, int)));
90 //------------------------------------------------------------------------------
93 //------------------------------------------------------------------------------
94 void vvROIActor::Update() {
95 DD("vvROIActor::Update");
96 for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
97 UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice());
100 //------------------------------------------------------------------------------
103 //------------------------------------------------------------------------------
104 void vvROIActor::UpdateSlice(int slicer, int slices) {
105 // DD("UpdateSlice");
108 if (!mROI->GetImage()) return;
110 if (!mSlicerManager) {
111 std::cerr << "Error. No mSlicerManager ?" << std::endl;
116 // mImageContour[slicer]->update(1.0);
119 mOverlayActors[slicer]->update(slicer, slices);
122 // mSlicerManager->GetSlicer(slicer)->Render();
124 //------------------------------------------------------------------------------