Пример #1
0
void ComponentDiagramView::read(char * st, char * k) {
  UmlCanvas * canvas = the_canvas();
  
  // reads first component package icons notes junctions text and images
  while (ComponentCanvas::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) ||
	 ArrowJunctionCanvas::read(st, canvas, k) ||
	 ImageCanvas::read(st, canvas, k))
    k = read_keyword(st);
  
  // then reads relations and anchors
  ArrowCanvas * a;
  
  while (((a = ArrowCanvas::read(st, canvas, k)) != 0) ||
	 ((a = SimpleRelationCanvas::read(st, canvas, k)) != 0)) {
    a->get_start()->check_line(a);
    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");
}
Пример #2
0
void ActivityDiagramView::read(char * st, char * k)
{
    // reads first state package icons notes text and image
    UmlCanvas * canvas = the_canvas();

    while (ActivityCanvas::read(st, canvas, k) ||
           InterruptibleActivityRegionCanvas::read(st, canvas, k) ||
           ExpansionRegionCanvas::read(st, canvas, k) ||
           ActivityPartitionCanvas::read(st, canvas, k) ||
           ActivityActionCanvas::read(st, canvas, k) ||
           ActivityObjectCanvas::read(st, canvas, k) ||
           ActivityNodeCanvas::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
    ArrowCanvas * a;

    while (((a = ArrowCanvas::read(st, canvas, k)) != 0) ||
           ((a = FlowCanvas::read(st, canvas, k)) != 0) ||
           ((a = SimpleRelationCanvas::read(st, canvas, k)) != 0)) {
        a->get_start()->check_line(a);
        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");
}
Пример #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);
}
Пример #4
0
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);
	    }
	  }
	}
      }
    }
  }
}