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}
)
--- /dev/null
+/* 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 ",
+" "};
--- /dev/null
+/* 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 ",
+" "};
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
#include "GBlackBoxController.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace bbtk
{
#include "GBoxController.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace bbtk
{
#include "GConnectorController.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace bbtk
{
#include <iostream>
+
namespace bbtk
{
#include "GObjectController.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
namespace bbtk
{
}
}
- _model->notifyObservers(getId());
+ //_model->notifyObservers(getId());
return true;
//------------
_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();
//------------
ADD_LIBRARY(bbsWxGUIEditorGraphic
${bbsWxGUIEditorGraphic_CXX_SOURCES}
- ${bbsWxGUIEditorGraphic_H_SOURCES} )
+ ${bbsWxGUIEditorGraphic_H_SOURCES} )
#include <bbtkInterpreter.h>
#include <bbtkFactory.h>
#include <bbtkPackage.h>
-
namespace bbtk
{
#include "bbtkFactory.h"
#include "bbtkUtilities.h"
-
-
namespace bbtk
{
#include "bbtkwxGUIEditorGraphicBBS.h"
#include "creaWx.h"
#include "creaSystem.h"
+#include <wx/defs.h>
#include <InterpreterBBS.h>
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
_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));
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));
}
//=========================================================================
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) {
file.close();
}
+//=========================================================================
+void wxGUIEditorGraphicBBS::SaveTempActualDiagram()
+{
+ _tabsMgr->saveTempActualDiagram();
+}
+
//=========================================================================
//The following method allows to save the current diagram asking the filename
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
}
#include "wxart_complexbox.xpm"
#include "wxart_complexinputport.xpm"
#include "wxart_complexoutputport.xpm"
+#include "wxart_undo.xpm"
+#include "wxart_redo.xpm"
//Includes creaMaracasVisu
void SaveActualComplexBox(std::string filename);
void SaveActualDiagram(std::string filename);
void SaveCurrentDiagramAs( ); //DFCH
+ void SaveTempActualDiagram();//FCY
// File menu and toolbar events
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);
{
//=========================================================================
- 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+=":";
_model->setValueToInputPort(i,text);
}
}
-
+ _parent->SaveTempActualDiagram();
Close(true);
}
#include <iostream>
-
-
namespace bbtk
{
private:
wxAuiManager *_dialogAUIMgr;
wxPanel *_panel;
-
+ wxGUIEditorGraphicBBS *_parent;
std::vector<wxTextCtrl*> _lstValues;
std::vector<wxStaticText*> _lstTypes;
std::vector<wxStaticText*> _lstNames;
_id=id;
_panelAUIMgr = new wxAuiManager(this);
_sceneManager = NULL;
+ _actualdo = states.begin();
initWxVtkCanvas();
printf("EED wxGEditorTabPanel::wxGEditorTabPanel 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()
// 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);
//=========================================================================
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;
{
_actual->loadDiagram(inputStream, path);
}
+ //=========================================================================
+ void wxTabPanelsManager::saveTempActualDiagram() //FCY
+ {
+ _actual->saveTempDiagram();
+ }
+ //=========================================================================
+ unsigned short wxTabPanelsManager::loadTempDiagram(unsigned short un) //FCY
+ {
+ return _actual->loadTempDiagram(un);
+ }
//=========================================================================
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);
if (finPort->getGObjectType() == GPORT) {
GPortModel* modelPort = (GPortModel*) finPort->getModel();
modelContour->setEndPort(modelPort);
+ _parent->saveTempDiagram();
}
manualConnectorContourController
CancelConnection();
UnSelectBlackBoxes();
} // isOverPort
+
} else { //_worldState
cont->getView()->setState(DRAG);
cont->getModel()->notifyObservers(_idManager);
} // for
-
+
} // if _selectedObjects.size
_controllers.erase(it);
}//if
}// for
+ _parent->saveTempDiagram();
}
//=========================================================================
//=========================================================================
-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;
//Includes std
#include <iostream>
+#include <string>
+#include <sstream>
#include <map>
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();