Example #1
0
void ArrowJunctionCanvas::draw(QPainter & p)
{
    if (!visible())
        return;

    ArrowCanvas * a;
    FILE * fp = svg();

    for (a = lines.first(); a != 0; a = lines.next()) {
        switch (a->type()) {
        case UmlRequired: {
            QRect r = rect();
            int wh = r.width() - 2;
            int startangle = a->get_point(1).x(); // degree * 16

            p.drawArc(r.x() + 1, r.y() + 1,
                      wh, wh,
                      startangle, 180 * 16);

            if (fp != 0) {
                int radius = r.width() / 2;

                QPoint ce = r.center();
                double r_startangle = startangle * 3.1415927 / 180 / 16;
                double dx = cos(r_startangle) * radius;
                double dy = sin(r_startangle) * radius;

                fprintf(fp, "<path fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" d=\"M%lg,%lg a%d,%d 0 0,1 %lg,%lg\" />\n",
                        ce.x() - dx, ce.y() + dy,
                        radius, radius,
                        dx + dx, -dy - dy);
            }
        }
        break;

        case UmlProvided:
            p.drawPixmap(QPoint((int) x(), (int) y()), *providedPixmap);

            if (fp != 0)
                fprintf(fp, "<ellipse fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
                        // 4 is the margin inside the pixmap
                        (int)(x() + PROVIDED_RADIUS + 4),
                        (int)(y() + PROVIDED_RADIUS + 4),
                        (int) PROVIDED_RADIUS, (int) PROVIDED_RADIUS);

            break;

        default:
            // to avoid compiler warning
            break;
        }
    }

    if (selected())
        show_mark(p, rect());
}
Example #2
0
// return true if a clone of lnk already exist between this and other
bool OdClassInstCanvas::is_duplicated(ObjectLinkCanvas * lnk, 
				      OdClassInstCanvas * other) const {
  RelationData * rel = lnk->get_rel();
  QListIterator<ArrowCanvas> it(lines);
  ArrowCanvas * ar;
  
  while ((ar = it.current()) != 0) {
    if ((ar != lnk) &&
	IsaRelation(ar->type()) &&
	(((ObjectLinkCanvas *) ar)->get_rel() == rel) &&
	(ar->get_end() == other))
      return TRUE;
    else
      ++it;
  }
  return FALSE;
}