]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
no message
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GConnectorModel.cxx
index f4ba5f4e1ceb9f46fb5a036002b6d3da3ecb5041..ebdf3715aeb5d46cc7854e77ed81c671fb2ded28 100644 (file)
@@ -43,8 +43,8 @@ namespace bbtk
 
        GConnectorModel::GConnectorModel()
        {               
-               //_startPort = NULL;
-               //_endPort = NULL;
+               _startPort = NULL;
+               _endPort = NULL;
        }
 
        //=========================================================================
@@ -58,6 +58,7 @@ namespace bbtk
        void GConnectorModel::setStartPort(GPortModel* startPort)
        {
                _startPort = startPort;
+               startPort->setConnected(true);
                
                double xCenter,yCenter,zCenter;
                startPort->getCenter(xCenter,yCenter,zCenter);
@@ -72,6 +73,7 @@ namespace bbtk
        void GConnectorModel::setEndPort(GPortModel* endPort)
        {
                _endPort = endPort;
+               endPort->setConnected(true);
 
                double xCenter,yCenter,zCenter;         
                endPort->getCenter(xCenter,yCenter,zCenter);
@@ -80,6 +82,7 @@ namespace bbtk
 
                setFinalPoint(xCenter,yIport,zCenter);
 
+               // Sets the last point of the contour model in the position of the end input port
                manualPoint* point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
                point->SetPoint(xCenter,yIport,zCenter);
        }
@@ -119,20 +122,56 @@ namespace bbtk
                //Start Point
                double xCenter,yCenter,zCenter;         
                _startPort->getCenter(xCenter,yCenter,zCenter);
-               double xIport,yIport,zIport;
-               _startPort->getInicPoint(xIport,yIport,zIport);
+               double xport,yport,zport;
+               _startPort->getFinalPoint(xport,yport,zport);
 
+               // Refresh the position of the contourModel first point with the data of the connector model
                manualPoint* point = _model->GetManualPoint(0);
-               point->SetPoint(xCenter,yIport,zCenter);
+               point->SetPoint(xCenter,yport,zCenter);
 
                //End Point     
                _endPort->getCenter(xCenter,yCenter,zCenter);
-               _endPort->getInicPoint(xIport,yIport,zIport);
+               _endPort->getInicPoint(xport,yport,zport);
 
+               // Refresh the position of the contourModel last point with the data of the connector model
                point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
-               point->SetPoint(xCenter,yIport,zCenter);
+               point->SetPoint(xCenter,yport,zCenter);
+       }
+
+       //=========================================================================
+
+       void GConnectorModel::disconnectConnection()
+       {
+               if(_startPort!=NULL)
+               {
+                       _startPort->setConnected(false);                        
+               }
+
+               if(_endPort!=NULL)
+               {
+                       _endPort->setConnected(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