]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContour_ButtonsBar.cxx
Feature #1772 Add licence terms for all files.
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContour_ButtonsBar.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 //----------------------------------------------------------------------------------------------------------------
28 // Class definition include
29 //----------------------------------------------------------------------------------------------------------------
30 #include "wxContour_ButtonsBar.h"
31
32 //----------------------------------------------------------------------------------------------------------------
33 // Class implementation
34 //----------------------------------------------------------------------------------------------------------------
35 /** @file wxConceptControl.cxx */
36
37
38 //------------------------------------------------------------------------------------------------------------
39 // Includes
40 //------------------------------------------------------------------------------------------------------------
41 #include "wxContour_ActionCommandsID.h"
42
43 #include <string>
44 #include "wx/toolbar.h"
45 #include "wx/log.h"
46 #include "wx/image.h"
47 #include "wx/filedlg.h"
48 #include "wx/spinctrl.h"
49 #include "wx/srchctrl.h"
50 #include <wx/wx.h>
51 //------------------------------------------------------------------------------------------------------------
52 // Generated events declaration and definition
53 //------------------------------------------------------------------------------------------------------------
54
55         //------------------------------------------------------------------------------------------------------------
56         // Constructors & Destructors
57         //------------------------------------------------------------------------------------------------------------
58
59         wxContour_ButtonsBar :: wxContour_ButtonsBar( wxWindow* parent, wxWindowID id, const wxPoint& pos , const wxSize& size, long style, const wxString& name )
60         //:wxToolBar(parent, id, pos, size, style, name)
61         :wxPanel( parent, id)//, pos, size, style, name)
62         {
63                 //SetToolBitmapSize(wxSize(16,16));
64         std::string as = (char)wxContour_ActionCommandsID::CREATE_TOOL +"";
65         _createContour_Button = new wxButton( this, -1, _T("+ New Contour"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
66 //              _createContour_Button->SetToolTip(_T("CTRL-N"));
67                 Connect( _createContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
68
69                 as = (char)wxContour_ActionCommandsID::DELETE_TOOL +"";
70                 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
71                 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
72                 Connect( _delete_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
73
74 /*              
75                 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::HIDE_TOOL );
76                 Connect( _hideContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
77
78                 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SHOW_TOOL );
79                 Connect( _show_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
80 */
81                 as = (char)wxContour_ActionCommandsID::COPY_TOOL +"";
82                 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
83                 _copy_Button->SetToolTip(_T("CTRL-C"));
84                 Connect( _copy_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
85
86                 as = (char)wxContour_ActionCommandsID::PASTE_TOOL +"";
87                 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
88                 _paste_Button->SetToolTip(_T("CTRL-V"));
89                 Connect( _paste_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
90
91                 as = (char)wxContour_ActionCommandsID::CHANGE_TOOL +"";
92                 _change_Button = new wxButton( this, -1, _T("    <-->  "), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
93                 _change_Button->SetToolTip(_T("CTRL-K"));
94                 Connect( _change_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
95
96                 as = (char)wxContour_ActionCommandsID::SAVE_TOOL +"";
97                 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
98                 _save_Button->SetToolTip(_T("CTRL-S"));
99                 Connect( _save_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
100
101                 as = (char)wxContour_ActionCommandsID::OPEN_TOOL +"";
102                 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
103                 _open_Button->SetToolTip(_T("CTRL-O"));
104                 Connect( _open_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
105
106                 as = (char)wxContour_ActionCommandsID::SPREAD_TOOL +"";
107                 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
108 //              _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
109                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
110
111                 as = (char)wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL +"";
112                 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
113 //              _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
114                 Connect( _automatiqueSegmentation_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
115
116                 as = (char)wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL +"";
117                 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
118 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
119                 Connect( _informationContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
120
121                 as = (char)wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL +"";
122                 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
123 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
124                 Connect( _interfaceConfiguration_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
125
126
127 //Test button Methods A-B-C in  Juan Carlos Prieto 22-09-08
128                 as = (char)wxContour_ActionCommandsID::TEST_TOOL +"";
129                 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
130 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
131                 Connect( _interfaceTest_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
132
133
134 /*
135                 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
136                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
137                 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SELECT_TOOL );
138                 Connect( _select_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
139
140                 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::EDIT_TOOL );
141                 Connect( _edit_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
142
143                 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::UNDO_TOOL );
144                 Connect( _undo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
145
146                 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::REDO_TOOL );
147                 Connect( _redo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
148 */
149                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
150                 panelSizer -> Add( _createContour_Button, 1, wxGROW );
151 /*
152                 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
153                 panelSizer -> Add( _show_Button, 1, wxGROW );
154 */
155                 panelSizer -> Add( _change_Button       , 1, wxGROW );
156                 panelSizer -> Add( _copy_Button         , 1, wxGROW );
157                 panelSizer -> Add( _paste_Button        , 1, wxGROW );
158                 panelSizer -> Add( _delete_Button       , 1, wxGROW );
159                 panelSizer -> Add( _save_Button         , 1, wxGROW );
160                 panelSizer -> Add( _open_Button         , 1, wxGROW );
161                 panelSizer -> Add( _spread_Button       , 1, wxGROW );
162                 panelSizer -> Add( _automatiqueSegmentation_Button      , 1, wxGROW );
163                 panelSizer -> Add( _informationContour_Button           , 1, wxGROW );
164                 panelSizer -> Add( _interfaceConfiguration_Button       , 1, wxGROW );
165                 panelSizer -> Add( _interfaceTest_Button        , 1, wxGROW );
166                 
167 /*
168                 panelSizer -> Add( _select_Button, 1, wxGROW );
169                 panelSizer -> Add( _edit_Button, 1, wxGROW );
170                 panelSizer -> Add( _undo_Button, 1, wxGROW );
171                 panelSizer -> Add( _redo_Button, 1, wxGROW );
172 */
173                 
174                 SetSizer( panelSizer );
175 /*
176                 this->AddControl( _createContour_Button );
177                 AddSeparator();
178                 this->AddControl( _hideContour_Button );
179 */
180                 SetSize( wxSize( 1500, 80));
181                 this->SetAutoLayout( true );
182                 this->Layout();         
183         }
184
185         wxContour_ButtonsBar :: ~wxContour_ButtonsBar(  )
186         {
187                 _eventHandler = NULL;
188                 /*delete        _createContour_Button;
189                 delete  _delete_Button;
190                 delete  _hideContour_Button;
191                 delete  _show_Button;
192                 delete  _copy_Button;
193                 delete  _paste_Button;
194                 delete  _spread_Button;
195                 delete  _select_Button;
196                 delete  _edit_Button;
197                 delete  _undo_Button;
198                 delete  _redo_Button;*/         
199         }
200         //------------------------------------------------------------------------------------------------------------
201         // Methods for capturing events
202         //------------------------------------------------------------------------------------------------------------
203         void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
204         {
205                 if(_eventHandler!=NULL)
206                 {
207                         std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
208                         const char * toolCommand = theStr.c_str();
209                         event.SetId( GetId() );
210                         event.SetEventObject( this );
211                         event.SetClientData( (void *) toolCommand);
212                         _eventHandler->ProcessEvent( event );
213                 }
214         }               
215         
216         //------------------------------------------------------------------------------------------------------------
217         //  Methods for sending events
218         //------------------------------------------------------------------------------------------------------------
219         void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
220         {
221                 wxCommandEvent cevent( theEventType, GetId() );
222                 cevent.SetEventObject( this );
223                 _eventHandler->ProcessEvent( cevent );
224         }
225
226
227         //------------------------------------------------------------------------------------------------------------
228         //  Attributes getters and setters
229         //------------------------------------------------------------------------------------------------------------
230
231         
232         //------------------------------------------------------------------------------------------------------------
233         //  Other functional methods
234         //------------------------------------------------------------------------------------------------------------
235
236         //------------------------------------------------------------------------------------------------------------
237         //  Private methods
238         //------------------------------------------------------------------------------------------------------------
239
240         //------------------------------------------------------------------------------------------------------------
241         // Creational and initialization methods
242         //------------------------------------------------------------------------------------------------------------
243
244         void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
245         {
246                 _eventHandler = theEventHandler;
247         }
248         
249         //------------------------------------------------------------------------------------------------------------
250         // Attributtes
251         //------------------------------------------------------------------------------------------------------------
252         
253