From: cervenansky <> Date: Fri, 25 May 2012 12:55:15 +0000 (+0000) Subject: Feature #1380 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtkGEditor.git;a=commitdiff_plain;h=9877bb1bc1cbfc8b4ac0dbd45d443ba670c9d8d2 Feature #1380 --- diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index a21ee89..4fb42db 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -147,6 +147,7 @@ void wxGUIEditorGraphicBBS::initToolbar() { 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); @@ -492,8 +493,11 @@ void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) { void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) { unsigned short disable; + std::string stundo; + std::string stredo; + _tabsMgr->loadTempDiagram(0); - disable = _tabsMgr->getUndoState(); + disable = _tabsMgr->getUndoState(stundo); if(disable == 0) { std::string name = _tabsMgr->GetNameTabPanel(); @@ -505,19 +509,26 @@ void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) { } GetToolBar()->EnableTool(ID_UNDO,disable); - GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo)); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo)); + GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo)); refreshGUIControls(); } void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) { unsigned short disable; + std::string stundo; + std::string stredo; + _tabsMgr->loadTempDiagram(1); std::string name = _tabsMgr->GetNameTabPanel(); if(name[name.length() - 1] != '*') name +="*"; _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8)); - GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); - GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo)); + GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo)); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo)); + GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo)); refreshGUIControls(); } @@ -677,15 +688,19 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) { } //========================================================================= -void wxGUIEditorGraphicBBS::SaveTempActualDiagram() +void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action) { + std::string stundo; + std::string stredo; std::string name = _tabsMgr->GetNameTabPanel(); if(name[name.length() - 1] != '*') name +="*"; _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8)); - _tabsMgr->saveTempActualDiagram(); - GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); - GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + _tabsMgr->saveTempActualDiagram(action); + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo)); + GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo)); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo)); + GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo)); } //========================================================================= @@ -754,6 +769,8 @@ void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) { //========================================================================= void wxGUIEditorGraphicBBS::refreshGUIControls() { + std::string stundo; + std::string stredo; wxToolBar* toolbar = GetToolBar(); if (_tabsMgr->isActualDiagramComplexBox()) { toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true); @@ -771,8 +788,10 @@ void wxGUIEditorGraphicBBS::refreshGUIControls() { GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true); } - GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); - GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo)); + GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo)); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo)); + GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo)); if (_tabsMgr->getNumActualSelectedObjects() > 0) { GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true); @@ -815,7 +834,7 @@ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) { assert(inputStream.good()); // fails _tabsMgr->addNewTab(openFileDialog->GetFilename()); _tabsMgr->loadDiagram(inputStream, fName); - _tabsMgr->saveTempActualDiagram(); + _tabsMgr->saveTempActualDiagram("load diagram"); GetToolBar()->EnableTool(ID_UNDO, false); GetToolBar()->EnableTool(ID_UNDO, false); inputStream.close(); @@ -841,7 +860,7 @@ void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) { scn->refresh(); } - SaveTempActualDiagram(); + SaveTempActualDiagram("New Box"); // if pnl }// if bbDes } @@ -918,12 +937,12 @@ void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event) { //========================================================================= void wxGUIEditorGraphicBBS::OnCreatePackage(wxCommandEvent& event) { - //bbtkSystemTools::CreatePackage(); + bbtkSystemTools::CreatePackage(); } //========================================================================= void wxGUIEditorGraphicBBS::OnCreateBlackBox(wxCommandEvent& event) { - //bbtkSystemTools::CreateBlackBox(); + bbtkSystemTools::CreateBlackBox(); } //========================================================================= void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index e34c5d4..b42475d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -141,7 +141,7 @@ namespace bbtk void SaveActualComplexBox(std::string filename); void SaveActualDiagram(std::string filename); void SaveCurrentDiagramAs( ); //DFCH - void SaveTempActualDiagram();//FCY + void SaveTempActualDiagram(const std::string &);//FCY // File menu and toolbar events diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx index d080363..850b9ed 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx @@ -213,7 +213,7 @@ namespace bbtk } if( closeok==1 ){ - _parent->SaveTempActualDiagram(); + _parent->SaveTempActualDiagram("edit values"); Close(true); } } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 10e10a0..b37e67d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -55,6 +55,7 @@ printf("EED wxGEditorTabPanel::wxGEditorTabPanel 0\n"); _panelAUIMgr = new wxAuiManager(this); _sceneManager = NULL; _actualdo = states.begin(); + _sactualdo = sstates.begin(); initWxVtkCanvas(); printf("EED wxGEditorTabPanel::wxGEditorTabPanel 1\n"); } @@ -111,14 +112,14 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); boxType += result; _sceneManager->createGBlackBox(x,y,packageName, boxType); - saveTempandUpdate(); + saveTempandUpdate("drop box"); return true; } //========================================================================= - void wxGEditorTabPanel::saveTempandUpdate() + void wxGEditorTabPanel::saveTempandUpdate(const std::string &action) { - _panelsManager->saveTempandUpdate(); + _panelsManager->saveTempandUpdate(action); } //========================================================================= @@ -189,7 +190,7 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); //========================================================================= - void wxGEditorTabPanel::saveTempDiagram() //FCY + void wxGEditorTabPanel::saveTempDiagram(const std::string &action) //FCY { std::string content = ""; // writing file header @@ -206,14 +207,20 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); if(_actualdo == states.end() ) // same size, write to the end { states.push_back (content); + saveStringAction(action); } else { std::vector::iterator it = _actualdo+1; states.erase(it, states.end()); states.push_back(content); + + std::vector::iterator sit = _sactualdo+1; + sstates.erase(sit, sstates.end()); + saveStringAction(action); } _actualdo = states.end(); + _sactualdo = sstates.end(); } @@ -228,25 +235,40 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); } //========================================================================= - unsigned short wxGEditorTabPanel::getUndoState() + unsigned short wxGEditorTabPanel::getUndoState( std::string &stun) { + stun = "Undo"; if(states.size()>0) { if(_actualdo == states.begin() ) + { + return 0; + } else + { + stun +=" - "; + stun += _sactualdo->substr(0,(--_sactualdo)->find_last_of(".")); + _sactualdo++; return 1; + } } } - unsigned short wxGEditorTabPanel::getRedoState() + unsigned short wxGEditorTabPanel::getRedoState( std::string &stre) { + stre = "Redo"; if(states.size()>0) { - if(_actualdo == --states.end() || states.size() == 1) + if(_actualdo == --states.end() || states.size() == 1 || _actualdo == states.end()) return 0; else + { + stre +=" - "; + stre += _sactualdo->substr(0,(++_sactualdo)->find_last_of(".")); + --_sactualdo; return 1; + } } } @@ -261,10 +283,12 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); if(_actualdo == states.end() ) // same size, write to the end { (_actualdo--); + (_sactualdo--); } if(_actualdo != states.begin() ) { ss << *(--_actualdo); + _sactualdo--; } else { @@ -275,6 +299,7 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); else //redo { _actualdo++; + _sactualdo++; if(_actualdo != states.end()) { ss << *_actualdo; @@ -287,13 +312,22 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); _sceneManager->loadDiagram(ss); } - + + void wxGEditorTabPanel::saveStringAction(const std::string &action) + { + char temp[50]; + sprintf(temp,".%d", sstates.size()); + sstates.push_back(action + temp); + } + //========================================================================= int wxGEditorTabPanel::getPanelId() { return _id; } + + //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index dddf555..59d615e 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -101,22 +101,24 @@ namespace bbtk void saveDiagram(std::string &content, const std::string &path); //DFCH // Save temporary diagram as BBG - void saveTempDiagram(); + void saveTempDiagram(const std::string &); // Save temporary diagram as BBG and update buttons - void saveTempandUpdate(); + void saveTempandUpdate(const std::string &); // Load BBG diagram void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH + void saveStringAction(const std::string &action); + // Load temporary diagram as BBG void loadTempDiagram(unsigned short un); // evaluate the position in the undo actions list - unsigned short getUndoState(); + unsigned short getUndoState(std::string &); // evaluate the position in the redo actions list - unsigned short getRedoState(); + unsigned short getRedoState(std::string &); // Add a new complex input object to the scene void addComplexInputPort(std::string portName); @@ -173,6 +175,8 @@ namespace bbtk private: std::vector states; // represents each modification of the tab. Maxixum size 100!! std::vector::iterator _actualdo; // actual position on modifications vector + std::vector sstates; // represents string of each modification of the tab. Maxixum size 100!! + std::vector::iterator _sactualdo; // actual position onstring modifications vector int _id; wxAuiManager *_panelAUIMgr; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index a7a7052..a3c0af0 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -153,14 +153,14 @@ printf("EED wxTabPanelsManager::addNewTab 1\n"); } //========================================================================= - void wxTabPanelsManager::saveTempandUpdate() //FCY + void wxTabPanelsManager::saveTempandUpdate(const std::string &action) //FCY { - _parent->SaveTempActualDiagram(); + _parent->SaveTempActualDiagram(action); } //========================================================================= - void wxTabPanelsManager::saveTempActualDiagram() //FCY + void wxTabPanelsManager::saveTempActualDiagram(const std::string &action) //FCY { - _actual->saveTempDiagram(); + _actual->saveTempDiagram(action); } //========================================================================= void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY @@ -169,14 +169,14 @@ printf("EED wxTabPanelsManager::addNewTab 1\n"); } //========================================================================= - unsigned short wxTabPanelsManager::getUndoState() //FCY + unsigned short wxTabPanelsManager::getUndoState( std::string &stun) //FCY { - return _actual->getUndoState(); + return _actual->getUndoState(stun); } //========================================================================= - unsigned short wxTabPanelsManager::getRedoState() //FCY + unsigned short wxTabPanelsManager::getRedoState(std::string &stre) //FCY { - return _actual->getRedoState(); + return _actual->getRedoState(stre); } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index e859022..39a77fc 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -89,11 +89,11 @@ namespace bbtk void saveActualDiagram(std::string &content, const std::string &path); //DFCH void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH - void saveTempActualDiagram(); //FCY - void saveTempandUpdate(); + void saveTempActualDiagram(const std::string &); //FCY + void saveTempandUpdate(const std::string &); void loadTempDiagram(unsigned short un); //FCY - unsigned short getUndoState(); - unsigned short getRedoState(); + unsigned short getUndoState(std::string &); + unsigned short getRedoState(std::string &); bool isActualDiagramComplexBox(); void setActualDiagramComplexBox(bool val); void addActualDiagramComplexInputPort(std::string portName); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 670ed13..6de3040 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -747,7 +747,7 @@ void wxVtkSceneManager::update(int idController, int command) { } // EO JGRR CM - _parent->saveTempDiagram(); + _parent->saveTempandUpdate("create connection"); } manualConnectorContourController @@ -1212,7 +1212,7 @@ void wxVtkSceneManager::deleteObject(int id) { _controllers.erase(it); }//if }// for - _parent->saveTempandUpdate(); + _parent->saveTempandUpdate("delete object"); } //=========================================================================