Exemple #1
0
void CodObjCanvas::connexion(UmlCode l, DiagramItem * dest,
                             const QPoint & s, const QPoint & e)
{
    switch (l) {
    case UmlSelfLink:
        self_link = new CodSelfLinkCanvas(the_canvas(), this, s, 0);
        self_link->show();
        the_canvas()->select(self_link);
        break;

    case UmlAnchor:
        DiagramCanvas::connexion(l, dest, s, e);
        break;

    default:
        if (dest != this) {
            ArrowCanvas * a =
                new CodLinkCanvas(the_canvas(), this, dest, 0, -1.0, -1.0);

            a->show();
            the_canvas()->select(a);
        }
    }
}
void ActivityContainerCanvas::prepare_for_move(bool on_resize) {
  if (! on_resize) {
    // select all sub nodes
    Q3CanvasItemList all = canvas()->allItems();
    Q3CanvasItemList::Iterator cit;
    UmlCanvas * canvas = the_canvas();
    
    for (cit = all.begin(); cit != all.end(); ++cit) {
      if ((*cit)->visible() && !(*cit)->selected()) {
	DiagramItem * di = QCanvasItemToDiagramItem(*cit);
	
	if ((di != 0) &&
	    (di->get_bn() != 0) &&
	    (((BrowserNode *) di->get_bn()->parent()) == browser_node)) {
	  // must look at the type because some canvas items have browser_node
	  // attr set to the diagram and the parent of the diagram is the activity
	  switch (di->type()) {
	  case UmlActivityObject:
	  case UmlActivityAction:
	  case UmlActivityPartition:
	  case InitialAN:
	  case FlowFinalAN:
	  case ActivityFinalAN:
	  case DecisionAN:
	  case MergeAN:
	  case ForkAN:
	  case JoinAN:
	  case UmlExpansionRegion:
	  case UmlInterruptibleActivityRegion:
	    canvas->select(*cit);
	    ((DiagramCanvas *) di)->prepare_for_move(on_resize);
	    break;
	  default:
	    break;
	  }
	}
      }
    }

    // select points on lines having the two extremities selected or
    // connecting pin/parameter/expansion node of element selected
    for (cit = all.begin(); cit != all.end(); ++cit) {
      if ((*cit)->visible() && !(*cit)->selected() && isa_arrow(*cit)) {
	ArrowCanvas * ar = (ArrowCanvas *) *cit;
	DiagramItem * b;
	DiagramItem * e;
	
	ar->extremities(b, e);

	if (!b->isSelected() || !e->isSelected()) {
	  DiagramItem * start = ar->get_start();
	  DiagramItem * dest = ar->get_end();

	  if ((start->isSelected() || indirectly_selected(start)) &&
	      (dest->isSelected() || indirectly_selected(dest))) {
	    while (b->type() == UmlArrowPoint) {
	      canvas->select((ArrowPointCanvas *) b);
	      ar = ((ArrowPointCanvas *) b)->get_other(ar);
	      ar->extremities(b, e);
	    }

	    ar = (ArrowCanvas *) *cit;
	    ar->extremities(b, e);

	    while (e->type() == UmlArrowPoint) {
	      canvas->select((ArrowPointCanvas *) e);
	      ar = ((ArrowPointCanvas *) e)->get_other(ar);
	      ar->extremities(b, e);
	    }
	  }
	}
      }
    }
  }
}
Exemple #3
0
void UcUseCaseCanvas::send(ToolCom * com, Q3CanvasItemList & all)
{
  Q3PtrList<UcUseCaseCanvas> lu;
  Q3PtrList<UcClassCanvas> la;
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && (*cit)->visible()) {
      switch (di->type()) {
      case UmlUseCase:
	lu.append((UcUseCaseCanvas *) di);
	break;
      case UmlClass:
	la.append((UcClassCanvas *) di);
	break;
      default:
	break;
      }
    }
  }
  
  // send UC
  
  com->write_unsigned(lu.count());
  
  Q3PtrListIterator<UcUseCaseCanvas> itu(lu);
  
  for (; itu.current(); ++itu) {
    com->write_unsigned((unsigned) itu.current()->get_ident());
    itu.current()->get_bn()->write_id(com);
    com->write(itu.current()->rect());
  }
  
  // send Actors
  
  com->write_unsigned(la.count());
  
  Q3PtrListIterator<UcClassCanvas> ita(la);
  
  for (; ita.current(); ++ita)
    ita.current()->get_bn()->write_id(com);
  
  // send rels
  
  Q3PtrList<ArrowCanvas> lr;
  
  for (itu.toFirst(); itu.current(); ++itu) {
    Q3PtrListIterator<ArrowCanvas> itl(itu.current()->lines);
    
    for (; itl.current(); ++itl) {
      ArrowCanvas * r = itl.current();
      DiagramItem * from = r->get_start();
      DiagramItem * to = r->get_end();
      
      if ((from->type() == UmlUseCase)
	  ? (to->type() == UmlClass)
	  : (from->type() == UmlClass))
	lr.append(r);
    }
  }
  
  com->write_unsigned(lr.count());
  
  Q3PtrListIterator<ArrowCanvas> itr(lr);
  
  for (; itr.current(); ++itr)
    itr.current()->write_uc_rel(com);
}
void ArrowPointCanvas::connexion(UmlCode action, DiagramItem * dest,
                                 const QPoint &, const QPoint &)
{
    ArrowCanvas * a;

    switch (the_canvas()->browser_diagram()->get_type()) {
    case UmlClassDiagram:
        if (IsaRelation(action)) {
            a = new RelationCanvas(the_canvas(), this, dest, 0, action, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }

        break;

    case UmlColDiagram:
        if (action == UmlLink) {
            a = new CodLinkCanvas(the_canvas(), this, dest, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }

        break;

    case UmlObjectDiagram:
        if (action == UmlObjectLink) {
            a = new ObjectLinkCanvas(the_canvas(), this, dest, UmlObjectLink, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }
        break;

    case UmlDeploymentDiagram:
    case UmlComponentDiagram:
        if (action == UmlContain) {
            a = new AssocContainCanvas(the_canvas(), this, dest, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }

    case UmlStateDiagram:
        if (action == UmlTransition) {
            a = new TransitionCanvas(the_canvas(), this, dest, 0, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }

    case UmlActivityDiagram:
        if (action == UmlFlow) {
            a = new FlowCanvas(the_canvas(), this, dest, 0, 0, -1.0, -1.0);
            a->show();
            the_canvas()->select(a);
            return;
        }
    default:	// to avoid warning
        break;
    }
    if (IsaSimpleRelation(action))
        a = new SimpleRelationCanvas(the_canvas(), this, dest, 0, action, 0, -1.0, -1.0);
    else
        a = new ArrowCanvas(the_canvas(), this, dest, action, 0, FALSE, -1.0, -1.0);

    a->show();
    the_canvas()->select(a);
}