Exemplo n.º 1
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);
	}
      }
    }
  }
}
Exemplo n.º 2
0
void SimpleRelationCanvas::drop(BrowserNode * bn, UmlCanvas * canvas)
{
    SimpleRelationData * def = (SimpleRelationData *) bn->get_data();
    BrowserNode * from = def->get_start_node();
    BrowserNode * to = def->get_end_node();
    DiagramItem * ccfrom = 0;
    DiagramItem * ccto = 0;
    Q3CanvasItemList all = canvas->allItems();
    Q3CanvasItemList::Iterator cit;

    // the two classes are drawn ?
    for (cit = all.begin(); cit != all.end(); ++cit) {
        if ((*cit)->visible()) {
            DiagramItem * adi = QCanvasItemToDiagramItem(*cit);

            if (adi != 0) {
                if (adi->get_bn() == from) {
                    ccfrom = adi;

                    if (ccto != 0)
                        break;
                }

                if (adi->get_bn() == to) {
                    ccto = adi;

                    if (ccfrom != 0)
                        break;
                }
            }
        }
    }

    if ((ccfrom != 0) && (ccto != 0)) {
        if (ccfrom->has_relation(def))
            msg_information("Douml", "relation already drawn");
        else {
            SimpleRelationCanvas * rel =
                new SimpleRelationCanvas(canvas, ccfrom, ccto, from,
                                         bn->get_type(), 0, -1.0, -1.0, def);

            rel->show();
            rel->package_modified();
        }
    }
}
// update sub nodes to be upper this, recursively
void ActivityContainerCanvas::force_sub_upper(QList<QGraphicsItem*> & all)
{
    QList<QGraphicsItem*>::Iterator cit;
    BrowserNode * browser_node = get_bn();

    for (cit = all.begin(); cit != all.end(); ++cit) {
        if ((*cit)->isVisible()) {
            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 equals to the diagram and the parent of the diagram is the activity
                switch (di->typeUmlCode()) {
                case UmlActivityObject:
                case UmlActivityAction:
                case UmlActivityPartition:
                case UmlExpansionRegion:
                case UmlInterruptibleActivityRegion:
                case InitialAN:
                case FlowFinalAN:
                case ActivityFinalAN:
                case DecisionAN:
                case MergeAN:
                case ForkAN:
                case JoinAN:
                    if ((*cit)->zValue() <= zValue())
                        ((DiagramCanvas *) di)->upper();

                    {
                        ActivityContainerCanvas * cntr =
                            dynamic_cast<ActivityContainerCanvas *>(di);

                        if (cntr != 0)
                            cntr->force_sub_upper(all);
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
}
Exemplo n.º 4
0
void FlowCanvas::drop(BrowserNode * bn, UmlCanvas * canvas)
{
  FlowData * def = (FlowData *) bn->get_data();
  BrowserNode * from = def->get_start_node();
  BrowserNode * to = def->get_end_node();
  DiagramItem * difrom = 0;
  DiagramItem * dito = 0;
  Q3CanvasItemList all = canvas->allItems();
  Q3CanvasItemList::Iterator cit;

  // the two extremities are drawn ?
  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
    
      if (di != 0) {
	if (di->get_bn() == from) {
	  difrom = di;
	  if (dito != 0)
	    break;
	}
	if (di->get_bn() == to) {
	  dito = di;
	  if (difrom != 0)
	    break;
	}
      }
    }
  }
  
  if ((difrom != 0) && (dito != 0)) {
    if (difrom->has_relation(UmlFlow, def))
      msg_information("Bouml", TR("flow already drawn"));
    else {
      FlowCanvas * tr = 
	new FlowCanvas(canvas, difrom, dito, from, 0, -1.0, -1.0, def);
      
      tr->show();
      tr->package_modified();
    }
  }
}
// update sub nodes position to be inside this
void ActivityContainerCanvas::force_sub_inside(QList<QGraphicsItem*> & all,
        BooL & need_sub_upper)
{
    QList<QGraphicsItem*>::Iterator cit;
    BrowserNode * browser_node = get_bn();

    for (cit = all.begin(); cit != all.end(); ++cit) {
        if ((*cit)->isVisible()/* && !(*cit)->isSelected()*/) {
            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 equals to the diagram and the parent of the diagram is the activity
                switch (di->typeUmlCode()) {
                case UmlActivityObject:
                case UmlActivityAction:
                case UmlActivityPartition:
                case UmlExpansionRegion:
                case UmlInterruptibleActivityRegion:
                case InitialAN:
                case FlowFinalAN:
                case ActivityFinalAN:
                case DecisionAN:
                case MergeAN:
                case ForkAN:
                case JoinAN:
                    force_inside(di, *cit, need_sub_upper);
                    break;

                default:
                    break;
                }
            }
        }
    }
}
Exemplo n.º 6
0
bool UmlCanvas::already_drawn(BrowserNode * bn) {
  Q3CanvasItemList all = allItems();
  Q3CanvasItemList::Iterator cit;
  UmlCode k = bn->get_type();

  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
    
      if ((di != 0) && (di->type() == k) && (di->get_bn() == bn))
	return TRUE;
    }
  }

  return FALSE;
}
Exemplo n.º 7
0
static void get_drawn(DiagramItemList & items,
		      Q3PtrDict<DiagramItem> & drawn)
{
  DiagramItem * di;
  
  for (di = items.first(); di != 0; di = items.next()) {
    UmlCode k = di->type();
    
    switch (k) {
    case UmlComponent:
    case UmlPackage:
      drawn.replace(di->get_bn()->get_data(), di);
      break;
    default:
      if (IsaSimpleRelation(k))
	drawn.replace(((ArrowCanvas *) di)->get_data(), di);
    }
  }
}
Exemplo n.º 8
0
void DiagramItem::remove_if_already_present()
{
    const UmlCode k = type();
    const BrowserNode * bn = get_bn();
    IdIterator<DiagramItem> it(the_canvas()->get_all_items());
    DiagramItem * di;

    while ((di = it.current()) != 0) {
        if ((di->type() == k) && (di->get_bn() == bn) && (di != this)) {
            // already present
            if (Undefined.isEmpty())
                msg_warning("Douml", TR("some elements already present in the diagram are NOT paste"));

            Undefined.append(this);
            return;
        }

        ++it;
    }
}
Exemplo n.º 9
0
ActivityPartitionCanvas::ActivityPartitionCanvas(BrowserNode * bn, UmlCanvas * canvas,
						 int x, int y)
    : ActivityContainerCanvas(0, canvas, x, y, 
			      ACTIVITY_PARTITION_CANVAS_MIN_SIZE,
			      ACTIVITY_PARTITION_CANVAS_MIN_SIZE, 0) {
  browser_node = bn;
  itscolor = UmlDefaultColor;
  
  BrowserNode * parent = (BrowserNode *) browser_node->parent();
  
  if (parent->get_type() == UmlActivityPartition) {
    Q3CanvasItemList all = the_canvas()->allItems();
    Q3CanvasItemList::Iterator cit;

    for (cit = all.begin(); cit != all.end(); ++cit) {
      if ((*cit)->visible()) {
	DiagramItem * di = QCanvasItemToDiagramItem(*cit);
	
	if ((di != 0) && (di->get_bn() == parent)) {
	  horiz = ((ActivityPartitionCanvas *) di)->horiz;
	  break;
	}
      }
    }
    
    if (cit == all.end())
      horiz = FALSE;
  }
  else
    horiz = FALSE;

  check_size();
  check_stereotypeproperties();
  
  ActivityPartitionData * data =
    (ActivityPartitionData *) browser_node->get_data();
  
  connect(data, SIGNAL(changed()), this, SLOT(modified()));
  connect(data, SIGNAL(deleted()), this, SLOT(deleted()));
  connect(DrawingSettings::instance(), SIGNAL(changed()), this, SLOT(modified()));
}
Exemplo n.º 10
0
// resize this to contain its sub elements
void ActivityContainerCanvas::resize_to_contain(Q3CanvasItemList & all,
						BooL & need_sub_upper) {
  Q3CanvasItemList::Iterator cit;
  BrowserNode * browser_node = get_bn();
  QRect r = rect();
  int resize_left = 0;
  int resize_right = 0;
  int resize_top = 0;
  int resize_bottom = 0;
  
  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 equals to the diagram and the parent of the diagram is the activity
	switch (di->type()) {
	case UmlActivityObject:
	case UmlActivityAction:
	case UmlActivityPartition:
	case UmlExpansionRegion:
	case UmlInterruptibleActivityRegion:
	case InitialAN:
	case FlowFinalAN:
	case ActivityFinalAN:
	case DecisionAN:
	case MergeAN:
	case ForkAN:
	case JoinAN:
	  {
	    QRect di_r = di->rect();
	    int dx = 0;
	    int dy = 0;
	    
	    if (di_r.left() < r.left()) {
	      dx = r.left() - di_r.left();
	      if (dx > resize_left)
		resize_left = dx;
	    }
	    
	    if (di_r.right() > r.right()) {
	      dx = di_r.right() - r.right();
	      if (dx > resize_right)
		resize_right = dx;
	    }
	    
	    if (di_r.top() < r.top()) {
	      dy = r.top() - di_r.top();
	      if (dy > resize_top)
		resize_top = dy;
	    }
	    
	    if (di_r.bottom() > r.bottom()) {
	      dy = di_r.bottom() - r.bottom();
	      if (dy > resize_bottom)
		resize_bottom = dy;
	    }
	  }
	      
	  need_sub_upper |= ((*cit)->z() <= z());
	  break;
	default:
	  break;
	}
      }
    }
  }
  
  int dx = 0;
  int dy = 0;
  int dw = 0;
  int dh = 0;
  
  if (resize_top != 0) {
    dy = -resize_top;
    dh = resize_top;
  }
  
  if (resize_bottom != 0)
    dh += resize_bottom;
  
  if (resize_left != 0) {
    dx = -resize_left;
    dw = resize_left;
  }
  
  if (resize_right != 0)
    dw += resize_right;
  
  if ((dx != 0) || (dy != 0)) {
    moveBy(dx, dy);
    moveSelfRelsBy(dx, dy);
  }
  
  if ((dw != 0) || (dh != 0))
    DiagramCanvas::resize(width() + dw, height() + dh);
}
Exemplo n.º 11
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);
	    }
	  }
	}
      }
    }
  }
}