]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/PlaneDirectionViewerPanel.cxx
#3086 creaMaracasVisu Bug New Normal - Init opacity in ColorLayer box
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / PlaneDirectionViewerPanel.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26
27 #include "PlaneDirectionViewerPanel.h"
28 #include "PlaneDirectionViewer.h"
29
30 #include "Color.xpm"
31 #include <wx/colordlg.h>
32
33 /********************************************************************************************
34 ** Start of data viewmanagerData
35 *********************************************************************************************/
36
37 PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
38 :wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){  
39     wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
40
41         _index = index;
42         this->SetSizer(sizer);
43         
44         checkbox = new  wxCheckBox(this,-1,wxString(_T("Show Actor")));
45         checkbox->SetValue(true);
46         Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onCheckBoxChange);
47
48         wxBitmap bitmap(Color_xpm);
49         _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));    
50         Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onColorChange);                 
51         
52
53         double* p0 = data->getPoint0();
54         double* p1 = data->getPoint1();
55         double* p2 = data->getPoint2();
56         double* dir = data->GetDirection();
57
58         wxString label(_T("[x, y, z]"));        
59         wxString tempstr0;
60         tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
61         wxString tempstr1;
62         tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
63         wxString tempstr2;
64         tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
65         wxString tempstr3;
66         tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
67
68         wxStaticText* textlabel = new wxStaticText(this, -1, label);
69         wxStaticText* textp0 = new wxStaticText(this, -1, tempstr0);
70         wxStaticText* textp1 = new wxStaticText(this, -1, tempstr1);
71         wxStaticText* textp2 = new wxStaticText(this, -1, tempstr2);
72         wxStaticText* textp3 = new wxStaticText(this, -1, tempstr3);
73         
74
75         sizer->Add(checkbox,1);
76         sizer->Add(_colorchoose,1);
77         sizer->Add(textlabel,1);
78         sizer->Add(textp0,1);
79         sizer->Add(textp1,1);
80         sizer->Add(textp2,1);
81         sizer->Add(textp3,1);
82
83         this->SetAutoLayout(true);
84         this->Layout();
85
86 }
87
88 void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){        
89         PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
90 }
91
92 void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
93         
94         wxColourDialog* colourdiag = new wxColourDialog(this);
95         if(colourdiag->ShowModal()==wxID_OK){
96                 wxColour colour = colourdiag->GetColourData().GetColour();
97                 _colorchoose->SetBackgroundColour(colour);
98
99                 double r = (double)(colour.Red())/255.0;
100                 double g = (double)(colour.Green())/255.0;
101                 double b = (double)(colour.Blue())/255.0;
102                 
103                 PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
104         }
105         delete colourdiag;
106
107 }
108
109 PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){
110
111 }
112