X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGConnectorModel.cxx;h=7be647f13f8797d20cb12d80de3a43e72434d3f6;hb=8d5cce101d80ada2ddc1db310c59574c7b3b5a06;hp=58f601bd1baabaff5b15955351e85b73eeb876b8;hpb=eaf825847b9ac4bd762deafa59a7df1c2ceba433;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index 58f601b..7be647f 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -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,9 +82,9 @@ 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); - cout<<"RaC GConnectorModel::setEndPort size:"<<_model->GetSizeLstPoints()<getCenter(xCenter,yCenter,zCenter); + 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,yport,zCenter); + + //End Point + _endPort->getCenter(xCenter,yCenter,zCenter); + _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,yport,zCenter); + + } + + //========================================================================= + + void GConnectorModel::disconnectConnection() + { + if(_startPort!=NULL) + { + _startPort->setConnected(false); + } + + if(_endPort!=NULL) + { + _endPort->setConnected(false); + } + } + + //========================================================================= + + void GConnectorModel::save(std::string &content) + { + char buffer[50]; + + content+="CONNECTION\n"; + + // Connection info + content+=_startPort->getParentBox()->getBBTKName(); + content+=":"; + content+=_startPort->getBBTKName(); + content+=":"; + content+=_endPort->getParentBox()->getBBTKName(); + content+=":"; + content+=_endPort->getBBTKName(); + content+="\n"; + + int i,sizeLstPoints = _model->GetSizeLstPoints()-2; + content+="NumberOfControlPoints:"; + sprintf (buffer, "%d", sizeLstPoints ); + content+=buffer; + content+="\n"; + + for (i=0;iGetManualPoint(i+1); + sprintf (buffer, "%f:%f:%f\n", (float)mp->GetX(),(float)mp->GetY(),(float)mp->GetZ() ); + content+=buffer; + } + } + + //========================================================================= + } // EO namespace bbtk // EOF