]> Creatis software - bbtkGEditor.git/commitdiff
It saves the diagram and it was added the icon to open a file ..... Now it is necessa...
authorcorredor <>
Thu, 6 May 2010 15:14:46 +0000 (15:14 +0000)
committercorredor <>
Thu, 6 May 2010 15:14:46 +0000 (15:14 +0000)
18 files changed:
data/icons/wxart_open.xpm [new file with mode: 0644]
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h

diff --git a/data/icons/wxart_open.xpm b/data/icons/wxart_open.xpm
new file mode 100644 (file)
index 0000000..e2bd507
--- /dev/null
@@ -0,0 +1,57 @@
+/* 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;  ",
+"                "
+};
index c7778f3667705f21563641cc50a613daae6e6aeb..7c7bebbcd3da6bde6dc992a7cbbe8b621f80b987 100644 (file)
@@ -38,18 +38,19 @@ Version:   $Revision$
 
 namespace bbtk
 {
-
-
        //=========================================================================
+
        GBlackBoxModel::GBlackBoxModel()
        {               
                _isExecutable = false;
        }
 
        //=========================================================================
+
        GBlackBoxModel::~GBlackBoxModel()
        {
        }
+
        //=========================================================================
 
        void GBlackBoxModel::setInicPoint(double& x, double& y, double& z)
@@ -174,6 +175,52 @@ namespace bbtk
 
        //=========================================================================     
 
+       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
 
index c766dba08a26d75bcad5c949dd9213d80010ac24..de8b7084137b1d03f4d2acf324b8e0b52eea9e00 100644 (file)
@@ -81,6 +81,7 @@ namespace bbtk
                void setBBTKPackage(std::string obpackage);
 
                virtual std::string getStatusText();
+               virtual void save(std::string &content);
 
                bool isExecutable();
                void setExecutable(bool executable);
index bd4ecf38c9fb01d79c5b604f0b996b3198aa32ca..28df0dd0f7b2fed660c102bfc5e3f58a4fe93a90 100644 (file)
@@ -157,6 +157,25 @@ namespace bbtk
                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
index 9e7d7f71d878200a96068083b0b67778d95296fe..d590b849aae30daf7553a206b15ca8ad2a35466d 100644 (file)
@@ -78,6 +78,7 @@ namespace bbtk
                void updateStartEndPoints();
                void disconnectConnection();
                virtual bool isPointInside(double x,double y, double z);
+               virtual void save(std::string &content);
                
        private:
 
index e4710a2e30ad3efc0e97aa424172c8916c873b19..125512896f7731c2b5f165092e5e68358b8c9402 100644 (file)
@@ -188,6 +188,14 @@ namespace bbtk
                _objectId=id;
        }
 
+       //=========================================================================
+
+       void GObjectModel::save(std::string &content)
+       {
+               //virtual
+       }
+       
+       //=========================================================================
 
 }  // EO namespace bbtk
 
index a6300386d4986ac813f46198ed41624775a82abb..d13b4593877ccaf764426e4d57e1a92b056f5022 100644 (file)
@@ -93,6 +93,7 @@ namespace bbtk
                void setObjectId(int id);
 
                virtual std::string getStatusText();
+               virtual void save(std::string &content);
                
        private:
 
index 326cbe2975f159b6d5c3f2d58ca0136da5065000..200a5f4b278d91ec1316fc04da66500b4b2083ca 100644 (file)
@@ -86,7 +86,7 @@ namespace bbtk
                }
 
                //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);
 
@@ -177,6 +177,19 @@ namespace bbtk
 
        //=========================================================================
 
+       void GPortModel::save(std::string &content)
+       {
+               content+="PORT\n";
+
+               // Port value info
+               content+=_bbtkName;
+               content+=":";
+               content+=_value;
+               content+="\n";
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 3d6c497b00eaf341bc4967e7c68d3ac92e977081..6b5d7723d00758e6ea93d410ddf969bd68300381 100644 (file)
@@ -79,6 +79,7 @@ namespace bbtk
                bool isValueSet();
                void setValue(std::string value);
                std::string getValue();
+               virtual void save(std::string &content);
 
        private:
 
index f9319af848bf0a5e6ab194cc7ae375436217f85d..7949d5bab16a1588e2fadb2fced661915a609fd4 100644 (file)
@@ -132,6 +132,12 @@ namespace bbtk
        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
index 41f2fd5b409f621812ce1f91e5eda5a22ee406f3..2227c9003b5245407b07340d5be07c8808aaadb7 100644 (file)
@@ -967,6 +967,79 @@ namespace bbtk
 
        //=========================================================================
 
+       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
index d789c7ad014733fa8e3e66925484e0eb4ec56541..1cee565cc6e8f518b6968e8ed1b39f2156389707 100644 (file)
@@ -117,10 +117,12 @@ namespace bbtk
                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:
index abda87988d64a489e8e8b3b889f11e3a1f9899e3..069b66dc5d57151be5233a9294948547f19fb761 100644 (file)
@@ -86,6 +86,7 @@ namespace bbtk
        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);
@@ -94,11 +95,12 @@ namespace bbtk
                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 );
@@ -106,11 +108,12 @@ namespace bbtk
                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));
 
        }
        //=========================================================================
@@ -367,7 +370,34 @@ namespace bbtk
        /*****************************************************/
        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();
+
+               }
+
        }
 
        //=========================================================================
@@ -390,12 +420,20 @@ namespace bbtk
 
        //=========================================================================
 
+       
+       void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event)
+       {
+               cout<<"RaC wxGUIEditorGraphicBBS::OnOpenDiagram "<<endl;
+       }
+
+       //=========================================================================
+
        void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
        {
                Close(true);
        }
 
-
+       //=========================================================================
 
 }  // EO namespace bbtk
 
index f6d6971d75a8c0386f1be37242c621aeafe7d2ef..b54d8ab202d94afdf2f0e6d46ed926066231eade 100644 (file)
@@ -50,6 +50,7 @@
 
 //#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"
@@ -111,6 +112,7 @@ namespace bbtk
                void DoRegenerateBoxesLists();
 
                void OnCreateNewTab(wxCommandEvent& event);
+               void OnOpenDiagram(wxCommandEvent& event);
                void OnSaveActualDiagram(wxCommandEvent& event);
                void OnExecuteActualDiagram(wxCommandEvent& event);
                void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event);
index 97a3d3abc45cd02e31d9e5e224f04fb96707c1d9..a82b584fb34160f05bda958c80e3aeb9026de026 100644 (file)
@@ -153,6 +153,13 @@ namespace bbtk
        }
 
        //=========================================================================
+       
+       void wxGEditorTabPanel::saveDiagram(std::string &content)
+       {
+               _sceneManager->saveDiagram(content);
+       }
+
+       //=========================================================================
 
 }  // EO namespace bbtk
 
index 3f6e69930439b10ca8e9d65b2f5342e71d322f4e..8ac5648f8d0525707000ffd9b66997c26d43e6d2 100644 (file)
@@ -86,6 +86,7 @@ namespace bbtk
                void editDiagramParameters(wxVtkSceneManager* scene);
                void deleteAllBoxes();
                void centerView();
+               void saveDiagram(std::string &content);
 
        //=========================================================================
                
index e6c91c19c98fe66b222517e0755da3be5189e2e8..b626f4bc69cc6fbbc58a60d8c1a7fe7275a2c006 100644 (file)
@@ -131,6 +131,13 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxTabPanelsManager::saveActualDiagram(std::string &content)
+       {
+               _actual->saveDiagram(content);
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 05b8b7c3c797845d76a233522c96993c97c1206b..ce207f40ef5df8f0f37132d08da21fe3e33daad0 100644 (file)
@@ -79,6 +79,7 @@ namespace bbtk
                void editDiagramParameters(wxVtkSceneManager* scene);
                void deleteAllBoxesActualDiagram();
                void centerViewActualDiagram();
+               void saveActualDiagram(std::string &content);
 
        private: