]> Creatis software - bbtkGEditor.git/commitdiff
Feature #1380
authorcervenansky <>
Fri, 25 May 2012 12:55:15 +0000 (12:55 +0000)
committercervenansky <>
Fri, 25 May 2012 12:55:15 +0000 (12:55 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx

index a21ee894291bd5b478bbd08c7ecb55de81f76ded..4fb42dbdafb20feab9362ca47ff96ae116f06d49 100644 (file)
@@ -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) {
index e34c5d44d3263fe5792eec29a91ee810077d5d14..b42475d1cc84d2a430375f03ff97670f70dd6ba4 100644 (file)
@@ -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
index d080363abb24c79ad2c57842fe62180ac928a3af..850b9edde5dbbe91a3618dd3a07baaa409b257e0 100644 (file)
@@ -213,7 +213,7 @@ namespace bbtk
                }
  
                if( closeok==1 ){
-                       _parent->SaveTempActualDiagram();
+                       _parent->SaveTempActualDiagram("edit values");
                        Close(true);
                }
        }
index 10e10a0270053a02c95b064b6961103f500670a7..b37e67d4b6b35cf0c13f3d04dd7c9b1d8485008e 100644 (file)
@@ -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<std::string>::iterator it = _actualdo+1;
                        states.erase(it, states.end());
                        states.push_back(content);
+
+                       std::vector<std::string>::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;
        }
+       
+
 
        //=========================================================================
 
index dddf555ea03f43aa9c7c5cfbf7dedd9de3f0cb6d..59d615e3f6801f38bd451987dd5b4244352fb31e 100644 (file)
@@ -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<std::string> states; // represents each modification of the tab. Maxixum size 100!!
                std::vector<std::string>::iterator _actualdo;   // actual position on modifications vector
+               std::vector<std::string> sstates; // represents string of each modification of the tab. Maxixum size 100!!
+               std::vector<std::string>::iterator _sactualdo;  // actual position onstring  modifications vector
 
                int                                             _id;
                wxAuiManager                    *_panelAUIMgr;
index a7a705221f2adea8b959d8065d1d5ffd454b364c..a3c0af043f251c6f1c282da9724812b09ee7f093 100644 (file)
@@ -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);
        }
        //=========================================================================
 
index e8590225f1437c1f4d506919cf9269ce3424b85a..39a77fc053c6065e6d7c86566bc9cbb099342c1f 100644 (file)
@@ -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);
index 670ed13ad7c0aeff4afb3ec1939c443dc3d6e0ce..6de30402b985bce8502bfbb80e2fdc5cb7e3a249 100644 (file)
@@ -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");
 }
 
 //=========================================================================