1 /*=========================================================================
4 Module: $RCSfile: wxMaracasMultipleVolumeRendererManager.cxx,v $
6 Date: $Date: 2009/11/20 17:09:05 $
7 Version: $Revision: 1.9 $
9 Copyright: (c) 2002, 2003
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.
16 =========================================================================*/
17 #include "wxMaracasMultipleVolumeRendererManager.h"
19 #include <vtkMetaImageReader.h>
20 #include <vtkImageCast.h>
22 ** Start of the manager class
24 wxMaracasMultipleVolumeRendererManager::wxMaracasMultipleVolumeRendererManager(){
28 wxMaracasMultipleVolumeRendererManager::~wxMaracasMultipleVolumeRendererManager(){
32 ** Sets the renderer to manage the prop3D from the view
34 void wxMaracasMultipleVolumeRendererManager::setRenderer(vtkRenderer* renderer){
39 ** Gets the renderer which manage the prop3D from the view
41 vtkRenderer* wxMaracasMultipleVolumeRendererManager::getRenderer(){
48 void wxMaracasMultipleVolumeRendererManager::Update(int ppid){
49 wxMaracasMultipleVolumeRendererManagerData* data = this->getViewData(ppid);
55 ** Adds a prop3D to the manager and returns the identifier
57 int wxMaracasMultipleVolumeRendererManager::addVolume(int idTP, vtkImageData* vol, std::string dataname) throw(char*){
61 wxMaracasMultipleVolumeRendererManagerData* data = new wxMaracasMultipleVolumeRendererManagerData(vol, dataname);
62 prop3Dvect.push_back(data);
63 _renderer->AddActor(data->getProp3D());
66 data->setId(_idCount);
73 printf("wxMaracasMultipleVolumeRendererManager::addVolume->idVolumeRenderer: %i\n", data->getId());
76 throw "Check mhd imagefile file or input";
81 ** adds or removes an actor depending of the bool value
84 void wxMaracasMultipleVolumeRendererManager::addRemoveActor(int propid, bool addremove) throw(char*){
87 wxMaracasMultipleVolumeRendererManagerData* data = this->getViewData(propid);
88 if(data->getProp3D()!=NULL){
90 _renderer->AddViewProp(data->getProp3D());
92 _renderer->RemoveViewProp(data->getProp3D());
99 ** Changes the opacity in a prop3D
101 void wxMaracasMultipleVolumeRendererManager::setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*){
104 this->getViewData(propid)->setVolumeOpacity(greylevel, value);
113 void wxMaracasMultipleVolumeRendererManager::setVolumeColor(int volid, std::vector<double> greylevel,
114 std::vector<double> red,
115 std::vector<double> green,
116 std::vector<double> blue)throw(char*){
119 this->getViewData(volid)->setVolumeColor(greylevel, red, green, blue);
124 vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(std::string filename){
125 if(filename.compare("")!= 0){
127 vtkMetaImageReader* reader = vtkMetaImageReader::New();
128 reader->SetFileName(filename.c_str());
130 vtkImageData* img = reader->GetOutput();
132 vtkImageCast* cast = vtkImageCast::New();
134 cast->SetOutputScalarTypeToUnsignedShort();
138 return cast->GetOutput();
144 vtkImageData* wxMaracasMultipleVolumeRendererManager::getImageData(){
148 void wxMaracasMultipleVolumeRendererManager::checkInvariant() throw(char*){
149 if(this->_renderer==NULL){
150 throw "Renderer not set";
154 wxMaracasMultipleVolumeRendererManagerData* wxMaracasMultipleVolumeRendererManager::getViewData(int id) throw(char*){
156 for(i = 0; i < (int)(prop3Dvect.size());i++){
157 if(prop3Dvect[i]->getId() == id){
158 return prop3Dvect[i];
161 throw "id not found in the data";
166 void wxMaracasMultipleVolumeRendererManager::deleteActor(int propid) throw (char *){
169 this->addRemoveActor(propid, false);
173 for(i = 0; i < (int)(prop3Dvect.size())&&!exit;i++){
174 if(prop3Dvect[i]->getId() == propid){
180 wxMaracasMultipleVolumeRendererManagerData* data = prop3Dvect[n];
182 for(j = i; j < (int)(prop3Dvect.size())-1;j++){
183 prop3Dvect[j] = prop3Dvect[j+1];
186 prop3Dvect.pop_back();
188 throw "id not found in the data";
193 vtkPiecewiseFunction* wxMaracasMultipleVolumeRendererManager::GetTransferFunction(int volumeid){
194 return getViewData(volumeid)->GetTransferFunction();
196 vtkColorTransferFunction* wxMaracasMultipleVolumeRendererManager::GetColorFunction(int volumeid){
198 return getViewData(volumeid)->GetColorFunction();
201 void wxMaracasMultipleVolumeRendererManager::changeCompositeMIPFunction(int id, int function) throw (char *){
202 getViewData(id)->changeCompositeMIPFunction(function);