]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfToolsSpreadPanel.cxx
Feature #1772 Add licence terms for all files.
[creaContours.git] / lib / Interface_Icons_NDimensions / interfToolsSpreadPanel.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 #include "interfToolsSpreadPanel.h"
27
28 interfToolsSpreadPanel::interfToolsSpreadPanel(wxWindow * parent, int sizex, int sizey,wxEvtHandler* evtHandler)        
29         : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_THEME){
30         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(3,1,2,2);      
31         this->SetSizer(flexsizer, true);
32         this->SetAutoLayout( true );
33
34         resetbuttxt = initializeButton("data/Icons/reset.png", "Reset");
35
36         wxFlexGridSizer* flexsizer1 = new wxFlexGridSizer(1,2,2,2);     
37         radiobox = initializeRadioBox();
38         addremovecont = initializeAddRemoveContour();   
39         flexsizer1->Add(radiobox,wxFIXED_MINSIZE);
40         flexsizer1->Add(addremovecont,wxEXPAND | wxALIGN_CENTRE_VERTICAL);
41
42         gobuttxt = initializeButton("data/Icons/Go.png", "Go"); 
43
44         flexsizer->Add(resetbuttxt, wxFIXED_MINSIZE);
45         flexsizer->Add(flexsizer1, wxFIXED );
46         flexsizer->Add(gobuttxt, wxFIXED_MINSIZE);
47         
48         
49         this->Layout();
50         
51 }
52
53
54 interfToolsSpreadPanel::~interfToolsSpreadPanel()
55 {
56 }
57
58 wxPanel* interfToolsSpreadPanel::initializeRadioBox(){
59         wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
60         wxString lstOptions[3];
61         lstOptions[0]=_T("A");
62         lstOptions[1]=_T("B");
63         lstOptions[2]=_T("C");
64         wxRadioBox* _spreadMethodRadiobox       = new wxRadioBox(panel, -1, _T("Method"), wxDefaultPosition, wxSize(45,80), 3 , lstOptions,  3, wxRA_SPECIFY_ROWS);
65         _spreadMethodRadiobox->SetSelection(2);
66         return panel;
67 }
68
69 wxPanel* interfToolsSpreadPanel::initializeButton(std::string path, std::string nom){
70                         
71
72         wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
73
74         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1,2,2,2);      
75         panel->SetSizer(flexsizer, true);
76         panel->SetAutoLayout( true );
77         
78         wxBitmap* bitmap = new wxBitmap(wxString(path.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
79
80         wxBitmapButton* bitmapbutton = new wxBitmapButton(panel, -1, *bitmap, wxDefaultPosition, wxDefaultSize,
81                                                                                 wxBU_AUTODRAW, wxDefaultValidator, wxString(_T("")));
82
83         
84         wxStaticText* statictext = new wxStaticText(panel, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition, 
85                                                                 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
86
87         
88         flexsizer->Add(bitmapbutton, wxFIXED_MINSIZE);
89         flexsizer->Add(statictext, wxALIGN_CENTRE_VERTICAL | wxALIGN_CENTER_HORIZONTAL |wxEXPAND);
90
91         panel->Layout();
92         
93         return panel;
94 }
95
96 wxPanel* interfToolsSpreadPanel::initializeAddRemoveContour(){
97         
98         wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE |wxVSCROLL , wxString(_T("")));
99
100         scrollwin = new wxScrolledWindow(panel, -1, wxDefaultPosition, wxSize(80,50), wxVSCROLL, wxString(_T("")));
101
102         checkboxsizer = new wxFlexGridSizer(0,1,2,2);   
103
104
105         scrollwin->SetSizer(checkboxsizer, true);
106         scrollwin->SetAutoLayout( false );
107         //scrollwin->SetInitialSize(wxSize(200,200));
108
109         
110         return panel;
111 }
112
113 void interfToolsSpreadPanel::addContourCheckBox(std::string id){
114
115
116         wxCheckBox* check = new wxCheckBox(scrollwin, -1, wxString(id.c_str(),wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0,
117                                                         wxDefaultValidator, wxString(id.c_str(),wxConvUTF8));
118
119         checkvect.push_back(id);
120
121         checkboxsizer->Add(check, wxFIXED_MINSIZE | wxALIGN_LEFT );
122         scrollwin->Layout();
123         checkboxsizer->Layout();
124
125 }
126
127 void interfToolsSpreadPanel::removeContourCheckBox(std::string id){
128
129         int index=-1;
130         for(int i = 0; i < checkvect.size(); i++){
131                 std::string temp = checkvect[i];
132                 if(id == temp){
133                         index = i;
134                 }
135         }
136         if( index != -1){
137                 if(checkboxsizer->Remove(index)){
138                         checkboxsizer->Layout();
139                 }else{
140             throw "The checkbox could not be removed";
141                 }
142         }
143 }
144
145