本文整理汇总了C++中NodeGuiPtr::scenePos方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeGuiPtr::scenePos方法的具体用法?C++ NodeGuiPtr::scenePos怎么用?C++ NodeGuiPtr::scenePos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeGuiPtr
的用法示例。
在下文中一共展示了NodeGuiPtr::scenePos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
ProjectPtr proj = getGui()->getApp()->getProject();
///default
QPointF position;
if (behavior == 0) {
position.setX( ( viewPos.bottomRight().x() + viewPos.topLeft().x() ) / 2. );
position.setY( ( viewPos.topLeft().y() + viewPos.bottomRight().y() ) / 2. );
} else if (behavior == 1) {
///pop it above the selected node
///If this is the first connected input, insert it in a "linear" way so the tree remains vertical
int nbConnectedInput = 0;
const std::vector<Edge*> & selectedNodeInputs = selected->getInputsArrows();
for (std::vector<Edge*>::const_iterator it = selectedNodeInputs.begin(); it != selectedNodeInputs.end(); ++it) {
NodeGuiPtr input;
if (*it) {
input = (*it)->getSource();
}
if (input) {
++nbConnectedInput;
}
}
///connect it to the first input
QSize selectedNodeSize = selected->getSize();
QSize createdNodeSize = node->getSize();
if (nbConnectedInput == 0) {
QPointF selectedNodeMiddlePos = selected->scenePos() +
QPointF(selectedNodeSize.width() / 2, selectedNodeSize.height() / 2);
position.setX(selectedNodeMiddlePos.x() - createdNodeSize.width() / 2);
position.setY( selectedNodeMiddlePos.y() - selectedNodeSize.height() / 2 - NodeGui::DEFAULT_OFFSET_BETWEEN_NODES
- createdNodeSize.height() );
QRectF createdNodeRect( position.x(), position.y(), createdNodeSize.width(), createdNodeSize.height() );
///now that we have the position of the node, move the inputs of the selected node to make some space for this node
for (std::vector<Edge*>::const_iterator it = selectedNodeInputs.begin(); it != selectedNodeInputs.end(); ++it) {
if ( (*it)->hasSource() ) {
(*it)->getSource()->moveAbovePositionRecursively(createdNodeRect);
}
}
int selectedInput = selectedNodeInternal->getPreferredInputForConnection();
if (selectedInput != -1) {
bool ok = proj->connectNodes(selectedInput, createdNodeInternal, selectedNodeInternal, true);
Q_UNUSED(ok);
}
} else {
//ViewerInstancePtr isSelectedViewer = selectedNodeInternal->isEffectViewerInstance();
//Don't pop a dot, it will most likely annoy the user, just fallback on behavior 0
/* position.setX( ( viewPos.bottomRight().x() + viewPos.topLeft().x() ) / 2. );
position.setY( ( viewPos.topLeft().y() + viewPos.bottomRight().y() ) / 2. );
}
else {
*/
QRectF selectedBbox = selected->mapToScene( selected->boundingRect() ).boundingRect();
QPointF selectedCenter = selectedBbox.center();