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


C++ NodeElement类代码示例

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


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

示例1: arrangeLinearPorts

void NodeElement::arrangeLinks()
{
	//Episode I: Home Jumps
	for (EdgeElement* edge : mEdgeList) {
		NodeElement* src = edge->src();
		NodeElement* dst = edge->dst();
		edge->reconnectToNearestPorts(this == src, this == dst);
	}

	//Episode II: Home Ports Arranging
	arrangeLinearPorts();

	//Episode III: Remote Jumps
	for (EdgeElement* edge : mEdgeList) {
		NodeElement* src = edge->src();
		NodeElement* dst = edge->dst();
		NodeElement* other = edge->otherSide(this);
		edge->reconnectToNearestPorts(other == src, other == dst);
	}

	//Episode IV: Remote Arrangigng
	QSet<NodeElement*> arranged;
	for (EdgeElement* edge : mEdgeList) {
		NodeElement* other = edge->otherSide(this);
		if (other && !arranged.contains(other)) {
			other->arrangeLinearPorts();
			arranged.insert(other);
		}
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:30,代码来源:nodeElement.cpp

示例2: setGeometry

void NodeElement::changeFoldState()
{
	mIsFolded = !mIsFolded;

	for (QGraphicsItem* childItem : childItems()) {
		NodeElement* curItem = dynamic_cast<NodeElement*>(childItem);
		if (curItem) {
			curItem->setVisible(!mIsFolded);
			curItem->setLinksVisible(!mIsFolded);
		}
	}

	if (mIsFolded) {
		mCurUnfoldedContents = mContents;
		mFoldedContents.moveTo(pos());
		setGeometry(mFoldedContents);
	}
	else {
		mCurUnfoldedContents.moveTo(pos());
		setGeometry(mCurUnfoldedContents);
	}
	mGraphicalAssistApi.mutableGraphicalRepoApi().setProperty(mId, "folded", mIsFolded ? "true" : "false");

	NodeElement* parent = dynamic_cast<NodeElement*>(parentItem());
	if (parent) {
		parent->resize();
	}
	updateLabels();
}
开发者ID:Antropovi,项目名称:qreal,代码行数:29,代码来源:nodeElement.cpp

示例3: hide

void EmbeddedLinker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
	hide();
	master->selectionState(false);
	EditorViewScene* scene = dynamic_cast<EditorViewScene*>(master->scene());

	if (!mPressed && scene && mEdge) {
		mEdge->hide();
		QPointF const &eScenePos = event->scenePos();
		NodeElement *under = dynamic_cast<NodeElement*>(scene->itemAt(eScenePos));
		mEdge->show();
		int result = 0;

		if (!under) {
			result = scene->launchEdgeMenu(mEdge, master, eScenePos);
			NodeElement *target = dynamic_cast<NodeElement*>(scene->getLastCreated());
			if (result == -1) {
				mEdge = NULL;
			} else if ((result == +1) && target) {
				QPointF const &posRelativeToTheTarget = target->mapFromScene(eScenePos);
				mEdge->placeEndTo(mapFromItem(target, target->getNearestPort(posRelativeToTheTarget)));
				mEdge->connectToPort();	//it provokes to move target somehow, so it needs to place edge end and connect to port again
				mEdge->placeEndTo(mapFromItem(target, target->getNearestPort(posRelativeToTheTarget)));
				mEdge->adjustLink();
			}
		}
		if (result != -1) {
			mEdge->connectToPort();
		}
	}
}
开发者ID:BogdanKl,项目名称:qreal,代码行数:31,代码来源:embeddedLinker.cpp

示例4: setOpacity

void NodeElement::drawPlaceholder(QGraphicsRectItem *placeholder, QPointF pos)
{
	// for non-sorting containers no need for drawing placeholder so just make them marked
	if (!mElementImpl->isSortingContainer()) {
		setOpacity(0.2);
		return;
	}

	// binary search? No because we need to know summary height of prev elements
	NodeElement *nextItem = nullptr;

	for (QGraphicsItem* childItem : childItems()) {
		NodeElement *curItem = dynamic_cast<NodeElement*>(childItem);
		if (curItem) {
			if (curItem->scenePos().y() > pos.y()) {
				nextItem = curItem;
				break;
			}
		}
	}

	erasePlaceholder(false);
	mPlaceholder = placeholder;
	mPlaceholder->setParentItem(this);
	if(nextItem) {
		mPlaceholder->stackBefore(nextItem);
	}

	resize();
}
开发者ID:Antropovi,项目名称:qreal,代码行数:30,代码来源:nodeElement.cpp

示例5: initNode

bool BaseMultiMappingElement::initNode()
{
    using namespace core::objectmodel;
    using namespace core;
    bool result = ObjectElement::initNode();


    if( result )
    {

        BaseMapping* multimapping = this->getTypedObject()->toBaseMapping();
        NodeElement* currentNodeElement = dynamic_cast<NodeElement *>(getParent());
        simulation::Node* currentNode =  dynamic_cast<simulation::Node* >( currentNodeElement->getTypedObject() );
        helper::vector<core::BaseState*> inputStates  = multimapping->getFrom();
        helper::vector<core::BaseState*> outputStates = multimapping->getTo();


        helper::vector<core::BaseState*>::iterator iterState;
        helper::vector<simulation::Node*> inputNodes, outputNodes;

        /* get the Nodes corresponding to each input BaseState context */
        for( iterState = inputStates.begin();  iterState != inputStates.end(); ++iterState)
        {
            simulation::Node* node = dynamic_cast< simulation::Node* >((*iterState)->getContext());
            inputNodes.push_back(node);
        }
        /* */
        /* get the Nodes corresponding to each output BaseState context */
        for( iterState = outputStates.begin(); iterState != outputStates.end(); ++iterState)
        {
            simulation::Node* node = dynamic_cast< simulation::Node* >((*iterState)->getContext());
            outputNodes.push_back(node);
        }

        helper::vector<simulation::Node*>::iterator iterNode;
        BaseNode* currentBaseNode;

        /* filter out inputNodes which already belong to the currentNode ancestors */
        helper::vector<simulation::Node*> otherInputNodes;
        helper::vector<simulation::Node*> ancestorInputNodes;
        iterNode = inputNodes.begin();
        currentBaseNode = currentNode;
        for( iterNode = inputNodes.begin(); iterNode != inputNodes.end(); ++iterNode)
        {
            if( !currentBaseNode->hasAncestor(*iterNode) )
            {
                otherInputNodes.push_back(*iterNode);
            }
            else
            {
                ancestorInputNodes.push_back(*iterNode);
            }
        }

        updateSceneGraph(multimapping, ancestorInputNodes, otherInputNodes, outputNodes );

    }

    return result;
}
开发者ID:david-cazier,项目名称:sofa,代码行数:60,代码来源:BaseMultiMappingElement.cpp

示例6: nodeById

void ResizeCommand::resizeTree(QMap<Id, QRectF> const &snapshot, const Id &root)
{
	NodeElement *element = nodeById(root);
	for (NodeElement *child : element->childNodes()) {
		if (snapshot.contains(child->id())) {
			resizeTree(snapshot, child->id());
		}
	}

	resize(element, snapshot[root]);
}
开发者ID:Antropovi,项目名称:qreal,代码行数:11,代码来源:resizeCommand.cpp

示例7: adjustLinks

void NodeElement::adjustLinks()
{
	for (EdgeElement *edge : mEdgeList) {
		edge->adjustLink();
	}

	for (QGraphicsItem *child : childItems()) {
		NodeElement *element = dynamic_cast<NodeElement*>(child);
		if (element) {
			element->adjustLinks();
		}
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:13,代码来源:nodeElement.cpp

示例8: makeChildrenSnapshot

void ResizeCommand::makeHierarchySnapshot(NodeElement *node, QMap<Id, QRectF> &target)
{
	// Here we remembering all binded items geometries.
	// Binded items are just element`s hierarchy:
	// all parents and children (siblings are not considered)
	makeChildrenSnapshot(node, target);
	for (NodeElement *parentElement = node; parentElement;
			parentElement = dynamic_cast<NodeElement *>(parentElement->parentItem()))
	{
		target.insert(parentElement->id(), geometryOf(parentElement));
		addEdges(parentElement);
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:13,代码来源:resizeCommand.cpp

示例9: setLinksVisible

void NodeElement::setLinksVisible(bool isVisible)
{
	for (EdgeElement *curEdge : mEdgeList) {
		curEdge->setVisible(isVisible);
	}

	for (QGraphicsItem* childItem : childItems()) {
		NodeElement* curItem = dynamic_cast<NodeElement*>(childItem);
		if (curItem) {
			curItem->setLinksVisible(isVisible);
		}
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:13,代码来源:nodeElement.cpp

示例10: deleteGuides

void SceneGridHandler::drawGuides()
{
	const int drift = 5;  // A dirft for scene not to resize from guide lines.
	const QPointF nodeScenePos = mNode->scenePos();
	const QRectF contentsRect = mNode->contentsRect();
	const QRectF sceneRect = mNode->scene()->sceneRect().adjusted(drift, drift, -drift, -drift);

	deleteGuides();

	QList<QGraphicsItem *> list = getAdjancedNodes();

	qreal myX1 = nodeScenePos.x() + contentsRect.x();
	qreal myY1 = nodeScenePos.y() + contentsRect.y();
	qreal myX2 = myX1 + contentsRect.width();
	qreal myY2 = myY1 + contentsRect.height();

	for (QGraphicsItem *graphicsItem : list) {
		NodeElement *item = dynamic_cast<NodeElement *>(graphicsItem);
		if (item == nullptr || item->parentItem() != nullptr || item == mNode) {
			continue;
		}

		const QPointF point = item->scenePos();
		const QRectF contents = item->contentsRect();

		const qreal pointX1 = point.x() + contents.x() - spacing;
		const qreal pointY1  = point.y() + contents.y() - spacing;
		const qreal pointX2 = pointX1  + contents.width() + 2 * spacing;
		const qreal pointY2  = pointY1 + contents.height() + 2 * spacing;

		if (pointX1 != myX1 || pointY1 != myY1) {
			const qreal deltaY1 = qAbs(pointY1 - myY1);
			const qreal deltaY2 = qAbs(pointY2 - myY2);
			const qreal deltaX1 = qAbs(pointX1 - myX1);
			const qreal deltaX2 = qAbs(pointX2 - myX2);

			buildLineY(deltaY1, pointY1, 0, myY1, myY2, sceneRect);
			buildLineY(deltaY2, pointY2, contentsRect.height(), myY1, myY2, sceneRect);

			buildLineX(deltaX1, pointX1, 0, myX1, myX2, sceneRect);
			buildLineX(deltaX2, pointX2, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY1 - myY2), pointY1, contentsRect.height(), myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX1 - myX2), pointX1, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY2 - myY1), pointY2, 0, myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX2 - myX1), pointX2, 0, myX1, myX2, sceneRect);
		}
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:50,代码来源:sceneGridHandler.cpp

示例11: getNewGraphicalPos

void PasteNodeCommand::restoreElement()
{
	Id const logicalId = mMVIface->graphicalAssistApi()->logicalId(mResult);
	mMVIface->graphicalAssistApi()->setProperties(logicalId, mNodeData.logicalProperties);
	mMVIface->graphicalAssistApi()->setProperties(mResult, mNodeData.graphicalProperties);
	mMVIface->graphicalAssistApi()->setPosition(mResult, getNewGraphicalPos());
	if (mCopiedIds->contains(mNodeData.parentId)) {
		mMVIface->graphicalAssistApi()->changeParent(mResult, mCopiedIds->value(mNodeData.parentId), getNewPos());
	}
	NodeElement *element = mScene->getNodeById(mResult);
	if (element) {
		element->updateData();
	}
}
开发者ID:alina-ptakhina,项目名称:qreal,代码行数:14,代码来源:pasteNodeCommand.cpp

示例12: delUnusedLines

void SceneGridHandler::drawGuides()
{
	QPointF const nodeScenePos = mNode->scenePos();
	QRectF const contentsRect = mNode->contentsRect();
	QRectF const sceneRect = mNode->scene()->sceneRect();

	delUnusedLines();

	QList<QGraphicsItem *> list = getAdjancedNodes();

	qreal myX1 = nodeScenePos.x() + contentsRect.x();
	qreal myY1 = nodeScenePos.y() + contentsRect.y();
	qreal myX2 = myX1 + contentsRect.width();
	qreal myY2 = myY1 + contentsRect.height();

	foreach (QGraphicsItem *graphicsItem, list) {
		NodeElement *item = dynamic_cast<NodeElement *>(graphicsItem);
		if (item == NULL || item->parentItem() != NULL || item == mNode) {
			continue;
		}

		QPointF const point = item->scenePos();
		QRectF const contents = item->contentsRect();

		qreal const pointX1 = point.x() + contents.x() - spacing;
		qreal const pointY1  = point.y() + contents.y() - spacing;
		qreal const pointX2 = pointX1  + contents.width() + 2 * spacing;
		qreal const pointY2  = pointY1 + contents.height() + 2 * spacing;

		if (pointX1 != myX1 || pointY1 != myY1) {
			qreal const deltaY1 = qAbs(pointY1 - myY1);
			qreal const deltaY2 = qAbs(pointY2 - myY2);
			qreal const deltaX1 = qAbs(pointX1 - myX1);
			qreal const deltaX2 = qAbs(pointX2 - myX2);

			buildLineY(deltaY1, pointY1, 0, myY1, myY2, sceneRect);
			buildLineY(deltaY2, pointY2, contentsRect.height(), myY1, myY2, sceneRect);

			buildLineX(deltaX1, pointX1, 0, myX1, myX2, sceneRect);
			buildLineX(deltaX2, pointX2, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY1 - myY2), pointY1, contentsRect.height(), myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX1 - myX2), pointX1, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY2 - myY1), pointY2, 0, myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX2 - myX1), pointX2, 0, myX1, myX2, sceneRect);
		}
	}
开发者ID:BogdanKl,项目名称:qreal,代码行数:48,代码来源:sceneGridHandler.cpp

示例13:

QList<NodeElement *> ClipboardHandler::getNodesForCopying()
{
	QList<NodeElement *> nodes;
	for (QGraphicsItem * const item : mScene.selectedItems()) {
		NodeElement *node = dynamic_cast<NodeElement *>(item);
		if (node && !mScene.selectedItems().contains(node->parentItem())) {
			nodes << node;
		}
	}

	for (NodeElement * const node : nodes) {
		addChildren(node, nodes);
	}

	return nodes;
}
开发者ID:Smirnov-Mikhail,项目名称:qreal,代码行数:16,代码来源:clipboardHandler.cpp

示例14: updateMasterEdges

void EmbeddedLinker::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
	updateMasterEdges();
	hide();
	mMaster->selectionState(false);
	EditorViewScene* scene = dynamic_cast<EditorViewScene*>(mMaster->scene());

	if (!mPressed && scene && mEdge) {
		mEdge->hide();
		QPointF const &eScenePos = event->scenePos();
		NodeElement *under = dynamic_cast<NodeElement*>(scene->itemAt(eScenePos, QTransform()));
		mEdge->show();
		int result = 0;

		commands::CreateElementCommand *createElementFromMenuCommand = NULL;
		if (!under) {
			result = scene->launchEdgeMenu(mEdge, mMaster, eScenePos, &createElementFromMenuCommand);
			NodeElement *target = dynamic_cast<NodeElement*>(scene->getLastCreated());
			if (result == -1) {
				mEdge = NULL;
			} else if ((result == 1) && target) {
				mEdge->setDst(target);
				target->storeGeometry();
			}
		}
		if (result != -1) {
			mEdge->connectToPort();
			mEdge->adjustNeighborLinks();
			mEdge->correctArrow();
			mEdge->correctInception();
			mEdge->adjustNeighborLinks();
			// This will restore edge state after undo/redo
			commands::ReshapeEdgeCommand *reshapeEdge = new commands::ReshapeEdgeCommand(mEdge);
			reshapeEdge->startTracking();
			reshapeEdge->stopTracking();
			reshapeEdge->setUndoEnabled(false);
			if (createElementFromMenuCommand) {
				createElementFromMenuCommand->addPostAction(reshapeEdge);
				mCreateEdgeCommand->addPostAction(createElementFromMenuCommand);
			} else {
				mCreateEdgeCommand->addPostAction(reshapeEdge);
			}
		}
	}
	mPressed = false;
	mEdge = NULL;
}
开发者ID:dima6120,项目名称:qreal,代码行数:47,代码来源:embeddedLinker.cpp

示例15: adjust

void LineHandler::adjust()
{
	QPolygonF line = mEdge->line();
	NodeElement *src = mEdge->src();
	NodeElement *dst = mEdge->dst();

	if (src && src->isSelected() && dst && dst->isSelected() && !mEdge->isLoop()) {
		QPointF offset = mEdge->mapFromItem(src, src->portPos(mEdge->fromPort())) - line.first();
		mEdge->setPos(mEdge->pos() + offset);
		return;
	}

	if (src) {
		line.first() = mEdge->mapFromItem(src, src->portPos(mEdge->fromPort()));
	}

	if (dst) {
		line.last() = mEdge->mapFromItem(dst, dst->portPos(mEdge->toPort()));
	}

	mEdge->setLine(line);

	if (mEdge->isLoop()) {
		mEdge->createLoopEdge();
	}
}
开发者ID:Esenin,项目名称:qreal,代码行数:26,代码来源:lineHandler.cpp


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