Example #1
0
void ClassDiagramView::read(char * st, char * k) {
    UmlCanvas * canvas = the_canvas();

    // reads first the classes package icons text notes and images
    while (CdClassCanvas::read(st, canvas, k) ||
            NoteCanvas::read(st, canvas, k) ||
            TextCanvas::read(st, canvas, k) ||
            IconCanvas::read(st, canvas, k) ||
            PackageCanvas::read(st, canvas, k) ||
            FragmentCanvas::read(st, canvas, k) ||
            ImageCanvas::read(st, canvas, k))
        k = read_keyword(st);

    // then reads relations and anchors
    while (ArrowCanvas::read(st, canvas, k) ||
            RelationCanvas::read(st, canvas, k) ||
            SimpleRelationCanvas::read(st, canvas, k))
        k = read_keyword(st);

    if (!strcmp(k, "preferred_whz") || !strcmp(k, "prefered_whz")) {
        preferred_size.setWidth(read_unsigned(st));
        preferred_size.setHeight(read_unsigned(st));
        preferred_zoom = read_double(st);
        k = read_keyword(st);
    }

    if (strcmp(k, "end"))
        wrong_keyword(k, "end");
}
Example #2
0
void UcClassCanvas::post_loaded() {
  force_self_rel_visible();
  if (the_canvas()->must_draw_all_relations()) {
    draw_all_depend_gene();    
    draw_all_simple_relations();
  }
}
Example #3
0
void SdSelfMsgCanvas::check_vpos(const QRect & r) {
  if (((BrowserSeqDiagram *) the_canvas()->browser_diagram())
      ->is_overlapping_bars()) {
    double v;
    
    switch (itsType) {
    case UmlSelfReturnMsg:
      v = r.bottom() - height() / 2;
      break;
    case UmlSyncSelfMsg:
      v = r.top();
      break;
    default:
      return;
    }
    
    if (y() != v) {
      double dy = v - y();
      
      DiagramCanvas::moveBy(0, dy);
      if ((stereotype != 0) && !stereotype->selected())
	stereotype->moveBy(0, dy);
    }
  }
}
Example #4
0
void ClassDiagramView::contentsMousePressEvent(QMouseEvent * e) {
    if (!window()->frozen()) {
        switch (window()->buttonOn()) {
        case UmlClass:
        {
            history_protected = TRUE;
            unselect_all();
            window()->selectOn();
            history_save();

            BrowserNode * parent =
                ((BrowserNode *) window()->browser_diagram()->parent());
            BrowserNode * b = BrowserClass::get_class(parent);

            if (b != 0) {
                CdClassCanvas * cl =
                    new CdClassCanvas(b, the_canvas(), e->x(), e->y());

                cl->show();
                cl->upper();
                window()->package_modified();
            }
            canvas()->update();
            history_protected = FALSE;
        }
        break;
        default:
            DiagramView::contentsMousePressEvent(e);
            break;
        }
    }
    else
        DiagramView::contentsMousePressEvent(e);
}
Example #5
0
void ImageCanvas::open()
{
    QString s = path;
    ImageDialog d(s);

    if ((d.exec() == QDialog::Accepted) &&
            !s.isEmpty() &&
            (s != path)) {
        QPixmap * p = get_pixmap(s.toLatin1().constData());

        if (p != 0) {
            path = s;
            width_scale100 = p->width();
            height_scale100 = p->height();
            px = get_pixmap(path.toLatin1().constData(), the_canvas()->zoom());

            hide();
            hide_lines();
            setRect(rect().x(), rect().y(), px->width(), px->height());

            recenter();
            show();
            update_show_lines();
            canvas()->update();
            package_modified();
        }
    }
}
Example #6
0
void ArrowPointCanvas::delete_it()
{
    if (lines.isEmpty())
        the_canvas()->del(this);
    else
        lines.first()->delete_it();	// will apply del on this
}
Example #7
0
aCorner PackageCanvas::on_resize_point(const QPoint & p) {
  return (ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(),
					     the_canvas()->zoom())
	  != 0)
    ? NoCorner
    : ::on_resize_point(p, rect());
}
Example #8
0
void PackageCanvas::prepare_for_move(bool on_resize) {
  if (! on_resize) {
    DiagramCanvas::prepare_for_move(on_resize);
    
    Q3CanvasItemList l = collisions(TRUE);
    Q3CanvasItemList::ConstIterator it;
    Q3CanvasItemList::ConstIterator end = l.end();
    DiagramItem * di;
    BrowserNode * p = get_bn();
  
    for (it = l.begin(); it != end; ++it) {
      if ((*it)->visible() && // at least not deleted
	  !(*it)->selected() &&
	  ((di = QCanvasItemToDiagramItem(*it)) != 0) &&
	  di->move_with_its_package()) {
	BrowserNode * bn = di->get_bn();
	
	do
	  bn = (BrowserNode *) bn->parent();
	while (bn->get_type() != UmlPackage);
	
	if (bn == p) {
	  the_canvas()->select(*it);
	  di->prepare_for_move(FALSE);
	}
      }
    }
  }
}
Example #9
0
void StateActionCanvas::post_loaded() {
  force_self_rel_visible();
  if (the_canvas()->must_draw_all_relations()) {
    //draw_all_simple_relations();
    draw_all_transitions();
  }
}
Example #10
0
void UcUseCaseCanvas::post_loaded()
{
    force_self_rel_visible();

    if (the_canvas()->must_draw_all_relations())
        draw_all_simple_relations();
}
Example #11
0
void TextCanvas::open()
{
    static QSize sz;

    // warning : 'note' is already unicode
    QString s = fromUnicode(text);
    bool created = s.isEmpty();

    MLEDialog::get(s, QCursor::pos(), sz);

    if (s.isEmpty())
        delete_it();
    else {
        text = s;

        if (created) {
            QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
            QSize sz = fm.size(0, text);

            DiagramCanvas::resize(sz.width(), sz.height());
        }

        // force son reaffichage
        hide();
        show();
    }

    canvas()->update();

    package_modified();
}
Example #12
0
void TransitionCanvas::select_associated() {
  if (!selected()) {
    if ((stereotypeproperties != 0) && !stereotypeproperties->selected())
      the_canvas()->select(stereotypeproperties);
    ArrowCanvas::select_associated();
  }
}
Example #13
0
void ObjectDiagramView::read(char * st, char * k) {
  UmlCanvas * canvas = the_canvas();
  
  // reads first the instances, package, fragment notes, icons text and image
  while (OdClassInstCanvas::read(st, canvas, k) ||
	 NoteCanvas::read(st, canvas, k) ||
	 TextCanvas::read(st, canvas, k) ||
	 IconCanvas::read(st, canvas, k) ||
	 PackageCanvas::read(st, canvas, k) ||
	 FragmentCanvas::read(st, canvas, k) ||
	 ImageCanvas::read(st, canvas, k))
    k = read_keyword(st);
  
  // then reads links 
  while (ObjectLinkCanvas::read(st, canvas, k))
    k = read_keyword(st);
  
  // then reads anchors
  while (ArrowCanvas::read(st, canvas, k))
    k = read_keyword(st);
  
  if (!strcmp(k, "preferred_whz") || !strcmp(k, "prefered_whz")) {
    preferred_size.setWidth(read_unsigned(st));
    preferred_size.setHeight(read_unsigned(st));
    preferred_zoom = read_double(st);
    k = read_keyword(st);
  }
  
  if (strcmp(k, "end"))
    wrong_keyword(k, "end");
}
Example #14
0
void PseudoStateCanvas::change_scale() {
  Q3CanvasRectangle::setVisible(FALSE);
  
  if (manual_size) {
    double scale = the_canvas()->zoom();
    
    if (horiz) {
      int w = (int) (width_scale100*scale);
      
      if (w < MIN_FORK_JOIN_LARGESIDE)
	w = MIN_FORK_JOIN_LARGESIDE;
      
      setSize(w | 1, FORK_JOIN_SMALLSIDE);
    }
    else {
      int h = (int) (height_scale100*scale);
      
      if (h < MIN_FORK_JOIN_LARGESIDE)
	h = MIN_FORK_JOIN_LARGESIDE;
      
      setSize(FORK_JOIN_SMALLSIDE, h | 1);
    }
    
    DiagramCanvas::resize(width(), height());
    recenter();
  }
  else
    set_xpm();
  
  recenter();
  Q3CanvasRectangle::setVisible(TRUE);
}
Example #15
0
void ActivityActionCanvas::post_loaded() {
  force_pins_arround();
  if (the_canvas()->must_draw_all_relations()) {
    draw_all_flows();
    draw_all_simple_relations();
  }
}
Example #16
0
void ArtifactCanvas::update_relations(ArtifactCanvas * other) {
  // 'this' is a non source, check association with 'other'
  const Q3PtrDict<BrowserArtifact> * associated = 
    ((ArtifactData *) browser_node->get_data())->get_associated();
  bool association_must_exist = 
    ((associated != 0) &&
     (associated->find((BrowserArtifact *) other->browser_node) != 0));
  Q3PtrListIterator<ArrowCanvas> it(lines);
    
  while (it.current()) {
    if ((it.current()->type() == UmlContain) &&
	(((AssocContainCanvas *) it.current())->get_end() == other)) {
      if (! association_must_exist)
	it.current()->delete_it();
      return;
    }
    ++it;
  }

  // association not yet exist
  
  if (association_must_exist)
    (new AssocContainCanvas(the_canvas(), this, other, 0, -1.0, -1.0))
      ->show();
}
Example #17
0
void SdSelfMsgCanvas::change_scale() {
    if (!((BrowserSeqDiagram *) the_canvas()->browser_diagram())
            ->is_overlapping_bars()) {
        // else done by check_vpos called by SdDurationCanvas::change_scale()
        SdMsgBaseCanvas::change_scale();
    }
}
Example #18
0
void LabelCanvas::moveBy(double dx, double dy)
{
    QGraphicsSimpleTextItem::moveBy(dx, dy);

    if (! the_canvas()->do_zoom())
        set_center100();
}
Example #19
0
void ActivityActionCanvas::check_pins() {
  // add missing pins
  const QValueList<BrowserPin *> brpins =
    ((BrowserActivityAction *) browser_node)->get_pins();
  QValueList<BrowserPin *>::ConstIterator iter;
  double zoom = the_canvas()->zoom();
  int sz = (int) (zoom * PIN_SIZE);
  int six = (int) (zoom * 6);
  int xl = (int) x() - sz;
  int xr = rect().right();
  int ymin = (int) y() + six;
  int ymax = (int) y() + height() - six - sz;
  int yr = ymin;
  int yl = ymin;

  sz += six;
  
  for (iter = brpins.begin(); iter != brpins.end(); ++iter) {
    QValueList<PinCanvas *>::ConstIterator itershown;
    
    for (itershown = pins.begin(); itershown != pins.end(); ++itershown)
      if ((*itershown)->get_bn() == *iter)
	break;
    
    if (itershown == pins.end()) {
      // add it
      PinCanvas * pc;
      
      if (((PinData *) (*iter)->get_data())->get_dir() ==  UmlIn) {
	pc = new PinCanvas(*iter, the_canvas(), xl, yl, 0, this);
        yl = (yl + sz);
	if (yl > ymax)
	  yl = ymin + 2;
      }
      else {
	pc = new PinCanvas(*iter, the_canvas(), xr, yr, 0, this);
        yr = (yr + sz);
	if (yr > ymax)
	  yr = ymin + 2;
      }
      
      pins.append(pc);
      pc->update();
      pc->show();
    }
  }
}
Example #20
0
void SubjectCanvas::menu(const QPoint&) {
  Q3PopupMenu m(0);
  
  MenuFactory::createTitle(m, TR("Subject"));
  m.insertSeparator();
  m.insertItem(TR("Upper"), 0);
  m.insertItem(TR("Lower"), 1);
  m.insertItem(TR("Go up"), 6);
  m.insertItem(TR("Go down"), 7);
  m.insertSeparator();
  m.insertItem(TR("Edit"), 2);
  m.insertSeparator();
  m.insertItem(TR("Edit drawing settings"), 3);
  if (linked()) {
    m.insertSeparator();
    m.insertItem(TR("Select linked items"), 4);
  }
  m.insertSeparator();
  m.insertItem(TR("Remove from diagram"),5);

  int index = m.exec(QCursor::pos());
  
  switch (index) {
  case 0:
    upper();
    modified();	// call package_modified()
    return;
  case 1:
    lower();
    modified();	// call package_modified()
    return;
  case 6:
    z_up();
    modified();	// call package_modified()
    return;
  case 7:
    z_down();
    modified();	// call package_modified()
    return;
  case 2:
    open();
    // modified then package_modified already called
    return;
  case 3:
    edit_drawing_settings();
    return;
  case 4:
    the_canvas()->unselect_all();
    select_associated();
    return;
  case 5:
    delete_it();
    break;
  default:
    return;
  }
  
  package_modified();
}
Example #21
0
void CodLinkCanvas::moveBy(double dx, double dy) {
  if (selected())
    the_canvas()->unselect(this);
  
  ArrowCanvas::moveBy(dx, dy);
  if (dirs)
    dirs->update_pos(beginp, endp);
}
Example #22
0
void ActivityPartitionCanvas::resize(const QSize & sz, bool w, bool h) {
  double zoom = the_canvas()->zoom();
  
  if (DiagramCanvas::resize(sz, w, h,
			    (int) (ACTIVITY_PARTITION_CANVAS_MIN_SIZE * zoom),
			    (int) (ACTIVITY_PARTITION_CANVAS_MIN_SIZE * zoom)))
    force_sub_inside(FALSE);
}
Example #23
0
void InterruptibleActivityRegionCanvas::resize(const QSize & sz, bool w, bool h) {
  double zoom = the_canvas()->zoom();
  
  if (DiagramCanvas::resize(sz, w, h,
			    (int) (INTERRUPTIBLE_ACTIVITY_REGION_CANVAS_MIN_SIZE * zoom),
			    (int) (INTERRUPTIBLE_ACTIVITY_REGION_CANVAS_MIN_SIZE * zoom)))
    force_sub_inside(FALSE);
}
Example #24
0
void UcUseCaseCanvas::modified() {
  used_color = (itscolor == UmlDefaultColor)
    ? the_canvas()->browser_diagram()->get_color(UmlUseCase)
    : itscolor;
  
  update_name();
  
  // force son reaffichage
  hide();
  show();
  force_self_rel_visible();
  if (the_canvas()->must_draw_all_relations())
    draw_all_simple_relations();
  check_stereotypeproperties();
  canvas()->update();
  package_modified();
}
Example #25
0
void CodClassInstCanvas::draw(QPainter & p) {
  if (visible()) {
    ClassInstCanvas::draw(p, the_canvas(), rect());

    if (selected())
      show_mark(p, rect());
  }
}
Example #26
0
void DiagramCanvas::set_center100()
{
    QPoint c = center();
    double scale = the_canvas()->zoom();

    center_x_scale100  = (int)(c.x() / scale + 0.5);
    center_y_scale100  = (int)(c.y() / scale + 0.5);
}
Example #27
0
void DiagramCanvas::recenter()
{
    double scale = the_canvas()->zoom();
    QPoint c = center();

    QGraphicsRectItem::moveBy(center_x_scale100 * scale - c.x(),
                              center_y_scale100 * scale - c.y());
}
Example #28
0
void DeploymentNodeCanvas::check_size() {
  DeploymentDiagramSettings dflt;
  
  dflt.write_horizontally = write_horizontally;
  the_canvas()->browser_diagram()->get_deploymentdiagramsettings(dflt);
  horiz = (dflt.write_horizontally == UmlYes);
  show_properties = (dflt.componentdrawingsettings.show_stereotype_properties == UmlYes);
    
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(),
				       the_canvas()->zoom());
  
  if (px != 0) {
    QFontMetrics fm(the_canvas()->get_font(UmlNormalBoldFont));
    int w;
    int h = px->height() + fm.height();
    
    if (horiz)
      w = fm.width(iname + ":" + browser_node->get_name());
    else {
      w = fm.width(browser_node->get_name());
      
      int iw = fm.width(iname + ":");
      
      if (iw > w)
	w = iw;
      
      h += fm.height() + (int) (3 * the_canvas()->zoom());
    }
    
    if (w < px->width())
      w = px->width();
    
    // force odd width and height for line alignment
    DiagramCanvas::resize(w | 1, h | 1);
  }
  else {
    int wi = min_width();
    int he = min_height();
    
    // warning : do NOT check if ((width() < wi) || (height() < he))
    // because te resize must be done to set data on scale change
    DiagramCanvas::resize((width() < wi) ? wi : width(),
			  (height() < he) ? he : height());
  }
}
Example #29
0
BrowserNode * DeploymentNodeCanvas::new_type() {
  BrowserNode * container = (BrowserNode *)
    the_canvas()->browser_diagram()->parent();
  
  return (container->is_writable())
    ? BrowserDeploymentNode::add_deploymentnode(container)
    : 0;
}
Example #30
0
void SdLifeLineCanvas::change_scale()
{
    double scale = the_canvas()->zoom();
    int w = (int)(width_scale100 * scale);
    // force odd width
    setSize(((w & 1) == 0) ? w + 1 : w, LIFE_LINE_HEIGHT);
    // don't move, the position is updated with its obj
}