本文整理汇总了C++中NodeElement::parentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeElement::parentItem方法的具体用法?C++ NodeElement::parentItem怎么用?C++ NodeElement::parentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeElement
的用法示例。
在下文中一共展示了NodeElement::parentItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeHierarchySnapshot
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);
}
}
示例2: drawGuides
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);
}
}
}
示例3: drawGuides
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);
}
}
示例4:
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;
}
示例5: resizeHierarchy
void ResizeCommand::resizeHierarchy(QMap<Id, QRectF> const &snapshot)
{
for (const Id &id : snapshot.keys()) {
NodeElement *element = nodeById(id);
if (!element->parentItem()) {
resizeTree(snapshot, id);
}
}
// Updating linker position
if (mScene->selectedItems().size() == 1) {
QGraphicsItem *selectedItem = mScene->selectedItems()[0];
NodeElement *selectedNode = dynamic_cast<NodeElement *>(selectedItem);
if (selectedNode) {
selectedNode->setVisibleEmbeddedLinkers(true);
}
}
}
示例6: mouseReleaseEvent
void NodeElement::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (dynamic_cast<NodeElement *>(scene()->mouseGrabberItem()) == this) {
ungrabMouse();
}
if (event->button() == Qt::RightButton) {
event->accept();
return;
}
deleteGuides();
storeGeometry();
if (scene() && (scene()->selectedItems().size() == 1) && isSelected()) {
setVisibleEmbeddedLinkers(true);
}
if (mDragState == None) {
Element::mouseReleaseEvent(event);
}
EditorViewScene *evScene = dynamic_cast<EditorViewScene *>(scene());
commands::InsertIntoEdgeCommand *insertCommand = new commands::InsertIntoEdgeCommand(
*evScene, mModels, id(), id(), Id::rootId(), event->scenePos(), boundingRect().bottomRight(), false);
bool shouldProcessResize = true;
// we should use mHighlightedNode to determine if there is a highlighted node
// insert current element into them and set mHighlightedNode to nullptr
// but because of mouseRelease twice triggering we can't do it
// This may cause more bugs
if (flags() & ItemIsMovable) {
if (mHighlightedNode) {
NodeElement *newParent = mHighlightedNode;
Element *insertBefore = mHighlightedNode->getPlaceholderNextElement();
mHighlightedNode->erasePlaceholder(false);
// commented because of bug with double event sending (see #204)
// mHighlightedNode = nullptr;
QPointF newPos = mapToItem(newParent, mapFromScene(scenePos()));
AbstractCommand *parentCommand = changeParentCommand(newParent->id(), newPos);
mController->execute(parentCommand);
// Position change already processed in change parent command
shouldProcessResize = parentCommand == nullptr;
setPos(newPos);
if (insertBefore) {
mGraphicalAssistApi.stackBefore(id(), insertBefore->id());
}
newParent->resize();
while (newParent) {
newParent->mContents = newParent->mContents.normalized();
newParent->storeGeometry();
newParent = dynamic_cast<NodeElement*>(newParent->parentItem());
}
} else {
AbstractCommand *parentCommand = changeParentCommand(evScene->rootItemId(), scenePos());
mController->execute(parentCommand);
// Position change already processed in change parent command
shouldProcessResize = parentCommand == nullptr;
}
}
for (EdgeElement* edge : mEdgeList) {
edge->layOut();
if (SettingsManager::value("ActivateGrid").toBool()) {
edge->alignToGrid();
}
}
if (shouldProcessResize && mResizeCommand) {
mResizeCommand->addPostAction(insertCommand);
endResize();
}
updateBySelection();
mDragState = None;
}