X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=327bbf190570ba5e2cd9dcafaa7ece8e33b454b8;hb=432cb7a04affad5c64de082e2f9d11dfb708efb4;hp=0f87071f6fdadb24053f960ae8a0102ab488d2b9;hpb=cef73d418644dcb545c7731df11c54146fe82174;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 0f87071..327bbf1 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,21 +47,21 @@ 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,21 +84,33 @@ namespace bbtk //========================================================================= void wxGUIEditorGraphicBBS::initToolbar() - { - //std::string filename= _dataDir + "/data/icons/wxart_new.xpm"; + { wxBitmap bmp_new(new_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")); + _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab")); + _toolbar->AddTool(1001,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram")); + _toolbar->AddTool(1002,_T("Execute"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram")); + _toolbar->AddTool(1003,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes")); + _toolbar->AddTool(1004,_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(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); + Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); + Connect(1002,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram)); + Connect(1003,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram)); + Connect(1004,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram)); } //========================================================================= @@ -132,9 +147,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_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(this); + _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane()); } @@ -242,29 +257,143 @@ namespace bbtk DoRegenerateBoxesLists(); } - //================================================================ + //================================================================ + + wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook() + { + return _notebook; + } + + //================================================================ + + void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName) + { + if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName ) + { + _actualPkgBrowserPkgName = packageName; + _actualPkgBrowserBoxName = boxName; + + BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->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(); + } + + //========================================================================= - /***************************************************** - /* HANDLERS - /*****************************************************/ + void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) + { + std::string script = _tabsMgr->getActualDiagramScript(); + cout<<"RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"<ShowModal() == wxID_YES) { - case wxID_NEW : - std::cout<<"RaC New"<addNewTab(); - break; + _tabsMgr->deleteAllBoxesActualDiagram(); } } + //========================================================================= + + void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event) + { + _tabsMgr->centerViewActualDiagram(); + } + + //========================================================================= + void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) { Close(true); } + } // EO namespace bbtk // EOF