]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
no 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                         file.open(fileName.c_str());
401
402                         std::string content="";
403                         
404                         // writing file header
405                         content += "# ----------------------------------\n";
406                         content += "# - BBTKGEditor v 1.0 BBS BlackBox Script\n";
407                         content += "# ----------------------------------\n";
408                         content += "\n";
409                         content += _tabsMgr->getActualDiagramBBS();
410                         file << content;
411                         file.close();
412                 }
413
414         }
415
416         //=========================================================================
417
418         void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
419         {
420                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
421                 std::string cbName="";
422                 if (nameDialog->ShowModal() == wxID_OK)
423                 {
424                         wxString fileName = nameDialog->GetValue();
425                         cbName=fileName;
426                 }               
427
428                 if(!cbName.empty())
429                 {       
430                         wxFileDialog * saveFileDialog = new wxFileDialog( this , _T("Save Complex Box BBS") ,_T(""), wxString( cbName.c_str(), wxConvUTF8),_T(""), wxSAVE | wxOVERWRITE_PROMPT);
431                         if (saveFileDialog->ShowModal() == wxID_OK)
432                         {
433                                 wxString fileName = saveFileDialog->GetPath();
434                                 
435                                 ofstream file;
436                                 file.open(fileName.c_str());
437
438                                 std::string content="";
439                                 
440                                 // writing file header
441                                 content += "# ----------------------------------\n";
442                                 content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
443                                 content += "# ----------------------------------\n";
444                                 content += "\n";
445                                 content += _tabsMgr->getActualComplexBoxBBS(cbName);
446                                 file << content;
447                                 file.close();
448                         }
449                 }
450
451         }
452
453         //=========================================================================
454
455         void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
456         {
457                 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save  actual diagram"),wxEmptyString,"NewDiagram","*.bbd",wxSAVE|wxOVERWRITE_PROMPT);
458                 if (saveFileDialog->ShowModal() == wxID_OK)
459                 {
460                         wxString fileName = saveFileDialog->GetPath();
461                         
462                         ofstream file;
463                         file.open(fileName.c_str());
464
465                         std::string content="";
466                         
467                         // writing file header
468                         content += "# ----------------------------------\n";
469                         content += "# - BBTKGEditor v 1.0 BBD BlackBox Diagram file\n";
470                         content += "# - ";
471                         content += fileName;
472                         content += "\n";
473                         content += "# ----------------------------------\n";
474                         content += "\n";
475                         content += "APP_START\n";
476                         _tabsMgr->saveActualDiagram(content);           
477                         content += "APP_END\n";
478                         file << content;
479                         file.close();
480                 }
481
482         }
483
484         //=========================================================================
485
486         void wxGUIEditorGraphicBBS::refreshGUIControls()
487         {
488                 wxToolBar* toolbar = GetToolBar();
489                 if(_tabsMgr->isActualDiagramComplexBox())
490                 {
491                         toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
492                         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
493                         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
494                         
495                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
496                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
497                 }
498                 else
499                 {
500                         toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
501                         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
502                         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
503
504                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
505                         GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
506                 }
507
508         }
509
510         //=========================================================================
511
512         void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
513         {
514                 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);
515                 if(dial->ShowModal() == wxID_YES)
516                 {
517                         _tabsMgr->deleteAllBoxesActualDiagram();
518                 }
519         }
520
521         //=========================================================================
522
523         void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
524         {
525                 _tabsMgr->centerViewActualDiagram();
526         }
527
528         //=========================================================================
529
530         
531         void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
532         {
533                 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,"","*.bbd",wxOPEN|wxFILE_MUST_EXIST);
534                 if (openFileDialog->ShowModal() == wxID_OK)
535                 {
536                         wxString fileName = openFileDialog->GetPath();
537                         
538                         ifstream inputStream;
539                         inputStream.open(fileName.c_str());
540
541                         _tabsMgr->addNewTab();
542                         _tabsMgr->loadDiagram(inputStream);
543                         
544                         inputStream.close();
545                 }
546                 refreshGUIControls();
547         }
548
549         //=========================================================================
550
551         void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
552         {
553                 wxToolBar* toolbar = GetToolBar();
554                 bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
555                 if(temp)
556                 {
557                         _tabsMgr->setActualDiagramComplexBox(true);
558                 }
559                 else
560                 {
561                         _tabsMgr->setActualDiagramComplexBox(false);
562                 }
563                 refreshGUIControls();           
564         }
565
566         //=========================================================================
567
568         void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
569         {               
570                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
571                 if (nameDialog->ShowModal() == wxID_OK)
572                 {
573                         wxString fileName = nameDialog->GetValue();
574                         if(!fileName.IsEmpty())
575                         {
576                                 std::string portName=(const char*) (fileName.mb_str());
577                                 _tabsMgr->addActualDiagramComplexInputPort(portName);
578                         }
579                 }               
580         }
581
582         //=========================================================================
583
584         void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
585         {
586                 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of output port"));
587                 if (nameDialog->ShowModal() == wxID_OK)
588                 {
589                         wxString fileName = nameDialog->GetValue();
590                         if(!fileName.IsEmpty())
591                         {
592                                 std::string portName=(const char*) (fileName.mb_str());
593                                 _tabsMgr->addActualDiagramComplexOutputPort(portName);
594                         }
595                 }       
596         }
597
598         //=========================================================================
599
600         void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
601         {
602                 Close(true);
603         }
604
605         //=========================================================================
606
607 }  // EO namespace bbtk
608
609 // EOF
610