00001 #include "wxMaracasSurfaceRenderingProp3D.h"
00002 #include "wxMaracasDialog_NViewers.h"
00003 
00004 #include <wx/colordlg.h>
00005 #include "wxMaracasSurfaceRendering.h"
00006 #include "wxMaracasRendererView.h"
00007 
00008 #include "vtkImageData.h"
00009 
00010 #include <OpenImage.xpm>
00011 #include <Add.xpm>
00012 #include "Color.xpm"
00013 
00017 wxMaracasSurfaceRenderingProp3D::wxMaracasSurfaceRenderingProp3D(wxWindow* parent, int propid, bool _isComplexBox, int _panID)
00018 :wxMaracasSurfaceRenderingPanel(parent, propid, _isComplexBox, _panID){
00019         createControls();       
00020 }
00021 
00025 wxMaracasSurfaceRenderingProp3D::~wxMaracasSurfaceRenderingProp3D(){    
00026         
00027         if(this->isComplex())
00028         {       
00029                 
00030                 
00031                 
00032                 
00033                 
00034                 
00035         }
00036         
00037                 
00038 }
00039 
00043 void wxMaracasSurfaceRenderingProp3D::createControls(){
00044 
00045         wxFlexGridSizer* sizersurfprop = new wxFlexGridSizer(1);
00046         
00047         if(!isComplexBox) 
00048         {
00049                 
00050                 
00051                 
00052                 wxFlexGridSizer* checkboxsizer = new wxFlexGridSizer(2);
00053 
00054                 checkbox = new  wxCheckBox(this,-1,wxString(_T("Show Actor")));
00055                 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxChange);  
00056                 checkbox->SetValue(true);       
00057                 checkboxsizer->Add(checkbox,wxFIXED_MINSIZE);
00058 
00059 
00060                 if(wxMaracasSurfaceRendering::getInstance()->interactorSet()){
00061                         checkboxsurface = new  wxCheckBox(this,-1,wxString(_T("Surface Box")));
00062                         Connect(checkboxsurface->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange);    
00063                         checkboxsurface->SetValue(true);
00064                         checkboxsizer->Add(checkboxsurface,wxFIXED_MINSIZE);
00065                 }       
00066 
00067 
00068                 sizersurfprop->Add(checkboxsizer,wxFIXED_MINSIZE);
00069         }
00070 
00071         
00072         wxFlexGridSizer* sizerbut = new wxFlexGridSizer(3);
00073 
00074         wxBitmap bitmap(Color_xpm);
00075         _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
00076         Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onColorChange);                   
00077         sizerbut->Add(_colorchoose,wxFIXED_MINSIZE);
00078 
00079         
00080 
00081 
00082 
00083 
00084 
00085         sizersurfprop->Add(sizerbut,wxFIXED_MINSIZE);
00086         
00087         
00088         
00089 
00090         wxStaticText* label = new wxStaticText(this, -1, wxString(_T("Opacity")));              
00091         opacity = new wxSlider(this, -1,100,0,100,wxDefaultPosition,wxDefaultSize,wxSL_HORIZONTAL|wxSL_LABELS); 
00092         Connect(opacity->GetId(), wxEVT_SCROLL_CHANGED, (wxObjectEventFunction)&wxMaracasSurfaceRenderingProp3D::onOpacityRelease);     
00093         wxFlexGridSizer* sizeropacity = new wxFlexGridSizer(1,1,1);     
00094         sizeropacity->Add(label,wxFIXED_MINSIZE);
00095         sizeropacity->Add(opacity,wxFIXED_MINSIZE);
00096 
00097         sizersurfprop->Add(sizeropacity,wxFIXED_MINSIZE);
00098 
00099         this->addControl(sizersurfprop);
00100         
00101 }
00102 
00106 void wxMaracasSurfaceRenderingProp3D::onCheckBoxChange(wxCommandEvent& event){  
00107         
00108         wxMaracasSurfaceRendering::getInstance()->addRemoveActor(this->getPropId(), checkbox->GetValue());      
00109 }
00110 void wxMaracasSurfaceRenderingProp3D::onCheckBoxSurfaceChange(wxCommandEvent& event){   
00111         
00112         wxMaracasSurfaceRendering::getInstance()->addRemoveSurfaceBox(this->getPropId(), checkboxsurface->GetValue());  
00113 }
00114 
00118 void wxMaracasSurfaceRenderingProp3D::onColorChange(wxCommandEvent& event){
00119         wxColourDialog* colourdiag = new wxColourDialog(this);
00120         if(colourdiag->ShowModal()==wxID_OK){
00121                 wxColour colour = colourdiag->GetColourData().GetColour();
00122                 _colorchoose->SetBackgroundColour(colour);
00123 
00124                 double r = (double)(colour.Red())/255.0;
00125                 double g = (double)(colour.Green())/255.0;
00126                 double b = (double)(colour.Blue())/255.0;
00127                 
00128                 if(this->isComplex()){
00129                         if(this->getPanId() == 1)
00130                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorA(this->getPropId(), r, g, b);
00131                         if(this->getPanId() == 2)
00132                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorB(this->getPropId(), r, g, b);
00133                         if(this->getPanId() == 3)
00134                                 ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeColorC(this->getPropId(), r, g, b);
00135                 }
00136                 else
00137                         wxMaracasSurfaceRendering::getInstance()->changeColor(this->getPropId(),r,g,b);
00138         }
00139         delete colourdiag;
00140 }
00141 
00142 
00143 
00144 
00148 void wxMaracasSurfaceRenderingProp3D::onOpacityRelease(wxScrollEvent& event ){
00149 
00150         if(this->isComplex()){
00151                 if(this->getPanId() == 1)
00152                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityA(this->getPropId(),opacity->GetValue());
00153                 if(this->getPanId() == 2)
00154                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityB(this->getPropId(),opacity->GetValue());
00155                 if(this->getPanId() == 3)
00156                         ( (wxMaracasRendererView::getInstance())->getTabbedPanel(getPropId()) )->changeOpacityC(this->getPropId(),opacity->GetValue());
00157         }
00158         else
00159                 wxMaracasSurfaceRendering::getInstance()->changeOpacity(this->getPropId(),opacity->GetValue());
00160 
00161 }
00162 
00166 void wxMaracasSurfaceRenderingProp3D::onViewImage(wxCommandEvent& event){       
00167         vtkImageData* img;
00168         if(this->isComplexBox){
00169                 if(this->getPanId() == 1)
00170                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfAImage();
00171                 if(this->getPanId() == 2)
00172                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfBImage();
00173                 if(this->getPanId() == 3)
00174                         img = (wxMaracasRendererView::getInstance())->getTabbedPanel(_propid)->getSurfCImage();
00175                 
00176                 std::vector<int> type;
00177                 type.push_back(6);
00178 
00179                 wxMaracasDialog_NViewers* dialog1 = new wxMaracasDialog_NViewers(this, img, &type, wxString(_T("Volume Visualization") ));
00180                 dialog1->SetSize(730, 700);
00181                 dialog1->Show();
00182         }
00183         else{   
00184                 
00185         }
00186 }