+ //=========================================================================
+ 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.2 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)
+ {
+ _tabsMgr->SetNameTabPanel( saveFileDialog->GetFilename() );
+
+ wxString pathfileName = saveFileDialog->GetPath();
+ std::string pathfilename = (const char*) (pathfileName.mb_str());
+ std::string pathfilenamebbs = pathfilename;
+ pathfilenamebbs[pathfilenamebbs.length()-1]='s';
+
+ if (_tabsMgr->isActualDiagramComplexBox()==false)
+ {
+ SaveActualDiagram( pathfilename );
+ SaveActualBBS(pathfilenamebbs);
+ } else {
+ AskComplexBoxConfiguration();
+ SaveActualDiagram( pathfilename );
+ SaveActualComplexBox(pathfilenamebbs);
+ } //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);
+ }
+
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event)
+ {
+ 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);
+ if(dial->ShowModal() == wxID_YES)
+ {
+ _tabsMgr->deleteAllBoxesActualDiagram();
+ }
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event)
+ {
+ _tabsMgr->centerViewActualDiagram();
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
+ {
+ wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,wxT(""),wxT("*.bbg"),wxOPEN|wxFILE_MUST_EXIST);
+ if (openFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = openFileDialog->GetPath();
+ ifstream inputStream;
+ std::string fName=(const char*) (fileName.mb_str());
+ inputStream.open( fName.c_str() );
+ _tabsMgr->addNewTab( openFileDialog->GetFilename() );
+
+ _tabsMgr->loadDiagram(inputStream);
+
+ inputStream.close();
+ }
+ refreshGUIControls();
+ }
+
+ //=========================================================================
+
+
+ void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event)
+ {
+ BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
+ if (bbDes!=NULL)
+ {
+ std::string typeName = bbDes->GetTypeName();
+ std::string packageName = bbDes->GetPackage()->GetName();
+
+
+ wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
+
+ if (pnl!=NULL)
+ {
+ wxVtkSceneManager *scn = pnl->getSceneManager();
+ scn->createGBlackBox(50,50,packageName, typeName);
+ scn->refresh();
+ } // if pnl
+ }// if bbDes
+ }
+
+ //=========================================================================
+
+
+ void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event)
+ {
+ wxToolBar* toolbar = GetToolBar();
+ bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
+ if(temp)
+ {
+ _tabsMgr->setActualDiagramComplexBox(true);
+ }
+ else
+ {
+ _tabsMgr->setActualDiagramComplexBox(false);
+ }
+ refreshGUIControls();
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event)
+ {
+ wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of input port"));
+ if (nameDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = nameDialog->GetValue();
+ if(!fileName.IsEmpty())
+ {
+ std::string portName=(const char*) (fileName.mb_str());
+ _tabsMgr->addActualDiagramComplexInputPort(portName);
+ }
+ }
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event)
+ {
+ wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,wxT("Name of output port"));
+ if (nameDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = nameDialog->GetValue();
+ if(!fileName.IsEmpty())
+ {
+ std::string portName=(const char*) (fileName.mb_str());
+ _tabsMgr->addActualDiagramComplexOutputPort(portName);
+ }
+ }
+ }
+
+ //=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(wxCommandEvent& event)
+ {
+ _tabsMgr->copySelectedBBoxesToComplexDiagram();
+ }
+
+
+ void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event)
+ {
+ printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ......\n");
+ }
+
+
+
+ //=========================================================================
+