Esempio n. 1
0
int accept_msg(const struct sockaddr_nl *who,
	       struct nlmsghdr *n, void *arg)
{
	FILE *fp = arg;

	if (timestamp)
		print_timestamp(fp);

	switch (n->nlmsg_type) {
	case RTM_NEWLINK:
	case RTM_DELLINK:
		if (prefix_banner)
			fprintf(fp, "[LINK]");

		return print_linkinfo(who, n, arg);

	case RTM_NEWNEIGH:
	case RTM_DELNEIGH:
		if (prefix_banner)
			fprintf(fp, "[NEIGH]");
		return print_fdb(who, n, arg);

	case 15:
		return show_mark(fp, n);

	default:
		return 0;
	}


}
Esempio n. 2
0
void ParameterSetCanvas::draw(QPainter & p) {
    if (! visible()) return;

    QBrush brsh = p.brush();
    QColor bckgrnd = p.backgroundColor();

    p.setBackgroundMode((used_color == UmlTransparent)
                        ? ::Qt::TransparentMode
                        : ::Qt::OpaqueMode);

    QColor co = color(used_color);
    QRect r = rect();
    FILE * fp = svg();

    p.setBackgroundColor(co);

    if (used_color != UmlTransparent)
        p.setBrush(co);

    if (fp != 0)
        fprintf(fp, "<g>\n"
                "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
                " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n"
                "</g>\n",
                svg_color(used_color),
                r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);

    p.setBackgroundColor(bckgrnd);
    p.setBrush(brsh);

    if (selected())
        show_mark(p, r);
}
Esempio n. 3
0
void CodClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
    ClassInstCanvas::draw(p, the_canvas(), rect());

    if (selected())
      show_mark(p, rect());
  }
}
Esempio n. 4
0
void CodClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
	p.setRenderHint(QPainter::Antialiasing, true);
    ClassInstCanvas::draw(p, the_canvas(), rect());

    if (selected())
      show_mark(p, rect());
  }
}
Esempio n. 5
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());
}
Esempio n. 6
0
void ArrowPointCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    QRect r = rect();

    r.setX(r.x() + 1);
    r.setY(r.y() + 1);
    r.setWidth(r.width() - 1);
    r.setHeight(r.height() - 1);

    p.fillRect(r, ::Qt::black);

    if (selected())
        show_mark(p, rect());
}
Esempio n. 7
0
void TextCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QColor bgcolor = p.background().color();
    QPen fgcolor = p.pen();
    QBrush backgroundColor = p.background();

    if (bg_c == UmlTransparent)
        p.setBackgroundMode(::Qt::TransparentMode);
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        //p.setBackgroundColor(color(bg_c));
        backgroundColor.setColor(bg_c);
        p.setBackground(backgroundColor);
    }

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    QRect r = rect();

    p.setFont(the_canvas()->get_font(itsfont));
    p.drawText(r.left(), r.top(), r.width(), r.height(),
               ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap, text);

    FILE * fp = svg();

    if (fp != 0)
        draw_text(r.left(), r.top(), r.width(), r.height(),
                  ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
                  text, p.font(), fp, fg_c, bg_c);

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    backgroundColor.setColor(bgcolor);
    //p.setBackgroundColor(bgcolor);
    p.setBackground(backgroundColor);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
Esempio n. 8
0
void ImageCanvas::draw(QPainter & p) {
    if (! visible()) return;
    p.setRenderHint(QPainter::Antialiasing, true);
    if (px == 0)
        p.fillRect (rect(), ::Qt::darkGray);
    else
        p.drawPixmap((int) x(), (int) y(), *px);

    FILE * fp = svg();

    if (fp != 0)
        // pixmap not really exported in SVG
        fprintf(fp, "<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
                " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
                svg_color(UmlBlack), (int) x(), (int) y(), width() - 1, height() - 1);

    if (selected())
        show_mark(p, rect());
}
Esempio n. 9
0
void SubjectCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QColor bckgrnd = p.backgroundColor();

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  p.setBackgroundColor(co);
  p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
  
  if (fp != 0)
    fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);

  p.drawRect(r);
  
  r.setTop(r.top() + (int) (2*the_canvas()->zoom()));
  p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name);
  if (fp != 0) {
    draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name,
	      p.font(), fp);
    fputs("</g>\n", fp);
  }
    
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 10
0
void IconCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  
  p.setBackgroundMode(::Qt::OpaqueMode);
  
  p.drawPixmap(r.topLeft(), *(browser_node->pixmap(0)));
    
  if (selected())
    show_mark(p, r);

  FILE * fp = svg();
  
  if (fp != 0) {
    fprintf(fp, "<g transform=\"translate(%d,%d)\">\n", 
	    r.left(), r.top());
    ((BrowserDiagram *) browser_node)->draw_svg();
    fputs("</g>\n", fp);
  }
}
Esempio n. 11
0
void HubCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QRect r = rect();

    p.drawRect(r);

    FILE * fp = svg();

    if (fp != 0)
        fprintf(fp, "<g>\n"
                "\t<rect fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n"
                "</g>\n",
                r.left(), r.top(), r.width() - 1, r.height() - 1);

    if (selected())
        show_mark(p, r);
}
Esempio n. 12
0
void InterruptibleActivityRegionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  QBrush brsh = p.brush();
  QColor bckgrnd = p.backgroundColor();
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  p.setBackgroundColor(co);
  
  if (used_color != UmlTransparent) 
    p.setBrush(co);
  
  p.setPen(::Qt::DotLine);
  p.drawRoundRect(r, 8, 8);

  FILE * fp = svg();

  if (fp != 0)
    fprintf(fp,
	    "\t<rect fill=\"%s\" stroke=\"black\" stroke-dasharray=\"4,4\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
	    svg_color(used_color),
	    r.left(), r.top(), r.width() - 1, r.height() - 1);
  
  p.setPen(::Qt::SolidLine);      
  p.setBackgroundColor(bckgrnd);
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, r);
}
Esempio n. 13
0
void FragmentSeparatorCanvas::drawShape(QPainter & p) {
  p.setBackgroundMode(::Qt::TransparentMode);
  p.setRenderHint(QPainter::Antialiasing, true);
  p.setPen(::Qt::DashLine);
  
  int m = (int) (fragment->y() + fragment->height() * vpos);
  
  p.drawLine((int) fragment->x(), m,
	     (int) fragment->x() + fragment->width() - 1, m);
  
  p.setPen(::Qt::SolidLine);


  FILE * fp = svg();

  if (fp != 0)
    fprintf(fp, "<g>\n\t<line stroke=\"black\" stroke-dasharray=\"20,4\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n</g>\n",
	    (int) fragment->x(), m,
	    (int) fragment->x() + fragment->width() - 1, m);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 14
0
void DeploymentNodeCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  const int three = (int) (3 * the_canvas()->zoom());  
  QColor bckgrnd = p.backgroundColor();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.setTop(r.top() + px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
  }
  else {  
    UmlColor c;
    
    if (itscolor != UmlDefaultColor)
      c = itscolor;
    else {
      if (used_color == UmlDefaultColor)
	used_color = the_canvas()->browser_diagram()->get_color(UmlDeploymentNode);
      c = used_color;
    }
    
    QColor co = color(c);
    const int added = (int) (DEPLOYMENTNODE_CANVAS_ADDED * the_canvas()->zoom());
    Q3PointArray a(7);
    
    r.setTop(r.top() + added);
    r.setRight(r.right() - added);
    
    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.left() + added, r.top() - added);
    a.setPoint(2, r.right() + added, r.top() - added);
    a.setPoint(3, r.right() + added, r.bottom() - added);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.right(), r.top());
    a.setPoint(6, r.left(), r.top());
    
    if (c == UmlTransparent) {
      p.setBackgroundMode(::Qt::TransparentMode);
      p.setBackgroundColor(co);
      p.drawPolyline(a);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, UmlTransparent);
      }
    }
    else {
      QBrush brsh = p.brush();
      
      p.setBackgroundMode(::Qt::OpaqueMode);
      p.fillRect(r, co);
      p.setBrush(co);
      p.drawPolygon(a, TRUE, 0, 6);
      p.setBrush(brsh);
      p.setBackgroundColor(co);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(c),
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, c);
      }
    }
    
    p.drawRect(r);
    p.drawLine(r.topRight(), a.point(2));
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.right(), r.top(), a.point(2).x(), a.point(2).y());
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = browser_node->get_data()->get_short_stereotype();
    QString s;
    
    r.setTop(r.top() + three);
    p.setFont(the_canvas()->get_font(UmlNormalFont));  
    
    if (st[0]) {
      s = QString("<<") + toUnicode(st) + ">>";
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
      r.setTop(r.top() + fm.height() + three);
    }
  }
    
  QFontMetrics fm(p.font());
  
  if (horiz) {
    QString s = iname + ":" + browser_node->get_name();
    
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
  }
  else {
    QString s = iname + ":";
    
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
    r.setTop(r.top() + fm.height() + three);
    s = browser_node->get_name();
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));  
  p.setBackgroundColor(bckgrnd);
  
  if (fp != 0)
    fputs("</g>\n", fp);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 15
0
void PseudoStateCanvas::draw(QPainter & p) {
  if (!visible() || ((xpm == 0) && !manual_size)) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QRect intern_r;
  
  p.setBackgroundMode(::Qt::OpaqueMode);
  
  if (xpm != 0)
    p.drawPixmap(r.topLeft(), *xpm);
  else {
    // jork join manually sized
    if (horiz) {
      intern_r.setX(r.x() + 1);
      intern_r.setWidth(r.width() - 2);
      intern_r.setY(r.y() + 6);
      intern_r.setHeight(3);
    }
    else {
      intern_r.setX(r.x() + 6);
      intern_r.setWidth(3);
      intern_r.setY(r.y() + 1);
      intern_r.setHeight(r.height() - 2);
    }
    p.fillRect(intern_r, ::Qt::black);
  }
    
  if (selected())
    show_mark(p, r);
  
  FILE * fp = svg();
  
  if (fp != 0) {
    bool big = the_canvas()->zoom() >= 1.0;
    int px = (int) x();
    int py = (int) y();
    
    switch (browser_node->get_type()) {
    case InitialPS:
      if (big)
	fprintf(fp, "<ellipse fill=\"black\" cx=\"%d\" cy=\"%d\" rx=\"8.5\" ry=\"8.5\" />\n",
		px + 9, py + 9);
      else
	fprintf(fp, "<ellipse fill=\"black\" cx=\"%d\" cy=\"%d\" rx=\"5.5\" ry=\"5.5\" />\n",
		px + 7, py + 7);
      break;
    case EntryPointPS:
      if (big)
	fprintf(fp, "<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"8.5\" ry=\"8.5\" />\n",
		px + 9, py + 9);
      else
	fprintf(fp, "<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"5.5\" ry=\"5.5\" />\n",
		px + 7, py + 7);
      break;
    case FinalPS:
      if (big) {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"11.5\" ry=\"11.5\" />\n",
		px + 12, py + 12);
	fprintf(fp, "\t<ellipse fill=\"black\" cx=\"%d\" cy=\"%d\" rx=\"8.5\" ry=\"8.5\" />\n"
		"</g>\n",
		px + 12, py + 12);
      }
      else {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"7.5\" ry=\"7.5\" />\n",
		px + 8, py + 8);
	fprintf(fp, "\t<ellipse fill=\"black\" cx=\"%d\" cy=\"%d\" rx=\"4.5\" ry=\"4.5\" />\n"
		"</g>\n",
		px + 8, py + 8);
      }
      break;
    case TerminatePS:
      if (big) {
	fprintf(fp, "<g>\n"
		"\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 1, py + 1, px + 19, py + 19);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 19, py + 1, px + 1, py + 19);
      }
      else{
	fprintf(fp, "<g>\n"
		"\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 2, py + 2, px + 12, py + 12);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 12, py + 2, px + 2, py + 12);
      }
      break;
    case ExitPointPS:
      if (big) {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"8.5\" ry=\"8.5\" />\n",
		px + 9, py + 9);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 4, px + 14, py + 14);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 14, py + 4, px + 4, py + 14);
      }
      else {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"5.5\" ry=\"5.5\" />\n",
		px + 7, py + 7);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 4, px + 10, py + 10);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 10, py + 4, px + 4, py + 10);
      }
      break;
    case DeepHistoryPS:
      if (big) {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"12.5\" ry=\"12.5\" />\n",
		px + 12, py + 12);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 8, px + 4, py + 16);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 10, py + 8, px + 10, py + 16);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 12, px + 10, py + 12);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 12, py + 9, px + 20, py + 9);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 13, py + 6, px + 19, py + 12);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 13, py + 12, px + 19, py + 6);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 16, py + 5, px + 16, py + 13);
      }
      else {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"7.5\" ry=\"7.5\" />\n",
		px + 8, py + 8);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 6, px + 4, py + 10);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 7, py + 6, px + 7, py + 10);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 4, py + 8, px + 7, py + 8);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 9, py + 7, px + 13, py + 7);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 9, py + 5, px + 13, py + 9);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 9, py + 9, px + 13, py + 5);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 11, py + 5, px + 11, py + 9);
      }
      break;
    case ShallowHistoryPS:
      if (big) {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"12.5\" ry=\"12.5\" />\n",
		px + 12, py + 12);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 8, py + 8, px + 8, py + 16);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 15, py + 8, px + 15, py + 16);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 8, py + 12, px + 15, py + 12);
      }
      else {
	fprintf(fp, "<g>\n"
		"\t<ellipse fill=\"white\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"7.5\" ry=\"7.5\" />\n",
		px + 8, py + 8);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 5, py + 5, px + 5, py + 11);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		px + 11, py + 5, px + 11, py + 11);
	fprintf(fp, "\t<line stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"</g>\n",
		px + 5, py + 8, px + 11, py + 8);
      }
      break;
    case JunctionPS:
      if (big)
	fprintf(fp, "<ellipse fill=\"black\" stroke=\"none\" cx=\"%d\" cy=\"%d\" rx=\"6.5\" ry=\"6.5\" />\n",
		px + 7, py + 7);
      else
	fprintf(fp, "<ellipse fill=\"black\" stroke=\"none\" cx=\"%d\" cy=\"%d\" rx=\"4.5\" ry=\"4.5\" />\n",
		px + 5, py + 5);
      break;
    case ChoicePS:
      // note : shadow not produced
      if (big)
	fprintf(fp, "<polygon fill=\"white\" stroke=\"black\" stroke-opacity=\"1\" points =\"%d,%d %d,%d %d,%d %d,%d\" />\n",
		px + 3, py + 18, px + 12, py + 1, px + 21, py + 18, px + 12, py + 35);
      else
	fprintf(fp, "<polygon fill=\"white\" stroke=\"black\" stroke-opacity=\"1\" points =\"%d,%d %d,%d %d,%d %d,%d\" />\n",
		px + 2, py + 12, px + 8, py + 1, px + 14, py + 12, px + 8, py + 23);
      break;
    case ForkPS:
    case JoinPS:
      if (horiz) {
	if (manual_size)
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  intern_r.x(), intern_r.y(), intern_r.x() + intern_r.width() - 1, intern_r.y());
	else if (big)
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  px + 1, py + 6, px + 23, py + 6);
	else
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  px + 1, py + 6, px + 16, py + 6);
      }
      else {
	if (manual_size)
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  intern_r.x(), intern_r.y(), intern_r.x(), intern_r.y() + intern_r.height() - 1);
	else if (big)
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  px + 6, py + 1, px + 6, py + 24);
	else
	  fprintf(fp, "<line stroke=\"black\" stroke-width=\"3\" stroke-opacity=\"1\" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  px + 6, py + 1, px + 6, py + 17);
      }
      break;
    default:
      break;
    }
  }
}
Esempio n. 16
0
void UcUseCaseCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  UseCaseData * data = (UseCaseData *) browser_node->get_data();
  p.setRenderHint(QPainter::Antialiasing, true);
  used_color = (itscolor == UmlDefaultColor)
    ? the_canvas()->browser_diagram()->get_color(UmlUseCase)
    : itscolor;
  
  QColor col = color(used_color);
  QBrush brsh = p.brush();
  bool realizationp =
    !strcmp(data->get_short_stereotype(), "realization");
  FILE * fp = svg();
  int rx = width()/2 - 1;
  int ry = height()/2 - 1;

  if (fp != 0)
    fputs("<g>\n", fp);
  
  if (used_color != UmlTransparent) {
    const int shadow = the_canvas()->shadow() - 1;
    
    if (shadow != -1) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
      p.setPen(::Qt::NoPen);
      p.setBrush(::Qt::darkGray);
      p.drawEllipse(r.left() + shadow, r.top() + shadow, r.width(), r.height());

      if (fp != 0) {
	rx = width()/2 - 1;
	ry = height()/2 - 1;

	fprintf(fp, "\t<ellipse fill=\"#%06x\" stroke=\"none\""
		" cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.left() + shadow + rx, r.top() + shadow + ry, rx, ry);
      }
    }

    if (fp != 0)
      fprintf(fp, "\t<ellipse fill=\"%s\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\""
	      " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
	      svg_color(used_color),
	      (realizationp) ? " stroke-dasharray=\"4,4\"" : "",
	      r.left() + rx, r.top() + ry, rx, ry);
  }
  else if (fp != 0)
    fprintf(fp, "\t<ellipse fill=\"none\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\""
	    " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
	    (realizationp) ? " stroke-dasharray=\"4,4\"" : "",
	    r.left() + rx, r.top() + ry, rx, ry);
  
  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
  p.setBrush(col);

  if (realizationp)
    p.setPen(::Qt::DotLine);
  else
    p.setPen(::Qt::SolidLine);
  p.drawEllipse(r.left(), r.top(), r.width(), r.height());
  if (realizationp)
    p.setPen(::Qt::SolidLine);

  QString ep = data->get_extension_points();
  
  if (!ep.isEmpty()) {
    QFontMetrics fbm(the_canvas()->get_font(UmlNormalBoldFont));
    const int two = (int) (2 * the_canvas()->zoom());
    int he = fbm.height() + two;
    int py = (int) y() + height()/4;
    int dx = width() / 15;
    int px = (int) x() + dx;
    
    p.drawLine(px, py, r.right() - dx, py);
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      px, py, r.right() - dx, py);
    
    int h = (height() * 3) / 4 - two;
    int w = width() - dx - dx;
    QColor bckgrnd = p.backgroundColor();
    
    py += two;
    p.setBackgroundColor(col);
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));

    p.drawText(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop,
	       "Extension Points");
    if (fp != 0)
      draw_text(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		"Extension Points", p.font(), fp);
    
    h -= he;
    
    if (h > he) {
      // at least one line may be written
      py += he;
      p.setFont(the_canvas()->get_font(UmlNormalFont));
      p.drawText(px, py, w, h, ::Qt::AlignCenter, ep);
      p.setBackgroundColor(bckgrnd);
      
      if (fp != 0)
	draw_text(px, py, w, h, ::Qt::AlignCenter, ep, p.font(), fp);
    }
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
  
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 17
0
void OdClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
    QRect r = rect();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    QColor bckgrnd = p.backgroundColor();
    double zoom = the_canvas()->zoom();

    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    FILE * fp = svg();

    if (fp != 0)
      fputs("<g>\n", fp);
    
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  ::Qt::darkGray.rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
    
    if (used_color != UmlTransparent)
      p.fillRect(r, co);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
    
    BrowserClass * cl = 
      ((ClassInstanceData *) browser_node->get_data())->get_class();
	  
    if (((ClassData *) cl->get_data())->get_is_active()) {
      const int eight = (int) (8 * zoom);
      
      r.setLeft(r.left() + eight);
      r.setRight(r.right() - eight);
      
      p.drawLine(r.topLeft(), r.bottomLeft());
      p.drawLine(r.topRight(), r.bottomRight());

      if (fp != 0)
	fprintf(fp,
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
		"\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.left(), r.bottom(),
		r.right(), r.top(), r.right(), r.bottom());
    }
    
    const int two = (int) (2 * zoom);
    int he = fm.height() + two;
    
    p.setFont(the_canvas()->get_font(UmlNormalUnderlinedFont));

    r.setTop(r.top() + two);
    if (horiz) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 full_name());
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  full_name(),
		  p.font(), fp);
    }
    else {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 get_name() + ":");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  get_name() + ":",
		  p.font(), fp);
      r.setTop(r.top() + fm.height());
      
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		 cl->contextual_name(used_show_context_mode));
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop,
		  cl->contextual_name(used_show_context_mode),
		  p.font(), fp);
    }
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));

    const QValueList<SlotAttr> & attributes = 
      ((ClassInstanceData *) browser_node->get_data())->get_attributes();

    if (!attributes.isEmpty()) {
      r.setTop(r.top() + he + two);
      p.drawLine(r.topLeft(), r.topRight());
      if (fp != 0)
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.left(), r.top(), r.right(), r.top());

      r.setTop(r.top() + two);
      r.setLeft(r.left() + (int) (4 * zoom));
      
      QValueList<SlotAttr>::ConstIterator it = attributes.begin();
      QString egal = " = ";

      do {
	QString s = (*it).att->get_name() + egal + (*it).value;

	p.drawText(r, ::Qt::AlignTop, s);
	if (fp != 0)
	  draw_text(r, ::Qt::AlignTop, s,
		    p.font(), fp);
	r.setTop(r.top() + he);
	++it;
      } while (it != attributes.end());
    }

    if (fp != 0)
      fputs("</g>\n", fp);
        
    if (selected())
      show_mark(p, rect());
  }
}
Esempio n. 18
0
void LabelCanvas::draw(QPainter & p)
{
    if (! isVisible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    p.setBackgroundMode(::Qt::TransparentMode);

    QRectF r = boundingRect();
    FILE * fp = svg();
    int index = text().indexOf(Triangle);

    if (fp != 0)
        fputs("<g>\n", fp);

    if (index == 0) {
        // triangle only
        int w = width() / 2 - 1;
        int b = r.bottom();
        int cx = (r.left() + r.right()) / 2;

        p.drawLine(cx - w, b, cx + w, b);
        //p.lineTo(cx, (int) y());
        p.drawLine(cx + w, b, cx, (int) y());
        //p.lineTo(cx - w, b);
        p.drawLine(cx, (int)y(), cx - w, b);

        if (fp != 0)
            fprintf(fp, "\t<polygon fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                    " points=\"%d,%d %d,%d %d,%d\" />\n",
                    cx - w, b, cx + w, b, cx, (int) y());
    }
    else if (index != -1) {
        // label then triangle under
        p.setFont(font());
        p.drawText(rect(), ::Qt::AlignHCenter, text().mid(0, index - 1));

        if (fp != 0)
            draw_text(rect(), ::Qt::AlignHCenter, text().mid(0, index - 1),
                      p.font(), fp);

        QFontMetrics fm(font());
        int w = fm.width(Triangle) / 2 - 1;
        int cx = (r.left() + r.right()) / 2;
        int cy = (int) y() + fm.height();
        int b = r.bottom();

        p.drawLine(cx - w, b, cx + w, b);
        //p.lineTo(cx, cy);
        p.drawLine(cx + w, b, cx, cy);
        //p.lineTo(cx - w, b);
        p.drawLine(cx, cy, cx - w, b);

        if (fp != 0)
            fprintf(fp, "\t<polygon fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                    " points=\"%d,%d %d,%d %d,%d\" />\n",
                    cx - w, b, cx + w, b, cx, cy);
    }
    else if (text() != Zigzag) {
        // no triangle nor zigzag
        if (text().indexOf('\n') != -1) {
            p.setFont(font());

            int flg = (multi_lines_centered) ? ::Qt::AlignHCenter : 0;

            p.drawText(rect(), flg, text().mid(0, index - 1));

            if (fp != 0)
                draw_text(rect(), flg, text().mid(0, index - 1),
                          p.font(), fp);
        }
        else {
            QStyleOptionGraphicsItem option;
            QGraphicsSimpleTextItem::paint(&p,&option,0);

            if (fp != 0)
                draw_text(rect(), 0, text(), p.font(), fp);
        }
    }
    else {
        // zigzag (only used as stereotype)
        int t = r.top() + 2;
        int h = height() - 2;
        int yb = r.bottom() - h / 4;
        int xr = r.right() - r.width() / 4;

        p.drawLine(r.left(), t, r.right(), t);
        //p.lineTo(r.left(), yb);
        p.drawLine(r.right(), t, r.left(), yb);
        //p.lineTo(r.right(), yb);
        p.drawLine(r.left(), yb, r.right(), yb);
        //p.lineTo(xr, r.bottom() - h / 2);
        p.drawLine(r.right(), yb, xr, r.bottom() - h / 2);
        p.drawLine(r.right(), yb, xr, r.bottom());

        if (fp != 0) {
            fprintf(fp, "\t<polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                    " points=\"%f,%d %f,%d %f,%d %f,%d %d,%f\" />\n",
                    r.left(), t, r.right(), t, r.left(), yb, r.right(), yb, xr, r.bottom() - h / 2);
            fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
                    " x1=\"%f\" y1=\"%d\" x2=\"%d\" y2=\"%f\" />\n",
                    r.right(), yb, xr, r.bottom());
        }
    }

    if (fp != 0)
        fputs("</g>\n", fp);

    if (isSelected())
        show_mark(p, r.toRect());
}
Esempio n. 19
0
void FragmentCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  int w = fm.width((name.isEmpty()) ? QString("X") : name);
  int h = fm.height() / 2;  
  QRect r = rect();
  QRect rname = r;
  
  rname.setWidth(w + h);
  rname.setHeight(fm.height() + h);
  
  int h1 = (fm.height() + h)/2;
  int x1 = rname.right() + h1;
  int y1 = rname.bottom() - h1;
  
  QColor bckgrnd = p.backgroundColor();

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
  
  p.setBackgroundColor(co);
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
  else if (!name.isEmpty()) {
    Q3PointArray a(6);
    QBrush brsh = p.brush();
    
    a.setPoint(0, rname.left(), rname.top());
    a.setPoint(1, x1, rname.top());
    a.setPoint(2, x1, y1);
    a.setPoint(3, rname.right(), rname.bottom());
    a.setPoint(4, rname.left(), rname.bottom());
    a.setPoint(5, rname.left(), rname.top());

    p.setBrush(UmlWhiteColor);
    p.drawPolygon(a, TRUE, 0, 5);
    p.setBrush(brsh);
    
    if (fp != 0)
      draw_poly(fp, a, UmlWhite);
  }

  if (fp != 0)
    fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);
  
  p.drawRect(r);
  
  if (refer != 0) {
    QString s = refer->get_name() + form;
    QRect r2(r.left(), r.top() + 2*fm.height(),
	     r.width(), fm.height());

    p.drawText(r2, ::Qt::AlignCenter, s);
    
    if (fp != 0)
      draw_text(r2, ::Qt::AlignCenter, s,
		p.font(), fp);
  }
  
  if (!name.isEmpty())
    p.drawText(rname, ::Qt::AlignCenter, name);
  if (fp != 0)
    draw_text(rname, ::Qt::AlignCenter, name,
	      p.font(), fp);
  
  p.drawLine(rname.left(), rname.bottom(), rname.right(), rname.bottom());
  p.drawLine(rname.right(), rname.bottom(), x1, y1);
  p.drawLine(x1, y1, x1, rname.top());

  if (fp != 0) {
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    rname.left(), rname.bottom(), rname.right(), rname.bottom());
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    rname.right(), rname.bottom(), x1, y1);
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    x1, y1, x1, rname.top());
    fputs("</g>\n", fp);
  }
	       
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, r);
}
Esempio n. 20
0
void ActivityActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  QBrush brsh = p.brush();
  QColor bckgrnd = p.backgroundColor();
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  p.setBackgroundColor(co);
  
  const ActivityActionData * data =
    (ActivityActionData *) browser_node->get_data();
  const int shadow = the_canvas()->shadow();
  int margin;
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  switch (data->get_action_kind()) {
  case UmlAcceptEventAction:
    if (((AcceptEventAction *) data->get_action())->timeevent) {
      // don't draw shadow
      margin = (int) (21 * the_canvas()->zoom());
      
      int t = (r.y() + r.bottom() - margin)/2;
      
      p.setPen(::Qt::SolidLine);
      p.setBackgroundMode(::Qt::TransparentMode);
      p.drawLine(r.right() - margin, t, r.right() - 1, t);
      p.lineTo(r.right() - margin - 1, t + margin);
      p.lineTo(r.right() - 1, t + margin);
      p.lineTo(r.right() - margin - 1, t);

      if (fp != 0) {
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin, t, r.right() - 1, t);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t, r.right() - margin - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin - 1, t + margin, r.right() - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t + margin, r.right() - margin - 1, t);
      }

      r.setWidth(r.width() - margin - 1);
      margin = (int) (3 * the_canvas()->zoom());
    }
    else {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right(), r.y());
      a.setPoint(2, r.right(), r.bottom());
      a.setPoint(3, r.x(), r.bottom());
      a.setPoint(4, r.x() + margin, (r.y() + r.bottom())/2);
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);

	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(3, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + margin + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setLeft(r.left() + margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  case UmlSendSignalAction:
  case UmlBroadcastSignalAction:
    {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right() - margin, r.y());
      a.setPoint(2, r.right(), (r.y() + r.bottom())/2);
      a.setPoint(3, r.right() - margin, r.bottom());
      a.setPoint(4, r.x(), r.bottom());
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() - margin + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(3, r.right() - margin + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
      
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setWidth(r.width() - margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  default:      
    margin = (int) (9 * the_canvas()->zoom());
      
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
      p.setPen(::Qt::NoPen);
      p.setBrush(::Qt::darkGray);
      p.drawRoundRect(r.left() + shadow, r.top() + shadow, r.width(), r.height());
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
		::Qt::darkGray.rgb()&0xffffff,
		r.left() + shadow, r.top() + shadow, r.width() - 1, r.height() - 1);

      p.setPen(::Qt::SolidLine);
    }
    
    p.setBrush(co);
    p.drawRoundRect(r);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
	      svg_color(used_color),
	      r.left(), r.top(), r.width() - 1, r.height() - 1);
    
    if (data->get_action_kind() == UmlCallBehaviorAction) {
      BrowserNode * behavior =
	((CallBehaviorAction *) data->get_action())->behavior;
      
      if ((behavior != 0) && (behavior->get_type() == UmlActivity)) {
	int l = (int) (6 * the_canvas()->zoom());
	int lx = r.right() - margin - l;
	int ty = r.bottom() - margin - l;
	int mx = lx + l;
	int my = ty + l;
	int rx = mx + l;
	int by = my + l;
	
	p.drawLine(lx, my, rx, my);
	p.drawLine(mx, ty, mx, by);
	p.drawLine(lx, my, lx, by);
	p.drawLine(rx, my, rx, by);

	if (fp != 0) {
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, rx, my);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  mx, ty, mx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, lx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  rx, my, rx, by);
	}
      }
    }
    break;
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  p.drawText(r.x() + margin,
	     r.y() + margin,
	     r.width() - margin - margin,
	     r.height() - margin - margin,
	     align, s);
  
  if (fp != 0) {
    fputs("</g>\n", fp);
    draw_text(r.x() + margin,
	      r.y() + margin,
	      r.width() - margin - margin,
	      r.height() - margin - margin,
	      align, s, p.font(), fp);
  }
  
  p.setBackgroundColor(bckgrnd);
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 21
0
void StateActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  double zoom = the_canvas()->zoom();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
    
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    int mw = min_width;
    QBrush brsh = p.brush();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = data->get_short_stereotype();
    const int shadow = the_canvas()->shadow();
    
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent)
			? ::Qt::TransparentMode
			: ::Qt::OpaqueMode);

    p.setBackgroundColor(co);
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    if (!strcmp(st, "send-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right() - hh, r.top());
      a.setPoint(2, r.right(), r.top() + hh);
      a.setPoint(3, r.right() - hh, r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() - hh + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() - hh + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else if (!strcmp(st, "receive-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right(), r.top());
      a.setPoint(2, r.right() - hh, r.top() + hh);
      a.setPoint(3, r.right(), r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() - hh + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else {
      if (used_color != UmlTransparent) {
	if (shadow != 0) {
	  r.setRight(r.right() - shadow);
	  r.setBottom(r.bottom() - shadow);
	  
	  p.fillRect (r.right(), r.top() + shadow,
		      shadow, r.height() - 1,
		      ::Qt::darkGray);
	  p.fillRect (r.left() + shadow, r.bottom(),
		      r.width() - 1, shadow,
		      ::Qt::darkGray);
	  
	  if (fp != 0) {
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	    
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	  }
	}
      }
      
      p.setBrush(co);
      p.drawRect(r);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
      
      if (st[0] != 0) {
	r.setTop(r.top() + fm.height() / 2);
	p.drawText(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>");
	if (fp != 0)
	  draw_text(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>",
		    p.font(), fp);
	r.setTop(r.top() + 3*fm.height()/2);
      }
    }
    
    r.setLeft(r.left() + (r.width() + (int) (8 * zoom) - mw)/2 + 1);
    p.drawText(r, ::Qt::AlignVCenter, s);
    if (fp != 0) {
      draw_text(r, ::Qt::AlignVCenter, s,
		p.font(), fp);
      fputs("</g>\n", fp);
    }
      
    p.setBrush(brsh);
    p.setBackgroundColor(bckgrnd);
  }
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 22
0
void ArtifactCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    if (fp != 0) {
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(), p.font(), fp);
      fputs("</g>\n", fp);
    }
  }
  else {  
    QColor bckgrnd = p.backgroundColor();
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    
    p.setBackgroundColor(co);
    
    // <<artifact>>/stereotype on 2*font_height with the icon on the right
    // the icon height = 2*font_height
    // the icon width = 3*height/4
    // name on font_height+4 points
    const int four = (int) (4 * the_canvas()->zoom());
    QFontMetrics fm(the_canvas()->get_font(UmlNormalBoldFont));
    const int he = fm.height();
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);
	
	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	  
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    QRect re = r;
    
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    r.setHeight(he*2);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    if (data->get_stereotype()[0]) {
      p.drawText(r, ::Qt::AlignCenter,
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter,
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
    }
    else {
      p.drawText(r, ::Qt::AlignCenter, "<<artifact>>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter, "<<artifact>>",
		  p.font(), fp);
    }
    
    r.moveBy(0, r.height());
    r.setHeight(he+four);
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignCenter, browser_node->get_name());
    if (fp != 0)
      draw_text(r, ::Qt::AlignCenter, browser_node->get_name(),
		p.font(), fp);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    // draw icon
    re.setLeft(re.right() - 6*he/4 + four);
    re.setRight(re.right() - four);
    re.setTop(re.top() + four);
    re.setHeight(2*(he - four));
    
    Q3PointArray a(7);
    const int corner_size = re.width()/3;
    
    a.setPoint(0, re.left(), re.top());
    a.setPoint(1, re.right() - corner_size, re.top());
    a.setPoint(2, re.right() - corner_size, re.top() + corner_size);
    a.setPoint(3, re.right(), re.top() + corner_size);
    a.setPoint(4, re.right(), re.bottom());
    a.setPoint(5, re.left(), re.bottom());
    a.setPoint(6, re.left(), re.top());
    p.drawPolyline(a);
    //p.moveTo(re.right() - corner_size, re.top());
    //p.lineTo(re.right(), re.top() + corner_size);
    p.drawLine(re.right() - corner_size, re.top(), re.right(), re.top() + corner_size);
    
    if (fp != 0) {
      draw_poly(fp, a, UmlTransparent);
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
	      "</g>\n",
	      re.right() - corner_size, re.top(), re.right(), re.top() + corner_size);
    }
    
    p.setBackgroundColor(bckgrnd);
  }
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 23
0
void ActivityPartitionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  
  QRect r = rect();
  FILE * fp = svg();
  QColor bckgrnd = p.backgroundColor();
  QColor co = color(used_color);
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  
  p.setBackgroundColor(co);
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
    
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  QFontMetrics fm(p.font());
  int h = 3*fm.height();
    
  if (fp != 0) {
    fprintf(fp, "<g>\n\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);
  }
  
  p.drawRect(r);

  if (horiz) {
    if (! str.isEmpty()) { 
      p.save();
      p.rotate(-90);
      p.drawText(-r.y(), r.x(), -r.height(), h,
		 ::Qt::AlignCenter, str);
      p.restore();
      
      if (fp != 0) {
	int index = str.find('\n');
	
	if (index == -1)
	  draw_rotate_text(r.x() + h/2, r.y() + r.height()/2,
			   270, str, p.font(), fp);
	else {
	  int vc = r.y() + r.height()/2;
	  
	  draw_rotate_text(r.x() + h/4, vc,
			   270, str.left(index), p.font(), fp);
	  draw_rotate_text(r.x() + (h*3)/4, vc,
			   270, str.mid(index + 1), p.font(), fp);
	}
      }
    }
    
    r.setLeft(r.left() + h);
    p.drawLine(r.topLeft(), r.bottomLeft());
    
    if (fp) {
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.left(), r.bottom());
      fputs("</g>\n", fp);
    }
  }
  else {
    if (! str.isEmpty()) { 
      p.drawText(r.x(), r.y(), r.width(), h,
		 ::Qt::AlignCenter, str);
      
      if (fp != 0)
	draw_text(r.x(), r.y(), r.width(), h,
		  ::Qt::AlignCenter, str, p.font(), fp);
    }
    
    r.setTop(r.top() + h);
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp) {
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
      fputs("</g>\n", fp);
    }
  }
  
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 24
0
void PackageCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();
  
  if (fp != 0)
    fputs("<g>\n", fp);

  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    // pixmap not yet exported in SVG
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(),
		p.font(), fp);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    p.setBackgroundColor(co);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const int four = (int) (4 * the_canvas()->zoom());
    const int he = fm.height();
    const int shadow = the_canvas()->shadow();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setWidth(r.width() * 2 / 5);
    r.setHeight(he + four);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      p.fillRect (r.right(), r.top() + shadow,
		  shadow, r.height() - 1 - shadow,
		  ::Qt::darkGray);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - shadow - 1);
    }
    
    const char * name = browser_node->get_name();
    
    if (in_tab) {
      p.drawText(r, ::Qt::AlignCenter, name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter, name,
		  p.font(), fp);
    }
    
    r = rect();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setTop(r.top() + he + four - 1);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color),
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      p.fillRect (r.right(), r.top() + shadow,
		  shadow, r.height() - 1,
		  ::Qt::darkGray);
      p.fillRect (r.left() + shadow, r.bottom(),
		  r.width() - 1, shadow,
		  ::Qt::darkGray);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
      }
    }
    
    const int three = (int) (3 * the_canvas()->zoom());
    
    r.setTop(r.top() + three);
    
    if (! in_tab) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name,
		  p.font(), fp);
      r.setTop(r.top() + he + three);
    }
    
    if (data->get_stereotype()[0]) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
      r.setTop(r.top() + he + three);
    }
    
    if (full_name != name) {
      p.setFont(the_canvas()->get_font(UmlNormalItalicFont));
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name,
		  p.font(), fp);
      p.setFont(the_canvas()->get_font(UmlNormalFont));
    }
  
    p.setBackgroundColor(bckgrnd);
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 25
0
void SdSelfMsgCanvas::draw(QPainter & p) {
    const QRect r = rect();
    int ah = (r.height() - 1 - 1 - 2 - 1 - 1)/2;
    int he = r.top() + 1 + 2 + ah + 1;
    FILE * fp = svg();
    p.setRenderHint(QPainter::Antialiasing, true);
    if (itsType == UmlSelfReturnMsg)
        p.setPen(::Qt::DotLine);

    p.drawLine(r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1);



    //p.lineTo(r.right() - 1, he);
    p.drawLine(r.right()-1, r.top() + 1, r.right() - 1, he);
    //p.lineTo(r.left() + 1, he);
    p.drawLine(r.right()-1, he, r.left() + 1, he);

    if (fp != 0) {
        fputs("<g>\n\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\"", fp);
        if (itsType == UmlSelfReturnMsg)
            fputs(" stroke-dasharray=\"4,4\"", fp);
        fprintf(fp, " d=\"M %d %d L %d %d L %d %d L %d %d\" />\n",
                r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1,
                r.right() - 1, he,
                r.left() + 1, he);
    }

    if (itsType == UmlSyncSelfMsg) {
        Q3PointArray poly(3);
        QBrush brsh = p.brush();

        p.setBrush(Qt::black);
        poly.setPoint(0, r.left() + 1, he);
        poly.setPoint(1, r.left() + 1 + ah, he + ah);
        poly.setPoint(2, r.left() + 1 + ah, he - ah);
        p.drawPolygon(poly/*, TRUE*/);
        p.setBrush(brsh);

        if (fp != 0) {
            draw_poly(fp, poly, UmlBlack, FALSE);
            fputs("</g>\n", fp);
        }
    }
    else {
        if (itsType == UmlSelfReturnMsg)
            p.setPen(::Qt::SolidLine);

        //p.lineTo(r.left() + 1 + ah, he + ah);
        p.drawLine(r.left()+1+ah, he - ah, r.left() + 1 + ah, he + ah); // assuming last call poly.setPoint
        p.drawLine(r.left() + 1, he, r.left() + 1 + ah, he - ah);

        if (fp != 0)
            fprintf(fp, "\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                    " d=\"M %d %d L %d %d L %d %d\" />\n"
                    "</g>\n",
                    r.left() + 1 + ah, he + ah,
                    r.left() + 1, he,
                    r.left() + 1 + ah, he - ah);
    }

    if (selected())
        show_mark(p, r);
}
Esempio n. 26
0
void SdDurationCanvas::draw(QPainter & p) {
  const QRect r = rect();
  p.setRenderHint(QPainter::Antialiasing, true);
  UmlColor used_color = (itscolor != UmlDefaultColor)
    ? itscolor
    : browser_node->get_color(UmlActivityDuration);
  QColor co = color(used_color);
  
  int w = width() - 1;
  int x = r.left();
  int y = r.top();
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);
  p.fillRect(r, co);
  if (coregion) {
    p.drawLine(x, y + w, x, y);



    //p.lineTo(x + w, y);
	p.drawLine(x, y, x + w, y);
   //p.lineTo(x + w, y + w);
   p.drawLine(x + w, y, x + w, y + w);
    
    int b = r.bottom();
    
    p.drawLine(x, b - w, x, b);



    //p.lineTo(x + w, b);
	p.drawLine(x, b, x + w, b);
    //p.lineTo(x + w, b - w);
	p.drawLine(x+w, b, x + w, b - w);
  }
  else
    p.drawRect(r);

  FILE * fp = svg();

  if (fp != 0) {
    if (coregion) {
      fprintf(fp, "<g>\n"
	      "\t<rect fill=\"%s\" stroke=\"none\" "
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n"
	      "\t<path fill = \"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" "
	      "d=\"M %d %d v %d h %d v %d M %d %d v %d h %d v %d\" />\n"
	      "</g>\n",
	      svg_color(used_color), 
	      x, y, w, r.height() - 1,
	      x, y + w, -w, w, w,
	      x, r.bottom() - w, w, w, -w);
    }
    else
      fprintf(fp, "<g>\n"
	      "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n"
	      "</g>\n",
	      svg_color(used_color), 
	      x, y, w, r.height() - 1);
  }
  
  if (selected())
    show_mark(p, r);
}
Esempio n. 27
0
void NoteCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QRect r = rect();
    QBrush brsh = p.brush();
    QColor bckgrnd = p.backgroundColor();
    QPen fgcolor = p.pen();
    Q3PointArray a(7);

    used_color = (itscolor == UmlDefaultColor)
                 ? the_canvas()->browser_diagram()->get_color(UmlNote)
                 : itscolor;

    QColor co = color(used_color);

    const int corner_size = (int)(NOTE_MARGIN * the_canvas()->zoom());

    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.right() - corner_size, r.top());
    a.setPoint(2, r.right() - corner_size, r.top() + corner_size);
    a.setPoint(3, r.right(), r.top() + corner_size);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.left(), r.bottom());
    a.setPoint(6, r.left(), r.top());

    FILE * fp = svg();

    if (fp != 0)
        fputs("<g>\n", fp);

    if (used_color == UmlTransparent) {
        p.setBackgroundMode(::Qt::TransparentMode);
        p.setBackgroundColor(co);
        p.drawPolyline(a);

        if (fp != 0)
            draw_poly(fp, a, UmlTransparent);
    }
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        p.setBrush(co);
        p.drawPolygon(a, TRUE, 0, 6);
        p.setBrush(brsh);
        p.setBackgroundColor(co);

        if (fp != 0)
            draw_poly(fp, a, used_color);
    }

    p.drawLine(r.right() - corner_size, r.top(),
               r.right(), r.top() + corner_size);

    if (fp != 0)
        fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
                " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
                r.right() - corner_size, r.top(), r.right(), r.top() + corner_size);

    p.setFont(the_canvas()->get_font(itsfont));

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    p.drawText(r.left() + corner_size, r.top() + corner_size,
               r.width() - 2 * corner_size, r.height() - 2 * corner_size,
               ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
               note);

    if (fp != 0) {
        draw_text(r.left() + corner_size, r.top() + corner_size,
                  r.width() - 2 * corner_size, r.height() - 2 * corner_size,
                  ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
                  note, p.font(), fp, fg_c);
        fputs("</g>\n", fp);
    }

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    p.setBackgroundColor(bckgrnd);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
Esempio n. 28
0
void UcClassCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  QFontMetrics fim(the_canvas()->get_font(UmlNormalItalicFont));
  QColor bckgrnd = p.backgroundColor();
  double zoom = the_canvas()->zoom();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  if (used_view_mode == asClass) {
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();

      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
  
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);

      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
  }
  
  const ClassData * data = ((ClassData *) browser_node->get_data());
  const int two = (int) (2 * zoom);
  int he = fm.height() + two;
  
  if (data->get_n_formalparams() != 0)
    r.setTop(r.top() + fm.height());
  
  switch (used_view_mode) {
  case asInterface:
    draw_interface_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (INTERFACE_SIZE * zoom) + two);
    break;
  case asControl:
    draw_control_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (CONTROL_HEIGHT * zoom) + two);
    break;
  case asBoundary:
    draw_boundary_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (BOUNDARY_HEIGHT * zoom) + two);
    break;
  case asEntity:
    draw_entity_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (ENTITY_SIZE * zoom) + two);
    break;
  case asActor:
    {
      QRect ra = r;
      
      ra.setHeight((int) (ACTOR_SIZE * zoom));
      ra.setLeft(ra.left() + 
		 (int) ((ra.width() - ACTOR_SIZE * zoom)/2));
      ra.setWidth(ra.height());
      draw_actor(&p, ra);
    }
    r.setTop(r.top() + (int) (ACTOR_SIZE * zoom) + two);
    break;
  case Natural:
    {
      const QPixmap * px = 
	ProfiledStereotypes::diagramPixmap(data->get_stereotype(), zoom);
      int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();

      p.drawPixmap(lft, r.y(), *px);
      if (fp != 0)
	// pixmap not really exported in SVG
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);

      r.setTop(r.top() + px->height());
    }
    break;
  default:	// class
    r.setTop(r.top() + two);
    if (data->get_stereotype()[0]) {
      p.setFont(the_canvas()->get_font(UmlNormalFont));
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
      r.setTop(r.top() + he + two);
    }
  }
  
  p.setBackgroundMode(::Qt::TransparentMode);
  p.setFont((data->get_is_abstract())
	    ? the_canvas()->get_font(UmlNormalItalicFont)
	    : the_canvas()->get_font(UmlNormalFont));
  p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name);
  if (fp != 0)
    draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name, p.font(), fp);

  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  if (used_view_mode == asClass) {
    r.setTop(r.top() + he);
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
    
    r.setTop(r.top() + (int) (8 * zoom));
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
    
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 29
0
void tex::show_node_list(ptr p)
	{
	int	n;

	if (cur_length() > depth_threshold) {
		if (p > null)
			print(" []");
		return;
	}
	n = 0;
	while (p > null) {
		print_ln();
		print_str();
		incr(n);
		if (n > breadth_max) {
			print("etc.");
			return;
		}
		if (is_char_node(p)) {
			print_font_and_char(p);
		} else {
			switch (type(p))
			{
			case HLIST_NODE:
			case VLIST_NODE:
			case UNSET_NODE:
				show_box1(p);
				break;

			case RULE_NODE:
				show_rule(p);
				break;
			
			case INS_NODE:
				show_insertion(p);
				break;
			
			case WHATSIT_NODE:
				show_whatsit(p);
				break;
			
			case GLUE_NODE:
				show_glue(p);
				break;
			
			case KERN_NODE:
				show_kern(p);
				break;
			
			case MATH_NODE:
				show_math(p);
				break;
			
			case LIGATURE_NODE:
				show_ligature(p);
				break;

			case PENALTY_NODE:
				show_penalty(p);
				break;
		
			case DISC_NODE:
				show_discretionary(p);
				break;
			
			case MARK_NODE:
				show_mark(p);
				break;
			
			case ADJUST_NODE:
				show_adjust(p);
				break;
			
			case STYLE_NODE:
				print_style(subtype(p));
				break;
			
			case CHOICE_NODE:
				show_choice_node(p);
				break;

			case INNER_NOAD:
			case ORD_NOAD:
			case OP_NOAD:
			case BIN_NOAD:
			case REL_NOAD:
			case OPEN_NOAD:
			case CLOSE_NOAD:
			case PUNCT_NOAD:
			case RADICAL_NOAD:
			case OVER_NOAD:
			case UNDER_NOAD:
			case VCENTER_NOAD:
			case ACCENT_NOAD:
			case LEFT_NOAD:
			case RIGHT_NOAD:
				show_normal_noad(p);
				break;
			
			case FRACTION_NOAD:
				show_fraction_noad(p);
				break;

			default:
				print("Unknown node type!");
				break;
			}
		}
		p = link(p);
	}
}