Ejemplo n.º 1
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();
        }
    }
}
Ejemplo n.º 2
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();
    }
  }
}