From: cervenansky <> Date: Wed, 23 May 2012 15:09:36 +0000 (+0000) Subject: Bug #1365, X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtkGEditor.git;a=commitdiff_plain;h=04884fa171fe877e5c2ca53d11d6838bc1f8a8f7 Bug #1365, Feature #1353 --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 5765f92..4fc8597 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -189,6 +189,7 @@ namespace bbtk const int ID_UNDO = 1024; // FCY const int ID_REDO = 1025; // FCY + const int ID_CHANGENAME = 1026; } // namespace bbtk #endif diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index bf26a19..af24586 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -147,8 +147,8 @@ 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->EnableTool(ID_UNDO, false); + toolbar->EnableTool(ID_REDO, false); toolbar->SetMargins(2, 2); toolbar->Realize(); SetToolBar(toolbar); @@ -190,7 +190,7 @@ void wxGUIEditorGraphicBBS::initToolbar() { wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput)); Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo)); Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo)); - + Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName)); } //========================================================================= void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() { @@ -483,19 +483,33 @@ void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) { 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); + _tabsMgr->loadTempDiagram(0); + disable = _tabsMgr->getUndoState(); + if(disable == 0) + { + std::string name = _tabsMgr->GetNameTabPanel(); + if(name[name.length() - 1] == '*') + { + name =name.substr(0,name.length()-1); + } + _tabsMgr->SetNameTabPanel(name); + } + + GetToolBar()->EnableTool(ID_UNDO,disable); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); 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); + _tabsMgr->loadTempDiagram(1); + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); refreshGUIControls(); } + +void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){ +} //========================================================================= void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) { @@ -652,6 +666,10 @@ void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) { //========================================================================= void wxGUIEditorGraphicBBS::SaveTempActualDiagram() { + std::string name = _tabsMgr->GetNameTabPanel(); + if(name[name.length() - 1] != '*') + name +="*"; + _tabsMgr->SetNameTabPanel(name); _tabsMgr->saveTempActualDiagram(); } @@ -696,7 +714,7 @@ void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) { } else { std::string pathfilenamebbs = pathfilename; pathfilenamebbs[pathfilenamebbs.length() - 1] = 's'; - + if (_tabsMgr->isActualDiagramComplexBox() == false) { SaveActualDiagram(pathfilename); SaveActualBBS(pathfilenamebbs); @@ -732,6 +750,9 @@ void wxGUIEditorGraphicBBS::refreshGUIControls() { GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true); } + GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState()); + GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState()); + if (_tabsMgr->getNumActualSelectedObjects() > 0) { GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true); } else { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index f14acf5..6fb6fdf 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -162,6 +162,7 @@ namespace bbtk void OnHelpBBeditor(wxCommandEvent& event); void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); + void OnChangeName(wxCommandEvent& event); // Edit menu events void OnCopySelectedToComplexDiagram(wxCommandEvent& event); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx index 93ded4c..d4663da 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx @@ -184,3 +184,8 @@ printf("EED wxBlackBoxEditionDialog::onClickClose\n"); } // EO namespace bbtk // EOF +/* // remove * from the name + std::string name = _tabsMgr->GetNameTabPanel(); + if(name[name.length() - 1] != '*') + name = name.substr(0, name.length()-2); + _tabsMgr->SetNameTabPanel(name);*/ \ No newline at end of file diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index 6225ee3..ab5c55f 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -221,7 +221,30 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); } //========================================================================= - unsigned short wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY + unsigned short wxGEditorTabPanel::getUndoState() + { + if(states.size()>0) + { + if(_actualdo == states.begin() ) + return 0; + else + return 1; + } + } + + unsigned short wxGEditorTabPanel::getRedoState() + { + if(states.size()>0) + { + if(_actualdo == --states.end() || states.size() == 1) + return 0; + else + return 1; + } + } + + //========================================================================= + void wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY { unsigned short res = 1; deleteAllBoxes(); @@ -255,7 +278,7 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n"); } } _sceneManager->loadDiagram(ss); - return res; + } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index d305732..db615aa 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -107,7 +107,13 @@ namespace bbtk void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH // Load temporary diagram as BBG - unsigned short loadTempDiagram(unsigned short un); + void loadTempDiagram(unsigned short un); + + // evaluate the position in the undo actions list + unsigned short getUndoState(); + + // evaluate the position in the redo actions list + unsigned short getRedoState(); // Add a new complex input object to the scene void addComplexInputPort(std::string portName); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index 2e5c4ee..32173e9 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -149,11 +149,21 @@ printf("EED wxTabPanelsManager::addNewTab 1\n"); _actual->saveTempDiagram(); } //========================================================================= - unsigned short wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY + void wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY { - return _actual->loadTempDiagram(un); + _actual->loadTempDiagram(un); } + //========================================================================= + unsigned short wxTabPanelsManager::getUndoState() //FCY + { + return _actual->getUndoState(); + } + //========================================================================= + unsigned short wxTabPanelsManager::getRedoState() //FCY + { + return _actual->getRedoState(); + } //========================================================================= bool wxTabPanelsManager::isActualDiagramComplexBox() @@ -220,6 +230,7 @@ printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPa int id = tab->getPanelId(); _actual = _panels[id]; _parent->refreshGUIControls(); + } //========================================================================= @@ -235,6 +246,12 @@ printf("wxTabPanelsManager::VerifyActualTabPanel %d \n", this->_notebook->GetPa _notebook->SetPageText( id , tabpanelname ); } + std::string wxTabPanelsManager::GetNameTabPanel() + { + int id = _notebook->GetSelection(); + return crea::wx2std(_notebook->GetPageText(id)); + } + //========================================================================= //DFCH std::string wxTabPanelsManager::GetCurrentTabPanelPath( ) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index bf617e3..529699b 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -49,6 +49,7 @@ Version: $Revision$ #include #include #include +#include #include "wxGEditorTabPanel.h" #include "wxVtkSceneManager.h" @@ -56,6 +57,7 @@ Version: $Revision$ using namespace std; + namespace bbtk { @@ -88,7 +90,9 @@ namespace bbtk void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH void saveTempActualDiagram(); //FCY - unsigned short loadTempDiagram(unsigned short un); //FCY + void loadTempDiagram(unsigned short un); //FCY + unsigned short getUndoState(); + unsigned short getRedoState(); bool isActualDiagramComplexBox(); void setActualDiagramComplexBox(bool val); void addActualDiagramComplexInputPort(std::string portName); @@ -111,6 +115,7 @@ namespace bbtk std::string GetCategory(); void SetNameTabPanel(wxString tabpanelname); + std::string GetNameTabPanel(); std::string GetCurrentTabPanelPath( ); //DFCH