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"
39 //must go #include "bbtkUtilities.h"
40 //must go #include "bbtkConfigurationFile.h"
43 #include <InterpreterBBS.h>
47 //=========================================================================
48 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent)
49 : wxFrame( parent, -1, _T("bbtkGEditor"), wxDefaultPosition, wxSize(1200,800) )
52 _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";
73 initTabPanelsManager();
74 // JGGR & CM initHelpHTMLBrowser();
75 _helpHtmlBrowser = NULL;
77 _frameAUIMgr->Update();
78 _actualPkgBrowserBoxName = "";
79 _actualPkgBrowserPkgName = "";
82 /////////////////////////////////
83 /// IMPORTANT!! FOR SAVE&LOAD PROCESSES THE VERSION IS VERY IMPORTANT.
84 /// RaC 2012 2nd Hackfest
85 _currentBBGversion="1.4";
88 //=========================================================================
89 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() {
91 printf("EED %p ~wxGUIEditorGraphicBBS()\n", this);
93 //EED02JUIN2010 delete _tabsMgr;
95 _frameAUIMgr->UnInit();
103 //=========================================================================
104 void wxGUIEditorGraphicBBS::initToolbar() {
105 wxBitmap bmp_new(new_xpm);
106 wxBitmap bmp_open(open_xpm);
107 wxBitmap bmp_save(save_xpm);
108 wxBitmap bmp_run(run_xpm);
109 wxBitmap bmp_delete(delete_xpm);
110 wxBitmap bmp_centerview(centerview_xpm);
111 wxBitmap bmp_box(box_xpm);
112 wxBitmap bmp_executablebox(executablebox_xpm);
113 wxBitmap bmp_complexbox(complexbox_xpm);
114 wxBitmap bmp_complexinputport(complexinputport_xpm);
115 wxBitmap bmp_complexoutputport(complexoutputport_xpm);
116 wxBitmap bmp_undo(undo_xpm);
117 wxBitmap bmp_redo(redo_xpm);
118 wxBitmap bmp_editProperties(editProperties_xpm);
119 wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
121 //Adds a tool btn to the toolbar
122 toolbar->AddTool(ID_NEW, _T("New"), bmp_new, wxNullBitmap, wxITEM_NORMAL,
123 _T("New tab"), _T("Create a new panel tab"));
124 toolbar->AddTool(ID_OPEN, _T("Open diagram"), bmp_open, wxNullBitmap,
125 wxITEM_NORMAL, _T("Open a diagram"), _T("Open a diagram"));
126 toolbar->AddTool(ID_SAVE_DIAGRAM, _T("Save Diagram"), bmp_save,
127 wxNullBitmap, wxITEM_NORMAL, _T("Saves the current diagram"),
128 _T("Saves the current diagram")); //DFCH
129 //toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save Diagram As"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves the current diagram"), _T("Saves the current diagram")); //DFCH
130 toolbar->AddTool(ID_RUN, _T("Run"), bmp_run, wxNullBitmap, wxITEM_NORMAL,
131 _T("Execute actual diagram"), _T("Execute actual diagram"));
132 toolbar->AddTool(ID_DELETEALL, _T("Delete all"), bmp_delete, wxNullBitmap,
133 wxITEM_NORMAL, _T("Delete all boxes"), _T("Delete all boxes"));
134 toolbar->AddTool(ID_CENTERVIEW, _T("Center view"), bmp_centerview,
135 wxNullBitmap, wxITEM_NORMAL, _T("Center view"), _T("Center view"));
136 toolbar->AddSeparator();
137 toolbar->AddTool(ID_BTNBOX, _T("New Box"), bmp_box, wxNullBitmap,
138 wxITEM_NORMAL, _T("New Box"), _T("Nex Box"));
139 toolbar->AddSeparator();
140 toolbar->AddTool(ID_BTEXECUTABLEBOX, _T("Select as executable Box"),
141 bmp_executablebox, wxNullBitmap, wxITEM_NORMAL,
142 _T("Select as executable Box"), _T("Select as executable Box"));
143 toolbar->AddSeparator();
144 toolbar->AddTool(ID_BTNCOMPLEXBOX, _T("Complex box"), complexbox_xpm,
145 wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box"));
146 toolbar->SetToggle(ID_BTNCOMPLEXBOX, true);
148 // RaC 2012 2nd HackFest - Now Complex inputs are any external input
149 // toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"),
150 // bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
151 // _T("Add input to Complex box"), _T("Add input to Complex box"));
152 toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add external input (Complex box or console app)"),
153 bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
154 _T("Add external input (Complex box or console app)"), _T("Add external input (Complex box or console app)"));
156 toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT, _T("Add output to Complex box"),
157 bmp_complexoutputport, wxNullBitmap, wxITEM_NORMAL,
158 _T("Add output Complex box"), _T("Add output Complex box"));
160 // toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest
161 toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true);
163 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
164 toolbar->AddSeparator();
165 toolbar->AddTool(ID_UNDO, _T("Undo"),bmp_undo, wxNullBitmap, wxITEM_NORMAL, _T("Undo"), _T("Undo"));
166 toolbar->AddTool(ID_REDO, _T("Redo"),bmp_redo, wxNullBitmap, wxITEM_NORMAL, _T("Redo"), _T("Redo"));
167 toolbar->AddSeparator();
168 toolbar->AddTool(ID_EDITPROPERTIES, _T("Edit diagram properties"),bmp_editProperties, wxNullBitmap, wxITEM_NORMAL, _T("Edit diagram properties"), _T("Edit diagram properties"));
169 toolbar->EnableTool(ID_EDITPROPERTIES, false);
171 toolbar->EnableTool(ID_UNDO, false);
172 toolbar->EnableTool(ID_REDO, false);
173 toolbar->SetMargins(2, 2);
178 // connect command event handlers
180 Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED,
181 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
182 Connect(ID_OPEN, wxEVT_COMMAND_TOOL_CLICKED,
183 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
184 Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
185 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
186 Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
187 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram)); //DFCH
190 wxEVT_COMMAND_TOOL_CLICKED,
191 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
194 wxEVT_COMMAND_TOOL_CLICKED,
195 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
198 wxEVT_COMMAND_TOOL_CLICKED,
199 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
200 Connect(ID_BTNBOX, wxEVT_COMMAND_TOOL_CLICKED,
201 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnBox));
204 wxEVT_COMMAND_TOOL_CLICKED,
205 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnExecutableBox));
206 Connect(ID_BTNCOMPLEXBOX, wxEVT_COMMAND_TOOL_CLICKED,
207 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
208 Connect(ID_ADDCOMPLEXBOXINPUT, wxEVT_COMMAND_TOOL_CLICKED,
209 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
210 Connect(ID_ADDCOMPLEXBOXOUTPUT, wxEVT_COMMAND_TOOL_CLICKED,
211 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
212 Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo));
213 Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo));
214 Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName));
215 Connect(ID_EDITPROPERTIES,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditDiagramProperties));
218 //=========================================================================
219 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() {
221 _helpHtmlBrowser = new WxGUIHtmlBrowser(this, wxSize(200, 0));
227 //=========================================================================
228 void wxGUIEditorGraphicBBS::initMenu() {
229 // Create File menu and its items
230 wxMenu *fileMenu = new wxMenu();
231 fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
232 fileMenu->Append(ID_SAVE_DIAGRAM, _T("Save Diagram"), _T("Save Diagram")); //DFCH
233 fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save Diagram As"),
234 _T("Save Diagram As")); //DFCH
235 fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
237 fileMenu->Append(ID_OPEN, _T("Open a diagram"), _T("Open a diagram"));
238 fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
239 fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"),
240 _T("Save complex box"));
241 fileMenu->Append(ID_EXPORT_CONSOLEAPP, _T("Export console commands"),
242 _T("Export console execution commands"));
243 fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
245 Connect(ID_NEW, wxEVT_COMMAND_MENU_SELECTED,
246 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
247 Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
248 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
249 Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
250 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram));
251 Connect(ID_OPEN_BBS, wxEVT_COMMAND_MENU_SELECTED,
252 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
253 Connect(ID_SAVE_AS_BBS, wxEVT_COMMAND_MENU_SELECTED,
254 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
255 Connect( ID_SAVE_AS_COMPLEXBOX, wxEVT_COMMAND_MENU_SELECTED,
256 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
257 Connect( ID_EXPORT_CONSOLEAPP, wxEVT_COMMAND_MENU_SELECTED,
258 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExportConsoleExecCommand));
259 Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
260 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
262 // Create Edit menu and its items
263 wxMenu *editMenu = new wxMenu;
264 editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
265 editMenu->Append(ID_EDIT_COMPLEXBOX_SCRIPT, _T("Edit Complex Box"), _T("Edit Complex Box"));
266 Connect( ID_COPY_TO_COMPLEXDIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
267 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
268 Connect( ID_EDIT_COMPLEXBOX_SCRIPT, wxEVT_COMMAND_MENU_SELECTED,
269 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditComplexBoxScript));
271 // Create Help menu and its items
272 wxMenu *helpMenu = new wxMenu;
273 helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
274 helpMenu->Append(ID_HELP_BBEDITOR, _T("&Help..."), _T("Help"));
275 Connect(ID_HELP_BBEDITOR, wxEVT_COMMAND_MENU_SELECTED,
276 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnHelpBBeditor));
279 wxMenu *menuTools = new wxMenu;
280 menuTools->Append(ID_bbEditor_Tool_Menu_CreatePackage,
281 _T("Create &package") );
282 menuTools->Append(ID_bbEditor_Tool_Menu_CreateBlackBox,
283 _T("Create &blackbox") );
284 menuTools->Append(ID_bbEditor_Tool_Menu_PlugPackage, _T("Plug package") );
285 menuTools->Append(ID_bbEditor_Tool_Menu_EditConfig, _T("&Edit bbtk config") );
286 menuTools->Append(ID_bbEditor_Tool_Menu_ShowHTMLDoc,
287 _T("Show &HTML documentation") );
288 menuTools->Append(ID_bbEditor_Tool_Menu_CreateIndex, _T("&Generate index") );
290 Connect(ID_bbEditor_Tool_Menu_CreatePackage, wxEVT_COMMAND_MENU_SELECTED,
291 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreatePackage));
292 Connect(ID_bbEditor_Tool_Menu_CreateBlackBox, wxEVT_COMMAND_MENU_SELECTED,
293 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateBlackBox));
294 Connect(ID_bbEditor_Tool_Menu_PlugPackage, wxEVT_COMMAND_MENU_SELECTED,
295 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnPlugPackage));
296 Connect(ID_bbEditor_Tool_Menu_EditConfig, wxEVT_COMMAND_MENU_SELECTED,
297 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditConfig));
298 Connect(ID_bbEditor_Tool_Menu_ShowHTMLDoc, wxEVT_COMMAND_MENU_SELECTED,
299 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowHTMLDoc));
300 Connect(ID_bbEditor_Tool_Menu_CreateIndex, wxEVT_COMMAND_MENU_SELECTED,
301 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateIndex));
303 // Append the created menu to the menu bar
304 wxMenuBar *menuBar = new wxMenuBar();
305 menuBar->Append(fileMenu, _T("&File") );
306 menuBar->Append(editMenu, _T("&Edit") );
307 menuBar->Append(menuTools, _T("&Tool") );
308 menuBar->Append(helpMenu, _T("&Help") );
310 // Attach this menu bar to the frame
314 //=========================================================================
315 void wxGUIEditorGraphicBBS::initTabPanelsManager()
317 _notebook = new wxAuiNotebook(this, wxID_NOTEBOOK, wxDefaultPosition,
318 wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_MOVE
319 | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | wxAUI_NB_TAB_FIXED_WIDTH
320 | wxAUI_NB_WINDOWLIST_BUTTON);
321 _tabsMgr = new wxTabPanelsManager(this);
322 _frameAUIMgr->AddPane(_notebook, wxAuiPaneInfo().CenterPane());
325 //=========================================================================
326 void wxGUIEditorGraphicBBS::initPackageBrowser()
328 _pkgBrowser = new WxGUIPackageBrowser2(this);
329 _pkgBrowser->IncludeAll();
330 _frameAUIMgr->AddPane(_pkgBrowser, wxAuiPaneInfo().Left().MinSize(30, 500).BestSize(750,500).CloseButton(false));
333 //================================================================
335 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc(const std::string& pack)
337 std::string mess("Regenerating doc for package '");
341 mess = "Regenerating doc for all packages";
344 mess += " ... please wait";
346 SetStatusText(std2wx(mess));
354 command += ConfigurationFile::GetInstance().Get_bin_path();
355 command += ConfigurationFile::GetInstance().Get_file_separator();
356 command += "bbRegeneratePackageDoc";
361 command += " " + pack + " -q";
362 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
364 if (!system(command.c_str())) {
365 SetStatusText(_T("Done !"));
367 wxMessageBox(_T("Done !"),_T("Regenerate package '")
368 +std2wx(pack)+_T("' doc"),
369 wxOK | wxICON_INFORMATION);
372 SetStatusText(_T("Done !"));
373 wxString err(_T("An error occured while running '"));
374 err += bbtk::std2wx(command) + _T("'");
375 wxMessageBox(err, _T("Regenerate package doc"), wxOK | wxICON_ERROR);
379 //================================================================
380 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists() {
381 SetStatusText(_T("Regenerating boxes lists ... please wait"));
388 command += ConfigurationFile::GetInstance().Get_bin_path();
389 command += ConfigurationFile::GetInstance().Get_file_separator();
390 command += "bbRegenerateBoxesLists";
397 bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
399 if (!system(command.c_str())) {
400 SetStatusText(_T("Done !"));
402 wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
403 wxOK | wxICON_INFORMATION);
406 SetStatusText(_T("Done !"));
407 wxString err(_T("An error occured while running '"));
408 err += bbtk::std2wx(command) + _T("'");
409 wxMessageBox(err, _T("Regenerate boxes lists"), wxOK | wxICON_ERROR);
413 //================================================================
414 void wxGUIEditorGraphicBBS::RegenerateAll() {
415 DoRegeneratePackageDoc("-a");
416 DoRegenerateBoxesLists();
419 //================================================================
421 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook() {
425 //================================================================
427 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
429 if (_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName)
431 _actualPkgBrowserPkgName = packageName;
432 _actualPkgBrowserBoxName = boxName;
434 //EED 15 oct 2012 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
437 BlackBoxDescriptor::Pointer descriptor;
438 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
439 k = _pkgBrowser->GetFactory()->GetPackage(packageName);
440 mapDesc = k->GetDescriptorMap();
441 descriptor = mapDesc[boxName];
443 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
447 //=========================================================================
449 void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel) {
450 wxBlackBoxEditionDialog* dialog =
451 new wxBlackBoxEditionDialog(this, bbmodel);
455 //=========================================================================
457 bool wxGUIEditorGraphicBBS::boxNameExists(std::string boxname) {
459 return this->_tabsMgr->getActualTabPanel()->getSceneManager()->boxExist(boxname);
462 //=========================================================================
464 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus) {
465 SetStatusText(crea::std2wx(textStatus));
468 //=========================================================================
470 void wxGUIEditorGraphicBBS::executeScript(std::string script) {
471 std::string separator =
472 ConfigurationFile::GetInstance().Get_file_separator();
473 std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
474 std::string filename = dir + separator + "tmp_bbtk.bbs";
477 tempFile.open(filename.c_str());
481 std::string command = "";
484 command += "start /b ";
487 // command += "\""+ crea::System::GetExecutablePath();
489 // command += separator + "../../../bbi.app/Contents/MacOS";
493 command += "\"" + filename + "\"";
499 printf("RaC wxGUIEditorGraphicBBS::executeScript %s \n", command.c_str());
500 system(command.c_str());
503 //=========================================================================
504 std::string wxGUIEditorGraphicBBS::CheckExtension(std::string filename, std::string extension) {
505 if(filename.size() > extension.size() ){
506 if( (filename.compare(filename.size()-extension.size(), extension.size(),extension)) !=0 ){
507 filename.append(extension);
510 filename.append(extension);
514 //=========================================================================
516 //=========================================================================
518 void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) {
519 _tabsMgr->addNewTab();
520 refreshGUIControls();
523 void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) {
524 unsigned short disable;
528 _tabsMgr->loadTempDiagram(0);
529 disable = _tabsMgr->getUndoState(stundo);
532 std::string name = _tabsMgr->GetNameTabPanel();
533 if(name[name.length() - 1] == '*')
535 name =name.substr(0,name.length()-1);
537 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
540 GetToolBar()->EnableTool(ID_UNDO,disable);
541 GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
542 GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
543 GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
544 refreshGUIControls();
547 //=========================================================================
549 void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) {
550 unsigned short disable;
554 _tabsMgr->loadTempDiagram(1);
555 std::string name = _tabsMgr->GetNameTabPanel();
556 if(name[name.length() - 1] != '*')
558 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
559 GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
560 GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
561 GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
562 GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
563 refreshGUIControls();
566 void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){
569 //=========================================================================
571 void wxGUIEditorGraphicBBS::OnEditDiagramProperties(wxCommandEvent& event)
573 wxDiagramPropertiesEditionDialog* dialog =
574 new wxDiagramPropertiesEditionDialog(this);
578 //=========================================================================
580 void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) {
581 std::string script1 = _tabsMgr->getActualDiagramBBS(true);
582 cout << endl << "RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"
584 cout << script1 << endl;
586 std::string script2 = _tabsMgr->getActualDiagramBBS(false);
587 executeScript(script2);
591 //=========================================================================
592 void wxGUIEditorGraphicBBS::OpenBBS(std::string filePathName, std::string fileName)
594 _tabsMgr->addNewTab( crea::std2wx(fileName) );
595 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager(), _pkgBrowser->GetFactory());
596 // We tell the interpreter to throw exceptions on error
598 // Interpret the file supposed to define a box called 'Processing'
599 I->InterpretFile( filePathName );
600 refreshGUIControls();
603 //=========================================================================
605 //=========================================================================
606 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event)
608 wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN);
610 if (openFileDialog->ShowModal() == wxID_OK)
612 OpenBBS( crea::wx2std(openFileDialog->GetPath()) , crea::wx2std(openFileDialog->GetFilename()) );
616 if (openFileDialog->ShowModal() == wxID_OK)
618 wxString fileName = openFileDialog->GetPath();
619 _tabsMgr->addNewTab(openFileDialog->GetFilename());
620 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager(), _pkgBrowser->GetFactory());
621 // We tell the interpreter to throw exceptions on error
623 // Interpret the file supposed to define a box called 'Processing'
624 I->InterpretFile((const char*) (fileName.mb_str()));
626 refreshGUIControls();
630 //=========================================================================
631 void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) {
634 //EED file.open(fileName.c_str());
635 file.open(filename.c_str());
636 std::string content = "";
637 // writing file header
638 content += "# ----------------------------------\n";
639 content += "# - BBTKGEditor v ";
640 content += _currentBBGversion; //VERSION
641 content += " BBS BlackBox Script\n";
645 content += "# ----------------------------------\n";
647 content += _tabsMgr->getActualDiagramBBS();
652 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) {
653 wxFileDialog * saveFileDialog = new wxFileDialog(this,
654 wxT("Save actual BBS"), wxEmptyString, wxT("NewBBS"),
655 wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
656 if (saveFileDialog->ShowModal() == wxID_OK) {
657 wxString fileName = saveFileDialog->GetPath();
658 std::string filename = (const char*) (fileName.mb_str());
659 filename=CheckExtension (filename, ".bbs");
660 SaveActualBBS(filename);
665 void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration() {
666 std::string cbName = _tabsMgr->GetCbName();
667 std::string paName = _tabsMgr->GetCbPackageName();
669 wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,
670 wxT("Complex Box name"));
671 wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,
672 wxT("Package name"));
674 cbNameDialog->SetValue(wxString(cbName.c_str(), wxConvUTF8));
675 paNameDialog->SetValue(wxString(paName.c_str(), wxConvUTF8));
677 if (cbNameDialog->ShowModal() == wxID_OK) {
678 wxString complexboxname = cbNameDialog->GetValue();
679 cbName = (const char*) (complexboxname.mb_str());
682 if (paNameDialog->ShowModal() == wxID_OK) {
683 wxString packagename = paNameDialog->GetValue();
684 paName = (const char*) (packagename.mb_str());
687 _tabsMgr->SetCbName(cbName);
688 _tabsMgr->SetCbPackageName(paName);
691 //=========================================================================
693 void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) {
695 file.open(filename.c_str());
697 std::string content = "";
699 // writing file header
700 content += "# ----------------------------------\n";
701 content += "# - BBTKGEditor v ";
702 content += _currentBBGversion;//VERSION
703 content += " BBS BlackBox Script (Complex Box)\n";
707 content += "# ----------------------------------\n";
709 content += _tabsMgr->getActualComplexBoxBBS();
714 //=========================================================================
716 void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) {
717 wxFileDialog * saveFileDialog = new wxFileDialog(this,
718 wxT("Save Complex Box BBS"), wxEmptyString,
719 _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE
720 | wxOVERWRITE_PROMPT);
721 if (saveFileDialog->ShowModal() == wxID_OK) {
722 wxString fileName = saveFileDialog->GetPath();
723 std::string filename = (const char*) (fileName.mb_str());
724 filename=CheckExtension (filename, ".bbs");
725 SaveActualComplexBox(filename);
729 //=========================================================================
730 void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) {
732 file.open(filename.c_str());
734 std::string content = "";
736 // writing file header
737 content += "# ----------------------------------\n";
738 content += "# - BBTKGEditor v ";
739 content += _currentBBGversion; //VERSION
740 content += " BBG BlackBox Diagram file\n";
746 content += "# ----------------------------------\n";
748 content += "APP_START\n";
749 _tabsMgr->saveActualDiagram(content, filename); //DFCH
750 content += "APP_END\n";
755 //=========================================================================
756 void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action)
760 std::string name = _tabsMgr->GetNameTabPanel();
761 if(name[name.length() - 1] != '*')
763 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
764 _tabsMgr->saveTempActualDiagram(action);
765 GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
766 GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
767 GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
768 GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
771 //=========================================================================
773 //The following method allows to save the current diagram asking the filename
775 void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() {
776 wxFileDialog * saveFileDialog = new wxFileDialog(this,
777 wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
778 wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT);
779 if (saveFileDialog->ShowModal() == wxID_OK) {
780 //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename());
781 wxString pathfileName = saveFileDialog->GetPath();
782 std::string pathfilename = (const char*) (pathfileName.mb_str());
783 pathfilename=CheckExtension (pathfilename, ".bbg");
785 //modify the tab name accordingly
786 wxString fileName = saveFileDialog->GetFilename();
787 std::string filename = (const char*) (fileName.mb_str());
788 filename=CheckExtension (filename, ".bbg");
789 _tabsMgr->SetNameTabPanel( wxString (filename.c_str(), wxConvUTF8) );
791 std::string pathfilenamebbs = pathfilename;
792 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
793 if (_tabsMgr->isActualDiagramComplexBox() == false) {
794 SaveActualDiagram(pathfilename);
795 SaveActualBBS(pathfilenamebbs);
797 AskComplexBoxConfiguration();
798 SaveActualDiagram(pathfilename);
799 SaveActualComplexBox(pathfilenamebbs);
800 } //if isActualDiagramComplexBox
801 } // if saveFileDialog
803 //=========================================================================
805 void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) {
806 std::string pathfilename = _tabsMgr->GetCurrentTabPanelPath();
807 if (pathfilename.empty()) {
808 SaveCurrentDiagramAs();
810 std::string pathfilenamebbs = pathfilename;
811 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
813 if (_tabsMgr->isActualDiagramComplexBox() == false) {
814 std::string name = _tabsMgr->GetNameTabPanel();
815 if(name[name.length() - 1] == '*')
817 name =name.substr(0,name.length()-1);
819 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
820 SaveActualDiagram(pathfilename);
821 SaveActualBBS(pathfilenamebbs);
823 AskComplexBoxConfiguration();
824 SaveActualDiagram(pathfilename);
825 SaveActualComplexBox(pathfilenamebbs);
826 } //if isActualDiagramComplexBox
829 //=========================================================================
831 void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) {
832 SaveCurrentDiagramAs();
835 //=========================================================================
836 void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event)
838 wxFileDialog * saveFileDialog = new wxFileDialog(this,
839 wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"),
840 wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxSAVE | wxOVERWRITE_PROMPT);
842 if (saveFileDialog->ShowModal() == wxID_OK)
844 wxString fileName = saveFileDialog->GetPath();
845 std::string filename = (const char*) (fileName.mb_str());
846 filename=CheckExtension (filename, ".txt");
849 file.open(filename.c_str());
851 std::vector<std::string> extInputs = _tabsMgr->getActualTabPanel()->getSceneManager()->GetExternalInputsNames();
853 //TODO PUT IN A METHOD OF A FILES AND TEXT MANAGER CLASS !!!
854 //std::string inputsInCommentsWin="";
855 //std::string inputsInCommentsUnix="";
856 //std::string inputsInOneLineWin="";
857 std::string inputsInOneLineUnix="";
858 for (unsigned int i = 0; i < extInputs.size(); ++i)
860 /* No gusto la idea al jefe pero por si acaso ...
861 * RaC 2012 2nd HackFest
863 inputsInCommentsWin+="REM ";
864 inputsInCommentsWin+=extInputs[i];
865 inputsInCommentsWin+="=\"value\"\n";
866 inputsInCommentsUnix+="# ";
867 inputsInCommentsUnix+=extInputs[i];
868 inputsInCommentsUnix+="=\"value\"\n";
871 sprintf (buffer, "%d", (i+1));
872 inputsInOneLineWin+=extInputs[i];
873 inputsInOneLineWin+="=\"%";
874 inputsInOneLineWin+=buffer;
875 inputsInOneLineWin+="\" ";
877 inputsInOneLineUnix+=extInputs[i];
878 inputsInOneLineUnix+="=\"<value>\" ";
883 std::string content = "";
884 // writing file header
885 content += "# ----------------------------------\n";
886 content += "# - BBTKGEditor v ";
887 content += _currentBBGversion; //VERSION
888 content += " Console Commands to execute BBS application\n";
892 content += "# ----------------------------------\n";
895 content += "# Command to execute bbi\n";
896 content += "bbi <bbs_path> ";
897 content += inputsInOneLineUnix;
899 /* No gusto la idea al jefe pero por si acaso ...
900 * RaC 2012 2nd HackFest
901 content += "# For Windows (copy the following lines to a .bat file)\n";
902 content += "REM BBS application\n";
903 content += "REM Inputs:\n";
904 content += inputsInCommentsWin;
905 content += "REM To use previous inputs, put %$inputName% in the corresponding input of the execution bbi line\n";
906 content += "bbi applicationBBS.bbs ";
907 content += inputsInOneLineWin;
910 content += "# For Linux or Mac (copy the following lines to a .sh file)\n";
911 content += "#!/bin/bash\n";
912 content += "# BBS application\n";
913 content += "# Inputs:\n";
914 content += inputsInCommentsUnix;
915 content += "# To use previous inputs, put $inputName in the corresponding input of the execution bbi line\n";
916 content += "bbi applicationBBS.bbs ";
917 content += inputsInOneLineUnix;
928 //=========================================================================
930 void wxGUIEditorGraphicBBS::refreshGUIControls() {
933 //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels
934 wxToolBar* toolbar = GetToolBar();
935 if (_tabsMgr->isActualDiagramComplexBox()) {
936 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true);
937 //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest
938 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true);
940 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, true);
941 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, false);
942 GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, false);
944 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, false);
945 //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest
946 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
948 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, false);
949 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true);
950 GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, true);
953 //RaC2012 2ndHackFest
954 GetToolBar()->EnableTool(ID_EDITPROPERTIES,true);
956 GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
957 GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
958 GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
959 GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
961 if (_tabsMgr->getNumActualSelectedObjects() > 0) {
962 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
964 ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
965 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
970 //=========================================================================
972 void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
974 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);
975 if (dial->ShowModal() == wxID_YES)
977 _tabsMgr->deleteAllBoxesActualDiagram();
981 //=========================================================================
983 void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
985 _tabsMgr->centerViewActualDiagram();
988 //=========================================================================
989 void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fileName)
991 ifstream inputStream;
992 inputStream.open(filePathName.c_str());
993 assert(inputStream.good()); // fails
995 if(_tabsMgr->FindTab(filePathName)!=-1) //RaC2012 avoid opening same diagram twice
998 printf("RaC: Diagram already opened\n");
1001 _tabsMgr->addNewTab( crea::std2wx(fileName) );
1002 _tabsMgr->loadDiagram(inputStream, filePathName);
1003 _tabsMgr->saveTempActualDiagram("load diagram");
1004 GetToolBar()->EnableTool(ID_UNDO, false);
1005 GetToolBar()->EnableTool(ID_UNDO, false);
1006 inputStream.close();
1007 refreshGUIControls();
1010 //=========================================================================
1012 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
1014 wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
1015 if (openFileDialog->ShowModal() == wxID_OK)
1017 wxString filePath = openFileDialog->GetPath();
1018 wxString fileName = openFileDialog->GetFilename();
1019 OpenDiagram( crea::wx2std(filePath) , crea::wx2std(fileName) );
1023 //=========================================================================
1024 void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event)
1026 BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
1027 if (bbDes != NULL) {
1028 std::string typeName = bbDes->GetTypeName();
1029 std::string packageName = bbDes->GetPackage()->GetName();
1030 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
1032 wxVtkSceneManager *scn = pnl->getSceneManager();
1033 scn->createGBlackBox(50, 50, packageName, typeName);
1036 SaveTempActualDiagram("New Box");
1041 //=========================================================================
1043 void wxGUIEditorGraphicBBS::OnClickBtnExecutableBox(wxCommandEvent& event)
1046 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
1049 wxVtkSceneManager *scn = pnl->getSceneManager();
1050 if( scn->MakeBoxExecutable() )
1051 std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...successful"<<std::endl;
1053 std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...Error!!"<<std::endl;
1059 //=========================================================================
1060 void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
1062 wxToolBar* toolbar = GetToolBar();
1063 bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
1067 disableComplexBox();
1071 //=========================================================================
1073 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
1075 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
1076 wxT("Name of input port"));
1077 if (nameDialog->ShowModal() == wxID_OK) {
1078 wxString fileName = nameDialog->GetValue();
1079 if (!fileName.IsEmpty()) {
1080 std::string portName = (const char*) (fileName.mb_str());
1081 _tabsMgr->addActualDiagramComplexInputPort(portName);
1086 //=========================================================================
1087 void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
1089 wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
1090 wxT("Name of output port"));
1091 if (nameDialog->ShowModal() == wxID_OK) {
1092 wxString fileName = nameDialog->GetValue();
1093 if (!fileName.IsEmpty()) {
1094 std::string portName = (const char*) (fileName.mb_str());
1095 _tabsMgr->addActualDiagramComplexOutputPort(portName);
1100 //=========================================================================
1101 void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(
1102 wxCommandEvent& event)
1104 _tabsMgr->copySelectedBBoxesToComplexDiagram();
1107 //=========================================================================
1108 void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event)
1110 printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ....not implemented..\n");
1113 //=========================================================================
1114 void wxGUIEditorGraphicBBS::OnCreatePackage(wxCommandEvent& event)
1116 bbtkSystemTools::CreatePackage();
1119 //=========================================================================
1120 void wxGUIEditorGraphicBBS::OnCreateBlackBox(wxCommandEvent& event)
1122 bbtkSystemTools::CreateBlackBox();
1125 //=========================================================================
1126 void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event)
1128 //DFGO2012 Plug Package functionnalities
1129 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
1132 _T("Select package directory"),
1138 userResponse = FD->ShowModal();
1139 if(userResponse==wxID_OK)
1141 std::string path = wx2std (FD->GetPath()) ;
1142 std::string fname = path + "/bbtkPackage";
1143 std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl;
1144 if ( Utilities::FileExists( fname ) )
1147 f.open(fname.c_str());
1152 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
1154 DoRegeneratePackageDoc(pname);
1155 DoRegenerateBoxesLists();
1157 _pkgBrowser->RebuildList();
1159 wxMessageBox(_T("Package successfully plugged. Please restart bbEditor to see the new package in the package browser."),_T("Plug package"),wxOK | wxICON_INFORMATION);
1160 userResponse = wxID_CANCEL;
1164 std::string err = "The directory \"" + path + "\" does not contain a 'bbtkPackage' file.";
1167 err += "\nNote: If you are on Linux please select the folder and click \"Open\", don't enter in it.";
1171 wxMessageBox(crea::std2wx(err), _T("Plug package"),wxOK | wxICON_ERROR);
1172 // THE FOLLOWING LINE GIVES ERRORS BECAUSE IT IS NECESSARY TO USE std2wx
1173 //wxMessageBox( _T( err) , _T("Plug package"),wxOK | wxICON_ERROR);
1176 }while(userResponse != wxID_CANCEL);
1180 //=========================================================================
1181 void wxGUIEditorGraphicBBS::OnEditConfig(wxCommandEvent& event)
1183 std::string commandStr;
1184 std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path();
1186 commandStr = "notepad.exe ";
1188 commandStr = "gedit ";
1190 commandStr = commandStr + configFile;
1191 std::cout << "system: " << commandStr << std::endl;
1192 system ( commandStr.c_str() );
1195 //=========================================================================
1196 void wxGUIEditorGraphicBBS::OnShowHTMLDoc(wxCommandEvent& event)
1199 if (_helpHtmlBrowser != NULL){
1200 _frameAUIMgr->DetachPane(_helpHtmlBrowser);
1201 _helpHtmlBrowser->Destroy();
1203 initHelpHTMLBrowser();
1204 _frameAUIMgr->AddPane(_helpHtmlBrowser, wxAuiPaneInfo().Right().MinSize(200, 200));
1205 _frameAUIMgr->Update();
1206 refreshGUIControls();
1211 //=========================================================================
1212 void wxGUIEditorGraphicBBS::OnCreateIndex(wxCommandEvent& event)
1214 printf("EED wxGUIEditorGraphicBBS::OnCreateIndex ... not implemented ..\n");
1218 //=========================================================================
1219 void wxGUIEditorGraphicBBS::OnEditComplexBoxScript(wxCommandEvent& event)
1221 BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
1224 std::string packageName = bbDes->GetPackage()->GetName();
1225 std::string typeName = bbDes->GetTypeName();
1226 if (!TryToOpenScriptComplexBox(packageName ,typeName))
1228 wxMessageDialog windowMessage1(NULL,_T("This is not a ComplexBox script."), _T("Alert !"), wxOK);
1229 windowMessage1.ShowModal();
1234 //=========================================================================
1235 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
1240 Factory::Pointer wxGUIEditorGraphicBBS::GetBBTKFactory()
1242 if (_pkgBrowser==NULL)
1244 printf ("EED ERROR! wxGUIEditorGraphicBBS::GetBBTKFactory _pkgBrowser = NULL\n");
1246 return _pkgBrowser->GetFactory();
1249 //=========================================================================
1250 void wxGUIEditorGraphicBBS::enableComplexBox()
1252 _tabsMgr->setActualDiagramComplexBox(true);
1253 refreshGUIControls();
1256 //=========================================================================
1258 void wxGUIEditorGraphicBBS::disableComplexBox()
1260 _tabsMgr->setActualDiagramComplexBox(false);
1261 refreshGUIControls();
1264 //=========================================================================
1265 void wxGUIEditorGraphicBBS::setCurrentDiagramDescription(std::string description)
1267 _tabsMgr->SetDescription(description);
1270 //=========================================================================
1271 void wxGUIEditorGraphicBBS::setCurrentDiagramAuthor(std::string author)
1273 _tabsMgr->SetAuthor(author);
1276 //=========================================================================
1277 void wxGUIEditorGraphicBBS::setCurrentDiagramCategory(std::string category)
1279 _tabsMgr->SetCategory(category);
1282 //=========================================================================
1283 std::string wxGUIEditorGraphicBBS::getCurrentDiagramDescription()
1285 return _tabsMgr->GetDescription();
1288 //=========================================================================
1289 std::string wxGUIEditorGraphicBBS::getCurrentDiagramAuthor()
1291 return _tabsMgr->GetAuthor();
1294 //=========================================================================
1295 std::string wxGUIEditorGraphicBBS::getCurrentDiagramCategory()
1297 return _tabsMgr->GetCategory();
1301 //=========================================================================
1302 bool wxGUIEditorGraphicBBS::isCurrentDiagramComplexBox()
1304 return _tabsMgr->isActualDiagramComplexBox();
1308 //=========================================================================
1309 void wxGUIEditorGraphicBBS::OpenScript(std::string filePathNameBBS ,std::string boxType)
1311 std::string fileName = boxType+".bbg";
1312 std::string filePathNameBBG = filePathNameBBS;
1313 filePathNameBBG[ filePathNameBBG.length()-1 ] = 'g';
1315 wxMessageDialog windowMessage1(NULL,_T("The system is going to open a bbg or bbs for you. Be careful if you save this file."), _T("Alert !"), wxOK);
1316 windowMessage1.ShowModal();
1318 if ( Utilities::FileExists( filePathNameBBG ) )
1320 OpenDiagram( filePathNameBBG , fileName );
1322 if ( Utilities::FileExists( filePathNameBBS ) )
1324 OpenBBS( filePathNameBBS , fileName );
1326 wxMessageDialog windowMessage1(NULL,_T("..ERROR.. loading script bbg/bbs."), _T("Alert !"), wxOK);
1327 windowMessage1.ShowModal();
1334 //=========================================================================
1335 bool wxGUIEditorGraphicBBS::TryToOpenScriptApplication(std::string packageName ,std::string boxType)
1337 return TryToOpenScript(packageName ,boxType, true, false);
1340 //=========================================================================
1341 bool wxGUIEditorGraphicBBS::TryToOpenScriptComplexBox(std::string packageName ,std::string boxType)
1343 return TryToOpenScript(packageName ,boxType, false, true);
1347 //=========================================================================
1348 bool wxGUIEditorGraphicBBS::TryToOpenScript(std::string packageName ,std::string boxType,bool scriptApplication, bool scriptComplexBox)
1351 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
1352 BlackBoxDescriptor::Pointer descriptor;
1353 k = GetBBTKFactory()->GetPackage(packageName);
1354 mapDesc = k->GetDescriptorMap();
1355 descriptor = mapDesc[boxType];
1360 ((descriptor->IsTypeOfScript_Application()==true) && (scriptApplication==true))
1362 ((descriptor->IsTypeOfScript_ComplexBox()==true) && (scriptComplexBox==true))
1366 OpenScript(descriptor->GetScriptFileName(),boxType);
1372 } // EO namespace bbtk