00001
00002 #include "PlaneDirectionViewerPanel.h"
00003 #include "PlaneDirectionViewer.h"
00004
00005 #include "Color.xpm"
00006 #include <wx/colordlg.h>
00007
00008
00009
00010
00011
00012 PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
00013 :wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){
00014 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
00015
00016 _index = index;
00017 this->SetSizer(sizer);
00018
00019 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
00020 checkbox->SetValue(true);
00021 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onCheckBoxChange);
00022
00023 wxBitmap bitmap(Color_xpm);
00024 _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
00025 Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onColorChange);
00026
00027
00028 double* p0 = data->getPoint0();
00029 double* p1 = data->getPoint1();
00030 double* p2 = data->getPoint2();
00031 double* dir = data->GetDirection();
00032
00033 wxString label(_T("[x, y, z]"));
00034 wxString tempstr0;
00035 tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
00036 wxString tempstr1;
00037 tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
00038 wxString tempstr2;
00039 tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
00040 wxString tempstr3;
00041 tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
00042
00043 wxStaticText* textlabel = new wxStaticText(this, -1, label);
00044 wxStaticText* textp0 = new wxStaticText(this, -1, tempstr0);
00045 wxStaticText* textp1 = new wxStaticText(this, -1, tempstr1);
00046 wxStaticText* textp2 = new wxStaticText(this, -1, tempstr2);
00047 wxStaticText* textp3 = new wxStaticText(this, -1, tempstr3);
00048
00049
00050 sizer->Add(checkbox,1);
00051 sizer->Add(_colorchoose,1);
00052 sizer->Add(textlabel,1);
00053 sizer->Add(textp0,1);
00054 sizer->Add(textp1,1);
00055 sizer->Add(textp2,1);
00056 sizer->Add(textp3,1);
00057
00058 this->SetAutoLayout(true);
00059 this->Layout();
00060
00061 }
00062
00063 void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){
00064 PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
00065 }
00066
00067 void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
00068
00069 wxColourDialog* colourdiag = new wxColourDialog(this);
00070 if(colourdiag->ShowModal()==wxID_OK){
00071 wxColour colour = colourdiag->GetColourData().GetColour();
00072 _colorchoose->SetBackgroundColour(colour);
00073
00074 double r = (double)(colour.Red())/255.0;
00075 double g = (double)(colour.Green())/255.0;
00076 double b = (double)(colour.Blue())/255.0;
00077
00078 PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
00079 }
00080 delete colourdiag;
00081
00082 }
00083
00084 PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){
00085
00086 }
00087