X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGConnectorModel.cxx;h=d76d7fe4870a3fa5bf3879ae01c9aba5f067f563;hb=de7c0454ab8fc1b0b97dcd7112dfdb4a55ac0215;hp=95f1b15e8d0bc96e3cef9cce381f4e8ee66f9f48;hpb=062ee1e352a911991a120c5bf95ba836a6b0871b;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index 95f1b15..d76d7fe 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -82,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); } @@ -118,23 +119,110 @@ namespace bbtk void GConnectorModel::updateStartEndPoints() { + + //back point + double bsx,bsy; // back start for x and y + double nsx,nsy; + double bex,bey; // new start for x and y + double nex,ney; + //Start Point double xCenter,yCenter,zCenter; _startPort->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); + bsx=point->GetX(); + bsy=point->GetY(); point->SetPoint(xCenter,yport,zCenter); - + nsx=xCenter; + nsy=yport; + //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); + bex=point->GetX(); + bey=point->GetY(); point->SetPoint(xCenter,yport,zCenter); + nex=xCenter; + ney=yport; + + + // moving point of the spline connection + if ( ((bsx!=nsx)&&(bex!=nex)) || ((bsy!=nsy)&&(bey!=ney)) ) + { + double difx=bsx-nsx; + double dify=bey-ney; + double tmpX, tmpY, tmpZ; + int i,size=_model->GetSizeLstPoints(); + if (size>2) + { + for (i=1;iGetManualPoint(i); + tmpX = point->GetX(); + tmpY = point->GetY(); + tmpZ = point->GetZ(); + point->SetPoint(tmpX-difx,tmpY-dify,tmpZ); + } // for i + }// if size + } // if bsx nsx bex nex bsy nsy bey ney + } + + //========================================================================= + + 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