Exemplo n.º 1
0
void BrowserNodeList::search(BrowserNode * bn, UmlCode k, const QString & s,
			     bool cs, bool even_deleted, bool for_name,
			     bool for_stereotype)
{
  Q3ListViewItem * child;
    
  for (child = bn->firstChild(); child != 0; child = child->nextSibling()) {
    if (even_deleted || !((BrowserNode *) child)->deletedp()) {
      BrowserNode * ch = (BrowserNode *) child;
      
      if (((k == UmlCodeSup) ||
	   ((k == UmlRelations)
	    ? IsaRelation(ch->get_type())
	    : (ch->get_type() == k))) &&
	  (s.isEmpty() ||
	   (QString((for_name)
		    ? ch->get_name()
		    : ((for_stereotype) ? ch->get_stereotype()
					: ch->get_comment()))
	    .find(s, 0, cs) != -1)))
	append((BrowserNode *) child);
      
      search((BrowserNode *) child, k, s, cs, even_deleted,
	     for_name, for_stereotype);
    }
  }
}
Exemplo n.º 2
0
void ClassDiagramView::save(QTextStream & st, QString & warning,
			    bool copy) const {
  DiagramItemList items(canvas()->allItems());
  DiagramItem * di;
  
  if (!copy)
    // sort is useless for a copy
    items.sort();
    
  st << "format " << FILEFORMAT << "\n";
  
  // save first the classes packages fragment notes and icons
  
  for (di = items.first(); di != 0; di = items.next()) {
    switch (di->type()) {
    case UmlClass:
    case UmlNote:
    case UmlText:
    case UmlImage:
    case UmlPackage:
    case UmlFragment:
    case UmlIcon:
      if (!copy || di->copyable())
	di->save(st, FALSE, warning);
      // no break
    default:
      break;
    }
  }

  // then saves relations
  
  for (di = items.first(); di != 0; di = items.next()) {
    if (!copy || di->copyable()) {
      UmlCode k = di->type();
      
      if (IsaRelation(k) || IsaSimpleRelation(k) || (k == UmlInner))
	di->save(st, FALSE, warning);
    }
  }
  
  // then saves anchors
  
  for (di = items.first(); di != 0; di = items.next())
    if ((!copy || di->copyable()) && (di->type() == UmlAnchor))
      di->save(st, FALSE, warning);
  
  if (!copy && (preferred_zoom != 0)) {
    nl_indent(st);
    st << "preferred_whz " << preferred_size.width() << ' '
      << preferred_size.height() << ' ' << preferred_zoom;
  }
  
  nl_indent(st);
  st << "end\n";
}
Exemplo n.º 3
0
void UcClassCanvas::connexion(UmlCode action, DiagramItem * dest,
			      const QPoint &, const QPoint &) {
  ArrowCanvas * a;
  
  if ((dest->type() == UmlClass) && IsaRelation(action))
    a = new RelationCanvas(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);
}
Exemplo n.º 4
0
bool UcClassCanvas::has_relation(BasicData * def) const {
  Q3PtrListIterator<ArrowCanvas> it(lines);
	
  while (it.current()) {
    if (IsaRelation(it.current()->type()) &&
	(((RelationCanvas *) it.current())->get_data() == def))
      return TRUE;
    ++it;
  }
  
  return FALSE;
}
Exemplo n.º 5
0
bool OdClassInstCanvas::has_relation(const SlotRel & slot_rel) const {
  QListIterator<ArrowCanvas> it(lines);
	
  while (it.current()) {
    if (IsaRelation(it.current()->type()) &&
	(((ObjectLinkCanvas *) it.current())
	 ->is(slot_rel, it.current()->get_start() == (DiagramItem *) this)))
	return TRUE;
    ++it;
  }
  
  return FALSE;
}
Exemplo n.º 6
0
// return true if a clone of lnk already exist between this and other
bool OdClassInstCanvas::is_duplicated(ObjectLinkCanvas * lnk, 
				      OdClassInstCanvas * other) const {
  RelationData * rel = lnk->get_rel();
  QListIterator<ArrowCanvas> it(lines);
  ArrowCanvas * ar;
  
  while ((ar = it.current()) != 0) {
    if ((ar != lnk) &&
	IsaRelation(ar->type()) &&
	(((ObjectLinkCanvas *) ar)->get_rel() == rel) &&
	(ar->get_end() == other))
      return TRUE;
    else
      ++it;
  }
  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 UmlClass:
    case UmlPackage:
      drawn.replace(di->get_bn()->get_data(), di);
      break;
    default:
      if (IsaRelation(k) || IsaSimpleRelation(k))
	drawn.replace(((ArrowCanvas *) di)->get_data(), di);
    }
  }    
}
Exemplo n.º 8
0
// have marked elements not yet drawn ?
static bool marked_not_yet_drawn(Q3PtrDict<DiagramItem> & drawn)
{
    const QList<BrowserNode *> & l = BrowserNode::marked_nodes();
    foreach (BrowserNode *bn, l) {
        UmlCode k = bn->get_type();

        switch (k) {
        default:
            if (!IsaRelation(k) && !IsaSimpleRelation(k))
                break;

            // no break
        case UmlClass:
        case UmlPackage:
        case UmlUseCase:
            if (drawn[bn->get_data()] == 0)
                return TRUE;
        }
    }
Exemplo n.º 9
0
void ObjectDiagramView::save(QTextStream & st, QString & warning,
                             bool copy) const
{
    DiagramItemList items(canvas()->items());

    if (!copy)
        // sort is useless for a copy
        items.sort();

    st << "format " << api_format() << "\n";

    // save first the packages fragment, classes instances, notes, icons and text

    foreach (DiagramItem *di, items) {
        switch (di->typeUmlCode()) {
        case UmlPackage:
        case UmlFragment:
        case UmlClassInstance:
        case UmlNote:
        case UmlText:
        case UmlImage:
        case UmlIcon:
            if (!copy || di->copyable())
                di->save(st, FALSE, warning);

            // no break
        default:
            break;
        }
    }

    // then save links

    foreach (DiagramItem *di, items) {
        UmlCode k = di->typeUmlCode();

        if (IsaRelation(k) || (k == UmlObjectLink)) {
            if (!copy || di->copyable())
                di->save(st, FALSE, warning);
        }
    }
Exemplo n.º 10
0
void BrowserNodeList::search_ddb(BrowserNode * bn, UmlCode k, const QString & s,
				 bool cs, bool even_deleted)
{
  Q3ListViewItem * child;
    
  for (child = bn->firstChild(); child != 0; child = child->nextSibling()) {
    if (even_deleted || !((BrowserNode *) child)->deletedp()) {
      BrowserNode * ch = (BrowserNode *) child;
      
      if (((k == UmlCodeSup) ||
	   ((k == UmlRelations)
	    ? IsaRelation(ch->get_type())
	    : (ch->get_type() == k))) &&
	  (s.isEmpty() || 
	   ch->get_data()->decldefbody_contain(s, cs, ch)))
	append(ch);
      
      search_ddb(ch, k, s, cs, even_deleted);
    }
  }
}
Exemplo n.º 11
0
// have marked elements not yet drawn ?
static bool marked_not_yet_drawn(Q3PtrDict<DiagramItem> & drawn)
{
  const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes();
  Q3PtrListIterator<BrowserNode> it(l);
  BrowserNode * bn;
      
  for (; (bn = it.current()) != 0; ++it) {
    UmlCode k = bn->get_type();
    
    switch (k) {
    default:
      if (!IsaRelation(k) && !IsaSimpleRelation(k))
	break;
      // no break
    case UmlClass:
    case UmlPackage:
      if (drawn[bn->get_data()] == 0)
	return TRUE;
    }
  }
  
  return FALSE;
}
Exemplo n.º 12
0
void OdClassInstCanvas::modified()
{
    if (visible()) {
        hide();
        hide_lines();
        compute_size();
        show();
        update_show_lines();

        if (browser_node->get_type() != UmlClass)
            check_stereotypeproperties();

        if (the_canvas()->must_draw_all_relations())
            draw_all_relations();

        foreach (ArrowCanvas *canvas, lines)
            if (IsaRelation(canvas->type()))
                // useless to check UmlObjectLink ie unset link
                ((ObjectLinkCanvas *) canvas)->check();

        canvas()->update();
        package_modified();
    }
}
Exemplo n.º 13
0
void OdClassInstCanvas::modified() {
  if (visible()) {
    hide();
    hide_lines();
    compute_size();
    show();
    update_show_lines();
    if (browser_node->get_type() != UmlClass)
      check_stereotypeproperties();
    
    if (the_canvas()->must_draw_all_relations())
      draw_all_relations();
    
    QListIterator<ArrowCanvas> it(lines);
    
    for (; it.current(); ++it)
      if (IsaRelation(it.current()->type()))
	// useless to check UmlObjectLink ie unset link
	((ObjectLinkCanvas *) it.current())->check();
    
    canvas()->update();
    package_modified();
  }
}
Exemplo n.º 14
0
void ClassDiagramView::add_marked_elements(const QPoint& p,
					   Q3PtrDict<DiagramItem> & drawn) {
  QApplication::setOverrideCursor(Qt::waitCursor);
  
  history_save();
  history_protected = TRUE;
  
  int xmax = canvas()->width() - Diagram_Margin;
  int ymax = canvas()->height() - Diagram_Margin;
  int x = p.x();
  int y = p.y();
  int future_y = y;
  const Q3PtrList<BrowserNode> & l = BrowserNode::marked_nodes();
  Q3PtrListIterator<BrowserNode> it(l);
  BrowserNode * bn;

  for (; (bn = it.current()) != 0; ++it) {
    if (drawn[bn->get_data()] == 0) {
      DiagramCanvas * dc;
      
      switch (bn->get_type()) {
      case UmlClass:
	dc = new CdClassCanvas(bn, the_canvas(), x, y);
	break;
      case UmlPackage:
	dc = new PackageCanvas(bn, the_canvas(), x, y, 0);
	break;
      default:
	continue;
      }

      drawn.replace(dc->get_bn()->get_data(), dc);
      
      if ((x + dc->width()) > xmax)
	dc->move(x = Diagram_Margin, y = future_y);
      
      if (y + dc->height() > ymax) {
	dc->move(x = Diagram_Margin, y = Diagram_Margin);
	future_y = y + dc->height() + Diagram_Margin;
      }
      else {
	int bot = y + dc->height() + Diagram_Margin;
	
	if (bot > future_y)
	  future_y = bot;
      }
      
      x = x + dc->width() + Diagram_Margin;
      
      dc->show();
      dc->upper();
    }
  }
  
  UmlCanvas * cnv = (UmlCanvas *) canvas();
  
  if (! cnv->must_draw_all_relations()) {
    for (it.toFirst(); (bn = it.current()) != 0; ++it) {
      if (drawn[bn->get_data()] == 0) {
	UmlCode k = bn->get_type();
	
	if (IsaRelation(k))
	  RelationCanvas::drop(bn, cnv, drawn);
	else if (IsaSimpleRelation(k))
	  SimpleRelationCanvas::drop(bn, cnv, drawn);
      }
    }
  }
  
  canvas()->update();
  history_protected = FALSE;
  window()->package_modified();
  
  QApplication::restoreOverrideCursor();
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
QString OdClassInstCanvas::may_connect(UmlCode & l, const DiagramItem * dest) const {
  return ((dest->type() == UmlClassInstance)
	  ? ((l == UmlObjectLink) || (l == UmlAnchor) || IsaRelation(l))
	  : (l == UmlAnchor))
    ? 0 : TR("illegal");
}