]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
It saves the diagram and it was added the icon to open a file ..... Now it is necessa...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / wxVtkSceneManager.cxx
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