]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/PlaneDirectionViewerPanel.cxx
e6dbd50257d71a6517852e28217555ac72138790
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / PlaneDirectionViewerPanel.cxx
1
2 #include "PlaneDirectionViewerPanel.h"
3 #include "PlaneDirectionViewer.h"
4
5 #include "Color.xpm"
6 #include <wx/colordlg.h>
7
8 /********************************************************************************************
9 ** Start of data viewmanagerData
10 *********************************************************************************************/
11
12 PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
13 :wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){  
14     wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
15
16         _index = index;
17         this->SetSizer(sizer);
18         
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);
22
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);                 
26         
27
28         double* p0 = data->getPoint0();
29         double* p1 = data->getPoint1();
30         double* p2 = data->getPoint2();
31         double* dir = data->GetDirection();
32
33         wxString label(_T("[x, y, z]"));        
34         wxString tempstr0;
35         tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
36         wxString tempstr1;
37         tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
38         wxString tempstr2;
39         tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
40         wxString tempstr3;
41         tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
42
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);
48         
49
50         sizer->Add(checkbox,1);
51         sizer->Add(_colorchoose,1);
52         sizer->Add(textlabel,1);
53         sizer->Add(textp0,1);
54         sizer->Add(textp1,1);
55         sizer->Add(textp2,1);
56         sizer->Add(textp3,1);
57
58         this->SetAutoLayout(true);
59         this->Layout();
60
61 }
62
63 void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){        
64         PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
65 }
66
67 void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
68         
69         wxColourDialog* colourdiag = new wxColourDialog(this);
70         if(colourdiag->ShowModal()==wxID_OK){
71                 wxColour colour = colourdiag->GetColourData().GetColour();
72                 _colorchoose->SetBackgroundColour(colour);
73
74                 double r = (double)(colour.Red())/255.0;
75                 double g = (double)(colour.Green())/255.0;
76                 double b = (double)(colour.Blue())/255.0;
77                 
78                 PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
79         }
80         delete colourdiag;
81
82 }
83
84 PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){
85
86 }
87