1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::WxInterfaceEditorGraphicBBS .
36 #include "bbtkwxGUIEditorGraphicBBS.h"
38 #include "creaSystem.h"
40 #include <InterpreterBBS.h>
48 //=========================================================================
49 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
50 : wxFrame(parent, -1, _T("bbtkGEditor"),wxDefaultPosition, wxSize(1200,800))
53 _frameAUIMgr = new wxAuiManager(this);
56 /*std::string datadir( crea::System::GetExecutablePath() );
57 std::string datadir (".");
58 cout<<"RaC //------------------"<<endl;
59 cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with crea::System::GetExecutablePath() ."<<endl;
60 cout<<"RaC //------------------"<<endl;
62 #ifdef LINUX // assume this is OSX
63 datadir=datadir+"/../share/creaContours";
66 #ifdef MACOSX // assume this is OSX
67 datadir=datadir+"/../../../../share/creaContours";
74 initTabPanelsManager();
76 initHelpHTMLBrowser();
79 _frameAUIMgr->Update();
80 _actualPkgBrowserBoxName="";
81 _actualPkgBrowserPkgName="";
86 //=========================================================================
87 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
89 printf ("EED %p ~wxGUIEditorGraphicBBS()\n" , this );
91 //EED02JUIN2010 delete _tabsMgr;
93 _frameAUIMgr->UnInit();
98 //=========================================================================
99 void wxGUIEditorGraphicBBS::initToolbar()
101 wxBitmap bmp_new(new_xpm);
102 wxBitmap bmp_open(open_xpm);
103 wxBitmap bmp_save(save_xpm);
104 wxBitmap bmp_run(run_xpm);
105 wxBitmap bmp_delete(delete_xpm);
106 wxBitmap bmp_centerview(centerview_xpm);
107 wxBitmap bmp_box(box_xpm);
108 wxBitmap bmp_complexbox(complexbox_xpm);
109 wxBitmap bmp_complexinputport(complexinputport_xpm);
110 wxBitmap bmp_complexoutputport(complexoutputport_xpm);
112 wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
114 //Adds a tool btn to the toolbar
115 toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
116 toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram"));
117 toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
118 toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
119 toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
120 toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
121 toolbar->AddSeparator();
122 toolbar->AddTool(ID_BTNBOX,_T("New Box"),bmp_box, wxNullBitmap, wxITEM_NORMAL,_T("New Box"), _T("Nex Box"));
123 toolbar->AddSeparator();
124 toolbar->AddTool(ID_BTNCOMPLEXBOX,_T("Complex box"),complexbox_xpm, wxNullBitmap, wxITEM_NORMAL,_T("Complex box"), _T("Complex box"));
125 toolbar->SetToggle(ID_BTNCOMPLEXBOX,true);
126 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"));
127 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"));
128 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
129 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
131 toolbar->SetMargins( 2, 2 );
135 // connect command event handlers
136 Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
137 Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
138 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
139 Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
140 Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
141 Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
142 Connect(ID_BTNBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnBox));
143 Connect(ID_BTNCOMPLEXBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
144 Connect(ID_ADDCOMPLEXBOXINPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
145 Connect(ID_ADDCOMPLEXBOXOUTPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
148 //=========================================================================
149 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
151 //TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES
153 _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
154 _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
157 //=========================================================================
158 void wxGUIEditorGraphicBBS::initMenu()
160 // Create File menu and its items
161 wxMenu *fileMenu = new wxMenu();
162 fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
163 fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save diagram"), _T("Save diagram"));
164 fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
165 fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
166 fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box"));
167 fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
169 Connect(ID_NEW,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
170 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
171 Connect(ID_OPEN_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
172 Connect(ID_SAVE_AS_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
173 Connect(ID_SAVE_AS_COMPLEXBOX,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
174 Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
176 // Create Help menu and its items
177 wxMenu *editMenu = new wxMenu;
178 editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
180 Connect(ID_COPY_TO_COMPLEXDIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
182 // Create Help menu and its items
183 wxMenu *helpMenu = new wxMenu;
184 helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
185 helpMenu->Append(ID_HELP_BBEDITOR, _T("&Help..."), _T("Help"));
186 Connect(ID_HELP_BBEDITOR,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnHelpBBeditor));
188 // Append the created menu to the menu bar
189 wxMenuBar *menuBar = new wxMenuBar();
190 menuBar->Append(fileMenu, _T("&File"));
191 menuBar->Append(editMenu, _T("&Edit"));
192 menuBar->Append(helpMenu, _T("&Help"));
194 // Attach this menu bar to the frame
198 //=========================================================================
199 void wxGUIEditorGraphicBBS::initTabPanelsManager()
201 _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);
202 _tabsMgr = new wxTabPanelsManager(this);
203 _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());
207 //=========================================================================
208 void wxGUIEditorGraphicBBS::initPackageBrowser()
210 _pkgBrowser = new WxGUIPackageBrowser2(this);
211 _pkgBrowser->IncludeAll();
212 _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
215 //================================================================
217 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
219 std::string mess("Regenerating doc for package '");
225 mess = "Regenerating doc for all packages";
228 mess += " ... please wait";
230 SetStatusText( std2wx(mess) );
238 command += ConfigurationFile::GetInstance().Get_bin_path();
239 command += ConfigurationFile::GetInstance().Get_file_separator();
240 command += "bbRegeneratePackageDoc";
245 command += " " + pack + " -q";
246 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
248 if ( ! system ( command.c_str() ) )
250 SetStatusText( _T("Done !"));
252 wxMessageBox(_T("Done !"),_T("Regenerate package '")
253 +std2wx(pack)+_T("' doc"),
254 wxOK | wxICON_INFORMATION);
259 SetStatusText( _T("Done !"));
260 wxString err(_T("An error occured while running '"));
261 err += bbtk::std2wx(command) + _T("'");
262 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
266 //================================================================
267 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
269 SetStatusText( _T("Regenerating boxes lists ... please wait") );
276 command += ConfigurationFile::GetInstance().Get_bin_path();
277 command += ConfigurationFile::GetInstance().Get_file_separator();
278 command += "bbRegenerateBoxesLists";
285 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
287 if ( ! system ( command.c_str() ) )
289 SetStatusText( _T("Done !"));
291 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
292 wxOK | wxICON_INFORMATION);
297 SetStatusText( _T("Done !"));
298 wxString err(_T("An error occured while running '"));
299 err += bbtk::std2wx(command) + _T("'");
300 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
304 //================================================================
305 void wxGUIEditorGraphicBBS::RegenerateAll()
307 DoRegeneratePackageDoc("-a");
308 DoRegenerateBoxesLists();
311 //================================================================
313 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook()
318 //================================================================
320 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
322 if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName )
324 _actualPkgBrowserPkgName = packageName;
325 _actualPkgBrowserBoxName = boxName;
327 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
328 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
332 //=========================================================================
334 void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel)
336 wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,bbmodel);
340 //=========================================================================
342 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus)
344 SetStatusText(crea::std2wx(textStatus));
347 //=========================================================================
349 void wxGUIEditorGraphicBBS::executeScript(std::string script)
351 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
352 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
353 std::string filename = dir + separator + "tmp_bbtk.bbs";
356 tempFile.open(filename.c_str());
360 std::string command = "\""+ crea::System::GetExecutablePath();
364 command += separator + "../../../bbi.app/Contents/MacOS";
373 //command += ConfigurationFile::GetInstance().Get_bin_path();
374 //EED command +="C:/temp/bbtkBIN/RelWithDebInfo//";
375 //EED command +="C:/Program Files/CreaTools/bbtk-0.9.5/bin";
379 command += separator + "usr/local/bin/bbi.app/Contents/MacOS/bbi\" ";
382 command += separator + "bbi\" ";
385 command += separator + "bbi\" ";
386 command += "\""+filename + "\"";
393 printf ("RaC wxGUIEditorGraphicBBS::executeScript %s \n" , command.c_str() );
394 system( command.c_str() );
397 //=========================================================================
399 //=========================================================================
401 void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event)
403 _tabsMgr->addNewTab();
404 refreshGUIControls();
407 //=========================================================================
409 void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
411 std::string script1 = _tabsMgr->getActualDiagramBBS(true);
412 cout<<endl<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl<<endl;
415 std::string script2 = _tabsMgr->getActualDiagramBBS(false);
416 executeScript(script2);
420 //=========================================================================
422 //=========================================================================
423 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event)
425 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxOPEN);
426 if (openFileDialog->ShowModal() == wxID_OK)
428 wxString fileName = openFileDialog->GetPath( );
431 _tabsMgr->addNewTab();
433 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory());
435 // We tell the interpreter to throw exceptions on error
437 // Interpret the file supposed to define a box called 'Processing'
438 I->InterpretFile( (const char*) (fileName.mb_str()) );
440 refreshGUIControls();
445 void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename)
449 //EED file.open(fileName.c_str());
450 file.open( filename.c_str() );
451 std::string content="";
452 // writing file header
453 content += "# ----------------------------------\n";
454 content += "# - BBTKGEditor v 1.1 BBS BlackBox Script\n";
458 content += "# ----------------------------------\n";
460 content += _tabsMgr->getActualDiagramBBS();
466 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event)
468 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxSAVE|wxOVERWRITE_PROMPT);
469 if (saveFileDialog->ShowModal() == wxID_OK)
471 wxString fileName = saveFileDialog->GetPath( );
472 SaveActualBBS( (const char*) (fileName.mb_str()) );
478 //=========================================================================
480 void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename)
482 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
483 std::string cbName="";
484 if (nameDialog->ShowModal() == wxID_OK)
486 wxString complexboxname = nameDialog->GetValue();
487 cbName=(const char*) (complexboxname.mb_str());
494 file.open( filename.c_str() );
496 std::string content="";
498 // writing file header
499 content += "# ----------------------------------\n";
500 content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
504 content += "# ----------------------------------\n";
506 content += _tabsMgr->getActualComplexBoxBBS(cbName);
514 //=========================================================================
516 void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
518 wxFileDialog * saveFileDialog = new wxFileDialog(this ,wxT("Save Complex Box BBS") ,wxEmptyString, _T("ComplexBoxName") ,wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
519 if (saveFileDialog->ShowModal() == wxID_OK)
521 wxString fileName = saveFileDialog->GetPath();
522 SaveActualComplexBox( (const char*) (fileName.mb_str()) );
526 //=========================================================================
527 void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename)
530 file.open( filename.c_str() );
532 std::string content="";
534 // writing file header
535 content += "# ----------------------------------\n";
536 content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n";
542 content += "# ----------------------------------\n";
544 content += "APP_START\n";
545 _tabsMgr->saveActualDiagram(content);
546 content += "APP_END\n";
552 //=========================================================================
553 void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
555 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
556 if (saveFileDialog->ShowModal() == wxID_OK)
558 wxString fileName = saveFileDialog->GetPath();
559 std::string filename = (const char*) (fileName.mb_str());
560 std::string filenamebbs = filename+"s";
562 SaveActualDiagram( filename );
563 if (_tabsMgr->isActualDiagramComplexBox()==false)
565 SaveActualBBS(filenamebbs);
567 SaveActualComplexBox(filenamebbs);
568 } //if isActualDiagramComplexBox
569 } // if saveFileDialog
572 //=========================================================================
574 void wxGUIEditorGraphicBBS::refreshGUIControls()
576 wxToolBar* toolbar = GetToolBar();
577 if(_tabsMgr->isActualDiagramComplexBox())
579 toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
580 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
581 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
583 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
584 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
588 toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
589 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
590 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
592 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
593 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
596 if(_tabsMgr->getNumActualSelectedObjects()>0)
598 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
602 ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
603 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
608 //=========================================================================
610 void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
612 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);
613 if(dial->ShowModal() == wxID_YES)
615 _tabsMgr->deleteAllBoxesActualDiagram();
619 //=========================================================================
621 void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
623 _tabsMgr->centerViewActualDiagram();
626 //=========================================================================
628 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
630 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,wxT(""),wxT("*.bbg"),wxOPEN|wxFILE_MUST_EXIST);
631 if (openFileDialog->ShowModal() == wxID_OK)
633 wxString fileName = openFileDialog->GetPath();
634 ifstream inputStream;
635 //EED inputStream.open(fileName.c_str());
636 inputStream.open( (const char*) (fileName.mb_str()) );
637 _tabsMgr->addNewTab();
638 _tabsMgr->loadDiagram(inputStream);
642 refreshGUIControls();
645 //=========================================================================
648 void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event)
650 BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
653 std::string typeName = bbDes->GetTypeName();
654 std::string packageName = bbDes->GetPackage()->GetName();
657 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
661 wxVtkSceneManager *scn = pnl->getSceneManager();
662 scn->createGBlackBox(50,50,packageName, typeName);
668 //=========================================================================
671 void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
673 wxToolBar* toolbar = GetToolBar();
674 bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
677 _tabsMgr->setActualDiagramComplexBox(true);
681 _tabsMgr->setActualDiagramComplexBox(false);
683 refreshGUIControls();
686 //=========================================================================
688 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
690 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
691 if (nameDialog->ShowModal() == wxID_OK)
693 wxString fileName = nameDialog->GetValue();
694 if(!fileName.IsEmpty())
696 std::string portName=(const char*) (fileName.mb_str());
697 _tabsMgr->addActualDiagramComplexInputPort(portName);
702 //=========================================================================
704 void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
706 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of output port"));
707 if (nameDialog->ShowModal() == wxID_OK)
709 wxString fileName = nameDialog->GetValue();
710 if(!fileName.IsEmpty())
712 std::string portName=(const char*) (fileName.mb_str());
713 _tabsMgr->addActualDiagramComplexOutputPort(portName);
718 //=========================================================================
720 void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(wxCommandEvent& event)
722 _tabsMgr->copySelectedBBoxesToComplexDiagram();
726 void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event)
728 printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ......\n");
733 //=========================================================================
735 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
742 //=========================================================================
744 } // EO namespace bbtk