+ std::string script1 = _tabsMgr->getActualDiagramBBS(true);
+ cout<<endl<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<<endl<<endl;
+ cout<<script1<<endl;
+
+ std::string script2 = _tabsMgr->getActualDiagramBBS(false);
+ executeScript(script2);
+ }
+
+
+ //=========================================================================
+ // HANDLERS
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event)
+ {
+ wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxOPEN);
+ if (openFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = openFileDialog->GetPath( );
+
+
+ _tabsMgr->addNewTab();
+
+ bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager() , _pkgBrowser->GetFactory());
+
+ // We tell the interpreter to throw exceptions on error
+ I->SetThrow(true);
+ // Interpret the file supposed to define a box called 'Processing'
+ I->InterpretFile( (const char*) (fileName.mb_str()) );
+ }
+ refreshGUIControls();
+ }
+
+
+
+ void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename)
+ {
+ ofstream file;
+
+//EED file.open(fileName.c_str());
+ file.open( filename.c_str() );
+ std::string content="";
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.1 BBS BlackBox Script\n";
+ content += "# - ";
+ content += filename;
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualDiagramBBS();
+ file << content;
+ file.close();
+ }
+
+
+ void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event)
+ {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual BBS"),wxEmptyString,wxT("NewBBS"),wxT("*.bbs"),wxSAVE|wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = saveFileDialog->GetPath( );
+ SaveActualBBS( (const char*) (fileName.mb_str()) );
+ }
+
+ }
+
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename)
+ {
+ wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of complex box"));
+ std::string cbName="";
+ if (nameDialog->ShowModal() == wxID_OK)
+ {
+ wxString complexboxname = nameDialog->GetValue();
+ cbName=(const char*) (complexboxname.mb_str());
+ }
+
+ if(!cbName.empty())
+ {
+
+ ofstream file;
+ file.open( filename.c_str() );
+
+ std::string content="";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.1 BBS BlackBox Script (Complex Box)\n";
+ content += "# - ";
+ content += filename;
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += _tabsMgr->getActualComplexBoxBBS(cbName);
+ file << content;
+ file.close();
+ }
+
+
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event)
+ {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this ,wxT("Save Complex Box BBS") ,wxEmptyString, _T("ComplexBoxName") ,wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = saveFileDialog->GetPath();
+ SaveActualComplexBox( (const char*) (fileName.mb_str()) );
+ }
+ }
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename)
+ {
+ ofstream file;
+ file.open( filename.c_str() );
+
+ std::string content="";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n";
+ content += "# - ";
+
+ content += filename;
+
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+ content += "APP_START\n";
+ _tabsMgr->saveActualDiagram(content);
+ content += "APP_END\n";
+ file << content;
+ file.close();
+ }
+
+
+ //=========================================================================
+ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
+ {
+ wxFileDialog * saveFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,wxT("NewDiagram"),wxT("*.bbg"),wxSAVE|wxOVERWRITE_PROMPT);
+ if (saveFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = saveFileDialog->GetPath();
+ std::string filename = (const char*) (fileName.mb_str());
+ std::string filenamebbs = filename+"s";
+
+ SaveActualDiagram( filename );
+ if (_tabsMgr->isActualDiagramComplexBox()==false)
+ {
+ SaveActualBBS(filenamebbs);
+ } else {
+ SaveActualComplexBox(filenamebbs);
+ } //if isActualDiagramComplexBox
+ } // if saveFileDialog
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::refreshGUIControls()
+ {
+ wxToolBar* toolbar = GetToolBar();
+ if(_tabsMgr->isActualDiagramComplexBox())
+ {
+ toolbar->ToggleTool(ID_BTNCOMPLEXBOX,true);
+ toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,true);
+ toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,true);
+
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,true);
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,false);
+ }
+ else
+ {
+ toolbar->ToggleTool(ID_BTNCOMPLEXBOX,false);
+ toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT,false);
+ toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT,false);
+
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX,false);
+ GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS,true);
+ }
+
+ if(_tabsMgr->getNumActualSelectedObjects()>0)
+ {
+ GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
+ }
+ else
+ {
+ ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
+ GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM,true);
+ }