]> Creatis software - clitk.git/blob - vv/vvROIActor.cxx
- add future structure set manager
[clitk.git] / vv / vvROIActor.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://oncora1.lyon.fnclcc.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 #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>
31
32 //------------------------------------------------------------------------------
33 vvROIActor::vvROIActor() {
34   mImageContour.clear();
35   mOverlayActors.clear();
36 }
37 //------------------------------------------------------------------------------
38
39
40 //------------------------------------------------------------------------------
41 vvROIActor::~vvROIActor() {
42 }
43 //------------------------------------------------------------------------------
44
45
46 //------------------------------------------------------------------------------
47 void vvROIActor::SetROI(const clitk::DicomRT_ROI * s) {
48   mROI = s;
49 }
50 //------------------------------------------------------------------------------
51
52
53 //------------------------------------------------------------------------------
54 void vvROIActor::SetSlicerManager(vvSlicerManager * s) {
55   mSlicerManager = s;
56 }
57 //------------------------------------------------------------------------------
58
59
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);        
75       
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();
83     }
84     
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)));
88   }
89 }
90 //------------------------------------------------------------------------------
91
92
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());
98   }
99 }
100 //------------------------------------------------------------------------------
101
102
103 //------------------------------------------------------------------------------
104 void vvROIActor::UpdateSlice(int slicer, int slices) {
105   // DD("UpdateSlice");
106   // DD(slicer);
107   // DD(slices);
108    if (!mROI->GetImage())  return;
109
110   if (!mSlicerManager) {
111     std::cerr << "Error. No mSlicerManager ?" << std::endl;
112     exit(0);
113   }
114
115   // CONTOUR HERE 
116   // mImageContour[slicer]->update(1.0); 
117
118
119   mOverlayActors[slicer]->update(slicer, slices);
120
121   // TOO SLOW !!!!!
122   //  mSlicerManager->GetSlicer(slicer)->Render(); 
123 }
124 //------------------------------------------------------------------------------