예제 #1
0
		void RegularData1DWidget::onNotify(Message *message)
		{
			if (!RTTI::isKindOf<RegularData1DMessage>(*message))
			{
				return;
			}

			RegularData1DMessage& msg = *(RegularData1DMessage*) message;
			if (msg.getData() != data_) return;

			if ((RegularData1DMessage::RegularDataMessageType) msg.getType() 
						== RegularData1DMessage::UPDATE)
			{
				createPlot();
			}
			else if ((RegularData1DMessage::RegularDataMessageType) msg.getType() 
									== RegularData1DMessage::REMOVE)
			{
				data_ = 0;

				Q3CanvasItemList list = canvas()->allItems();
				Q3CanvasItemList::Iterator it = list.begin();
				for (; it != list.end(); ++it) 
				{
					if ( *it ) delete *it;
				}
			}
		}
예제 #2
0
Q3CanvasItem * UmlCanvas::collision(const QPoint & p) const
{
    Q3CanvasItemList l = collisions(p);
    Q3CanvasItemList::ConstIterator it;
    Q3CanvasItemList::ConstIterator end = l.end();
    ArrowCanvas * arrow = 0;

    for (it = l.begin(); it != end; ++it)
        if (((*it)->visible()) && // at least not deleted
            !isa_alien(*it) &&
            !isa_col_msg_dirs(*it)) {
            switch ((*it)->rtti()) {
            case RTTI_ARROW:
                if (arrow == 0)
                    arrow = (ArrowCanvas *) *it;

                break;

            case RTTI_LABEL:
                return (arrow == 0) ? *it : arrow;

            default:
                // isa DiagramCanvas
                return ((arrow == 0) ||
                        (small_element(((DiagramCanvas *) *it)->rect()) &&
                         ((DiagramCanvas *) *it)->attached_to(arrow)))
                       ? *it : arrow;
            }
        }

    return arrow;
}
예제 #3
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);
	}
      }
    }
  }
}
예제 #4
0
void SubjectCanvas::send(ToolCom * com, Q3CanvasItemList & all)
{
  Q3PtrList<SubjectCanvas> subjects;
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && 
	(*cit)->visible() &&
	(di->type() == UmlSubject))
      subjects.append((SubjectCanvas *) di);
  }
  
  com->write_unsigned(subjects.count());
  
  SubjectCanvas * sc;
  
  for (sc = subjects.first(); sc != 0; sc = subjects.next()) {
    Q3CString s = fromUnicode(sc->name);
    
    com->write_string((const char *) s);
    com->write(sc->rect());
  }
}
예제 #5
0
void ColDiagramView::update_msg_supports()
{
    Q3CanvasItemList l = canvas()->allItems();
    Q3CanvasItemList::Iterator it;

    for (it = l.begin(); it != l.end(); ++it) {
        if ((*it)->visible()) { // at least not deleted
            DiagramItem * di = QCanvasItemToDiagramItem(*it);

            if (di != 0) {
                switch (di->type()) {
                case UmlSelfLink:
                    ((CodSelfLinkCanvas *) di)->update_msgs();
                    break;

                case UmlLinkDirs:
                    ((CodDirsCanvas *) di)->update_msgs();
                    break;

                default:	// to avoid compiler warning
                    break;
                }
            }
        }
    }
}
예제 #6
0
// if elt parent is present, force inside it
bool ActivityContainerCanvas::force_inside(DiagramCanvas * elt, bool part)
{
  // if its parent is present, force inside it  
  Q3CanvasItemList all = elt->the_canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  BrowserNode * parent = (BrowserNode *) elt->get_bn()->parent();

  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
      
      if ((di != 0) &&
	  IsaActivityContainer(di->type(), part) &&
	  (((ActivityContainerCanvas *) di)->get_bn() == parent)) {
	BooL under = FALSE;
	
	((ActivityContainerCanvas *) di)->force_inside(elt, elt, under);
	
	if (under)
	  elt->upper();
	
	return TRUE;
      }
    }
  }
  
  elt->upper();
  return FALSE;
}
예제 #7
0
void ArtifactCanvas::draw_all_relations() {
  if (strcmp(browser_node->get_stereotype(), "source") != 0)
    // may start association
    update_relations();
  else if (!DrawingSettings::just_modified() &&
	   !on_load_diagram()) {
    // remove all association starting from 'this'
    Q3PtrListIterator<ArrowCanvas> it(lines);
    
    while (it.current()) {
      if ((it.current()->type() == UmlContain) &&
	  (((AssocContainCanvas *) it.current())->get_start() == this))
	it.current()->delete_it();
      else
	++it;
    }
    
    // update non source artifact vis a vis 'this'
    Q3CanvasItemList all = canvas()->allItems();
    Q3CanvasItemList::Iterator cit;
    
    for (cit = all.begin(); cit != all.end(); ++cit) {
      if ((*cit)->visible()) {
	DiagramItem * adi = QCanvasItemToDiagramItem(*cit);
	
	if ((adi != 0) &&		// an uml canvas item
	    (adi->type() == UmlArtifact) &&
	    strcmp(((ArtifactCanvas *) adi)->browser_node->get_stereotype(), "source"))
	  ((ArtifactCanvas *) adi)->update_relations(this);
      }
    }
  }
}
예제 #8
0
void CanvasDialog::clear()
{
	Q3CanvasItemList list = m_canvasView->canvas()->allItems();
	Q3CanvasItemList::Iterator it = list.begin();
	for( ; it != list.end(); ++it )
	{
		if ( *it ) delete *it;
	}
}
예제 #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()));
}
예제 #10
0
/**
 * Returns -1 if the given point is not on the line.
 * else returns the line segment the point is on.
 * Use the value to insert points at the point position.
 */
int LinePath::onLinePath( const QPoint &position )
{
    Q3CanvasItemList list = getScene()->collisions( position );
    int index = -1;

    Q3CanvasItemList::iterator end(list.end());
    for(Q3CanvasItemList::iterator item_it(list.begin()); item_it != end; ++item_it ) {
        if( ( index = m_LineList.indexOf( (Q3CanvasLine*)*item_it ) ) != -1 )
            break;
    }//end for
    return index;
}
예제 #11
0
DiagramItemList::DiagramItemList(Q3CanvasItemList l)
{
    Q3CanvasItemList::Iterator it;

    for (it = l.begin(); it != l.end(); ++it) {
        if ((*it)->visible()) {
            DiagramItem * di = QCanvasItemToDiagramItem(*it);

            if (di != 0)
                append(di);
        }
    }
}
예제 #12
0
void ReportSection::buildXML(QDomDocument & doc, QDomElement & section) {
    //qDebug("ReportSection::buildXML()");
    float f = (float)canvas->height() / dpiY * 100.0;
    f = ((f - (int)f) > .5 ? (int)f : (int)f + 1);
    QDomElement height = doc.createElement("height");
    height.appendChild(doc.createTextNode(QString::number((int)f)));
    section.appendChild(height);

    // now get a list of all the QCanvasItems on this canvas and output them.
    Q3CanvasItemList list = canvas->allItems();
    for(Q3CanvasItemList::iterator it = list.begin();
          it != list.end(); it++ ) {
          ReportEntity::buildXML((*it),doc,section);
    }
}
예제 #13
0
Q3CanvasItemList DigitView::collisionsFiltered(Q3CanvasItemList listIn, int rtti)
{
  // filter out all but the desired types
  Q3CanvasItemList listOut;

  Q3CanvasItemList::iterator itrIn;
  for (itrIn = listIn.begin(); itrIn != listIn.end(); ++itrIn)
  {
    ASSERT_ENGAUGE((*itrIn) != 0);
    if ((*itrIn)->rtti() == rtti)
      listOut.append(*itrIn);
  }

  return listOut;
}
예제 #14
0
파일: UmlCanvas.cpp 프로젝트: SciBoy/douml
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;
}
예제 #15
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();
        }
    }
}
예제 #16
0
// update sub nodes to be upper this, recursively
void ActivityContainerCanvas::force_sub_upper(Q3CanvasItemList & all) {
  Q3CanvasItemList::Iterator cit;
  BrowserNode * browser_node = get_bn();
  
  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      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:	    
	    if ((*cit)->z() <= z())
	      ((DiagramCanvas *) di)->upper();
	    
	    {
	      ActivityContainerCanvas * cntr =
		dynamic_cast<ActivityContainerCanvas *>(di);
	      
	      if (cntr != 0)
		cntr->force_sub_upper(all);
	    }
	    break;
	  default:
	    break;
	  }
      }
    }
  }  
}
예제 #17
0
void ActivityPartitionCanvas::turn(int cx100, int cy100)
{
  horiz ^= TRUE;
  setSize(height(), width());
  
  if (cx100 == -1000) {
    // first turn partition
    cx100 = center_x_scale100;
    cy100 = center_y_scale100;
  }
  else {
    int dx = center_x_scale100 - cx100;
    int dy = center_y_scale100 - cy100;
    
    if (horiz) {
      center_x_scale100 = cx100 + dy;
      center_y_scale100 = cy100 - dx;
    }
    else {
      center_x_scale100 = cx100 - dy;
      center_y_scale100 = cy100 + dx;
    }
  }
  
  recenter();
  DiagramCanvas::resize(width(), height());
  
  Q3CanvasItemList all = the_canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  
  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      ActivityPartitionCanvas * p = dynamic_cast<ActivityPartitionCanvas *>(*cit);

      if ((p != 0) && 
	  (p->get_bn()->parent() == browser_node) &&
	  (p->horiz != horiz)) {
	p->turn(cx100, cy100);
      }
    }
  }
}
예제 #18
0
파일: FlowCanvas.cpp 프로젝트: SciBoy/douml
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();
    }
  }
}
예제 #19
0
void ColorChooser::ClickableView::contentsMousePressEvent(QMouseEvent* e)
{
  Q3CanvasItemList list = canvas()->collisions(e->pos());
  if (!list.isEmpty())
  {
    // sift through list looking for a Tab
   Q3CanvasItemList::iterator itr;
    for (itr = list.begin(); itr != list.end(); ++itr)
    {
      Q3CanvasItem* item = *itr;
      if (item->rtti() == Divider::Tab::RttiTab)
      {
        dragging = true;
        draggedTab = (Divider::Tab*) item;
        ASSERT_ENGAUGE(e != 0);
        draggedTab->divider()->dragStart(e->pos().x());
        break;
      }
    }
  }
}
예제 #20
0
void FragmentCanvas::prepare_for_move(bool on_resize) {
  if (!on_resize) {
    DiagramCanvas::prepare_for_move(on_resize);
    
    QRect r = rect();
    Q3CanvasItemList l = collisions(TRUE);
    Q3CanvasItemList::ConstIterator it;
    Q3CanvasItemList::ConstIterator end = l.end();
    DiagramItem * di;
  
    for (it = l.begin(); it != end; ++it) {
      if ((*it)->visible() && // at least not deleted
	  !(*it)->selected() &&
	  ((di = QCanvasItemToDiagramItem(*it)) != 0) &&
	  r.contains(di->rect(), TRUE) &&
	  di->move_with(UmlFragment)) {
	the_canvas()->select(*it);
	di->prepare_for_move(FALSE);
      }
    }
  }
}
예제 #21
0
bool ActivityActionCanvas::force_inside() {
  // if its parent is present, force inside it
  
  Q3CanvasItemList all = the_canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  BrowserNode * parent = (BrowserNode *) browser_node->parent();

  for (cit = all.begin(); cit != all.end(); ++cit) {
    if ((*cit)->visible()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
      
      if ((di != 0) &&
	  IsaActivityContainer(di->type()) &&
	  (((ActivityContainerCanvas *) di)->get_bn() == parent)) {
	((ActivityContainerCanvas *) di)->force_inside(this, this);
	return TRUE;
      }
    }
  }
  
  return FALSE;
}
예제 #22
0
void CodClassInstCanvas::send(ToolCom * com, Q3CanvasItemList & all)
{
  Q3PtrList<CodClassInstCanvas> l;
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && (*cit)->visible()) {
       switch (di->type()) {
       case UmlClass:
       case UmlClassInstance:
	 l.append((CodClassInstCanvas *) di);
	 break;
       default:
	 break;
       }
    }
  }

  com->write_unsigned(l.count());
  
  Q3PtrListIterator<CodClassInstCanvas> it(l);
  
  for (; it.current(); ++it) {
    CodClassInstCanvas * i = it.current();
    
    com->write_unsigned((unsigned) i->get_ident());
    if (i->browser_node->get_type() == UmlClass) {      
      com->write_id(0);
      
      Q3CString s = fromUnicode(i->iname);
      
      com->write_string((const char *) s);
    }
    i->browser_node->write_id(com);
  }
}
예제 #23
0
// update sub nodes position to be inside this
void ActivityContainerCanvas::force_sub_inside(Q3CanvasItemList & all,
					       BooL & need_sub_upper) {
  Q3CanvasItemList::Iterator cit;
  BrowserNode * browser_node = get_bn();
  
  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:
	  force_inside(di, *cit, need_sub_upper);
	  break;
	default:
	  break;
	}
      }
    }
  }
}
예제 #24
0
void FragmentCanvas::send(ToolCom * com, Q3CanvasItemList & all,
			  Q3PtrList<FragmentCanvas> & fragments,
			  Q3PtrList<FragmentCanvas> & refs)
{
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && (*cit)->visible() && (di->type() == UmlFragment))
      fragments.append((FragmentCanvas *) di);
  }
  
  com->write_unsigned(fragments.count());
  
  FragmentCanvas * f;
  
  for (f = fragments.first(); f != 0; f = fragments.next()) {
    Q3CString s = fromUnicode(f->name);
    
    com->write_string((const char *) s);
    com->write(f->rect());
    
    // few separators, use bubble sort
    unsigned sz = f->separators.count();
    
    if (sz == 0)
      com->write_unsigned(1);
    else {
      FragmentSeparatorCanvas ** v = new FragmentSeparatorCanvas *[sz];
      unsigned index;      
      Q3PtrListIterator<FragmentSeparatorCanvas> it(f->separators);
      
      for (index = 0; it.current(); ++it, index += 1)
	v[index] = it.current();
      
      bool modified;
      
      do {
	modified = FALSE;
	
	for (index = 1; index < sz; index += 1) {
	  if (v[index - 1]->y() > v[index]->y()) {
	    modified = TRUE;
	    
	    FragmentSeparatorCanvas * fs = v[index - 1];
	    
	    v[index - 1] = v[index];
	    v[index] = fs;
	  }
	}
      } while (modified);
      
      com->write_unsigned(sz + 1);
      
      for (index = 0; index != sz; index += 1)
	com->write_unsigned((unsigned) v[index]->y());
      
      delete [] v;
    }
      
    com->write_unsigned((unsigned) (f->y() + f->height() - 1));

    if (com->api_format() >= 41) {
      if (f->refer != 0)
	f->refer->write_id(com);
      else
	com->write_id(0);
      
      s = fromUnicode(f->form);
      com->write_string((const char *) s);
      
      if (f->name == "ref")
	refs.append(f);
    }
  }
}
예제 #25
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);
}
예제 #26
0
void SdLifeLineCanvas::send(ToolCom * com, const Q3CanvasItemList & l,
			    Q3PtrList<FragmentCanvas> & fragments,
			    Q3PtrList<FragmentCanvas> & refs)
{
  int api_format = com->api_format();
  Q3PtrDict<SdLifeLineCanvas> used_refs; // the key is the fragment ref
  Q3PtrList<SdLifeLineCanvas> lls;
  Q3CanvasItemList::ConstIterator cit;
  unsigned n = 0;
  
  // count msgs
  
  for (cit = l.begin(); cit != l.end(); ++cit) {
    DiagramItem * it = QCanvasItemToDiagramItem(*cit);
      
    if ((it != 0) && // an uml canvas item
	(*cit)->visible() &&
	(it->type() == UmlLifeLine)) {
      SdLifeLineCanvas * ll = (SdLifeLineCanvas *) it;

      lls.append(ll);
      
      Q3PtrListIterator<SdDurationCanvas> iter(ll->durations);
      
      // standard msgs
      for (; iter.current(); ++iter)
	n += iter.current()->count_msg(api_format);
      
      if (com->api_format() >= 41) {
	if (ll->end != LIFE_LINE_HEIGHT)
	  // deletion message, ll can't masked by user
	  n += 1;
      
	FragmentCanvas * f;
	
	for (f = refs.first(); f != 0; f = refs.next()) {
	  if (f->collidesWith(ll)) {
	    // interaction use message
	    if (used_refs.find((void *) f) == 0) {
	      n += 1;
	      used_refs.insert((void *) f, ll);
	    }
	  }
	}
      }
    }
  }
  
  // write messages
  
  com->write_unsigned(n);
  
  SdLifeLineCanvas * ll;
  
  for (ll = lls.first(); ll != 0; ll = lls.next()) {
    int id = ll->obj->get_ident();
    Q3PtrListIterator<SdDurationCanvas> iter(ll->durations);
  
    // write standard messages
    for (; iter.current(); ++iter)
      iter.current()->send(com, id);
    
    if ((ll->end != LIFE_LINE_HEIGHT) && (com->api_format() >= 41)) {
      // deletion message, lf can't masked by user
      int m = ll->width()/2;
      
      SdMsgBaseCanvas::send(com, id, (unsigned) ll->x() + m,
			    (unsigned) ll->end + m, aDestruction, "", "", "");
    }
  }
  
  if (com->api_format() >= 41) {
    // interaction use messages
    Q3PtrDictIterator<SdLifeLineCanvas>itref(used_refs);
    
    while ((ll = itref.current()) != 0) {
      FragmentCanvas * f = (FragmentCanvas *) itref.currentKey();
      int m = ll->width()/2;
      
      SdMsgBaseCanvas::send(com, ll->obj->get_ident(),
			    (unsigned) ll->x() + m, (unsigned) f->center().y(),
			    anInteractionUse, "", "", f->arguments());
      
      ++itref;
    }
    
    // send life lines covered by fragment
    FragmentCanvas * f;
    
    for (f = fragments.first(); f != 0; f = fragments.next()) {
      Q3PtrList<SdLifeLineCanvas> covered;
      
      for (ll = lls.first(); ll != 0; ll = lls.next())
	if (f->collidesWith(ll))
	  covered.append(ll);
      
      com->write_unsigned(covered.count());
      
      for (ll = covered.first(); ll != 0; ll = covered.next())
	com->write_unsigned((unsigned) ll->obj->get_ident());
    }
  }
}
예제 #27
0
void SdDurationCanvas::menu(const QPoint & p) {
  Q3PopupMenu m(0);
  Q3CanvasItemList items = collisions(TRUE);
  Q3PtrList<SdDurationCanvas> l;
  Q3CanvasItemList::ConstIterator it;
  Q3CanvasItemList::ConstIterator end = items.end();
  
  for (it = items.begin(); it != end; ++it) {
    if ((*it)->visible()) {
      DiagramItem * di = QCanvasItemToDiagramItem(*it);
      
      if ((di != 0) &&
	  (di->type() == UmlActivityDuration) &&
	  (((SdDurationCanvas *) di)->support == support))
	l.append((SdDurationCanvas *) di);
    }
  }
  
  m.insertItem(new MenuTitle(TR("Activity bar"), m.font()), -1);
  m.insertSeparator();
  m.insertItem(TR("Upper"), 0);
  m.insertItem(TR("Lower"), 1);
  m.insertItem(TR("Go up"), 9);
  m.insertItem(TR("Go down"), 10);
  m.insertSeparator();
  m.insertItem((coregion) ? TR("Draw as activity bar") :  TR("Draw as a coregion"), 7);
  m.insertItem(TR("Edit drawing settings"), 2);
  m.insertSeparator();
  m.insertItem(TR("Select linked items"), 3);
  m.insertSeparator();
  m.insertItem(TR("Remove from diagram"), 4);
  m.insertSeparator();
  m.insertItem(TR("Cut here"), 5);
  if (!l.isEmpty())
    m.insertItem(TR("Merge juxtaposed activity bars"), 6);
  if (support->isaDuration())
    m.insertItem(TR("Collapse in parent bar"), 8);

  switch (m.exec(QCursor::pos())) {
  case 0:
    upper();
    modified();
    return;
  case 1:
    lower();
    modified();
    return;
  case 9:
    z_up();
    modified();	// call package_modified()
    return;
  case 10:
    z_down();
    modified();	// call package_modified()
    return;
  case 2:
    edit_drawing_settings();
    return;
  case 3:
    select_associated();
    break;
  case 4:
    delete_it();
    package_modified();
    break;
  case 5:
    cut(p);
    package_modified();
    break;
  case 6:
    merge(l);
    package_modified();
    break;
  case 7:
    coregion = !coregion;
    modified();
    return;
  case 8:
    {
      SdDurationCanvas * d = (SdDurationCanvas *) support;
      
      d->collapse(this);
      d->update_hpos(); // update sub duration and msg hpos
      d->update_self();
    }    
    package_modified();
    break;
  default:
    return;
  }
  
  canvas()->update();
}
예제 #28
0
void UcClassCanvas::draw_all_depend_gene(UcClassCanvas * end) {
  Q3ListViewItem * child;
  Q3CanvasItemList all = canvas()->allItems();
  Q3CanvasItemList::Iterator cit;
  
  for (child = browser_node->firstChild(); child; child = child->nextSibling()) {
    if (dependencyOrGeneralization(((BrowserNode *) child)->get_type()) &&
	!((BrowserNode *) child)->deletedp()) {
      RelationData * def =
	((RelationData *) ((BrowserNode *) child)->get_data());

      if ((def->get_start_class() == browser_node) && 	// rel begins by this
	  ((end == 0) || (def->get_end_class() == end->browser_node)) &&
	  !has_relation(def)) {
	// adds it in case the other class is drawn
	BrowserClass * end_class = 
	  ((BrowserClass *) def->get_end_class());
	DiagramItem * di;
	
	if (end_class == browser_node)
	  di = this;
	else {	
	  di = 0;
	  for (cit = all.begin(); cit != all.end(); ++cit) {
	    DiagramItem * adi = QCanvasItemToDiagramItem(*cit);
	    
	    if ((adi != 0) &&		// an uml canvas item
		(adi->type() == UmlClass) &&
		(((UcClassCanvas *) adi)->browser_node == end_class) &&
		((((UcClassCanvas *) adi) == end) || (*cit)->visible())) {
	      // other class canvas find
	      di = adi;
	      break;
	    }
	  }
	}
	
	if (di != 0)
	  (new RelationCanvas(the_canvas(), this, di,
			      ((BrowserClass *) browser_node), 
			      def->get_type(), 0, -1.0, -1.0, def))
	    ->show();
      }
    }
  }
  
  if ((end == 0) &&
      !DrawingSettings::just_modified() &&
      !on_load_diagram()) {
    for (cit = all.begin(); cit != all.end(); ++cit) {
      DiagramItem * di = QCanvasItemToDiagramItem(*cit);
      
      if ((di != 0) &&	// an uml canvas item
	  (di->type() == UmlClass) &&
	  (((UcClassCanvas *) di) != this) &&
	  !((UcClassCanvas *) di)->browser_node->deletedp() &&
	  ((UcClassCanvas *) di)->visible())
	((UcClassCanvas *) di)->draw_all_depend_gene(this);
    }
  }
}
예제 #29
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);
}
예제 #30
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);
	    }
	  }
	}
      }
    }
  }
}