本文整理汇总了C++中ProjectPtr::connectNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectPtr::connectNodes方法的具体用法?C++ ProjectPtr::connectNodes怎么用?C++ ProjectPtr::connectNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectPtr
的用法示例。
在下文中一共展示了ProjectPtr::connectNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
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();
double y = selectedCenter.y() - selectedNodeSize.height() / 2.
- NodeGui::DEFAULT_OFFSET_BETWEEN_NODES - createdNodeSize.height();
double x = selectedCenter.x() + nbConnectedInput * 150;
position.setX(x - createdNodeSize.width() / 2.);
position.setY(y);
int index = selectedNodeInternal->getPreferredInputForConnection();
if (index != -1) {
bool ok = proj->connectNodes(index, createdNodeInternal, selectedNodeInternal, true);
Q_UNUSED(ok);
}
//} // if (isSelectedViewer) {*/
} // if (nbConnectedInput == 0) {
} else {
///pop it below the selected node
const NodesWList& outputs = selectedNodeInternal->getGuiOutputs();
if ( !createdNodeInternal->isOutputNode() || outputs.empty() ) {
QSize selectedNodeSize = selected->getSize();