--- /dev/null
+/* XPM */
+static const char *open_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 36 1",
+"6 c #9BACC2",
+"< c #9AEA53",
+"9 c #94A5BD",
+"5 c #839CB5",
+"; c #4D7492",
+". c #376485",
+"$ c #7F99B4",
+"r c #D1D9E5",
+"7 c #EAEDF3",
+"@ c #CAD2DC",
+"% c #718BA7",
+"t c #BECAD9",
+"& c #65839D",
+"0 c #DCE2EA",
+"4 c #F5F6F7",
+"w c #597B9A",
+"O c #8DA0B9",
+" c None",
+"+ c #467291",
+"u c #305F81",
+"= c #B4C4D3",
+"# c #CAE2AA",
+"1 c #FAFCFE",
+"3 c #A8B6CA",
+"q c #E4E9ED",
+"8 c #EEF1F3",
+"X c #215579",
+"2 c #7F97B0",
+": c #B3BFD1",
+"y c #7A90AC",
+", c #C2CBDB",
+"- c #ADD668",
+"* c #B6D791",
+"e c #CAD6E1",
+"o c #DFF0D0",
+"> c #BBC4D6",
+/* pixels */
+" ",
+" .... ",
+"XXXXX .oo. ",
+"XOOOO+@.#o. ",
+"XOOOO$%&.*oXXX ",
+"XOOOOOOO.*oX=X ",
+"XOXXXX...-oXXXX;",
+"XOX:>,.<<<<<oX1;",
+"X2X3:>,.<<<oX4=;",
+"XX563:>>.<oX78; ",
+"XXO963:>>.X0q7; ",
+"Xw2O963:>>er0t; ",
+"X&y2O963:>,er; ",
+"uXXXXXXXXXXXX; ",
+" "
+};
namespace bbtk
{
-
-
//=========================================================================
+
GBlackBoxModel::GBlackBoxModel()
{
_isExecutable = false;
}
//=========================================================================
+
GBlackBoxModel::~GBlackBoxModel()
{
}
+
//=========================================================================
void GBlackBoxModel::setInicPoint(double& x, double& y, double& z)
//=========================================================================
+ void GBlackBoxModel::save(std::string &content)
+ {
+ content+="BOX\n";
+ // Box info
+ content+=_bbtkPackage;
+ content+=":";
+ content+=_bbtkType;
+ content+=":";
+ content+=_bbtkName;
+ content+="\n";
+
+ //Box Position
+ char buffer [50];
+ sprintf (buffer, "%f", _xInic);
+ content+=buffer;
+ content+=":";
+ sprintf (buffer, "%f", _yInic);
+ content+=buffer;
+ content+=":";
+ sprintf (buffer, "%f", _zInic);
+ content+=buffer;
+ content+="\n";
+
+ sprintf (buffer, "%f", _xFin);
+ content+=buffer;
+ content+=":";
+ sprintf (buffer, "%f", _yFin);
+ content+=buffer;
+ content+=":";
+ sprintf (buffer, "%f", _zFin);
+ content+=buffer;
+ content+="\n";
+
+ //Ports with a value
+ for(int i = 0; i<_inputs.size();i++)
+ {
+ if(_inputs[i]->isValueSet())
+ {
+ _inputs[i]->save(content);
+ }
+ }
+
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
void setBBTKPackage(std::string obpackage);
virtual std::string getStatusText();
+ virtual void save(std::string &content);
bool isExecutable();
void setExecutable(bool executable);
return false;
}
+ //=========================================================================
+
+ void GConnectorModel::save(std::string &content)
+ {
+ content+="CONNECTION\n";
+
+ // Connection info
+ content+=_startPort->getParentBox()->getBBTKName();
+ content+=".";
+ content+=_startPort->getBBTKName();
+ content+=":";
+ content+=_endPort->getParentBox()->getBBTKName();
+ content+=".";
+ content+=_endPort->getBBTKName();
+ content+="\n";
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
void updateStartEndPoints();
void disconnectConnection();
virtual bool isPointInside(double x,double y, double z);
+ virtual void save(std::string &content);
private:
_objectId=id;
}
+ //=========================================================================
+
+ void GObjectModel::save(std::string &content)
+ {
+ //virtual
+ }
+
+ //=========================================================================
} // EO namespace bbtk
void setObjectId(int id);
virtual std::string getStatusText();
+ virtual void save(std::string &content);
private:
}
//Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right
- posX = xInic + PORT_WIDTH + _posInBox*2*PORT_WIDTH;
+ posX = xInic + (PORT_WIDTH/2) + _posInBox*1.6*PORT_WIDTH;
setInicPoint(posX,posY,posZ);
//=========================================================================
+ void GPortModel::save(std::string &content)
+ {
+ content+="PORT\n";
+
+ // Port value info
+ content+=_bbtkName;
+ content+=":";
+ content+=_value;
+ content+="\n";
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
bool isValueSet();
void setValue(std::string value);
std::string getValue();
+ virtual void save(std::string &content);
private:
const double BOXTEXT_SELECTED_B=0.05;
// Id's
+ const int ID_NEW = 1000;
+ const int ID_SAVE = 1001;
+ const int ID_OPEN = 1002;
+ const int ID_RUN = 1003;
+ const int ID_DELETEALL = 1004;
+ const int ID_CENTERVIEW = 1005;
}
// namespace bbtk
#endif
//=========================================================================
+ void wxVtkSceneManager::saveDiagram(std::string &content)
+ {
+ //Print boxes
+ char buffer [50];
+ std::vector<int> boxes = getBoxes();
+ int bsize = boxes.size();
+ content+="BOXES ";
+ sprintf (buffer, "%d", bsize);
+ content+=buffer;
+ content+="\n";
+
+ for(int i = 0;i<bsize;i++)
+ {
+ int id = boxes[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+
+ content+="\n";
+
+ //Print connections
+ std::vector<int> connections = getConnections();
+ int csize = connections.size();
+ content+="CONNECTIONS ";
+ sprintf (buffer, "%d", csize);
+ content+=buffer;
+ content+="\n";
+
+ for(int i = 0;i<csize;i++)
+ {
+ int id = connections[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+
+ }
+
+ //=========================================================================
+
+ std::vector<int> wxVtkSceneManager::getBoxes()
+ {
+ std::vector<int> vect;
+ std::map<int, GObjectController*>::iterator it;
+ for(it = _controllers.begin(); it != _controllers.end(); ++it)
+ {
+ GObjectController *cont = it->second;
+ if(cont->getGObjectType()==GBLACKBOX)
+ {
+ vect.push_back(cont->getId());
+ }
+ }
+ return vect;
+ }
+
+ //=========================================================================
+
+ std::vector<int> wxVtkSceneManager::getConnections()
+ {
+ std::vector<int> vect;
+ std::map<int, GObjectController*>::iterator it;
+ for(it = _controllers.begin(); it != _controllers.end(); ++it)
+ {
+ GObjectController *cont = it->second;
+ if(cont->getGObjectType()==GCONNECTOR)
+ {
+ vect.push_back(cont->getId());
+ }
+ }
+ return vect;
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
std::string getDiagramScript();
void deleteObject(int id);
void deleteAllBoxes();
-
+ void saveDiagram(std::string &content);
void centerView();
void refreshScene();
+ std::vector<int> getBoxes();
+ std::vector<int> getConnections();
private:
void wxGUIEditorGraphicBBS::initToolbar()
{
wxBitmap bmp_new(new_xpm);
+ wxBitmap bmp_open(open_xpm);
wxBitmap bmp_save(save_xpm);
wxBitmap bmp_run(run_xpm);
wxBitmap bmp_delete(delete_xpm);
wxToolBar *_toolbar = new wxToolBar(this, wxID_ANY);
//Adds a tool btn to the toolbar
- _toolbar->AddTool(1000,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
- _toolbar->AddTool(1001,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
- _toolbar->AddTool(1002,_T("Execute"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
- _toolbar->AddTool(1003,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
- _toolbar->AddTool(1004,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
+ _toolbar->AddTool(ID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
+ _toolbar->AddTool(ID_OPEN,_T("Open diagram"),bmp_open, wxNullBitmap, wxITEM_NORMAL,_T("Open a diagram"), _T("Open a diagram"));
+ _toolbar->AddTool(ID_SAVE,_T("Save diagram"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves actual diagram"), _T("Saves actual diagram"));
+ _toolbar->AddTool(ID_RUN,_T("Run"),bmp_run, wxNullBitmap, wxITEM_NORMAL,_T("Execute actual diagram"), _T("Execute actual diagram"));
+ _toolbar->AddTool(ID_DELETEALL,_T("Delete all"),bmp_delete, wxNullBitmap, wxITEM_NORMAL,_T("Delete all boxes"), _T("Delete all boxes"));
+ _toolbar->AddTool(ID_CENTERVIEW,_T("Center view"),bmp_centerview, wxNullBitmap, wxITEM_NORMAL,_T("Center view"), _T("Center view"));
_toolbar->SetMargins( 2, 2 );
SetToolBar(_toolbar);
// connect command event handlers
- Connect(1000,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
- Connect(1001,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
- Connect(1002,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
- Connect(1003,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
- Connect(1004,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
+ Connect(ID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
+ Connect(ID_OPEN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
+ Connect(ID_SAVE,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram));
+ Connect(ID_RUN,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
+ Connect(ID_DELETEALL,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
+ Connect(ID_CENTERVIEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
}
//=========================================================================
/*****************************************************/
void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event)
{
+ wxFileDialog * openFileDialog = new wxFileDialog(this,wxT("Save actual diagram"),wxEmptyString,"NewDiagram","*.bbd",wxSAVE|wxOVERWRITE_PROMPT);
+ if (openFileDialog->ShowModal() == wxID_OK)
+ {
+ wxString fileName = openFileDialog->GetPath();
+
+ ofstream file;
+ file.open(fileName.c_str());
+
+ std::string content="";
+
+ // writing file header
+ content += "# ----------------------------------\n";
+ content += "# - BBTKGEditor v 1.0 Diagram file\n";
+ content += "# - ";
+ content += fileName;
+ content += "\n";
+ content += "# ----------------------------------\n";
+ content += "\n";
+
+ _tabsMgr->saveActualDiagram(content);
+ file << content;
+ file.close();
+ wxMessageDialog *dial = new wxMessageDialog(NULL, wxT(" Diagram successfully saved!! "), wxT("Saved!!"), wxOK);
+ dial->ShowModal();
+
+ }
+
}
//=========================================================================
//=========================================================================
+
+ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
+ {
+ cout<<"RaC wxGUIEditorGraphicBBS::OnOpenDiagram "<<endl;
+ }
+
+ //=========================================================================
+
void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
{
Close(true);
}
-
+ //=========================================================================
} // EO namespace bbtk
//#include "C:\RaC\CREATIS\bbtkGEditor\data\icons\wxart_new.xpm" // JPR
#include "wxart_new.xpm" // JPR
+#include "wxart_open.xpm"
#include "wxart_save.xpm"
#include "wxart_run.xpm"
#include "wxart_delete.xpm"
void DoRegenerateBoxesLists();
void OnCreateNewTab(wxCommandEvent& event);
+ void OnOpenDiagram(wxCommandEvent& event);
void OnSaveActualDiagram(wxCommandEvent& event);
void OnExecuteActualDiagram(wxCommandEvent& event);
void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event);
}
//=========================================================================
+
+ void wxGEditorTabPanel::saveDiagram(std::string &content)
+ {
+ _sceneManager->saveDiagram(content);
+ }
+
+ //=========================================================================
} // EO namespace bbtk
void editDiagramParameters(wxVtkSceneManager* scene);
void deleteAllBoxes();
void centerView();
+ void saveDiagram(std::string &content);
//=========================================================================
//=========================================================================
+ void wxTabPanelsManager::saveActualDiagram(std::string &content)
+ {
+ _actual->saveDiagram(content);
+ }
+
+ //=========================================================================
+
} // EO namespace bbtk
// EOF
void editDiagramParameters(wxVtkSceneManager* scene);
void deleteAllBoxesActualDiagram();
void centerViewActualDiagram();
+ void saveActualDiagram(std::string &content);
private: