1 #include "wxMaracasRenderTabbedPanel.h"
2 #include "HistogramDialogComboBox.h"
4 #include "wxMaracasMultipleVolumeRendererPanel.h"
5 #include "wxMaracasSurfaceRenderingPanel.h"
6 #include "wxMaracasSurfaceRenderingProp3DMHD.h"
7 #include "wxMaracasMultipleVolumeRendererManagerData.h"
9 #include <wx/colordlg.h>
10 #include <wx/button.h>
12 #include <OpenImage.xpm>
15 #include <vtkProp3D.h>
20 wxMaracasRenderTabbedPanel::wxMaracasRenderTabbedPanel(wxWindow* parent)
21 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
24 volmanager = new wxMaracasMultipleVolumeRendererManager();
25 surrendmanager1 = new wxMaracasSurfaceRenderingManager();
26 surrendmanager2 = new wxMaracasSurfaceRenderingManager();
27 surrendmanager3 = new wxMaracasSurfaceRenderingManager();
33 wxMaracasRenderTabbedPanel::~wxMaracasRenderTabbedPanel()
35 //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorV(_propid, false);
36 //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSA(_propid, false);
37 //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSB(_propid, false);
38 //wxMaracasRenderTabbedPanel::getInstance()->addRemoveActorSC(_propid, false);
39 this->deleteVolume(_propidV);
44 ** Initializes rendered images, and creates and adds elements to the panel
46 void wxMaracasRenderTabbedPanel::createControls(vtkImageData* inImg, std::string pathfile, std::string filename)
48 wxFlexGridSizer* sizerrenderprop = new wxFlexGridSizer(1);
50 wxFlexGridSizer* sizercheck = new wxFlexGridSizer(2);
51 checkboxVol = new wxCheckBox(this,-1,wxString(_T("Volume Rendering")));
52 Connect(checkboxVol->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxVChange);
53 checkboxVol->SetValue(true);
54 sizercheck->Add(checkboxVol, wxFIXED_MINSIZE);
56 checkboxSA = new wxCheckBox(this,-1,wxString(_T("Surface Rendering A")));
57 Connect(checkboxSA->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxSAChange);
58 checkboxSA->SetValue(true);
59 sizercheck->Add(checkboxSA, wxFIXED_MINSIZE);
61 checkboxSB = new wxCheckBox(this,-1,wxString(_T("Surface Rendering B")));
62 Connect(checkboxSB->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxSBChange);
63 checkboxSB->SetValue(true);
64 sizercheck->Add(checkboxSB, wxFIXED_MINSIZE);
66 checkboxSC = new wxCheckBox(this,-1,wxString(_T("Surface Rendering C")));
67 Connect(checkboxSC->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onCheckBoxSCChange);
68 checkboxSC->SetValue(true);
69 sizercheck->Add(checkboxSC, wxFIXED_MINSIZE);
71 wxButton* _openParameters = new wxButton(this, -1, wxString(_T("Apply Transformation")));
72 Connect(_openParameters->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onOpenParameters);
73 sizercheck->Add(_openParameters,wxFIXED_MINSIZE);
75 wxButton* _openCutter = new wxButton(this, -1, wxString(_T("Open Cutter View")));
76 Connect(_openCutter->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasRenderTabbedPanel::onOpenCutter);
77 sizercheck->Add(_openCutter,wxFIXED_MINSIZE);
78 sizerrenderprop->Add(sizercheck, wxFIXED_MINSIZE);
80 wxtabs = new wxNotebook(this, -1);
84 //std::string s = std::string(pathfile.mb_str());
85 vtkImageData* img = volmanager->getImageData(pathfile);
86 vtkImageData* img1 = surrendmanager1->getImageData(pathfile);
87 vtkImageData* img2 = surrendmanager2->getImageData(pathfile);
88 vtkImageData* img3 = surrendmanager3->getImageData(pathfile);
89 if(img!=NULL && img1!=NULL && img2!=NULL && img3!=NULL)
91 //s = std::string(filename.mb_str());
92 addVolume(img, filename);
93 addSurface1(img1, filename);
94 addSurface2(img2, filename);
95 addSurface3(img3, filename);
101 //s = std::string(filename.mb_str());
102 addVolume(inImg, filename);
103 addSurface1(inImg, filename);
104 addSurface2(inImg, filename);
105 addSurface3(inImg, filename);
109 sizerrenderprop->Add(wxtabs, wxSizerFlags().Expand().Center());
111 this->SetSizer(sizerrenderprop, true);
112 this->SetAutoLayout( true );
117 ** Sets given renderer
119 void wxMaracasRenderTabbedPanel::setRenderer(vtkRenderer* renderer)
121 volmanager->setRenderer(renderer);
122 surrendmanager1->setRenderer(renderer);
123 surrendmanager2->setRenderer(renderer);
124 surrendmanager3->setRenderer(renderer);
128 ** Adds a volume using Volume Rendering
130 void wxMaracasRenderTabbedPanel::addVolume(vtkImageData* img, std::string dataname)
134 _propidV = volmanager->addVolume(img, dataname);
137 wxMaracasMultipleVolumeRendererPanel* controlpanV = new wxMaracasMultipleVolumeRendererPanel(wxtabs, _propidV, img, true);
138 wxtabs->AddPage(controlpanV, _T("Vol Rendering"), true);
139 controlpanV->updateVolume();
144 std::cout << "Exception : " << str << '\n';
145 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
152 ** Adds a volume using surface rendering
154 void wxMaracasRenderTabbedPanel::addSurface1(vtkImageData* img, std::string dataname)
158 _propidSA = surrendmanager1->addPropMHD(img, dataname);
162 wxMaracasSurfaceRenderingPanel* controlpanSA = new wxMaracasSurfaceRenderingProp3DMHD(wxtabs, _propidSA, true, 1);
163 int maxiso = surrendmanager1->getMaxIsoValue(_propidSA);
164 ((wxMaracasSurfaceRenderingProp3DMHD*)controlpanSA)->createControls(maxiso);
165 wxtabs->AddPage(controlpanSA, _T("SR A"));
170 std::cout << "Exception : " << str << '\n';
171 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
178 ** Adds a volume using surface rendering
180 void wxMaracasRenderTabbedPanel::addSurface2(vtkImageData* img, std::string dataname)
184 _propidSB = surrendmanager2->addPropMHD(img, dataname);
187 wxMaracasSurfaceRenderingPanel* controlpanSB = new wxMaracasSurfaceRenderingProp3DMHD(wxtabs, _propidSB, true, 2);
188 int maxiso = surrendmanager2->getMaxIsoValue(_propidSB);
189 ((wxMaracasSurfaceRenderingProp3DMHD*)controlpanSB)->createControls(maxiso);
190 wxtabs->AddPage(controlpanSB, _T("SR B"));
196 std::cout << "Exception : " << str << '\n';
197 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
204 ** Adds a volume using Surface Rendering
206 void wxMaracasRenderTabbedPanel::addSurface3(vtkImageData* img, std::string dataname)
210 _propidSC = surrendmanager3->addPropMHD(img, dataname);
214 wxMaracasSurfaceRenderingPanel* controlpanSC = new wxMaracasSurfaceRenderingProp3DMHD(wxtabs, _propidSC, true, 3);
215 int maxiso = surrendmanager3->getMaxIsoValue(_propidSC);
216 ((wxMaracasSurfaceRenderingProp3DMHD*)controlpanSC)->createControls(maxiso);
217 wxtabs->AddPage(controlpanSC, _T("SR C"));
222 std::cout << "Exception : " << str << '\n';
223 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
230 ** Deletes complete volume
232 void wxMaracasRenderTabbedPanel::deleteVolume(int volid)
236 volmanager->deleteActor(volid);
237 surrendmanager1->deleteActor(volid);
238 surrendmanager2->deleteActor(volid);
239 surrendmanager3->deleteActor(volid);
243 std::cout << "Exception : " << str << '\n';
244 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
251 ** Adds or removes volume rendering actor with given ID
253 void wxMaracasRenderTabbedPanel::addRemoveActorV(int id, bool addremove)
256 volmanager->addRemoveActor(id, addremove);
259 std::cout << "Exception : " << str << '\n';
260 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
267 ** Adds or removes surface rendering actor with given ID
269 void wxMaracasRenderTabbedPanel::addRemoveActorSA(int id, bool addremove)
272 surrendmanager1->addRemoveActor(id, addremove);
275 std::cout << "Exception : " << str << '\n';
276 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
283 ** Adds or removes surface rendering actor with given ID
285 void wxMaracasRenderTabbedPanel::addRemoveActorSB(int id, bool addremove)
288 surrendmanager2->addRemoveActor(id, addremove);
291 std::cout << "Exception : " << str << '\n';
292 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
299 ** Adds or removes surface rendering actor with given ID
301 void wxMaracasRenderTabbedPanel::addRemoveActorSC(int id, bool addremove)
304 surrendmanager3->addRemoveActor(id, addremove);
307 std::cout << "Exception : " << str << '\n';
308 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
315 ** Sets color points values for the given volume rendering identified by parameter: volumeid
317 void wxMaracasRenderTabbedPanel::SetValuesColorPointsFunction(int volid, std::vector<double> greylevelcolors,std::vector<double> red,std::vector<double> green,std::vector<double> blue)
319 volmanager->setVolumeColor(volid, greylevelcolors, red, green, blue);
323 ** Sets points values for the given volume rendering identified by parameter: volumeid
325 void wxMaracasRenderTabbedPanel::SetValuesPointsFunction(int volid, std::vector<double> greylevel, std::vector<double> values)
328 volmanager->setVolumeOpacity(volid, greylevel, values);
332 wxString s( str,wxConvUTF8 );
333 wxMessageDialog* diag = new wxMessageDialog(this, s, s, wxICON_ERROR);
341 ** Returns transfer function for the given volume rendering identified by parameter: volumeid
343 vtkPiecewiseFunction* wxMaracasRenderTabbedPanel::GetTransferFunction(int volumeid)
345 return volmanager->GetTransferFunction(volumeid);
349 ** Returns color function for the given volume rendering identified by parameter: volumeid
351 vtkColorTransferFunction* wxMaracasRenderTabbedPanel::GetColorFunction(int volumeid)
353 return volmanager->GetColorFunction(volumeid);
357 ** Changes color function by the given value for the given volume rendering identified by parameter: volumeid
359 void wxMaracasRenderTabbedPanel::changeOpacityA(int _propid, int value)
361 surrendmanager1->changeOpacity(_propid,value);
365 ** Changes isoValue by the given value for the given surface rendering image identified by parameter: propid
367 void wxMaracasRenderTabbedPanel::changeIsoValueA(int propid, double value)
369 surrendmanager1->changeIsoValue(propid, value);
373 ** Changes color for the given surface rendering image identified by parameter: propid
375 void wxMaracasRenderTabbedPanel::changeColorA(int propid, double red, double green, double blue)
379 surrendmanager1->changeColor(propid, red, green, blue);
383 wxString s( str,wxConvUTF8 );
384 wxMessageDialog* diag = new wxMessageDialog(this, s, s, wxICON_ERROR);
391 ** Changes color function by the given value for the given volume rendering identified by parameter: volumeid
393 void wxMaracasRenderTabbedPanel::changeOpacityB(int _propid, int value)
395 surrendmanager2->changeOpacity(_propid,value);
399 ** Changes isoValue by the given value for the given surface rendering image identified by parameter: propid
401 void wxMaracasRenderTabbedPanel::changeIsoValueB(int propid, double value)
403 surrendmanager2->changeIsoValue(propid, value);
407 ** Changes color for the given surface rendering image identified by parameter: propid
409 void wxMaracasRenderTabbedPanel::changeColorB(int propid, double red, double green, double blue)
413 surrendmanager2->changeColor(propid, red, green, blue);
417 wxString s( str,wxConvUTF8 );
418 wxMessageDialog* diag = new wxMessageDialog(this, s, s, wxICON_ERROR);
425 ** Changes color function by the given value for the given volume rendering identified by parameter: volumeid
427 void wxMaracasRenderTabbedPanel::changeOpacityC(int _propid, int value)
429 surrendmanager3->changeOpacity(_propid,value);
433 ** Changes isoValue by the given value for the given surface rendering image identified by parameter: propid
435 void wxMaracasRenderTabbedPanel::changeIsoValueC(int propid, double value)
437 surrendmanager3->changeIsoValue(propid, value);
441 ** Changes color for the given surface rendering image identified by parameter: propid
443 void wxMaracasRenderTabbedPanel::changeColorC(int propid, double red, double green, double blue)
447 surrendmanager3->changeColor(propid, red, green, blue);
451 wxString s( str,wxConvUTF8 );
452 wxMessageDialog* diag = new wxMessageDialog(this, s, s, wxICON_ERROR);
459 ** Method called when VolumeRendering checkbox status changes: Either shows or hides VolumeRendering image
461 void wxMaracasRenderTabbedPanel::onCheckBoxVChange(wxCommandEvent& event)
464 volmanager->addRemoveActor(this->getPropIdV(), checkboxVol->GetValue());
467 std::cout << "Exception : " << str << '\n';
468 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
475 ** Method called when SurfaceRendering A checkbox status changes: Either shows or hides SurfaceRendering image
477 void wxMaracasRenderTabbedPanel::onCheckBoxSAChange(wxCommandEvent& event)
480 surrendmanager1->addRemoveActor(this->getPropIdSA(), checkboxSA->GetValue());
483 std::cout << "Exception : " << str << '\n';
484 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
491 ** Method called when SurfaceRendering B checkbox status changes: Either shows or hides SurfaceRendering B image
493 void wxMaracasRenderTabbedPanel::onCheckBoxSBChange(wxCommandEvent& event)
496 surrendmanager2->addRemoveActor(this->getPropIdSB(), checkboxSB->GetValue());
499 std::cout << "Exception : " << str << '\n';
500 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
507 ** Method called when SurfaceRendering C checkbox status changes: Either shows or hides SurfaceRendering C image
509 void wxMaracasRenderTabbedPanel::onCheckBoxSCChange(wxCommandEvent& event)
512 surrendmanager3->addRemoveActor(this->getPropIdSC(), checkboxSC->GetValue());
515 std::cout << "Exception : " << str << '\n';
516 wxMessageDialog* diag = new wxMessageDialog(this, wxString(str,wxConvUTF8 ), wxString(str,wxConvUTF8 ), wxICON_ERROR);
525 void wxMaracasRenderTabbedPanel::onOpenParameters(wxCommandEvent& event){
527 dialog = new wxMaracasRenderImageManagementPanel(this, volmanager, surrendmanager1, surrendmanager2, surrendmanager3, this->getPropIdV());
528 dialog->SetSize(400, 580);
534 ** Gets volume rendering image asociated to the given ID
536 void wxMaracasRenderTabbedPanel::onColorChange(wxCommandEvent& event)
538 /*Temporarily disabled*/
540 //if(mwxwidget->ShowModal()==wxID_OK){
542 // mwxwidget->Show(false);
549 vtkImageData* wxMaracasRenderTabbedPanel::getVolImage(int id)
551 return volmanager->getImageData();
555 ** Gets surface rendering A image asociated to the given ID
557 vtkImageData* wxMaracasRenderTabbedPanel::getSurfAImage(int id)
559 return surrendmanager1->getImageData();
563 ** Gets surface rendering B image asociated to the given ID
565 vtkImageData* wxMaracasRenderTabbedPanel::getSurfBImage(int id)
567 return surrendmanager2->getImageData();
571 ** Gets surface rendering C image asociated to the given ID
573 vtkImageData* wxMaracasRenderTabbedPanel::getSurfCImage(int id)
575 return surrendmanager3->getImageData();
581 void wxMaracasRenderTabbedPanel::onOpenCutter(wxCommandEvent& event)
589 int wxMaracasRenderTabbedPanel::getPropIdV()
597 int wxMaracasRenderTabbedPanel::getPropIdSA()
605 int wxMaracasRenderTabbedPanel::getPropIdSB()
613 int wxMaracasRenderTabbedPanel::getPropIdSC()