From fea0c6ff7e209a7bb61bcc8176742e5f1a609443 Mon Sep 17 00:00:00 2001 From: cervenansky <> Date: Tue, 22 May 2012 15:13:37 +0000 Subject: [PATCH] Feature #1347 --- appli/bbEditor/CMakeLists.txt | 6 +- data/icons/wxart_redo.xpm | 104 ++++++++++++++++++ data/icons/wxart_undo.xpm | 104 ++++++++++++++++++ .../bbsKernelEditorGraphic/GlobalConstants.h | 2 + .../GBlackBoxController.cxx | 3 + .../bbsVtkGUIEditorGraphic/GBoxController.cxx | 3 + .../GConnectorController.cxx | 3 + .../GConnectorController.h | 1 + .../GObjectController.cxx | 5 +- .../vtkGBlackBoxView.cxx | 9 +- .../bbsWxGUIEditorGraphic/CMakeLists.txt | 2 +- .../GObjectsMVCFactory.h | 1 - .../bbsWxGUIEditorGraphic/InterpreterBBS.cxx | 2 - .../bbtkwxGUIEditorGraphicBBS.cxx | 48 +++++++- .../bbtkwxGUIEditorGraphicBBS.h | 5 + .../wxBlackBoxEditionDialog.cxx | 5 +- .../wxBlackBoxEditionDialog.h | 4 +- .../wxGEditorTabPanel.cxx | 73 +++++++++++- .../bbsWxGUIEditorGraphic/wxGEditorTabPanel.h | 8 ++ .../wxTabPanelsManager.cxx | 10 ++ .../wxTabPanelsManager.h | 3 + .../wxVtkSceneManager.cxx | 8 +- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 4 +- 23 files changed, 391 insertions(+), 22 deletions(-) create mode 100644 data/icons/wxart_redo.xpm create mode 100644 data/icons/wxart_undo.xpm diff --git a/appli/bbEditor/CMakeLists.txt b/appli/bbEditor/CMakeLists.txt index d4966aa..4db7bcd 100644 --- a/appli/bbEditor/CMakeLists.txt +++ b/appli/bbEditor/CMakeLists.txt @@ -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 index 0000000..1ce8803 --- /dev/null +++ b/data/icons/wxart_redo.xpm @@ -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 index 0000000..35b01e7 --- /dev/null +++ b/data/icons/wxart_undo.xpm @@ -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 ", +" "}; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index a63a813..5765f92 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -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 diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index 0480ece..bdec8ae 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -36,6 +36,9 @@ Version: $Revision$ #include "GBlackBoxController.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx index 52e80a2..b0175e6 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx @@ -36,6 +36,9 @@ Version: $Revision$ #include "GBoxController.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx index ce8717a..40a1a34 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx @@ -36,6 +36,9 @@ Version: $Revision$ #include "GConnectorController.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#endif namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h index 679c3ce..52badfe 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.h @@ -56,6 +56,7 @@ Version: $Revision$ #include + namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx index 43f57c7..745cbf2 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx @@ -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; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index ea07a9a..0eec429 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -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(); //------------ diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/CMakeLists.txt b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/CMakeLists.txt index 741c06e..657caa3 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/CMakeLists.txt +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/CMakeLists.txt @@ -11,4 +11,4 @@ INCLUDE_DIRECTORIES(../../../data/icons) ADD_LIBRARY(bbsWxGUIEditorGraphic ${bbsWxGUIEditorGraphic_CXX_SOURCES} - ${bbsWxGUIEditorGraphic_H_SOURCES} ) + ${bbsWxGUIEditorGraphic_H_SOURCES} ) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/GObjectsMVCFactory.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/GObjectsMVCFactory.h index b7459dd..099e7a6 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/GObjectsMVCFactory.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/GObjectsMVCFactory.h @@ -73,7 +73,6 @@ Version: $Revision$ #include #include #include - namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx index 9604f18..3bd1dcf 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/InterpreterBBS.cxx @@ -41,8 +41,6 @@ Version: $Revision$ #include "bbtkFactory.h" #include "bbtkUtilities.h" - - namespace bbtk { diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index e76f8bc..fd7fa65 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -36,6 +36,7 @@ #include "bbtkwxGUIEditorGraphicBBS.h" #include "creaWx.h" #include "creaSystem.h" +#include #include @@ -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 } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h index 3a4df85..2afb269 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h @@ -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); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx index f72d05b..5ffbdbe 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx @@ -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); } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.h index 8f3021f..be859b6 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.h @@ -59,8 +59,6 @@ Version: $Revision$ #include - - namespace bbtk { @@ -83,7 +81,7 @@ namespace bbtk private: wxAuiManager *_dialogAUIMgr; wxPanel *_panel; - + wxGUIEditorGraphicBBS *_parent; std::vector _lstValues; std::vector _lstTypes; std::vector _lstNames; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx index cd591b1..bd32772 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx @@ -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::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() diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h index 402e2a7..7a6b39f 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h @@ -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 states; // represents each modification of the tab. Maxixum size 100!! + std::vector::iterator _actualdo; // actual position on modifications vector int _id; wxAuiManager *_panelAUIMgr; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index f2aa6b0..2e5c4ee 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -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); + } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h index 35618a7..bf617e3 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h @@ -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); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index b080d31..645d959 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -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 = ""; std::string line = ""; char delims[] = ":"; char *result = NULL; + getline(inputStream, line); bool start = false; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 12c4fc4..3fb4c0b 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -82,6 +82,8 @@ Version: $Revision$ //Includes std #include +#include +#include #include 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(); -- 2.47.1