X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FbbtkwxGUIEditorGraphicBBS.cxx;h=fd7fa6528d6bae23f661004c5f2a6ff8a7a02716;hb=fea0c6ff7e209a7bb61bcc8176742e5f1a609443;hp=e76f8bcecb98b8bf41302e20bafa3bc4df48d14c;hpb=775c8164b5f679027b8bbafa97c0e0110711909b;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index e76f8bc..fd7fa65 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -36,6 +36,7 @@ #include "bbtkwxGUIEditorGraphicBBS.h" #include "creaWx.h" #include "creaSystem.h" +#include #include @@ -104,7 +105,8 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxBitmap bmp_complexbox(complexbox_xpm); wxBitmap bmp_complexinputport(complexinputport_xpm); wxBitmap bmp_complexoutputport(complexoutputport_xpm); - + wxBitmap bmp_undo(undo_xpm); + wxBitmap bmp_redo(redo_xpm); wxToolBar *toolbar = new wxToolBar(this, wxID_ANY); //Adds a tool btn to the toolbar @@ -141,11 +143,16 @@ void wxGUIEditorGraphicBBS::initToolbar() { _T("Add output Complex box"), _T("Add output Complex box")); toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false); - + toolbar->AddSeparator(); + toolbar->AddTool(ID_UNDO, _T("Undo"),bmp_undo, wxNullBitmap, wxITEM_NORMAL, _T("Undo"), _T("Undo")); + toolbar->AddTool(ID_REDO, _T("Redo"),bmp_redo, wxNullBitmap, wxITEM_NORMAL, _T("Redo"), _T("Redo")); + //toolbar->EnableTool(ID_UNDO, false); + //toolbar->EnableTool(ID_REDO, false); toolbar->SetMargins(2, 2); toolbar->Realize(); SetToolBar(toolbar); + // connect command event handlers Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab)); @@ -179,6 +186,8 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput)); Connect(ID_ADDCOMPLEXBOXOUTPUT, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput)); + Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo)); + Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo)); } //========================================================================= @@ -459,6 +468,21 @@ void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) { refreshGUIControls(); } +void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) { + unsigned short disable; + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->loadTempDiagram(0)); + if (GetToolBar()->GetToolEnabled(ID_REDO) == false) + GetToolBar()->EnableTool(ID_REDO,true); + refreshGUIControls(); +} + +void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) { + unsigned short disable; + GetToolBar()->EnableTool(ID_REDO, _tabsMgr->loadTempDiagram(1)); + if (GetToolBar()->GetToolEnabled(ID_UNDO) == false) + GetToolBar()->EnableTool(ID_UNDO,true); + refreshGUIControls(); +} //========================================================================= void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) { @@ -608,6 +632,12 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) { file.close(); } +//========================================================================= +void wxGUIEditorGraphicBBS::SaveTempActualDiagram() +{ + _tabsMgr->saveTempActualDiagram(); +} + //========================================================================= //The following method allows to save the current diagram asking the filename @@ -733,12 +763,22 @@ void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) { std::string packageName = bbDes->GetPackage()->GetName(); wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel(); - + + // save empty state!! + /* if (_tabsMgr->getNumActualSelectedObjects() == 0) + { + SaveTempActualDiagram(); + } + */ if (pnl != NULL) { wxVtkSceneManager *scn = pnl->getSceneManager(); scn->createGBlackBox(50, 50, packageName, typeName); scn->refresh(); - } // if pnl + } + if (GetToolBar()->GetToolEnabled(ID_UNDO) == false) + GetToolBar()->EnableTool(ID_UNDO,true); + SaveTempActualDiagram(); + // if pnl }// if bbDes }