Exemple #1
0
void CodLinkCanvas::save(QTextStream & st, bool ref, QString & warning) const
{
    if (ref)
        st << "linkcanvas_ref " << get_ident();
    else if (begin->typeUmlCode() != UmlArrowPoint) {
        nl_indent(st);
        st << "linkcanvas " << get_ident();

        if (decenter_begin >= 0)
            // float output/input bugged
            st << " decenter_begin " << ((int)(decenter_begin * 1000));

        if (decenter_end >= 0)
            // float output/input bugged
            st << " decenter_end " << ((int)(decenter_end * 1000));

        indent(+1);
        save_lines(st, TRUE, TRUE, warning);
        indent(-1);

        CodDirsCanvas * d = find_dirs();

        if (d != 0)
            d->save(st, FALSE, warning);
    }
}
Exemple #2
0
ArrowCanvas * CodLinkCanvas::join(ArrowCanvas * other, ArrowPointCanvas * ap) {
  // has already check is join is possible (self relation must have two points)
  CodDirsCanvas * d = (dirs != 0) ? dirs : ((CodLinkCanvas *) other)->dirs;
  
  CodLinkCanvas * result = (CodLinkCanvas *) ArrowCanvas::join(other, ap);
  
  // here this may be 'deleted' (delete_it)
  result->dirs = d;	// result cannot be 0 because start != end
  if (d != 0) {
    d->set_link(result);
    d->update_pos(result->beginp, result->endp);
  }
  result->modified();
  
  return result;
}
Exemple #3
0
void CodObjCanvas::get_all_in_all_out(ColMsgList & all_in, ColMsgList & all_out) const
{
    if (self_link) {
        ColMsg::get_all_in_all_out(all_in, all_out, self_link->get_msgs());
        // all_out still empty equals all_in
        all_out = all_in;
    }

    foreach (ArrowCanvas *canvas, lines) {
        CodDirsCanvas * dirs;

        if ((canvas->type() == UmlLink) &&
            ((dirs = ((CodLinkCanvas *) canvas)->find_dirs()) != 0)) {
            CodObjCanvas * from;
            CodObjCanvas * to;

            ((CodLinkCanvas *) canvas)->get_start_end(from, to);

            if (this == to)
                ColMsg::get_all_in_all_out(all_in, all_out, dirs->get_msgs());
            else
                ColMsg::get_all_in_all_out(all_out, all_in, dirs->get_msgs());
        }
    }
Exemple #4
0
void CodLinkCanvas::menu(const QPoint&) {
  bool new_dirs;
  CodDirsCanvas * d = find_dirs();
  CodObjCanvas * from;
  CodObjCanvas * to;

  get_start_end(from, to);
  
  if (d == 0) {
    new_dirs = TRUE;
    (d = dirs = new CodDirsCanvas(the_canvas(), this, 0))->show();
  }
  else
    new_dirs = FALSE;
  
  Q3PopupMenu m;
  Q3PopupMenu geo;
  
  m.insertItem(new MenuTitle(TR("Link"), m.font()), -1);
  m.insertSeparator();
  m.insertItem(TR("add messages to ") + from->get_full_name(), 1);
  m.insertItem(TR("add messages to ") + to->get_full_name(), 2);
  m.insertSeparator();
  m.insertItem(TR("Edit its messages"), 3);
  m.insertItem(TR("Edit all the messages"), 4);
  m.insertSeparator();
  m.insertItem(TR("Select linked items"), 7);
  m.insertSeparator();
  if (!new_dirs) {
    m.insertItem(TR("Edit drawing settings"), 5);
    m.insertSeparator();
  }
  if (get_start() != get_end()) {
    init_geometry_menu(geo, 10);
    m.insertItem(TR("Geometry (Ctrl+l)"), &geo);
    m.insertSeparator();
  }
  m.insertItem(TR("Remove from diagram"), 6);
  
  int rank = m.exec(QCursor::pos());
  
  switch (rank) {
  case 1:
    {
      CodAddMsgDialog dialog(to, from, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     FALSE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 2:
    {
      CodAddMsgDialog dialog(from, to, d,
			     (ColDiagramView *) the_canvas()->get_view(),
			     TRUE);
      
      dialog.raise();
      if (dialog.exec() != QDialog::Accepted)
	return;
    }
    break;
  case 3:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(), d->get_msgs());
    return;
  case 4:
    CodEditMsgDialog::exec((ColDiagramView *) the_canvas()->get_view(),
			   ((ColDiagramView *) the_canvas()->get_view())->get_msgs());
    return;
  case 5:
    if (d->edit_drawing_settings())
      modified();
    return;
  case 6:
    delete_it();
    ((ColDiagramView *) the_canvas()->get_view())->update_msgs();
    break;
  case 7:
    select_associated();
    return;
  default:
    if (rank >= 10) {
      rank -= 10;
      if (rank == RecenterBegin)
	set_decenter(-1.0, decenter_end);
      else if (rank == RecenterEnd)
	set_decenter(decenter_begin, -1.0);
      else if (rank != (int) geometry)
	set_geometry((LineGeometry) rank, TRUE);
      else
	return;
    }
    else
      return;
  }
  
  package_modified();
  
  if (new_dirs && (dirs != 0)) {
    if (dirs->get_msgs().count() == 0) {
      dirs->delete_it();
      dirs = 0;
    }
    else
      dirs->update_pos(beginp, endp);
  }
}
Exemple #5
0
CodDirsCanvas * CodDirsCanvas::read(char *& st, UmlCanvas * canvas, char *& k)
{
    if (!strcmp(k, "dirscanvas_ref"))
        return ((CodDirsCanvas *) dict_get(read_id(st), "dirs canvas", canvas));
    else if (!strcmp(k, "dirscanvas")) {
        int id = read_id(st);
        double z;

        if (read_file_format() < 5)
            z = OLD_COL_MSG_Z;
        else {
            read_keyword(st, "z");
            z = read_double(st);
        }

        k = read_keyword(st);

        CodDirsCanvas * result =
            new CodDirsCanvas(canvas, CodLinkCanvas::read(st, canvas, k), id);

        result->setZValue(z);
        result->link->set_dirs(result);
        result->link->update_pos();		// to place result

        k = read_keyword(st);
        result->settings.read(st, k);		// updates k

        if (!strcmp(k, "forward_label")) {
            result->label = new LabelCanvas(read_string(st), canvas, 0, 0);

            if (read_file_format() < 5) {
                read_keyword(st, "xy");
                read_xy(st, result->label);
            }
            else {
                read_keyword(st, "xyz");
                read_xyz(st, result->label);
            }

            result->label->set_center100();
            k = read_keyword(st);
        }

        if (!strcmp(k, "backward_label")) {
            result->backward_label = new LabelCanvas(read_string(st), canvas, 0, 0);

            if (read_file_format() < 5) {
                read_keyword(st, "xy");
                read_xy(st, result->backward_label);
            }
            else {
                read_keyword(st, "xyz");
                read_xyz(st, result->backward_label);
            }

            result->backward_label->set_center100();
            k = read_keyword(st);
        }

        return result;
    }
    else
        return 0;
}