]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
Feature #1380
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxGEditorTabPanel.cxx
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;
        }
+       
+
 
        //=========================================================================