1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
27 #include "PlaneDirectionViewerPanel.h"
28 #include "PlaneDirectionViewer.h"
31 #include <wx/colordlg.h>
33 /********************************************************************************************
34 ** Start of data viewmanagerData
35 *********************************************************************************************/
37 PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
38 :wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){
39 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
42 this->SetSizer(sizer);
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);
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);
53 double* p0 = data->getPoint0();
54 double* p1 = data->getPoint1();
55 double* p2 = data->getPoint2();
56 double* dir = data->GetDirection();
58 wxString label(_T("[x, y, z]"));
60 tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
62 tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
64 tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
66 tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
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);
75 sizer->Add(checkbox,1);
76 sizer->Add(_colorchoose,1);
77 sizer->Add(textlabel,1);
83 this->SetAutoLayout(true);
88 void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){
89 PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
92 void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
94 wxColourDialog* colourdiag = new wxColourDialog(this);
95 if(colourdiag->ShowModal()==wxID_OK){
96 wxColour colour = colourdiag->GetColourData().GetColour();
97 _colorchoose->SetBackgroundColour(colour);
99 double r = (double)(colour.Red())/255.0;
100 double g = (double)(colour.Green())/255.0;
101 double b = (double)(colour.Blue())/255.0;
103 PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
109 PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){