]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasIRMViewManager.cxx
module IRM view
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasIRMViewManager.cxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: wxMaracasIRMViewManager.cxx,v $
5   Language:  C++
6   Date:      $Date: 2009/04/01 16:16:59 $
7   Version:   $Revision: 1.1 $
8
9   Copyright: (c) 2002, 2003
10   License:
11
12      This software is distributed WITHOUT ANY WARRANTY; without even
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14      PURPOSE.  See the above copyright notice for more information.
15
16 =========================================================================*/
17 #include "wxMaracasIRMViewManager.h"
18
19 /**
20 **      Start of the manager class
21 **/
22 wxMaracasIRMViewManager::wxMaracasIRMViewManager(){
23         _renderer = NULL;
24 }
25 wxMaracasIRMViewManager::~wxMaracasIRMViewManager(){
26 }
27
28 /**
29 **      Sets the renderer to manage the prop3D from the view
30 **/
31 void wxMaracasIRMViewManager::setRenderer(vtkRenderer*  renderer){
32         _renderer = renderer;
33 }
34 /**
35 **      Adds a prop3D to the manager and returns the identifier
36 **/
37 int wxMaracasIRMViewManager::addProp3D(vtkProp3D* prop3D){
38         if(prop3D != NULL){
39                 prop3Dvect.push_back(prop3D);
40
41                 if(_renderer!=NULL){
42                         _renderer->AddActor(prop3D);
43                 }else{
44                         throw "Imposible to add actor, check renderer";
45                 }
46                 
47
48                 return prop3Dvect.size()-1;
49         }else{
50                 return -1;
51         }
52 }
53 /**
54 **      Changes the opacity in a prop3D
55 **/
56 void wxMaracasIRMViewManager::changeOpacity(int propid, int value){
57         if(propid < prop3Dvect.size()){
58                 vtkActor* actor = (vtkActor*)prop3Dvect[propid];                
59                 actor->GetProperty()->SetOpacity((double)value/100.0);  
60                 _renderer->Render();
61         }
62 }
63
64 /**
65 **      changes the isovalue in a prop3D
66 **/
67 void wxMaracasIRMViewManager::changeIsoValue(int propid, int value){
68         if(propid<prop3Dvect.size()){
69
70         }
71 }
72
73 vtkProp3D* wxMaracasIRMViewManager:: getProp3D(std::string filename){
74         if(filename.compare("")!= 0){
75                 vtkSTLReader *STLReader=vtkSTLReader::New();
76                 STLReader->SetFileName(filename.c_str());
77                 STLReader->Update();
78                 vtkPolyDataMapper* dataMapper = vtkPolyDataMapper::New();
79                 dataMapper->SetInput(STLReader->GetOutput());
80                 
81                 vtkActor* dataActor = vtkActor::New();
82                 dataActor->SetMapper(dataMapper);       
83                 dataActor->GetProperty()->SetOpacity(1);
84                 
85                 return dataActor;
86         }       
87         return NULL;
88 }