00001 #include "wxMaracasMultipleVolumeRendererPanel.h"
00002
00003 #include <wx/colordlg.h>
00004 #include "wxMaracasMultipleVolumeRendererView.h"
00005 #include "Color.xpm"
00006
00011 wxMaracasMultipleVolumeRendererPanel::wxMaracasMultipleVolumeRendererPanel(wxWindow* parent,int propid, vtkImageData* img)
00012 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize)
00013 {
00014 _propid = propid;
00015
00016 createControls(img);
00017 }
00018
00019 wxMaracasMultipleVolumeRendererPanel::~wxMaracasMultipleVolumeRendererPanel(){
00020
00021 wxMaracasMultipleVolumeRendererView::getInstance()->deleteVolume(_propid);
00022 delete mwxwidget;
00023 }
00024
00025 void wxMaracasMultipleVolumeRendererPanel::createControls(vtkImageData* img){
00026
00027 wxFlexGridSizer* sizerirmprop = new wxFlexGridSizer(1,1,1);
00028
00029 wxString choices[2];
00030 choices[0] = wxString(_T("On"));
00031 choices[1] = wxString(_T("Off"));
00032 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
00033 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange);
00034 checkbox->SetValue(true);
00035
00036 sizerirmprop->Add(checkbox,wxFIXED_MINSIZE);
00037
00038 wxBitmap bitmap(Color_xpm);
00039 _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
00040 Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasMultipleVolumeRendererPanel::onColorChange);
00041 sizerirmprop->Add(_colorchoose,wxFIXED_MINSIZE);
00042
00043
00044 this->SetSizer(sizerirmprop, true);
00045 this->SetAutoLayout( true );
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 mwxwidget = new HistogramDialog(this, _T("Color Transfer Function"));
00060 mwxwidget->initializeHistogram(img);
00061
00062 mwxwidget->erasePointsTransferenceFunction();
00063 double range[2];
00064 img->GetScalarRange(range);
00065 double max = range[1];
00066
00067
00068
00069
00070
00071 mwxwidget->addPointToTransferenceFunction(max * 0/2,0.0);
00072 mwxwidget->addPointToTransferenceFunction(max * 1/2,100.0);
00073 mwxwidget->addPointToTransferenceFunction(max * 2/2,100.0);
00074
00075 mwxwidget->addColorPoint(max*0/4,(int)(0.0*255),(int)(0.0*255),(int)(0.0*255));
00076 mwxwidget->addColorPoint(max*1/4,(int)(1.0*255),(int)(0.0*255),(int)(0.0*255));
00077 mwxwidget->addColorPoint(max*2/4,(int)(0.0*255),(int)(0.0*255),(int)(1.0*255));
00078 mwxwidget->addColorPoint(max*3/4,(int)(0.0*255),(int)(1.0*255),(int)(0.0*255));
00079 mwxwidget->addColorPoint(max*4/4,(int)(0.0*255),(int)(0.0*255),(int)(0.2*255));
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 mwxwidget->SetFunctions(wxMaracasMultipleVolumeRendererView::getInstance()->GetTransferFunction(getPropId()),
00104 wxMaracasMultipleVolumeRendererView::getInstance()->GetColorFunction(getPropId()));
00105 mwxwidget->Refresh();
00106 }
00107 void wxMaracasMultipleVolumeRendererPanel::onOK(wxCommandEvent& event){
00108 updateVolume();
00109
00110 }
00111 void wxMaracasMultipleVolumeRendererPanel::onCancel(wxCommandEvent& event){
00112
00113 }
00114 void wxMaracasMultipleVolumeRendererPanel::onUpdate(wxCommandEvent& event){
00115 updateVolume();
00116 }
00117 void wxMaracasMultipleVolumeRendererPanel::updateVolume(){
00118 std::vector<double> greylevelcolors;
00119 std::vector<double> red;
00120 std::vector<double> green;
00121 std::vector<double> blue;
00122
00123 std::vector<double> greylevel;
00124 std::vector<double> values;
00125
00126 mwxwidget->GetValuesColorPointsFunction(greylevelcolors, red, green, blue);
00127 mwxwidget->GetValuesPointsFunction(greylevel, values);
00128
00129
00130 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesColorPointsFunction(this->_propid, greylevelcolors, red, green, blue);
00131 wxMaracasMultipleVolumeRendererView::getInstance()->SetValuesPointsFunction(this->_propid, greylevel, values);
00132
00133 }
00134 void wxMaracasMultipleVolumeRendererPanel::onColorChange(wxCommandEvent& event){
00135
00136 if(mwxwidget->ShowModal()==wxID_OK){
00137 updateVolume();
00138 mwxwidget->Show(false);
00139 }
00140 }
00141 void wxMaracasMultipleVolumeRendererPanel::onCheckBoxChange(wxCommandEvent& event){
00142 wxMaracasMultipleVolumeRendererView::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());
00143 }
00144
00145 int wxMaracasMultipleVolumeRendererPanel::getPropId(){
00146 return _propid;
00147 }