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 # ------------------------------------------------------------------------ */
26 #include "interfToolsSpreadPanel.h"
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 );
34 resetbuttxt = initializeButton("data/Icons/reset.png", "Reset");
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);
42 gobuttxt = initializeButton("data/Icons/Go.png", "Go");
44 flexsizer->Add(resetbuttxt, wxFIXED_MINSIZE);
45 flexsizer->Add(flexsizer1, wxFIXED );
46 flexsizer->Add(gobuttxt, wxFIXED_MINSIZE);
54 interfToolsSpreadPanel::~interfToolsSpreadPanel()
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);
69 wxPanel* interfToolsSpreadPanel::initializeButton(std::string path, std::string nom){
72 wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
74 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1,2,2,2);
75 panel->SetSizer(flexsizer, true);
76 panel->SetAutoLayout( true );
78 wxBitmap* bitmap = new wxBitmap(wxString(path.c_str(),wxConvUTF8), wxBITMAP_TYPE_PNG);
80 wxBitmapButton* bitmapbutton = new wxBitmapButton(panel, -1, *bitmap, wxDefaultPosition, wxDefaultSize,
81 wxBU_AUTODRAW, wxDefaultValidator, wxString(_T("")));
84 wxStaticText* statictext = new wxStaticText(panel, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition,
85 wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
88 flexsizer->Add(bitmapbutton, wxFIXED_MINSIZE);
89 flexsizer->Add(statictext, wxALIGN_CENTRE_VERTICAL | wxALIGN_CENTER_HORIZONTAL |wxEXPAND);
96 wxPanel* interfToolsSpreadPanel::initializeAddRemoveContour(){
98 wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE |wxVSCROLL , wxString(_T("")));
100 scrollwin = new wxScrolledWindow(panel, -1, wxDefaultPosition, wxSize(80,50), wxVSCROLL, wxString(_T("")));
102 checkboxsizer = new wxFlexGridSizer(0,1,2,2);
105 scrollwin->SetSizer(checkboxsizer, true);
106 scrollwin->SetAutoLayout( false );
107 //scrollwin->SetInitialSize(wxSize(200,200));
113 void interfToolsSpreadPanel::addContourCheckBox(std::string id){
116 wxCheckBox* check = new wxCheckBox(scrollwin, -1, wxString(id.c_str(),wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0,
117 wxDefaultValidator, wxString(id.c_str(),wxConvUTF8));
119 checkvect.push_back(id);
121 checkboxsizer->Add(check, wxFIXED_MINSIZE | wxALIGN_LEFT );
123 checkboxsizer->Layout();
127 void interfToolsSpreadPanel::removeContourCheckBox(std::string id){
130 for(int i = 0; i < checkvect.size(); i++){
131 std::string temp = checkvect[i];
137 if(checkboxsizer->Remove(index)){
138 checkboxsizer->Layout();
140 throw "The checkbox could not be removed";