1 #include "wxMaracasMultipleVolumeRendererPanel.h"
2 #include "wxMaracasMultipleVolumeRendererView.h"
3 #include "wxMaracas_N_ViewersWidget.h"
4 #include "wxMaracasDialog_NViewers.h"
5 #include "wxMaracasRendererView.h"
7 #include <wx/colordlg.h>
9 #include "vtkImageData.h"
10 #include "vtkRenderer.h"
12 #include <OpenImage.xpm>
16 //#include <vtkImageCast.h>
18 ** Implementation of viewProp3D
24 wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img, bool _isComplexBox)
25 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
28 isComplexBox = _isComplexBox;
36 wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
39 //((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->deleteVolume(_propid);
41 //wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
46 ** Sets panel elements
48 void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
50 wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(3);
54 // wxStaticText* label = new wxStaticText(this, -1, wxString(_T("")));
55 // wxStaticText* label2 = new wxStaticText(this, -1, wxString(_T("")));
58 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
59 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);
60 checkbox->SetValue(true);
62 wxString choices[] = {_T("Composite"), _T("MIP")};
63 _radiobox = new wxRadioBox(this, -1, wxString(_T("Function")), wxDefaultPosition, wxDefaultSize, 2, choices);
64 Connect(_radiobox->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction);
66 sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
67 sizerirmprop->AddSpacer(5);
68 sizerirmprop->Add(_radiobox,wxFIXED_MINSIZE);
69 //sizerirmprop->Add(label2,wxFIXED_MINSIZE);
71 //wxBitmap bitmap(Color_xpm);
72 //_colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
73 //Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
75 mwxwidget = new HistogramDialogComboBox(this);
76 mwxwidget->setImageData(img);
77 //mwxwidget->PushEventHandler(this);
78 Connect(mwxwidget->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
79 sizerirmprop->Add(mwxwidget,wxFIXED_MINSIZE);
81 wxBitmap bitmap0(Add_xpm);
82 _viewimage = new wxBitmapButton(this, -1, bitmap0, wxDefaultPosition, wxSize(30,30));
83 Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onViewImage);
84 sizerirmprop->Add(_viewimage,wxFIXED_MINSIZE);
86 //std::string iconsdir = wxMaracasMultipleVolumeRendererView::getInstance()->getPath();
87 //iconsdir+="/data/Icons/Add.xmp";
88 //wxBitmap* bitmap = new wxBitmap(wxString(iconsdir.c_str(),wxConvUTF8), wxBITMAP_TYPE_XPM);
90 this->SetSizer(sizerirmprop, true);
91 this->SetAutoLayout( true );
93 //_frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));
95 /*wxButton* button1 = new wxButton(_frame,20,_T("OK"));
96 Connect(button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onOK);
97 wxButton* button2 = new wxButton(_frame,30,_T("Cancel") );
98 Connect(button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCancel);
99 wxButton* button3 = new wxButton(_frame,40,_T("Update"));
100 Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate); */
102 /*mwxwidget->erasePointsTransferenceFunction();
104 img->GetScalarRange(range);
105 double max = range[1];
109 mwxwidget->addPointToTransferenceFunction(max * 0/2,0.0);
110 mwxwidget->addPointToTransferenceFunction(max * 1/2,100.0);
111 mwxwidget->addPointToTransferenceFunction(max * 2/2,100.0);
113 mwxwidget->addColorPoint(max*0/4,(int)(0.0*255),(int)(0.0*255),(int)(0.0*255));
114 mwxwidget->addColorPoint(max*1/4,(int)(1.0*255),(int)(0.0*255),(int)(0.0*255));
115 mwxwidget->addColorPoint(max*2/4,(int)(0.0*255),(int)(0.0*255),(int)(1.0*255));
116 mwxwidget->addColorPoint(max*3/4,(int)(0.0*255),(int)(1.0*255),(int)(0.0*255));
117 mwxwidget->addColorPoint(max*4/4,(int)(0.0*255),(int)(0.0*255),(int)(0.2*255)); */
119 /*wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
120 boxSizer0->Add(mwxwidget, 4, wxGROW);
122 wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
123 boxSizer->AddSpacer(40);
124 boxSizer->Add(button1, wxCENTER);
125 boxSizer->AddSpacer(40);
126 boxSizer->Add(button2, wxCENTER);
127 boxSizer->AddSpacer(40);
128 boxSizer->Add(button3, wxCENTER);
130 wxBoxSizer* boxsizer2 = new wxBoxSizer(wxVERTICAL);
131 boxsizer2->Add(boxSizer0,1,wxEXPAND);
132 boxsizer2->Add(boxSizer,0,wxCENTER);
134 _frame->SetAutoLayout(true);
137 _frame->SetSizer(boxsizer2);
141 //mwxwidget->SetFunctions(wxMaracasMultipleVolumeRendererView::getInstance()->GetTransferFunction(getPropId()),
142 // wxMaracasMultipleVolumeRendererView::getInstance()->GetColorFunction(getPropId()));
143 mwxwidget->Refresh();
149 void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
151 //_frame->Show(false);
157 void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
158 //_frame->Show(false);
164 void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
171 void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
172 std::vector<double> greylevelcolors;
173 std::vector<double> red;
174 std::vector<double> green;
175 std::vector<double> blue;
177 std::vector<double> greylevel;
178 std::vector<double> values;
180 mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue);
181 mwxwidget->GetValuesPointsFunction(greylevel, values);
183 if(this->isComplexBox)
185 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesColorPointsFunction(this->_propid,greylevelcolors, red, green, blue);
186 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesPointsFunction(this->_propid, greylevel, values);
190 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue);
191 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
196 ** Updates the volume visualization
198 void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
200 //if(mwxwidget->ShowModal()==wxID_OK){
202 // mwxwidget->Show(false);
209 void wxMaracasMultipleVolumeRendererPanel::onViewImage(wxCommandEvent& event)
212 std::vector<int> type;
215 wxFrame* frame = new wxFrame(this, -1, wxString(_T("Volume Visualization")));
216 frame->SetSize(wxDefaultSize);
218 if(this->isComplexBox)
220 img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getVolImage();
224 img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolumeRenderManager()->getImageData();
227 // wxMaracas_N_ViewersWidget* viewer = new wxMaracas_N_ViewersWidget(frame, img, &type);
228 new wxMaracas_N_ViewersWidget(frame, img, &type);
235 void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){
236 if(this->isComplexBox)
237 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->addRemoveActorV(this->getPropId(), checkbox->GetValue());
239 wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
245 int wxMaracasMultipleVolumeRendererPanel::getPropId(){
249 void wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction(wxCommandEvent& event){
251 wxMaracasMultipleVolumeRendererView::getInstance()->changeCompositeMIPFunction(this->getPropId(), _radiobox->GetSelection());
255 ** Carolina Perez: Recently added method
257 HistogramDialogComboBox* wxMaracasMultipleVolumeRendererPanel::getMwxwidget()