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