当前位置: 首页>>代码示例>>C++>>正文


C++ DiagramItem类代码示例

本文整理汇总了C++中DiagramItem的典型用法代码示例。如果您正苦于以下问题:C++ DiagramItem类的具体用法?C++ DiagramItem怎么用?C++ DiagramItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DiagramItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: items

//! [11]
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;
//! [11] //! [12]

        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == DiagramItem::Type &&
            endItems.first()->type() == DiagramItem::Type &&
            startItems.first() != endItems.first()) {
            DiagramItem *startItem =
                qgraphicsitem_cast<DiagramItem *>(startItems.first());
            DiagramItem *endItem =
                qgraphicsitem_cast<DiagramItem *>(endItems.first());
            Arrow *arrow = new Arrow(startItem, endItem);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();
        }
    }
//! [12] //! [13]
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:36,代码来源:diagramscene.cpp

示例2: update_relations

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);
      }
    }
  }
}
开发者ID:kralf,项目名称:bouml,代码行数:33,代码来源:ArtifactCanvas.cpp

示例3: it

uint TreeDiagram::computeRows()
{
  //printf("TreeDiagram::computeRows()=%d\n",count());
  int count=0;
  QListIterator<DiagramRow> it(*this);
  DiagramRow *row;
  for (;(row=it.current()) && !row->getFirst()->isInList();++it)
  {
    count++;
  }
  //printf("count=%d row=%p\n",count,row);
  if (row)
  {
    int maxListLen=0;
    int curListLen=0;
    DiagramItem *opi=0;
    QListIterator<DiagramItem> rit(*row);
    DiagramItem *di;
    for (;(di=rit.current());++rit)
    {
      if (di->parentItem()!=opi) curListLen=1; else curListLen++; 
      if (curListLen>maxListLen) maxListLen=curListLen;
      opi=di->parentItem();
    }
    //printf("maxListLen=%d\n",maxListLen);
    count+=maxListLen;
  }
  return count;
}
开发者ID:Beachy13,项目名称:doxygen,代码行数:29,代码来源:diagram.cpp

示例4: apply

Action* ActionMoveResize::apply()
{
    ActionMoveResize* undo = NULL;
    
    DiagramItem* item = NULL;
    
    if (m_revertItemID != -1)
        item = m_pItemCollector->getItemByID( m_revertItemID);
    
    if (item == NULL)
        return NULL;
    
    if (m_pPosAndSize != NULL)
    {
        undo = new ActionMoveResize (m_pItemCollector, item, item->getPosAndSize());
        item->setPosAndSize(m_pPosAndSize);
        
        // update box connections
        DiagramBox *box = dynamic_cast<DiagramBox*> (item);
        
        if (box != 0)
        {
            box->updateConnections();
            
            // item is a DiagramBox, action with DiagramBox have high priority
            undo->setHightPriority( false);
        }
    }
    
    return undo;
}
开发者ID:BackupTheBerlios,项目名称:qshapes-svn,代码行数:31,代码来源:ActionMoveResize.cpp

示例5: switch

void SeqDiagramView::keyPressEvent(QKeyEvent * e)
{
    if (!window()->frozen()) {
        DiagramView::keyPressEvent(e);

        if (e->modifiers() != ::Qt::ControlModifier) {
            switch (e->key()) {
            case ::Qt::Key_Left:
            case ::Qt::Key_Up:
            case ::Qt::Key_Right:
            case ::Qt::Key_Down: {
                QList<QGraphicsItem*> all = canvas()->items();
                QList<QGraphicsItem*>::Iterator cit;

                for (cit = all.begin(); cit != all.end(); ++cit) {
                    DiagramItem * it = QCanvasItemToDiagramItem(*cit);

                    if ((it != 0) && // an uml canvas item
                            (*cit)->isVisible())
                        it->update();
                }
            }
                break;

            default:
                break;
            }
        }
    }
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:30,代码来源:SeqDiagramView.cpp

示例6: canvas

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;
                }
            }
        }
    }
}
开发者ID:jeremysalwen,项目名称:douml,代码行数:26,代码来源:ColDiagramView.cpp

示例7: QCanvasItemToDiagramItem

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());
  }
}
开发者ID:SciBoy,项目名称:douml,代码行数:25,代码来源:SubjectCanvas.cpp

示例8: collisions

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);
	}
      }
    }
  }
}
开发者ID:kralf,项目名称:bouml,代码行数:29,代码来源:PackageCanvas.cpp

示例9: switch

void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (mouseEvent->button() != Qt::LeftButton)
        return;

    DiagramItem *item;
    switch (myMode) {
        case InsertItem:
            item = new DiagramItem(myItemType, myItemMenu);
            addItem(item);
            connect(item, SIGNAL(itemSelected(DiagramItem*)), this, SIGNAL(itemSelected(DiagramItem*)));
            connect(item, SIGNAL(PropertiesRequest(DiagramItem*)), this, SIGNAL(propertiesRequest(DiagramItem*)));
            item->setPos(mouseEvent->scenePos());
            emit itemInserted(item);
            break;
        case InsertLine:
            line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(),
                                        mouseEvent->scenePos()));
            addItem(line);
            break;
    default:
        ;
    }
    QGraphicsScene::mousePressEvent(mouseEvent);
}
开发者ID:who-is-here,项目名称:FreeCiscoSimulator,代码行数:25,代码来源:diagramscene.cpp

示例10: switch

void DiagramScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (mouseEvent->button() != Qt::LeftButton)
        return;

    DiagramItem *item;
    DiagramNode nod;
    QDomNode xmlNode;
    switch (myMode)
    {
        case InsertItem:
            if(((DiagramWindow*)parent())->itemListEmpty(myItemType))
                return;
            nod  = ((DiagramWindow*)parent())->returnCurrentItem(myItemType);
            xmlNode = createItemXml(nod,mouseEvent->scenePos());
            item = new DiagramItem(myItemType, myItemMenu,nod.name,
                                   xmlNode,itemCount,
                                   nod.inputs);
            itemCount++;
            addItem(item);
            item->setPos(mouseEvent->scenePos());
            diagItems.append(item);
            emit itemInserted(item);
            break;
        case InsertLine:
            line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(),
                                            mouseEvent->scenePos()));
            line->setPen(QPen(myLineColor, 2));
            addItem(line);
        break;
    default:
        ;
    }
    QGraphicsScene::mousePressEvent(mouseEvent);
}
开发者ID:andreimariusdincu,项目名称:WHC-IDE,代码行数:35,代码来源:diagramscene.cpp

示例11: QCanvasItemToDiagramItem

// 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;
}
开发者ID:SciBoy,项目名称:douml,代码行数:30,代码来源:ActivityContainerCanvas.cpp

示例12: setItemColor

//! [3]
void DiagramScene::setItemColor(const QColor &color)
{
    myItemColor = color;
    if (isItemChange(DiagramItem::Type)) {
        DiagramItem *item = qgraphicsitem_cast<DiagramItem *>(selectedItems().first());
        item->setBrush(myItemColor);
    }
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:9,代码来源:diagramscene.cpp

示例13: onMouseDoubleClick

bool SelectMode::onMouseDoubleClick(DiagramView* view, QMouseEvent* event) {
    if (view->scene()) {
        DiagramItem* item = dynamic_cast<DiagramItem*>(view->itemAt(event->pos()));
        if (item) {
            item->showSettings();
        }
    }
    return true;
}
开发者ID:Zycon42,项目名称:qumledt,代码行数:9,代码来源:modes.cpp

示例14: items

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";
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例15: onKeyPress

bool SelectMode::onKeyPress(DiagramView* view, QKeyEvent* event) {
    if (view->scene() && view->scene()->isActive()) {
        DiagramItem* item = dynamic_cast<DiagramItem*>(view->scene()->focusItem());
        if (item && event->key() == Qt::Key_Delete) {
            item->killSelf();
            return false;
        }
    }
    return true;
}
开发者ID:Zycon42,项目名称:qumledt,代码行数:10,代码来源:modes.cpp


注:本文中的DiagramItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。