1 #include "wxMaracasMultipleVolumeRendererPanel.h"
2 #include "wxMaracasMultipleVolumeRendererView.h"
3 #include "wxMaracasDialog_NViewers.h"
4 #include "wxMaracasRendererView.h"
6 #include <wx/colordlg.h>
8 #include "vtkImageData.h"
9 #include "vtkRenderer.h"
11 #include <OpenImage.xpm>
14 //#include <vtkImageCast.h>
16 ** Implementation of viewProp3D
22 wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img, bool _isComplexBox)
23 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
26 isComplexBox = _isComplexBox;
34 wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
37 //((wxMaracasRenderTabbedPanel*)(wxMaracasRendererView::getInstance())->getTabbedPanel())->deleteVolume(_propid);
39 //wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
44 ** Sets panel elements
46 void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
48 wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(3);
52 wxStaticText* label = new wxStaticText(this, -1, wxString(_T("")));
53 wxStaticText* label2 = new wxStaticText(this, -1, wxString(_T("")));
56 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
57 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);
58 checkbox->SetValue(true);
60 wxString choices[] = {_T("Composite"), _T("MIP")};
61 _radiobox = new wxRadioBox(this, -1, wxString(_T("Function")), wxDefaultPosition, wxDefaultSize, 2, choices);
62 Connect(_radiobox->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction);
64 sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
65 sizerirmprop->AddSpacer(5);
66 sizerirmprop->Add(_radiobox,wxFIXED_MINSIZE);
67 //sizerirmprop->Add(label2,wxFIXED_MINSIZE);
69 //wxBitmap bitmap(Color_xpm);
70 //_colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
71 //Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
73 mwxwidget = new HistogramDialogComboBox(this);
74 mwxwidget->setImageData(img);
75 //mwxwidget->PushEventHandler(this);
76 Connect(mwxwidget->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
77 sizerirmprop->Add(mwxwidget,wxFIXED_MINSIZE);
79 wxBitmap bitmap0(Add_xpm);
80 _viewimage = new wxBitmapButton(this, -1, bitmap0, wxDefaultPosition, wxSize(30,30));
81 Connect(_viewimage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onViewImage);
82 sizerirmprop->Add(_viewimage,wxFIXED_MINSIZE);
84 //std::string iconsdir = wxMaracasMultipleVolumeRendererView::getInstance()->getPath();
85 //iconsdir+="/data/Icons/Add.xmp";
86 //wxBitmap* bitmap = new wxBitmap(wxString(iconsdir.c_str(),wxConvUTF8), wxBITMAP_TYPE_XPM);
88 this->SetSizer(sizerirmprop, true);
89 this->SetAutoLayout( true );
91 //_frame = new wxFrame(this, 10, _T("Configure Transfer Functions"));
93 /*wxButton* button1 = new wxButton(_frame,20,_T("OK"));
94 Connect(button1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onOK);
95 wxButton* button2 = new wxButton(_frame,30,_T("Cancel") );
96 Connect(button2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCancel);
97 wxButton* button3 = new wxButton(_frame,40,_T("Update"));
98 Connect(button3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onUpdate); */
100 /*mwxwidget->erasePointsTransferenceFunction();
102 img->GetScalarRange(range);
103 double max = range[1];
107 mwxwidget->addPointToTransferenceFunction(max * 0/2,0.0);
108 mwxwidget->addPointToTransferenceFunction(max * 1/2,100.0);
109 mwxwidget->addPointToTransferenceFunction(max * 2/2,100.0);
111 mwxwidget->addColorPoint(max*0/4,(int)(0.0*255),(int)(0.0*255),(int)(0.0*255));
112 mwxwidget->addColorPoint(max*1/4,(int)(1.0*255),(int)(0.0*255),(int)(0.0*255));
113 mwxwidget->addColorPoint(max*2/4,(int)(0.0*255),(int)(0.0*255),(int)(1.0*255));
114 mwxwidget->addColorPoint(max*3/4,(int)(0.0*255),(int)(1.0*255),(int)(0.0*255));
115 mwxwidget->addColorPoint(max*4/4,(int)(0.0*255),(int)(0.0*255),(int)(0.2*255)); */
117 /*wxBoxSizer* boxSizer0 = new wxBoxSizer(wxHORIZONTAL);
118 boxSizer0->Add(mwxwidget, 4, wxGROW);
120 wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
121 boxSizer->AddSpacer(40);
122 boxSizer->Add(button1, wxCENTER);
123 boxSizer->AddSpacer(40);
124 boxSizer->Add(button2, wxCENTER);
125 boxSizer->AddSpacer(40);
126 boxSizer->Add(button3, wxCENTER);
128 wxBoxSizer* boxsizer2 = new wxBoxSizer(wxVERTICAL);
129 boxsizer2->Add(boxSizer0,1,wxEXPAND);
130 boxsizer2->Add(boxSizer,0,wxCENTER);
132 _frame->SetAutoLayout(true);
135 _frame->SetSizer(boxsizer2);
139 //mwxwidget->SetFunctions(wxMaracasMultipleVolumeRendererView::getInstance()->GetTransferFunction(getPropId()),
140 // wxMaracasMultipleVolumeRendererView::getInstance()->GetColorFunction(getPropId()));
141 mwxwidget->Refresh();
147 void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
149 //_frame->Show(false);
155 void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
156 //_frame->Show(false);
162 void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
169 void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
170 std::vector<double> greylevelcolors;
171 std::vector<double> red;
172 std::vector<double> green;
173 std::vector<double> blue;
175 std::vector<double> greylevel;
176 std::vector<double> values;
178 mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue);
179 mwxwidget->GetValuesPointsFunction(greylevel, values);
181 if(this->isComplexBox)
183 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesColorPointsFunction(this->_propid,greylevelcolors, red, green, blue);
184 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->SetValuesPointsFunction(this->_propid, greylevel, values);
188 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue);
189 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
194 ** Updates the volume visualization
196 void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
198 //if(mwxwidget->ShowModal()==wxID_OK){
200 // mwxwidget->Show(false);
207 void wxMaracasMultipleVolumeRendererPanel::onViewImage(wxCommandEvent& event)
210 if(this->isComplexBox){
211 img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getVolImage();
212 std::vector<int> type;
215 wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
216 dialog1->SetSize(wxDefaultSize);
220 //vtkImageData* img = wxMaracasMultipleVolumeRendererView::getInstance()->getVolImage();
227 void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){
228 if(this->isComplexBox)
229 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(this->_propid) )->addRemoveActorV(this->getPropId(), checkbox->GetValue());
231 wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
237 int wxMaracasMultipleVolumeRendererPanel::getPropId(){
241 void wxMaracasMultipleVolumeRendererPanel::onRadioBoxSelectFunction(wxCommandEvent& event){
243 wxMaracasMultipleVolumeRendererView::getInstance()->changeCompositeMIPFunction(this->getPropId(), _radiobox->GetSelection());
247 ** Carolina Perez: Recently added method
249 HistogramDialogComboBox* wxMaracasMultipleVolumeRendererPanel::getMwxwidget()