]> Creatis software - bbtkGEditor.git/commitdiff
Feature #1347
authorcervenansky <>
Tue, 22 May 2012 15:13:37 +0000 (15:13 +0000)
committercervenansky <>
Tue, 22 May 2012 15:13:37 +0000 (15:13 +0000)
23 files changed:
appli/bbEditor/CMakeLists.txt
data/icons/wxart_redo.xpm [new file with mode: 0644]
data/icons/wxart_undo.xpm [new file with mode: 0644]
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/CMakeLists.txt
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/GObjectsMVCFactory.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.h
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
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index d4966aa249a1d9ef5f39c33fad466025cf6734f4..4db7bcde82cfc4e4c13e1f9eb9b0bba56ac98000 100644 (file)
@@ -21,16 +21,18 @@ ELSE(BBTK_USE_WXWIDGETS AND WIN32)
   ADD_EXECUTABLE(bbEditor MACOSX_BUNDLE ${SOURCES}  )  
 ENDIF(BBTK_USE_WXWIDGETS AND WIN32)
 
+
+
 TARGET_LINK_LIBRARIES(bbEditor 
                                ${WXWIDGETS_LIBRARIES}
                                ${VTK_LIBRARIES} 
                                crea
                                ${creaMaracasVisu_LIBRARIES} 
+                               ${BBTK_LIBRARIES}
                                bbsWxGUIEditorGraphic
                                bbsKernelEditorGraphic
                                bbsVtkGUIEditorGraphic
-                               ${BBTK_LIBRARIES}
+
                                ${WXWIDGETS_LIBRARIES}
                        )
 
diff --git a/data/icons/wxart_redo.xpm b/data/icons/wxart_redo.xpm
new file mode 100644 (file)
index 0000000..1ce8803
--- /dev/null
@@ -0,0 +1,104 @@
+/* XPM */
+static char * redo_xpm[] = {
+"17 17 84 1",
+"      c None",
+".     c #4D78CE",
+"+     c #517ED7",
+"@     c #4877D6",
+"#     c #4876D6",
+"$     c #4F7ED9",
+"%     c #4B77CE",
+"&     c #4C79D6",
+"*     c #4876D5",
+"=     c #4775D5",
+"-     c #4676D5",
+";     c #4576D6",
+">     c #4675D6",
+",     c #4677D7",
+"'     c #4D7BD1",
+")     c #3B68C4",
+"!     c #456EBC",
+"~     c #4A77D6",
+"{     c #4775D6",
+"]     c #4776D5",
+"^     c #4575D5",
+"/     c #4577D7",
+"(     c #4578D8",
+"_     c #4477D7",
+":     c #4D81DA",
+"<     c #3B69C4",
+"[     c #467ADB",
+"}     c #4C78D1",
+"|     c #4776D6",
+"1     c #4976CF",
+"2     c #3D6CC6",
+"3     c #4478D8",
+"4     c #467ADA",
+"5     c #4579D9",
+"6     c #4D80DA",
+"7     c #467BDA",
+"8     c #467CDB",
+"9     c #4673CA",
+"0     c #467BDB",
+"a     c #477DDB",
+"b     c #477EDC",
+"c     c #477FDB",
+"d     c #467EDD",
+"e     c #4A76CF",
+"f     c #4775D3",
+"g     c #2A68D5",
+"h     c #2C6AD6",
+"i     c #2E6CD7",
+"j     c #306ED8",
+"k     c #3270DA",
+"l     c #4976D1",
+"m     c #4574CC",
+"n     c #3168CB",
+"o     c #2C6BD7",
+"p     c #2E6DD8",
+"q     c #2F6FDA",
+"r     c #3171DB",
+"s     c #3072DB",
+"t     c #4776D1",
+"u     c #3C67B5",
+"v     c #3269CE",
+"w     c #2D6CD8",
+"x     c #2F70DA",
+"y     c #3173DB",
+"z     c #3375DD",
+"A     c #3577DE",
+"B     c #3578DF",
+"C     c #4675D0",
+"D     c #4777D6",
+"E     c #2F69CC",
+"F     c #336CCC",
+"G     c #356FCC",
+"H     c #3772CD",
+"I     c #3A74CF",
+"J     c #3C76CE",
+"K     c #3C76CF",
+"L     c #2C61CF",
+"M     c #1B53CB",
+"N     c #2A5CBA",
+"O     c #265DCA",
+"P     c #255DCA",
+"Q     c #1F57CC",
+"R     c #2E65C8",
+"S     c #326BC5",
+"                 ",
+"    .+@#$%       ",
+"   &*=-;>;,'   )!",
+"  ~*{]^^,/(_: <[ ",
+" }@|1   2(345678 ",
+" ~#9      08abcd ",
+"e*f        ghijk ",
+"l|m       nopqrs ",
+"t|u      vwxyzAB ",
+"CD       EFGHIJK ",
+" L               ",
+" MN              ",
+" OP              ",
+"  Q              ",
+"  R              ",
+"   S             ",
+"                 "};
diff --git a/data/icons/wxart_undo.xpm b/data/icons/wxart_undo.xpm
new file mode 100644 (file)
index 0000000..35b01e7
--- /dev/null
@@ -0,0 +1,104 @@
+/* XPM */
+static char * undo_xpm[] = {
+"17 17 84 1",
+"      c None",
+".     c #4B77CE",
+"+     c #4F7ED9",
+"@     c #4876D6",
+"#     c #4877D6",
+"$     c #517ED7",
+"%     c #4D78CE",
+"&     c #456EBC",
+"*     c #3B68C4",
+"=     c #4D7BD1",
+"-     c #4677D7",
+";     c #4576D6",
+">     c #4675D6",
+",     c #4676D5",
+"'     c #4775D5",
+")     c #4876D5",
+"!     c #4C79D6",
+"~     c #467ADB",
+"{     c #3B69C4",
+"]     c #4D81DA",
+"^     c #4477D7",
+"/     c #4578D8",
+"(     c #4577D7",
+"_     c #4575D5",
+":     c #4776D5",
+"<     c #4775D6",
+"[     c #4A77D6",
+"}     c #467CDB",
+"|     c #467BDA",
+"1     c #4D80DA",
+"2     c #4579D9",
+"3     c #467ADA",
+"4     c #4478D8",
+"5     c #3D6CC6",
+"6     c #4976CF",
+"7     c #4776D6",
+"8     c #4C78D1",
+"9     c #467EDD",
+"0     c #477FDB",
+"a     c #477EDC",
+"b     c #477DDB",
+"c     c #467BDB",
+"d     c #4673CA",
+"e     c #3270DA",
+"f     c #306ED8",
+"g     c #2E6CD7",
+"h     c #2C6AD6",
+"i     c #2A68D5",
+"j     c #4775D3",
+"k     c #4A76CF",
+"l     c #3072DB",
+"m     c #3171DB",
+"n     c #2F6FDA",
+"o     c #2E6DD8",
+"p     c #2C6BD7",
+"q     c #3168CB",
+"r     c #4574CC",
+"s     c #4976D1",
+"t     c #3578DF",
+"u     c #3577DE",
+"v     c #3375DD",
+"w     c #3173DB",
+"x     c #2F70DA",
+"y     c #2D6CD8",
+"z     c #3269CE",
+"A     c #3C67B5",
+"B     c #4776D1",
+"C     c #3C76CF",
+"D     c #3C76CE",
+"E     c #3A74CF",
+"F     c #3772CD",
+"G     c #356FCC",
+"H     c #336CCC",
+"I     c #2F69CC",
+"J     c #4777D6",
+"K     c #4675D0",
+"L     c #2C61CF",
+"M     c #2A5CBA",
+"N     c #1B53CB",
+"O     c #255DCA",
+"P     c #265DCA",
+"Q     c #1F57CC",
+"R     c #2E65C8",
+"S     c #326BC5",
+"                 ",
+"       .+@#$%    ",
+"&*   =-;>;,')!   ",
+" ~{ ]^/(-__:<)[  ",
+" }|1234/5   67#8 ",
+" 90ab}c      d@[ ",
+" efghi        j)k",
+" lmnopq       r7s",
+" tuvwxyz      A7B",
+" CDEFGHI       JK",
+"               L ",
+"              MN ",
+"              OP ",
+"              Q  ",
+"              R  ",
+"             S   ",
+"                 "};
index a63a81397ff02ad47d4fdc286d813dc9b3c0dba6..5765f9208b8a5bb49d3e50d2f861aeb32d98f4cf 100644 (file)
@@ -187,6 +187,8 @@ namespace bbtk
        const int ID_bbEditor_Tool_Menu_ShowHTMLDoc                     =       1022;  // EED
        const int ID_bbEditor_Tool_Menu_CreateIndex                     =       1023;  // EED
        
+       const int ID_UNDO                                                                       =       1024;  // FCY
+       const int ID_REDO                                                                       =       1025;  // FCY
 }
 // namespace bbtk
 #endif
index 0480ece566d47accda9b61f7b89d4adfdac314e5..bdec8ae4b6e14e5e24889e09c7ff789d0a6ccfd6 100644 (file)
@@ -36,6 +36,9 @@ Version:   $Revision$
 
 #include "GBlackBoxController.h"
 
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
 namespace bbtk
 {
 
index 52e80a2f493eb9f5c76594a0d6b3156f7cafe0d7..b0175e6e07d425a6d299c2d934d941f330375807 100644 (file)
@@ -36,6 +36,9 @@ Version:   $Revision$
 
 #include "GBoxController.h"
 
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
 namespace bbtk
 {
 
index ce8717aee8991eae3ede989e0d2cc12bb50d8d2d..40a1a343548494603465d32d5e1a6575e8304c2e 100644 (file)
@@ -36,6 +36,9 @@ Version:   $Revision$
 
 #include "GConnectorController.h"
 
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
 namespace bbtk
 {
 
index 679c3ce017ab6253665d794776a192e03c53fbaf..52badfecf567d488e551a9bc0cba77454d8fa31f 100644 (file)
@@ -56,6 +56,7 @@ Version:   $Revision$
 #include <iostream>
 
 
+
 namespace bbtk
 {
 
index 43f57c75ea11d870fe8944a63e31c7e7ca9aeb29..745cbf22c8e3d2e05879d085b2fd3416db7bcc09 100644 (file)
@@ -36,6 +36,9 @@ Version:   $Revision$
 
 #include "GObjectController.h"
 
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
 namespace bbtk
 {
 
@@ -86,7 +89,7 @@ namespace bbtk
                        }
                }
 
-               _model->notifyObservers(getId());
+               //_model->notifyObservers(getId());
 
 
                return true;
index ea07a9ae76c6fbdd76ad9e8d33246b338c27a35b..0eec429fa6f1b4438bee7883163b39c107f79d34 100644 (file)
@@ -190,8 +190,13 @@ namespace bbtk
                //------------
 
                _boxTextActor           = vtkTextActor3D::New();
-               _boxTextActor->GetTextProperty()->SetFontSize(80);
-               _boxTextActor->GetTextProperty()->BoldOn();
+               vtkTextProperty *prop =  vtkTextProperty::New();
+               prop->BoldOn();
+               prop->SetFontFamilyToArial();
+               prop->SetFontSize(100);
+               _boxTextActor->SetTextProperty(prop);
+               //_boxTextActor->GetTextProperty()->SetFontSize(80);
+               //_boxTextActor->GetTextProperty()->BoldOn();
 
                //------------
 
index 741c06eef4ddfd2ccb0267c94cfde11c53f70369..657caa3336db402cc792279fcd55e2af1cc9815e 100644 (file)
@@ -11,4 +11,4 @@ INCLUDE_DIRECTORIES(../../../data/icons)
 
 ADD_LIBRARY(bbsWxGUIEditorGraphic
                 ${bbsWxGUIEditorGraphic_CXX_SOURCES}
-                ${bbsWxGUIEditorGraphic_H_SOURCES}  )
+                ${bbsWxGUIEditorGraphic_H_SOURCES} )
index b7459ddac502efa02c2b89247898742886e7ea14..099e7a652ae7b2fd1d8cb24d7ac923f81d51341b 100644 (file)
@@ -73,7 +73,6 @@ Version:   $Revision$
 #include <bbtkInterpreter.h>
 #include <bbtkFactory.h>
 #include <bbtkPackage.h>
-
 namespace bbtk
 {
 
index 9604f1800fa3decb048f247f5ab29f3d3605bae4..3bd1dcf6eeb4cbeca5419b6cac9cdbf1cd7c6100 100644 (file)
@@ -41,8 +41,6 @@ Version:   $Revision$
 #include "bbtkFactory.h"
 #include "bbtkUtilities.h"
 
-
-
 namespace bbtk
 {
 
index e76f8bcecb98b8bf41302e20bafa3bc4df48d14c..fd7fa6528d6bae23f661004c5f2a6ff8a7a02716 100644 (file)
@@ -36,6 +36,7 @@
 #include "bbtkwxGUIEditorGraphicBBS.h"
 #include "creaWx.h"
 #include "creaSystem.h"
+#include <wx/defs.h>
 
 #include <InterpreterBBS.h>
 
@@ -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
 }
 
index 3a4df85f8ef3e05efa48c18994b4b38564296da6..2afb269300b4d3893c9436a2baa197ef5af460af 100644 (file)
@@ -61,6 +61,8 @@
 #include "wxart_complexbox.xpm"
 #include "wxart_complexinputport.xpm"
 #include "wxart_complexoutputport.xpm"
+#include "wxart_undo.xpm"
+#include "wxart_redo.xpm"
 
 //Includes creaMaracasVisu
 
@@ -134,6 +136,7 @@ namespace bbtk
             void SaveActualComplexBox(std::string filename);
             void SaveActualDiagram(std::string filename);
                        void SaveCurrentDiagramAs( ); //DFCH
+                       void SaveTempActualDiagram();//FCY
 
 
                        // File menu and toolbar events
@@ -154,6 +157,8 @@ namespace bbtk
                        void OnAddComplexBoxOutput(wxCommandEvent& event);
                        void OnExit(wxCommandEvent& event);
                        void OnHelpBBeditor(wxCommandEvent& event);
+                       void OnUndo(wxCommandEvent& event);
+                       void OnRedo(wxCommandEvent& event);
 
                        // Edit menu events
                        void OnCopySelectedToComplexDiagram(wxCommandEvent& event);
index f72d05bb8a8066f5503747c6ac5e8f0ee7bd5944..5ffbdbe68359d58d661c53aa9cbda3cca5f711d7 100644 (file)
@@ -40,9 +40,10 @@ namespace bbtk
 {
        //=========================================================================
 
-       wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(480, 640),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+       wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(480, 640),wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) 
        {
                _model=model;
+               _parent = parent;
                std::string title("BlackBox Editing - ");
                title+=_model->getBBTKPackage();
                title+=":";
@@ -166,7 +167,7 @@ namespace bbtk
                                _model->setValueToInputPort(i,text);
                        }
                }
-
+               _parent->SaveTempActualDiagram();
                Close(true);
        }
 
index 8f3021f002f010a09a2f59d5412069f036192711..be859b614ebc5387be52b39626be5e55fdefe8fd 100644 (file)
@@ -59,8 +59,6 @@ Version:   $Revision$
 #include <iostream>
 
 
-
-
 namespace bbtk
 {
 
@@ -83,7 +81,7 @@ namespace bbtk
        private:
                wxAuiManager *_dialogAUIMgr;
                wxPanel *_panel;
-
+               wxGUIEditorGraphicBBS *_parent;
                std::vector<wxTextCtrl*> _lstValues;
                std::vector<wxStaticText*> _lstTypes;
                std::vector<wxStaticText*> _lstNames;
index cd591b16d36a18a543dc1a82928c583aa0ebd911..bd327721ba3c4e24723805aff9ae0b3f6804b597 100644 (file)
@@ -54,6 +54,7 @@ printf("EED wxGEditorTabPanel::wxGEditorTabPanel 0\n");
                _id=id;
                _panelAUIMgr = new wxAuiManager(this);
                _sceneManager = NULL;
+               _actualdo = states.begin();
                initWxVtkCanvas();
 printf("EED wxGEditorTabPanel::wxGEditorTabPanel 1\n");
        }
@@ -181,12 +182,82 @@ printf("EED wxGEditorTabPanel::initWxVtkCanvas 1\n");
 
        //=========================================================================
 
+       void wxGEditorTabPanel::saveTempDiagram() //FCY
+       {
+               std::string content = "";
+               // writing file header
+               content += "# ----------------------------------\n";
+               content += "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file\n";
+               content += "# - ";
+               content += "temp";
+               content += "\n";
+               content += "# ----------------------------------\n";
+               content += "\n";
+               content += "APP_START\n";
+               _sceneManager->saveDiagram(content);
+               content += "APP_END\n"; //put here to avoid mistakes
+               if(_actualdo == states.end() ) // same size, write to the end
+               {
+                       states.push_back (content);
+               }
+               else
+               {
+                       std::vector<std::string>::iterator it = _actualdo+1;
+                       states.erase(it, states.end());
+                       states.push_back(content);
+               }
+               _actualdo = states.end();
+                       
+       }
+
+       //=========================================================================
+
        void wxGEditorTabPanel::loadDiagram(ifstream &inputStream, const std::string &path) //DFCH
        {
                this->SetFullPath(path);
-               _sceneManager->loadDiagram(inputStream);
+               stringstream ss;
+               ss << inputStream ;
+               _sceneManager->loadDiagram(ss);
        }
 
+       //=========================================================================
+       unsigned short wxGEditorTabPanel::loadTempDiagram(unsigned short un) //FCY
+       {
+               unsigned short res = 1;
+               deleteAllBoxes();
+               std::stringstream ss;
+               if (un == 0) //undo
+               {
+                       if(_actualdo == states.end() ) // same size, write to the end
+                       {
+                               (_actualdo--);
+                       }
+                       if(_actualdo != states.begin() )
+                       {
+                               ss << *(--_actualdo);
+                       }
+                       else
+                       {
+                               ss << *_actualdo;
+                               res = 0;
+                       }
+               }
+               else //redo
+               {
+                       _actualdo++;
+                       if(_actualdo != states.end())
+                       {
+                               ss << *_actualdo;
+                       }
+                       else
+                       {
+                               res = 0;
+                       }
+               }
+               _sceneManager->loadDiagram(ss);
+               return res;
+       }
+       
        //=========================================================================
 
        int wxGEditorTabPanel::getPanelId()
index 402e2a7c0e43e30648f037739c85039046a2e1a6..7a6b39fe21b2a34866a3bd97714bf3908fd5e68b 100644 (file)
@@ -100,9 +100,15 @@ namespace bbtk
                // Save diagram as BBG
                void saveDiagram(std::string &content, const std::string &path); //DFCH
 
+               // Save temporary diagram as BBG
+               void saveTempDiagram();
+
                // Load BBG diagram
                void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH
 
+               // Load temporary diagram as BBG
+               unsigned short  loadTempDiagram(unsigned short un);
+
                // Add a new complex input object to the scene
                void addComplexInputPort(std::string portName);
 
@@ -156,6 +162,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
 
                int                                             _id;
                wxAuiManager                    *_panelAUIMgr;
index f2aa6b03d9f5b89221ca481d073811c77598ec97..2e5c4eedf032c02e7095fefaa886384f93a60ff2 100644 (file)
@@ -143,6 +143,16 @@ printf("EED wxTabPanelsManager::addNewTab 1\n");
        {
                _actual->loadDiagram(inputStream, path);
        }
+       //=========================================================================
+       void wxTabPanelsManager::saveTempActualDiagram() //FCY
+       {
+               _actual->saveTempDiagram();
+       }
+       //=========================================================================
+       unsigned short wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
+       {
+               return _actual->loadTempDiagram(un);
+       }
 
        //=========================================================================
 
index 35618a7cec9c0fe0b79654d3ae27c95e9bc5cbd8..bf617e3369a467d3a1a29ffdea47970028349099 100644 (file)
@@ -86,6 +86,9 @@ namespace bbtk
                void centerViewActualDiagram();
                void saveActualDiagram(std::string &content, const std::string &path); //DFCH
                void loadDiagram(ifstream &inputStream, const std::string &path); //DFCH
+
+               void saveTempActualDiagram(); //FCY
+               unsigned short loadTempDiagram(unsigned short un); //FCY
                bool isActualDiagramComplexBox();
                void setActualDiagramComplexBox(bool val);
                void addActualDiagramComplexInputPort(std::string portName);
index b080d31f1933b9544d03025e4e07760b8579206f..645d959e12e38b7e2dcbe18bd699ecb206bb2772 100644 (file)
@@ -685,6 +685,7 @@ void wxVtkSceneManager::update(int idController, int command) {
                        if (finPort->getGObjectType() == GPORT) {
                                GPortModel* modelPort = (GPortModel*) finPort->getModel();
                                modelContour->setEndPort(modelPort);
+                               _parent->saveTempDiagram();
                        }
 
                        manualConnectorContourController
@@ -819,6 +820,7 @@ bool wxVtkSceneManager::OnLeftButtonDown() {
                        CancelConnection();
                        UnSelectBlackBoxes();
                } // isOverPort
+       
 
        } else { //_worldState
 
@@ -845,7 +847,7 @@ bool wxVtkSceneManager::OnLeftButtonDown() {
                        cont->getView()->setState(DRAG);
                        cont->getModel()->notifyObservers(_idManager);
                } // for
-
+               
        } // if _selectedObjects.size
 
 
@@ -1104,6 +1106,7 @@ void wxVtkSceneManager::deleteObject(int id) {
                        _controllers.erase(it);
                }//if
        }// for
+       _parent->saveTempDiagram();
 }
 
 //=========================================================================
@@ -1641,12 +1644,13 @@ void wxVtkSceneManager::saveDiagram(std::string &content) {
 
 //=========================================================================
 
-void wxVtkSceneManager::loadDiagram(ifstream &inputStream) {
+void wxVtkSceneManager::loadDiagram(stringstream &inputStream) {
 
        std::string version = "<void>";
        std::string line = "";
        char delims[] = ":";
        char *result = NULL;
+
        getline(inputStream, line);
 
        bool start = false;
index 12c4fc4a31a3c9ff304dae64fc4b9709dbbd7808..3fb4c0be6f3747619c709e85f9c0652d3d37c613 100644 (file)
@@ -82,6 +82,8 @@ Version:   $Revision$
 
 //Includes std
 #include <iostream>
+#include <string>
+#include <sstream>
 #include <map>
 
 namespace bbtk
@@ -182,7 +184,7 @@ namespace bbtk
                void saveDiagram(std::string &content);
 
                //Load the diagram
-               void loadDiagram(ifstream &inputStream);
+               void loadDiagram(std::stringstream &inputStream);
 
                //Center the view of the camera in the initial position
                void centerView();