2 #include "PlaneDirectionViewerPanel.h"
3 #include "PlaneDirectionViewer.h"
6 #include <wx/colordlg.h>
8 /********************************************************************************************
9 ** Start of data viewmanagerData
10 *********************************************************************************************/
12 PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
13 :wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){
14 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
17 this->SetSizer(sizer);
19 checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
20 checkbox->SetValue(true);
21 Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onCheckBoxChange);
23 wxBitmap bitmap(Color_xpm);
24 _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
25 Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onColorChange);
28 double* p0 = data->getPoint0();
29 double* p1 = data->getPoint1();
30 double* p2 = data->getPoint2();
31 double* dir = data->GetDirection();
33 wxString label(_T("[x, y, z]"));
35 tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
37 tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
39 tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
41 tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
43 wxStaticText* textlabel = new wxStaticText(this, -1, label);
44 wxStaticText* textp0 = new wxStaticText(this, -1, tempstr0);
45 wxStaticText* textp1 = new wxStaticText(this, -1, tempstr1);
46 wxStaticText* textp2 = new wxStaticText(this, -1, tempstr2);
47 wxStaticText* textp3 = new wxStaticText(this, -1, tempstr3);
50 sizer->Add(checkbox,1);
51 sizer->Add(_colorchoose,1);
52 sizer->Add(textlabel,1);
58 this->SetAutoLayout(true);
63 void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){
64 PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
67 void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
69 wxColourDialog* colourdiag = new wxColourDialog(this);
70 if(colourdiag->ShowModal()==wxID_OK){
71 wxColour colour = colourdiag->GetColourData().GetColour();
72 _colorchoose->SetBackgroundColour(colour);
74 double r = (double)(colour.Red())/255.0;
75 double g = (double)(colour.Green())/255.0;
76 double b = (double)(colour.Blue())/255.0;
78 PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
84 PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){