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>
46 //=========================================================================
47 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
48 : wxFrame(parent, -1, _T("bbtkGEditor"),wxDefaultPosition, wxSize(1200,800))
51 _frameAUIMgr = new wxAuiManager(this);
54 /*std::string datadir( crea::System::GetExecutablePath() );
55 std::string datadir (".");
56 cout<<"RaC //------------------"<<endl;
57 cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with crea::System::GetExecutablePath() ."<<endl;
58 cout<<"RaC //------------------"<<endl;
60 #ifdef LINUX // assume this is OSX
61 datadir=datadir+"/../share/creaContours";
64 #ifdef MACOSX // assume this is OSX
65 datadir=datadir+"/../../../../share/creaContours";
72 initTabPanelsManager();
74 initHelpHTMLBrowser();
77 _frameAUIMgr->Update();
78 _actualPkgBrowserBoxName="";
79 _actualPkgBrowserPkgName="";
84 //=========================================================================
85 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS()
87 printf ("EED %p ~wxGUIEditorGraphicBBS()\n" , this );
89 //EED02JUIN2010 delete _tabsMgr;
91 _frameAUIMgr->UnInit();
100 //=========================================================================
101 void wxGUIEditorGraphicBBS::initToolbar()
103 wxBitmap bmp_new(new_xpm);
104 wxBitmap bmp_open(open_xpm);
105 wxBitmap bmp_save(save_xpm);
106 wxBitmap bmp_run(run_xpm);
107 wxBitmap bmp_delete(delete_xpm);
108 wxBitmap bmp_centerview(centerview_xpm);
109 wxBitmap bmp_box(box_xpm);
110 wxBitmap bmp_complexbox(complexbox_xpm);
111 wxBitmap bmp_complexinputport(complexinputport_xpm);
112 wxBitmap bmp_complexoutputport(complexoutputport_xpm);
114 wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
116 //Adds a tool btn to the toolbar
117 toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
118 toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram"));
119 toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
120 toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
121 toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
122 toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
123 toolbar->AddSeparator();
124 toolbar->AddTool(ID_BTNBOX,_T("New Box"),bmp_box, wxNullBitmap, wxITEM_NORMAL,_T("New Box"), _T("Nex Box"));
125 toolbar->AddSeparator();
126 toolbar->AddTool(ID_BTNCOMPLEXBOX,_T("Complex box"),complexbox_xpm, wxNullBitmap, wxITEM_NORMAL,_T("Complex box"), _T("Complex box"));
127 toolbar->SetToggle(ID_BTNCOMPLEXBOX,true);
128 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"));
129 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"));
130 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
131 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
133 toolbar->SetMargins( 2, 2 );
137 // connect command event handlers
138 Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
139 Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
140 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
141 Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
142 Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
143 Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
144 Connect(ID_BTNBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnBox));
145 Connect(ID_BTNCOMPLEXBOX,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
146 Connect(ID_ADDCOMPLEXBOXINPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
147 Connect(ID_ADDCOMPLEXBOXOUTPUT,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
150 //=========================================================================
151 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
153 //TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES
155 _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
156 _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));
159 //=========================================================================
160 void wxGUIEditorGraphicBBS::initMenu()
162 // Create File menu and its items
163 wxMenu *fileMenu = new wxMenu();
164 fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
165 fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save diagram"), _T("Save diagram"));
166 fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
167 fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
168 fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"), _T("Save complex box"));
169 fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
171 Connect(ID_NEW,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
172 Connect(ID_SAVE_AS_DIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
173 Connect(ID_OPEN_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
174 Connect(ID_SAVE_AS_BBS,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
175 Connect(ID_SAVE_AS_COMPLEXBOX,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
176 Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
178 // Create Help menu and its items
179 wxMenu *editMenu = new wxMenu;
180 editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
182 Connect(ID_COPY_TO_COMPLEXDIAGRAM,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
184 // Create Help menu and its items
185 wxMenu *helpMenu = new wxMenu;
186 helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
187 helpMenu->Append(ID_HELP_BBEDITOR, _T("&Help..."), _T("Help"));
188 Connect(ID_HELP_BBEDITOR,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnHelpBBeditor));
190 // Append the created menu to the menu bar
191 wxMenuBar *menuBar = new wxMenuBar();
192 menuBar->Append(fileMenu, _T("&File"));
193 menuBar->Append(editMenu, _T("&Edit"));
194 menuBar->Append(helpMenu, _T("&Help"));
196 // Attach this menu bar to the frame
200 //=========================================================================
201 void wxGUIEditorGraphicBBS::initTabPanelsManager()
203 _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);
204 _tabsMgr = new wxTabPanelsManager(this);
205 _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());
209 //=========================================================================
210 void wxGUIEditorGraphicBBS::initPackageBrowser()
212 _pkgBrowser = new WxGUIPackageBrowser2(this);
213 _pkgBrowser->IncludeAll();
214 _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));
217 //================================================================
219 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
221 std::string mess("Regenerating doc for package '");
227 mess = "Regenerating doc for all packages";
230 mess += " ... please wait";
232 SetStatusText( std2wx(mess) );
240 command += ConfigurationFile::GetInstance().Get_bin_path();
241 command += ConfigurationFile::GetInstance().Get_file_separator();
242 command += "bbRegeneratePackageDoc";
247 command += " " + pack + " -q";
248 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
250 if ( ! system ( command.c_str() ) )
252 SetStatusText( _T("Done !"));
254 wxMessageBox(_T("Done !"),_T("Regenerate package '")
255 +std2wx(pack)+_T("' doc"),
256 wxOK | wxICON_INFORMATION);
261 SetStatusText( _T("Done !"));
262 wxString err(_T("An error occured while running '"));
263 err += bbtk::std2wx(command) + _T("'");
264 wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);
268 //================================================================
269 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
271 SetStatusText( _T("Regenerating boxes lists ... please wait") );
278 command += ConfigurationFile::GetInstance().Get_bin_path();
279 command += ConfigurationFile::GetInstance().Get_file_separator();
280 command += "bbRegenerateBoxesLists";
287 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
289 if ( ! system ( command.c_str() ) )
291 SetStatusText( _T("Done !"));
293 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
294 wxOK | wxICON_INFORMATION);
299 SetStatusText( _T("Done !"));
300 wxString err(_T("An error occured while running '"));
301 err += bbtk::std2wx(command) + _T("'");
302 wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);
306 //================================================================
307 void wxGUIEditorGraphicBBS::RegenerateAll()
309 DoRegeneratePackageDoc("-a");
310 DoRegenerateBoxesLists();
313 //================================================================
315 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook()
320 //================================================================
322 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
324 if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName )
326 _actualPkgBrowserPkgName = packageName;
327 _actualPkgBrowserBoxName = boxName;
329 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
330 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
334 //=========================================================================
336 void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel)
338 wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,bbmodel);
342 //=========================================================================
344 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus)
346 SetStatusText(crea::std2wx(textStatus));
349 //=========================================================================
351 void wxGUIEditorGraphicBBS::executeScript(std::string script)
353 std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
354 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
355 std::string filename = dir + separator + "tmp_bbtk.bbs";
358 tempFile.open(filename.c_str());
362 std::string command = "";
367 command += "\""+ crea::System::GetExecutablePath();
371 command += separator + "../../../bbi.app/Contents/MacOS";
377 //command += ConfigurationFile::GetInstance().Get_bin_path();
378 //EED command +="C:/temp/bbtkBIN/RelWithDebInfo//";
379 //EED command +="C:/Program Files/CreaTools/bbtk-0.9.5/bin";
383 command += separator + "usr/local/bin/bbi.app/Contents/MacOS/bbi\" ";
386 command += separator + "bbi\" ";
389 command += separator + "bbi\" ";
390 command += "\""+filename + "\"";
399 printf ("RaC wxGUIEditorGraphicBBS::executeScript %s \n" , command.c_str() );
400 system( command.c_str() );
403 //=========================================================================
405 //=========================================================================
407 void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event)
409 _tabsMgr->addNewTab();
410 refreshGUIControls();
413 //=========================================================================
415 void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event)
417 std::string script1 = _tabsMgr->getActualDiagramBBS(true);
418 cout<<endl<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl<<endl;
421 std::string script2 = _tabsMgr->getActualDiagramBBS(false);
422 executeScript(script2);
426 //=========================================================================
428 //=========================================================================
429 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event)
431 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxOPEN);
432 if (openFileDialog->ShowModal() == wxID_OK)
434 wxString fileName = openFileDialog->GetPath( );
437 _tabsMgr->addNewTab( openFileDialog->GetFilename() );
439 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory());
441 // We tell the interpreter to throw exceptions on error
443 // Interpret the file supposed to define a box called 'Processing'
444 I->InterpretFile( (const char*) (fileName.mb_str()) );
446 refreshGUIControls();
451 void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename)
455 //EED file.open(fileName.c_str());
456 file.open( filename.c_str() );
457 std::string content="";
458 // writing file header
459 content += "# ----------------------------------\n";
460 content += "# - BBTKGEditor v 1.2 BBS BlackBox Script\n";
464 content += "# ----------------------------------\n";
466 content += _tabsMgr->getActualDiagramBBS();
472 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event)
474 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxSAVE|wxOVERWRITE_PROMPT);
475 if (saveFileDialog->ShowModal() == wxID_OK)
477 wxString fileName = saveFileDialog->GetPath( );
478 SaveActualBBS( (const char*) (fileName.mb_str()) );
484 void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration()
486 std::string cbName = _tabsMgr->GetCbName();
487 std::string paName = _tabsMgr->GetCbPackageName();
489 wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,wxT("Complex Box name"));
490 wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,wxT("Package name"));
492 cbNameDialog->SetValue( wxString(cbName.c_str(),wxConvUTF8) );
493 paNameDialog->SetValue( wxString(paName.c_str(),wxConvUTF8) );
495 if (cbNameDialog->ShowModal() == wxID_OK)
497 wxString complexboxname = cbNameDialog->GetValue();
498 cbName=(const char*) (complexboxname.mb_str());
502 if (paNameDialog->ShowModal() == wxID_OK)
504 wxString packagename = paNameDialog->GetValue();
505 paName=(const char*) (packagename.mb_str());
508 _tabsMgr->SetCbName(cbName);
509 _tabsMgr->SetCbPackageName(paName);
512 //=========================================================================
514 void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename)
517 file.open( filename.c_str() );
519 std::string content="";
521 // writing file header
522 content += "# ----------------------------------\n";
523 content += "# - BBTKGEditor v 1.2 BBS BlackBox Script (Complex Box)\n";
527 content += "# ----------------------------------\n";
529 content += _tabsMgr->getActualComplexBoxBBS();
534 //=========================================================================
536 void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
538 wxFileDialog * saveFileDialog = new wxFileDialog(this ,wxT("Save Complex Box BBS") ,wxEmptyString, _T("ComplexBoxName") ,wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
539 if (saveFileDialog->ShowModal() == wxID_OK)
541 wxString fileName = saveFileDialog->GetPath();
542 SaveActualComplexBox( (const char*) (fileName.mb_str()) );
546 //=========================================================================
547 void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename)
550 file.open( filename.c_str() );
552 std::string content="";
554 // writing file header
555 content += "# ----------------------------------\n";
556 content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n";
562 content += "# ----------------------------------\n";
564 content += "APP_START\n";
565 _tabsMgr->saveActualDiagram(content);
566 content += "APP_END\n";
572 //=========================================================================
573 void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
575 wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
576 if (saveFileDialog->ShowModal() == wxID_OK)
578 _tabsMgr->SetNameTabPanel( saveFileDialog->GetFilename() );
580 wxString pathfileName = saveFileDialog->GetPath();
581 std::string pathfilename = (const char*) (pathfileName.mb_str());
582 std::string pathfilenamebbs = pathfilename;
583 pathfilenamebbs[pathfilenamebbs.length()-1]='s';
585 if (_tabsMgr->isActualDiagramComplexBox()==false)
587 SaveActualDiagram( pathfilename );
588 SaveActualBBS(pathfilenamebbs);
590 AskComplexBoxConfiguration();
591 SaveActualDiagram( pathfilename );
592 SaveActualComplexBox(pathfilenamebbs);
593 } //if isActualDiagramComplexBox
594 } // if saveFileDialog
597 //=========================================================================
599 void wxGUIEditorGraphicBBS::refreshGUIControls()
601 wxToolBar* toolbar = GetToolBar();
602 if(_tabsMgr->isActualDiagramComplexBox())
604 toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
605 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
606 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
608 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
609 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
613 toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
614 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
615 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
617 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
618 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
621 if(_tabsMgr->getNumActualSelectedObjects()>0)
623 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
627 ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
628 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
633 //=========================================================================
635 void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
637 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);
638 if(dial->ShowModal() == wxID_YES)
640 _tabsMgr->deleteAllBoxesActualDiagram();
644 //=========================================================================
646 void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
648 _tabsMgr->centerViewActualDiagram();
651 //=========================================================================
653 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
655 wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,wxT(""),wxT("*.bbg"),wxOPEN|wxFILE_MUST_EXIST);
656 if (openFileDialog->ShowModal() == wxID_OK)
658 wxString fileName = openFileDialog->GetPath();
659 ifstream inputStream;
660 std::string fName=(const char*) (fileName.mb_str());
661 inputStream.open( fName.c_str() );
662 _tabsMgr->addNewTab( openFileDialog->GetFilename() );
664 _tabsMgr->loadDiagram(inputStream);
668 refreshGUIControls();
671 //=========================================================================
674 void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event)
676 BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
679 std::string typeName = bbDes->GetTypeName();
680 std::string packageName = bbDes->GetPackage()->GetName();
683 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
687 wxVtkSceneManager *scn = pnl->getSceneManager();
688 scn->createGBlackBox(50,50,packageName, typeName);
694 //=========================================================================
697 void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
699 wxToolBar* toolbar = GetToolBar();
700 bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
703 _tabsMgr->setActualDiagramComplexBox(true);
707 _tabsMgr->setActualDiagramComplexBox(false);
709 refreshGUIControls();
712 //=========================================================================
714 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
716 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
717 if (nameDialog->ShowModal() == wxID_OK)
719 wxString fileName = nameDialog->GetValue();
720 if(!fileName.IsEmpty())
722 std::string portName=(const char*) (fileName.mb_str());
723 _tabsMgr->addActualDiagramComplexInputPort(portName);
728 //=========================================================================
730 void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
732 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of output port"));
733 if (nameDialog->ShowModal() == wxID_OK)
735 wxString fileName = nameDialog->GetValue();
736 if(!fileName.IsEmpty())
738 std::string portName=(const char*) (fileName.mb_str());
739 _tabsMgr->addActualDiagramComplexOutputPort(portName);
744 //=========================================================================
746 void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(wxCommandEvent& event)
748 _tabsMgr->copySelectedBBoxesToComplexDiagram();
752 void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event)
754 printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ......\n");
759 //=========================================================================
761 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
768 //=========================================================================
770 } // EO namespace bbtk