X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=35c4e77cf7c07ad4bb18da7296232982a9863815;hb=066e10b43998a3b236a60549f99794255871fce9;hp=f2e6e086a58a0aa4986deefee9258e30e904ba5e;hpb=ac7e88cf5991d996435b15c7d731b67078f8b2c9;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index f2e6e08..35c4e77 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -34,6 +34,7 @@ Version: $Revision$ */ #include "bbtkwxGUIEditorGraphicBBS.h" +#include "creaWx.h" namespace bbtk { @@ -46,30 +47,32 @@ namespace bbtk _frameAUIMgr = new wxAuiManager(this); - //std::string datadir( crea::System::GetExecutablePath() ); + /*std::string datadir( crea::System::GetExecutablePath() ); std::string datadir ("."); cout<<"RaC //------------------"<Update(); + _actualPkgBrowserBoxName=""; + _actualPkgBrowserPkgName=""; } @@ -81,34 +84,46 @@ namespace bbtk //========================================================================= void wxGUIEditorGraphicBBS::initToolbar() - { - //std::string filename= _dataDir + "/data/icons/wxart_new.xpm"; + { wxBitmap bmp_new(new_xpm); + wxBitmap bmp_open(open_xpm); + wxBitmap bmp_save(save_xpm); + wxBitmap bmp_run(run_xpm); + wxBitmap bmp_delete(delete_xpm); + wxBitmap bmp_centerview(centerview_xpm); wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY); //Adds a tool btn to the toolbar - _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab")); - - - //////////////////// - // TEMP to avoid drag and drop - - _toolbar->AddTool(15,_T("New Box"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New Box"), _T("Create a new Box")); - - - // - //////////////////// + _toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab")); + _toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram")); + _toolbar->AddTool(ID_SAVE,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram")); + _toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram")); + _toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes")); + _toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view")); + _toolbar->SetMargins( 2, 2 ); _toolbar->Realize(); SetToolBar(_toolbar); // connect command event handlers - Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick)); - Connect(15,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick)); + Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); + Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram)); + Connect(ID_SAVE,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); + Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram)); + Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram)); + Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram)); } + //========================================================================= + void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() + { + //TO FIX THE PATH OF BBTK BIN IN ORDER TO USE REGENERATE EXECUTABLES + //RegenerateAll(); + _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0)); + _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200)); + } //========================================================================= void wxGUIEditorGraphicBBS::initMenu() @@ -121,6 +136,8 @@ namespace bbtk helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About")); fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit")); + Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit)); + // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, _T("&File")); @@ -133,9 +150,9 @@ namespace bbtk //========================================================================= void wxGUIEditorGraphicBBS::initTabPanelsManager() { - wxAuiNotebook *notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON); - _tabsMgr = new wxTabPanelsManager(notebook); - _frameAUIMgr->AddPane(notebook,wxAuiPaneInfo().CenterPane()); + _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); + _tabsMgr = new wxTabPanelsManager(this); + _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane()); } @@ -144,29 +161,290 @@ namespace bbtk { _pkgBrowser = new WxGUIPackageBrowser2(this); _pkgBrowser->IncludeAll(); - _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false)); + _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false)); + } + + //================================================================ + + void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack ) + { + std::string mess("Regenerating doc for package '"); + if (pack!="-a"){ + mess += pack + "'"; + } + else + { + mess = "Regenerating doc for all packages"; + } + mess += " ... please wait"; + + SetStatusText( std2wx(mess) ); + + //BBTK_BUSY_CURSOR; + + std::string command; + #if defined(WIN32) + command = "\""; + #endif + command += ConfigurationFile::GetInstance().Get_bin_path(); + command += ConfigurationFile::GetInstance().Get_file_separator(); + command += "bbRegeneratePackageDoc"; + #if defined(WIN32) + command += "\""; + #endif + + command += " " + pack + " -q"; + bbtkMessage("debug",1,"Executing system command '"<getBlackBoxDescriptor(packageName, boxName); + _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get()); + } + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel) + { + wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,bbmodel); + dialog->Show(); + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::editDiagramParameters(wxVtkSceneManager* scene) + { + wxBlackBoxEditionDialog* dialog = new wxBlackBoxEditionDialog(this,scene); + dialog->Show(); } - /***************************************************** + //========================================================================= + + void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus) + { + SetStatusText(crea::std2wx(textStatus)); + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::executeScript(std::string script) + { + std::string separator = ConfigurationFile::GetInstance().Get_file_separator (); + std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); + std::string filename = dir + separator + "tmp_bbtk.bbs"; + + ofstream tempFile; + tempFile.open(filename.c_str()); + tempFile << script; + tempFile.close(); + + std::string command = "\""; + + #ifdef WIN32 + command += "\""; + #endif + + //command += ConfigurationFile::GetInstance().Get_bin_path(); + command +="C:/temp/bbtkBIN/RelWithDebInfo//"; + + #ifdef MACOSX + command += separator + "bbi.app/Contents/MacOS/bbi\" "; + #else + command += separator + "bbi\" "; + #endif + command += "\""+filename + "\""; + + #ifdef WIN32 + command += "\""; + #endif + + command += " & "; + + printf ("RaC wxGUIEditorGraphicBBS::executeScript %s \n" , command.c_str() ); + system( command.c_str() ); + } + + //========================================================================= + // EVENT HANDLERS + //========================================================================= + + void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) + { + _tabsMgr->addNewTab(); + } + + //========================================================================= + + void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) + { + std::string script = _tabsMgr->getActualDiagramScript(); + cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<ShowModal() == wxID_OK) + { + wxString fileName = saveFileDialog->GetPath(); + + ofstream file; + file.open(fileName.c_str()); - void wxGUIEditorGraphicBBS::OnToolLeftClick(wxCommandEvent& event) + std::string content=""; + + // writing file header + content += "# ----------------------------------\n"; + content += "# - BBTKGEditor v 1.0 BBD 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::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) { - switch (event.GetId()) + wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Open diagram"),wxEmptyString,"","*.bbd",wxOPEN|wxFILE_MUST_EXIST); + if (openFileDialog->ShowModal() == wxID_OK) { - case wxID_NEW : - std::cout<<"RaC New"<GetPath(); + + ifstream inputStream; + inputStream.open(fileName.c_str()); + _tabsMgr->addNewTab(); - break; - case 15 : - BlackBoxDescriptor* desc = _pkgBrowser->GetActualSelected(); - cout<<"RaC GetActualSelected desc:"<GetAuthor()<loadDiagram(inputStream); + + inputStream.close(); + } } + //========================================================================= + + void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) + { + Close(true); + } + + //========================================================================= } // EO namespace bbtk