]> Creatis software - creaMaracasVisu.git/blob - lib/GUI/Base/VolumeRenderer/volumerendererdata.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / GUI / Base / VolumeRenderer / volumerendererdata.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "volumerendererdata.h"
27 #include "vtkObjectFactory.h"
28
29 vtkCxxRevisionMacro(VolumeRendererData, "$Revision: 1.11 $");
30 vtkStandardNewMacro(VolumeRendererData);
31
32 VolumeRendererData::VolumeRendererData()
33 {
34     VolRendManager      = NULL;
35     ImageData           = NULL;
36     Renderer            = NULL;
37     Interactor          = NULL;
38     LookUpTable         = NULL;
39     //ImageDataSeparateComponents = false;
40 }
41
42
43 void VolumeRendererData::ShowVolume(bool checked){
44     try{
45         if(checked){
46                 invariant();
47                 if(!VolRendManager){
48                     VolRendManager = new VolumeRendererManager();
49                     VolRendManager->addVolume(ImageData, Interactor);
50                 }
51                 if(LookUpTable)
52                                 {
53                     VolRendManager->SetLookupTable(LookUpTable);
54                                 }
55                 vector< vtkProp3D* > props = VolRendManager->getProps3D();
56                 for(unsigned i = 0; i < props.size(); i++){
57                     Renderer->AddActor(props[i]);
58                 }
59
60         }else{
61             vector< vtkProp3D* > props = VolRendManager->getProps3D();
62             for(unsigned i = 0; i < props.size(); i++){
63                 Renderer->RemoveActor(props[i]);
64             }
65             delete VolRendManager;
66             VolRendManager = 0;
67         }
68     }catch(char* e){
69         cout<<"Exception in: "<<e<<endl;
70     }catch(exception e){
71         cout<<"Exception in: "<<e.what()<<endl;
72     }
73
74 }
75
76 void VolumeRendererData::invariant()
77 {
78     if(!ImageData)
79         {
80         throw "Image data not set";
81     }
82     if(!Renderer)
83         {
84         throw "renderer not initialized";
85     }
86 }
87
88 void VolumeRendererData::OpacityChanged(vector<double> greyvalues, vector<double> values)
89 {
90     //invariant();
91     if(VolRendManager!=NULL)
92         {
93         ShowVolume(true);
94                 VolRendManager->setVolumeOpacity(greyvalues,values);
95         }       
96 }
97
98
99 void  VolumeRendererData::BoundingBoxChanged(bool checked){
100    // invariant();
101
102     if(VolRendManager==NULL)
103     {
104          ShowVolume(true);
105     }
106
107
108     if(VolRendManager && Interactor){
109         if(checked){
110             VolRendManager->EnableBoundingBox(Interactor);
111         }else{
112             VolRendManager->DisableBoundingBox();
113         }
114     }
115         
116 }
117
118
119 void VolumeRendererData::changeCompositeMIPFunction(int function){
120     invariant();
121     if(VolRendManager)
122         {
123         VolRendManager->changeCompositeMIPFunction(0, function);
124         }
125 }
126
127 /**
128   changes the interoplation type of the volume
129   type = 0 linear
130   type = 1 nearest
131    */
132 void VolumeRendererData::changeInterpolationType(int type){
133     invariant();
134     if(VolRendManager)
135         {
136         VolRendManager->changeInterpolationType(type);
137         }       
138 }