Logo Search packages:      
Sourcecode: qcad version File versions  Download package

RS_Vector RS_EntityContainer::getNearestMiddle ( const RS_Vector coord,
double *  dist = NULL 
) [virtual, inherited]

Must be overwritten to get the (nearest) middle point to the given coordinate for this entity.

coord Coordinate (typically a mouse coordinate)
dist Pointer to a value which will contain the measured distance between 'coord' and the closest middle point. The passed pointer can also be NULL in which case the distance will be lost.
The closest middle point.

Implements RS_Entity.

Reimplemented in RS_Spline.

Definition at line 934 of file rs_entitycontainer.cpp.

References RS_Entity::getNearestMiddle(), and RS2::ResolveNone.

Referenced by RS_Snapper::snapMiddle().


    RS_Vector point(false);
    RS_Entity* closestEntity;

    closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);

    if (closestEntity!=NULL) {
        point = closestEntity->getNearestMiddle(coord, dist);

    return point;

       double minDist = RS_MAXDOUBLE;  // minimum measured distance
       double curDist;                 // currently measured distance
       RS_Vector closestPoint;         // closest found endpoint
       RS_Vector point;                // endpoint found

       for (RS_Entity* en = firstEntity();
               en != NULL;
               en = nextEntity()) {

           if (en->isVisible()) {
               point = en->getNearestMiddle(coord, &curDist);
               if (curDist<minDist) {
                   closestPoint = point;
                   minDist = curDist;
                   if (dist!=NULL) {
                       *dist = curDist;

       return closestPoint;

Generated by  Doxygen 1.6.0   Back to index