X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGConnectorModel.cxx;h=2956f0dc383fc7ea07a17502f2a1d53488e839be;hb=refs%2Ftags%2FCreatools2-0-3_bbGEditor1-0-0_17Feb2011;hp=eed5e18f79db27d5790590b90934da68a59a666e;hpb=a4190a7eed1e2336d333d226b4982b067608bf67;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index eed5e18..2956f0d 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,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); } @@ -122,6 +125,7 @@ namespace bbtk 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); @@ -129,10 +133,60 @@ namespace bbtk _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