static real attribute_distance_from(Attribute *attribute, Point *point) { Element *elem = &attribute->element; Point center; center.x = elem->corner.x+elem->width/2; center.y = elem->corner.y+elem->height/2; return distance_ellipse_point(¢er, elem->width, elem->height, attribute->border_width, point); }
static real req_distance_from(Requirement *req, Point *point) { Element *elem = &req->element; Point center; center.x = elem->corner.x+elem->width/2; center.y = elem->corner.y+elem->height/2; return distance_ellipse_point(¢er, elem->width, elem->height, REQ_LINEWIDTH, point); }
static real ellipse_distance_from(Ellipse *ellipse, Point *point) { Element *elem = &ellipse->element; Point c; c.x = elem->corner.x + elem->width / 2; c.y = elem->corner.y + elem->height/ 2; return distance_ellipse_point (&c, elem->width, elem->height, ellipse->border_width, point); }
static real actor_distance_from(Actor *actor, Point *point) { Element *elem = &actor->element; Point c; c.x = elem->corner.x + elem->width / 2; c.y = elem->corner.y + elem->height/ 2; return distance_ellipse_point (&c, elem->width, elem->height, ACTOR_BORDER_WIDTH, point); }
double Ellipse::distanceFrom(Point *point) { Element *elem = this; Point center; center.setX(elem->corner().x() + elem->width() / 2); center.setY(elem->corner().y() + elem->height() / 2); return distance_ellipse_point(¢er, elem->width(), elem->height(), m_data->borderWidth, point); }
/*! * \brief Set the other point of the pattern * * The meaning of the point depends on the type of the pattern. * For line gradient it is the second point giving the direction. * With a radial gradient it is the focal point. * * \ingroup DiaPattern */ void dia_pattern_set_point (DiaPattern *self, real x, real y) { self->other.x = x; self->other.y = y; /* with radial we have to ensure the point is in circle */ if (self->type == DIA_RADIAL_GRADIENT) { real dist = distance_ellipse_point (&self->start, self->radius*2, self->radius*2, 0.0, &self->other); if (dist > 0) { /* If the point defined by ‘fx’ and ‘fy’ lies outside the circle defined * by ‘cx’, ‘cy’ and ‘r’, then the user agent shall set the focal point to * the intersection of the line from (‘cx’, ‘cy’) to (‘fx’, ‘fy’) with the * circle defined by ‘cx’, ‘cy’ and ‘r’ */ Point p1 = self->start; Point p2 = self->other; point_sub (&p2, &p1); point_normalize (&p2); point_add_scaled (&p1, &p2, self->radius); self->other = p1; } } }