本文整理汇总了C++中NodeGuiPtr::getInputsArrows方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeGuiPtr::getInputsArrows方法的具体用法?C++ NodeGuiPtr::getInputsArrows怎么用?C++ NodeGuiPtr::getInputsArrows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeGuiPtr
的用法示例。
在下文中一共展示了NodeGuiPtr::getInputsArrows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
///if behaviour is 1 , just check that we can effectively connect the node to avoid moving them for nothing
///otherwise fallback on behaviour 0
if (behavior == 1) {
const std::vector<NodeWPtr > & inputs = selected->getNode()->getGuiInputs();
bool oneInputEmpty = false;
for (std::size_t i = 0; i < inputs.size(); ++i) {
if ( !inputs[i].lock() ) {
oneInputEmpty = true;
break;
}
}
if (!oneInputEmpty) {
behavior = 0;
}
}
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);
}