]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
*** empty log message ***
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
1 /*=========================================================================                                                                               
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32 *  \file 
33 *  \brief Class bbtk::WxInterfaceEditorGraphicBBS . 
34 */
35
36 #include "bbtkwxGUIEditorGraphicBBS.h"
37 #include "creaWx.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
45                 : wxFrame(parent, -1, _T("bbtkGEditor"),wxDefaultPosition, wxSize(1200,800))
46         {
47                 _frameAUIMgr = new wxAuiManager(this);
48                 
49
50                 /*std::string datadir( crea::System::GetExecutablePath() );
51                 std::string datadir (".");
52                 cout<<"RaC //------------------"<<endl;
53                 cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with  crea::System::GetExecutablePath() ."<<endl;
54                 cout<<"RaC //------------------"<<endl;
55
56             #ifdef LINUX // assume this is OSX 
57                    datadir=datadir+"/../share/creaContours";
58             #endif // MACOSX    
59         
60                 #ifdef MACOSX // assume this is OSX 
61                         datadir=datadir+"/../../../../share/creaContours";
62                 #endif // MACOSX        
63
64                 _dataDir = datadir;*/
65
66                 initMenu();
67                 initToolbar();
68                 initTabPanelsManager();
69                 initPackageBrowser();
70                 initHelpHTMLBrowser();
71
72                 CreateStatusBar();
73                 _frameAUIMgr->Update();
74                 _actualPkgBrowserBoxName="";
75                 _actualPkgBrowserPkgName="";
76                 refreshGUIControls();
77         }
78
79
80         //=========================================================================
81         wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
82         {
83                 _frameAUIMgr->UnInit();
84         }
85
86         //=========================================================================
87         void wxGUIEditorGraphicBBS::initToolbar()
88         {        
89                 wxBitmap bmp_new(new_xpm);
90                 wxBitmap bmp_open(open_xpm);
91                 wxBitmap bmp_save(save_xpm);
92                 wxBitmap bmp_run(run_xpm);
93                 wxBitmap bmp_delete(delete_xpm);
94                 wxBitmap bmp_centerview(centerview_xpm);
95                 wxBitmap bmp_complexbox(complexbox_xpm);
96                 wxBitmap bmp_complexinputport(complexinputport_xpm);
97                 wxBitmap bmp_complexoutputport(complexoutputport_xpm);
98
99                 wxToolBar  *toolbar = new wxToolBar(this, wxID_ANY);
100
101                 //Adds a tool btn to the toolbar
102                 toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
103                 toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram"));
104                 toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
105                 toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
106                 toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
107                 toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
108                 toolbar->AddSeparator();
109                 toolbar->AddTool(ID_BTNCOMPLEXBOX,_T("Complex box"),complexbox_xpm, wxNullBitmap, wxITEM_NORMAL,_T("Complex box"), _T("Complex box"));
110                 toolbar->SetToggle(ID_BTNCOMPLEXBOX,true);
111                 toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT,_T("Add input to Complex box"),bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,_T("Add input to Complex box"), _T("Add input to Complex box"));
112                 toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT,_T("Add output to Complex box"),bmp_complexoutputport, wxNullBitmap, wxITEM_NORMAL,_T("Add output Complex box"), _T("Add output Complex box"));
113                 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
114                 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
115                 
116                 toolbar->SetMargins( 2, 2 );
117                 toolbar->Realize();
118                 SetToolBar(toolbar);
119
120                 // connect command event handlers
121                 Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
122                 Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
123                 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
124                 Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
125                 Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
126                 Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
127                 Connect(ID_BTNCOMPLEXBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
128                 Connect(ID_ADDCOMPLEXBOXINPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
129                 Connect(ID_ADDCOMPLEXBOXOUTPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
130
131         }
132         //=========================================================================
133         void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
134         {
135                 //TO FIX THE PATH OF BBTK BIN  IN ORDER TO USE REGENERATE EXECUTABLES
136                 //RegenerateAll();
137                 _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
138                 _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));       
139         }
140
141         //=========================================================================
142         void wxGUIEditorGraphicBBS::initMenu()
143         {
144                 // create a menu bar
145                 wxMenu *fileMenu = new wxMenu();
146                 fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
147                 fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save diagram"), _T("Save diagram"));
148                 fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
149                 fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box"));
150                 fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
151
152                 Connect(ID_NEW,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
153                 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
154                 Connect(ID_SAVE_AS_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
155                 Connect(ID_SAVE_AS_COMPLEXBOX,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
156                 Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
157
158                 // the "About" item should be in the help menu
159                 wxMenu *helpMenu = new wxMenu;
160                 helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));             
161
162                 // now append the freshly created menu to the menu bar...
163                 wxMenuBar *menuBar = new wxMenuBar();
164                 menuBar->Append(fileMenu, _T("&File"));
165                 menuBar->Append(helpMenu, _T("&Help"));
166
167                 // attach this menu bar to the frame
168                 SetMenuBar(menuBar);            
169         }
170
171         //=========================================================================
172         void wxGUIEditorGraphicBBS::initTabPanelsManager()
173         {
174                 _notebook = new wxAuiNotebook(this,wxID_NOTEBOOK,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
175                 _tabsMgr = new wxTabPanelsManager(this);
176                 _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());  
177
178         }
179         
180         //=========================================================================
181         void wxGUIEditorGraphicBBS::initPackageBrowser()
182         {
183                 _pkgBrowser = new WxGUIPackageBrowser2(this);
184                 _pkgBrowser->IncludeAll();
185                 _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));          
186         }
187
188         //================================================================
189
190         void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
191         {
192                 std::string mess("Regenerating doc for package '");
193                 if (pack!="-a"){
194                         mess += pack + "'";
195                 }
196                 else
197                 {
198                         mess = "Regenerating doc for all packages";
199                 }
200                 
201                 mess += " ... please wait";             
202
203                 SetStatusText( std2wx(mess) );
204
205                 //BBTK_BUSY_CURSOR;
206
207                 std::string command;
208                 #if defined(WIN32)
209                         command = "\"";
210                 #endif
211                         command += ConfigurationFile::GetInstance().Get_bin_path();
212                         command += ConfigurationFile::GetInstance().Get_file_separator();
213                         command += "bbRegeneratePackageDoc";
214                 #if defined(WIN32)
215                         command += "\"";
216                 #endif
217
218                 command += " " + pack + " -q";
219             bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
220
221                 if ( ! system ( command.c_str() ) )
222                 {
223                         SetStatusText( _T("Done !"));
224                         /*
225                         wxMessageBox(_T("Done !"),_T("Regenerate package '")
226                                          +std2wx(pack)+_T("' doc"),
227                                          wxOK | wxICON_INFORMATION);
228                         */
229                 }
230                 else 
231                 {
232                         SetStatusText( _T("Done !"));
233                         wxString err(_T("An error occured while running '"));
234                         err +=  bbtk::std2wx(command) + _T("'");
235                         wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);      
236             }
237         }
238
239         //================================================================
240         void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
241         {
242                 SetStatusText( _T("Regenerating boxes lists ... please wait") );
243                 //BBTK_BUSY_CURSOR ;
244
245                 std::string command;
246                 #if defined(WIN32)
247                         command = "\"";
248                 #endif
249                         command += ConfigurationFile::GetInstance().Get_bin_path();
250                         command += ConfigurationFile::GetInstance().Get_file_separator();
251                         command += "bbRegenerateBoxesLists";
252
253                 #if defined(WIN32)
254                         command += "\"";
255                 #endif
256                         command += " -q";
257
258                 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
259
260                 if ( ! system ( command.c_str() ) )
261                 {
262                         SetStatusText( _T("Done !"));
263                         /*
264                         wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
265                                          wxOK | wxICON_INFORMATION);
266                         */
267                 }
268                 else 
269                 {
270                         SetStatusText( _T("Done !"));
271                         wxString err(_T("An error occured while running '"));
272                         err +=  bbtk::std2wx(command) + _T("'");
273                         wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);      
274                 }
275         }
276         
277   //================================================================
278         void wxGUIEditorGraphicBBS::RegenerateAll()
279         {
280                 DoRegeneratePackageDoc("-a");   
281                 DoRegenerateBoxesLists();
282         }
283
284         //================================================================
285
286         wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook()
287         {
288                 return _notebook;
289         }
290
291         //================================================================
292
293         void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
294         {
295                 if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName )
296                 {
297                         _actualPkgBrowserPkgName = packageName;
298                         _actualPkgBrowserBoxName = boxName;
299
300                         BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
301                         _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
302                 }
303         }
304
305         //=========================================================================
306
307         void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel)
308         {
309                 wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,bbmodel);
310                 dialog->Show();
311         }
312
313         //=========================================================================
314
315         void wxGUIEditorGraphicBBS::editDiagramParameters(wxVtkSceneManager* scene)
316         {
317                 wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,scene);
318                 dialog->Show();
319         }
320
321         //=========================================================================
322
323         void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus)
324         {
325                 SetStatusText(crea::std2wx(textStatus));
326         }
327
328         //=========================================================================
329
330         void wxGUIEditorGraphicBBS::executeScript(std::string script)
331         {
332                 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
333                 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
334                 std::string filename = dir + separator + "tmp_bbtk.bbs";
335                 
336                 ofstream tempFile;
337                 tempFile.open(filename.c_str());
338                 tempFile << script;
339                 tempFile.close();
340                 
341                 std::string command = "\"";
342
343                 #ifdef WIN32
344                         command += "\"";
345                 #endif
346
347                 //command += ConfigurationFile::GetInstance().Get_bin_path();
348                 command +="C:/temp/bbtkBIN/RelWithDebInfo//";
349
350                 #ifdef MACOSX
351                         command += separator + "bbi.app/Contents/MacOS/bbi\" ";
352                 #else 
353                         command += separator + "bbi\" ";
354                 #endif
355                 command += "\""+filename + "\"";
356
357                 #ifdef WIN32
358                         command += "\"";
359                 #endif
360
361                 command += " & ";
362                   
363                 printf ("RaC wxGUIEditorGraphicBBS::executeScript %s \n" , command.c_str() );
364                 system( command.c_str() );
365         }
366
367         //=========================================================================
368         // EVENT HANDLERS 
369         //=========================================================================
370
371         void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event)
372         {
373                 _tabsMgr->addNewTab();  
374                 refreshGUIControls();
375         }
376
377         //=========================================================================
378
379         void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
380         {
381                 std::string script = _tabsMgr->getActualDiagramBBS();
382                 cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl;
383                 cout<<script<<endl;
384
385                 executeScript(script);          
386         }
387
388         //=========================================================================
389         // HANDLERS 
390         //=========================================================================
391
392         void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event)
393         {
394                 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxSAVE|wxOVERWRITE_PROMPT);
395                 if (saveFileDialog->ShowModal() == wxID_OK)
396                 {
397                         wxString fileName = saveFileDialog->GetPath();
398                         
399                         ofstream file;
400
401 //EED                   file.open(fileName.c_str()); 
402                         file.open( (const char*) (fileName.mb_str()) );
403
404                         std::string content="";
405                         
406                         // writing file header
407                         content += "# ----------------------------------\n";
408                         content += "# - BBTKGEditor v 1.0 BBS BlackBox Script\n";
409                         content += "# ----------------------------------\n";
410                         content += "\n";
411                         content += _tabsMgr->getActualDiagramBBS();
412                         file << content;
413                         file.close();
414                 }
415
416         }
417
418         //=========================================================================
419
420         void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
421         {
422                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
423                 std::string cbName="";
424                 if (nameDialog->ShowModal() == wxID_OK)
425                 {
426                         wxString fileName = nameDialog->GetValue();
427 //EED                   cbName=fileName;
428                         cbName=(const char*) (fileName.mb_str());
429                 }               
430
431                 if(!cbName.empty())
432                 {       
433                         wxFileDialog * saveFileDialog = new wxFileDialog( this , _T("Save Complex Box BBS") ,_T(""), wxString( cbName.c_str(), wxConvUTF8),_T(""), wxSAVE | wxOVERWRITE_PROMPT);
434                         if (saveFileDialog->ShowModal() == wxID_OK)
435                         {
436                                 wxString fileName = saveFileDialog->GetPath();
437                                 
438                                 ofstream file;
439 //EED                           file.open(fileName.c_str());
440                                 file.open( (const char*) (fileName.mb_str()) );
441
442                                 std::string content="";
443                                 
444                                 // writing file header
445                                 content += "# ----------------------------------\n";
446                                 content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
447                                 content += "# ----------------------------------\n";
448                                 content += "\n";
449                                 content += _tabsMgr->getActualComplexBoxBBS(cbName);
450                                 file << content;
451                                 file.close();
452                         }
453                 }
454
455         }
456
457         //=========================================================================
458
459         void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
460         {
461                 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbd"),wxSAVE|wxOVERWRITE_PROMPT);
462                 if (saveFileDialog->ShowModal() == wxID_OK)
463                 {
464                         wxString fileName = saveFileDialog->GetPath();
465                         
466                         ofstream file;
467 //EED                   file.open(fileName.c_str());
468                         file.open( (const char*) (fileName.mb_str()) );
469
470                         std::string content="";
471                         
472                         // writing file header
473                         content += "# ----------------------------------\n";
474                         content += "# - BBTKGEditor v 1.0 BBD BlackBox Diagram file\n";
475                         content += "# - ";
476
477 //EED                   content += fileName;
478                         content += (const char*) (fileName.mb_str());
479
480                         content += "\n";
481                         content += "# ----------------------------------\n";
482                         content += "\n";
483                         content += "APP_START\n";
484                         _tabsMgr->saveActualDiagram(content);           
485                         content += "APP_END\n";
486                         file << content;
487                         file.close();
488                 }
489
490         }
491
492         //=========================================================================
493
494         void wxGUIEditorGraphicBBS::refreshGUIControls()
495         {
496                 wxToolBar* toolbar = GetToolBar();
497                 if(_tabsMgr->isActualDiagramComplexBox())
498                 {
499                         toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
500                         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
501                         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
502                         
503                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
504                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
505                 }
506                 else
507                 {
508                         toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
509                         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
510                         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
511
512                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
513                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
514                 }
515
516         }
517
518         //=========================================================================
519
520         void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
521         {
522                 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Are you sure to delete all boxes of the diagram?"), wxT("Delete all boxes"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
523                 if(dial->ShowModal() == wxID_YES)
524                 {
525                         _tabsMgr->deleteAllBoxesActualDiagram();
526                 }
527         }
528
529         //=========================================================================
530
531         void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
532         {
533                 _tabsMgr->centerViewActualDiagram();
534         }
535
536         //=========================================================================
537
538         
539         void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
540         {
541                 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,wxT(""),wxT("*.bbd"),wxOPEN|wxFILE_MUST_EXIST);
542                 if (openFileDialog->ShowModal() == wxID_OK)
543                 {
544                         wxString fileName = openFileDialog->GetPath();
545                         
546                         ifstream inputStream;
547
548 //EED                   inputStream.open(fileName.c_str());
549                         inputStream.open( (const char*) (fileName.mb_str()) );
550
551
552
553                         _tabsMgr->addNewTab();
554                         _tabsMgr->loadDiagram(inputStream);
555                         
556                         inputStream.close();
557                 }
558                 refreshGUIControls();
559         }
560
561         //=========================================================================
562
563         void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
564         {
565                 wxToolBar* toolbar = GetToolBar();
566                 bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
567                 if(temp)
568                 {
569                         _tabsMgr->setActualDiagramComplexBox(true);
570                 }
571                 else
572                 {
573                         _tabsMgr->setActualDiagramComplexBox(false);
574                 }
575                 refreshGUIControls();           
576         }
577
578         //=========================================================================
579
580         void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
581         {               
582                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
583                 if (nameDialog->ShowModal() == wxID_OK)
584                 {
585                         wxString fileName = nameDialog->GetValue();
586                         if(!fileName.IsEmpty())
587                         {
588                                 std::string portName=(const char*) (fileName.mb_str());
589                                 _tabsMgr->addActualDiagramComplexInputPort(portName);
590                         }
591                 }               
592         }
593
594         //=========================================================================
595
596         void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
597         {
598                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of output port"));
599                 if (nameDialog->ShowModal() == wxID_OK)
600                 {
601                         wxString fileName = nameDialog->GetValue();
602                         if(!fileName.IsEmpty())
603                         {
604                                 std::string portName=(const char*) (fileName.mb_str());
605                                 _tabsMgr->addActualDiagramComplexOutputPort(portName);
606                         }
607                 }       
608         }
609
610         //=========================================================================
611
612         void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
613         {
614                 Close(true);
615         }
616
617         //=========================================================================
618
619 }  // EO namespace bbtk
620
621 // EOF
622