本文整理汇总了C++中NodeGroupPtr类的典型用法代码示例。如果您正苦于以下问题:C++ NodeGroupPtr类的具体用法?C++ NodeGroupPtr怎么用?C++ NodeGroupPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeGroupPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toAnimationModule
void
NodeAnimPrivate::refreshParentContainerRange()
{
NodeGuiPtr nodeUI = nodeGui.lock();
NodePtr node = nodeUI->getNode();
if (!node) {
return;
}
AnimationModulePtr isAnimModule = toAnimationModule(model.lock());
assert(isAnimModule);
// If inside a group, refresh the group
{
NodeGroupPtr parentGroup = toNodeGroup( node->getGroup() );
NodeAnimPtr parentGroupNodeAnim;
if (parentGroup) {
parentGroupNodeAnim = isAnimModule->findNodeAnim( parentGroup->getNode() );
}
if (parentGroupNodeAnim) {
parentGroupNodeAnim->refreshFrameRange();
}
}
// if modified by a time node, refresh its frame range as well
{
NodeAnimPtr isConnectedToTimeNode = isAnimModule->getNearestTimeNodeFromOutputsInternal(node);
if (isConnectedToTimeNode) {
isConnectedToTimeNode->refreshFrameRange();
}
}
} // refreshParentContainerRange
示例2: getGui
ViewerTab::~ViewerTab()
{
Gui* gui = getGui();
if (gui) {
NodeGraph* graph = 0;
ViewerNodePtr internalNode = getInternalNode();
ViewerInstancePtr viewerNode = internalNode ? internalNode->getInternalViewerNode() : ViewerInstancePtr();
if (viewerNode) {
NodeCollectionPtr collection = viewerNode->getNode()->getGroup();
if (collection) {
NodeGroupPtr isGrp = toNodeGroup(collection);
if (isGrp) {
NodeGraphI* graph_i = isGrp->getNodeGraph();
if (graph_i) {
graph = dynamic_cast<NodeGraph*>(graph_i);
assert(graph);
}
} else {
graph = gui->getNodeGraph();
}
}
internalNode->invalidateUiContext();
} else {
graph = gui->getNodeGraph();
}
assert(graph);
GuiAppInstancePtr app = gui->getApp();
if ( app && !app->isClosing() && graph && (graph->getLastSelectedViewer() == this) ) {
graph->setLastSelectedViewer(0);
}
}
_imp->nodesContext.clear();
}
示例3: assert
std::vector<NodeAnimPtr > AnimationModule::getChildrenNodes(const NodeAnimPtr& node) const
{
std::vector<NodeAnimPtr > children;
AnimatedItemTypeEnum nodeType = node->getItemType();
if (nodeType == eAnimatedItemTypeGroup) {
// If the node is a group, make all its children to be a child in the tree view
NodeGroupPtr nodeGroup = node->getInternalNode()->isEffectNodeGroup();
assert(nodeGroup);
NodesList nodes = nodeGroup->getNodes();
for (NodesList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
NodePtr childNode = (*it);
NodeAnimPtr isInDopeSheet = findNodeAnim( childNode );
if (isInDopeSheet) {
children.push_back(isInDopeSheet);
}
}
} else if ( node->isTimeNode() ) {
// If the node is a time node, all input nodes recursively are considered to be a child
std::list<NodePtr> markedNodes;
_imp->getInputs_recursive(node->getInternalNode(), markedNodes, &children);
}
return children;
}
示例4: toNodeGroup
void
Gui::createGroupGui(const NodePtr & group,
const CreateNodeArgs& args)
{
NodeGroupPtr isGrp = toNodeGroup( group->getEffectInstance()->shared_from_this() );
assert(isGrp);
NodeCollectionPtr collection = boost::dynamic_pointer_cast<NodeCollection>(isGrp);
assert(collection);
TabWidget* where = 0;
if (_imp->_lastFocusedGraph) {
TabWidget* isTab = dynamic_cast<TabWidget*>( _imp->_lastFocusedGraph->parentWidget() );
if (isTab) {
where = isTab;
} else {
std::list<TabWidgetI*> panes = getApp()->getTabWidgetsSerialization();
assert( !panes.empty() );
where = dynamic_cast<TabWidget*>(panes.front());
}
}
QGraphicsScene* scene = new QGraphicsScene(this);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
std::string newName = isGrp->getNode()->getFullyQualifiedName();
for (std::size_t i = 0; i < newName.size(); ++i) {
if (newName[i] == '.') {
newName[i] = '_';
}
}
newName += "_NodeGraph";
std::string label = tr(" Node Graph").toStdString();
NodeGraph::makeFullyQualifiedLabel(group, &label);
NodeGraph* nodeGraph = new NodeGraph(this, collection, newName, scene, this);
nodeGraph->setLabel(label);
nodeGraph->setObjectName( QString::fromUtf8( group->getLabel().c_str() ) );
_imp->_groups.push_back(nodeGraph);
SERIALIZATION_NAMESPACE::NodeSerializationPtr serialization = args.getPropertyUnsafe<SERIALIZATION_NAMESPACE::NodeSerializationPtr>(kCreateNodeArgsPropNodeSerialization);
bool showSubGraph = args.getPropertyUnsafe<bool>(kCreateNodeArgsPropSubGraphOpened);
if ( showSubGraph && where && !serialization ) {
where->appendTab(nodeGraph, nodeGraph);
QTimer::singleShot( 25, nodeGraph, SLOT(centerOnAllNodes()) );
} else {
nodeGraph->setVisible(false);
}
}
示例5: NodeAnimPtr
NodeAnimPtr AnimationModule::getGroupNodeAnim(const NodeAnimPtr& node) const
{
NodePtr internalNode = node->getInternalNode();
if (!internalNode) {
return NodeAnimPtr();
}
NodeGroupPtr parentGroup = toNodeGroup( internalNode->getGroup() );
NodeAnimPtr parentGroupNodeAnim;
if (parentGroup) {
parentGroupNodeAnim = findNodeAnim( parentGroup->getNode() );
}
return parentGroupNodeAnim;
}
示例6: runOnNodeDeleteCBInternal
void
NodePrivate::runOnNodeDeleteCB()
{
if (_publicInterface->getScriptName_mt_safe().empty()) {
return;
}
std::string cb = _publicInterface->getApp()->getProject()->getOnNodeDeleteCB();
NodeCollectionPtr group = _publicInterface->getGroup();
if (!group) {
return;
}
std::string callbackFunction;
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeDeleteCBInternal(callbackFunction);
}
// If this is a group, run the node deleted callback on itself
{
cb = effect->getBeforeNodeRemovalCallback();
if (!cb.empty()) {
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeDeleteCBInternal(callbackFunction);
}
}
}
// if there's a parent group, run the node deletec callback on the parent
NodeGroupPtr isParentGroup = toNodeGroup(group);
if (isParentGroup) {
NodePtr grpNode = isParentGroup->getNode();
if (grpNode) {
cb = isParentGroup->getBeforeNodeRemovalCallback();
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeDeleteCBInternal(callbackFunction);
}
}
}
}
示例7: assert
void
GuiAppInstance::onGroupCreationFinished(const NodePtr& node,
const NodeSerializationPtr& serialization, bool autoConnect)
{
NodeGuiIPtr node_gui_i = node->getNodeGui();
if (autoConnect && !serialization && node_gui_i) {
NodeGraph* graph = 0;
NodeCollectionPtr collection = node->getGroup();
assert(collection);
NodeGroupPtr isGrp = toNodeGroup(collection);
if (isGrp) {
NodeGraphI* graph_i = isGrp->getNodeGraph();
assert(graph_i);
graph = dynamic_cast<NodeGraph*>(graph_i);
} else {
graph = _imp->_gui->getNodeGraph();
}
assert(graph);
if (!graph) {
throw std::logic_error("");
}
NodesGuiList selectedNodes = graph->getSelectedNodes();
NodeGuiPtr selectedNode;
if ( !selectedNodes.empty() ) {
selectedNode = selectedNodes.front();
if (toBackdropGui(selectedNode) ) {
selectedNode.reset();
}
}
NodeGuiPtr nodeGui = boost::dynamic_pointer_cast<NodeGui>(node_gui_i);
graph->moveNodesForIdealPosition(nodeGui, selectedNode, true);
}
AppInstance::onGroupCreationFinished(node, serialization, autoConnect);
/*std::list<ViewerInstancePtr> viewers;
node->hasViewersConnected(&viewers);
for (std::list<ViewerInstancePtr>::iterator it2 = viewers.begin(); it2 != viewers.end(); ++it2) {
(*it2)->renderCurrentFrame(false);
}*/
}
示例8: runOnNodeCreatedCBInternal
void
NodePrivate::runOnNodeCreatedCB(bool userEdited)
{
std::string cb = _publicInterface->getApp()->getProject()->getOnNodeCreatedCB();
NodeCollectionPtr group = _publicInterface->getGroup();
if (!group) {
return;
}
std::string callbackFunction;
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeCreatedCBInternal(callbackFunction, userEdited);
}
// If this is a group, run the node created callback on itself
cb = effect->getAfterNodeCreatedCallback();
if (!cb.empty()) {
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeCreatedCBInternal(callbackFunction, userEdited);
}
}
// if there's a parent group, run the node created callback on the parent
NodeGroupPtr isParentGroup = toNodeGroup(group);
if (isParentGroup) {
NodePtr grpNode = isParentGroup->getNode();
if (grpNode) {
cb = isParentGroup->getAfterNodeCreatedCallback();
if (figureOutCallbackName(cb, &callbackFunction)) {
runOnNodeCreatedCBInternal(callbackFunction, userEdited);
}
}
}
}
示例9: catch
void
NodePrivate::runChangedParamCallback(const std::string& cb, const KnobIPtr& k, bool userEdited)
{
std::vector<std::string> args;
std::string error;
if ( !k || (k->getName() == "onParamChanged") ) {
return;
}
std::string callbackFunction;
if (!figureOutCallbackName(cb, &callbackFunction)) {
return;
}
try {
NATRON_PYTHON_NAMESPACE::getFunctionArguments(callbackFunction, &error, &args);
} catch (const std::exception& e) {
_publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( e.what() ) ).toStdString() );
return;
}
if ( !error.empty() ) {
_publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( error.c_str() ) ).toStdString() );
return;
}
std::string signatureError;
signatureError.append( tr("The param changed callback supports the following signature(s):").toStdString() );
signatureError.append("\n- callback(thisParam,thisNode,thisGroup,app,userEdited)");
if (args.size() != 5) {
_publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( signatureError.c_str() ) ).toStdString() );
return;
}
if ( ( (args[0] != "thisParam") || (args[1] != "thisNode") || (args[2] != "thisGroup") || (args[3] != "app") || (args[4] != "userEdited") ) ) {
_publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( signatureError.c_str() ) ).toStdString() );
return;
}
std::string appID = _publicInterface->getApp()->getAppIDString();
assert(k);
std::string thisNodeVar = appID + ".";
thisNodeVar.append( _publicInterface->getFullyQualifiedName() );
NodeCollectionPtr collection = _publicInterface->getGroup();
assert(collection);
if (!collection) {
return;
}
std::string thisGroupVar;
NodeGroupPtr isParentGrp = toNodeGroup(collection);
if (isParentGrp) {
std::string nodeName = isParentGrp->getNode()->getFullyQualifiedName();
std::string nodeFullName = appID + "." + nodeName;
thisGroupVar = nodeFullName;
} else {
thisGroupVar = appID;
}
bool alreadyDefined = false;
PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(thisNodeVar, NATRON_PYTHON_NAMESPACE::getMainModule(), &alreadyDefined);
if (!nodeObj || !alreadyDefined) {
return;
}
if (!PyObject_HasAttrString( nodeObj, k->getName().c_str() ) ) {
return;
}
std::stringstream ss;
ss << callbackFunction << "(" << thisNodeVar << "." << k->getName() << "," << thisNodeVar << "," << thisGroupVar << "," << appID
<< ",";
if (userEdited) {
ss << "True";
} else {
ss << "False";
}
ss << ")\n";
std::string script = ss.str();
std::string err;
std::string output;
if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) {
_publicInterface->getApp()->appendToScriptEditor( tr("Failed to execute onParamChanged callback: %1").arg( QString::fromUtf8( err.c_str() ) ).toStdString() );
} else {
if ( !output.empty() ) {
_publicInterface->getApp()->appendToScriptEditor(output);
}
}
} // runChangedParamCallback
示例10: moveGroupNode
void
moveGroupNode(DopeSheetEditor* model,
const NodePtr& node,
double dt)
{
NodeGroupPtr group = node->isEffectNodeGroup();
assert(group);
NodesList nodes;
group->getNodes_recursive(nodes, true);
for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) {
NodeGuiPtr nodeGui = boost::dynamic_pointer_cast<NodeGui>( (*it)->getNodeGui() );
assert(nodeGui);
std::string pluginID = (*it)->getPluginID();
NodeGroupPtr isChildGroup = (*it)->isEffectNodeGroup();
// Move readers
#ifndef NATRON_ENABLE_IO_META_NODES
if ( ReadNode::isBundledReader( pluginID, node->getApp()->wasProjectCreatedWithLowerCaseIDs() ) ) {
#else
if (pluginID == PLUGINID_NATRON_READ) {
#endif
moveReader(*it, dt);
} else if (pluginID == PLUGINID_OFX_TIMEOFFSET) {
moveTimeOffset(*it, dt);
} else if (pluginID == PLUGINID_OFX_FRAMERANGE) {
moveFrameRange(*it, dt);
} else if (isChildGroup) {
moveGroupNode(model, *it, dt);
}
// Move keyframes
const KnobsVec &knobs = (*it)->getKnobs();
for (KnobsVec::const_iterator knobIt = knobs.begin(); knobIt != knobs.end(); ++knobIt) {
const KnobIPtr& knob = *knobIt;
if ( !knob->hasAnimation() ) {
continue;
}
for (int dim = 0; dim < knob->getDimension(); ++dim) {
if ( !knob->isAnimated( dim, ViewIdx(0) ) ) {
continue;
}
KeyFrameSet keyframes = knob->getCurve(ViewIdx(0), dim)->getKeyFrames_mt_safe();
for (KeyFrameSet::iterator kfIt = keyframes.begin(); kfIt != keyframes.end(); ++kfIt) {
KeyFrame kf = (*kfIt);
KeyFrame fake;
knob->moveValueAtTime(eCurveChangeReasonDopeSheet, kf.getTime(), ViewSpec::all(), dim, dt, 0, &fake);
}
}
}
}
} // moveGroupNode
NATRON_NAMESPACE_ANONYMOUS_EXIT
////////////////////////// DSMoveKeysCommand //////////////////////////
DSMoveKeysAndNodesCommand::DSMoveKeysAndNodesCommand(const DSKeyPtrList &keys,
const std::vector<DSNodePtr >& nodes,
double dt,
DopeSheetEditor *model,
QUndoCommand *parent)
: QUndoCommand(parent),
_keys(keys),
_nodes(),
_dt(dt),
_model(model)
{
setText( tr("Move selected keys") );
std::set<NodePtr > nodesSet;
for (std::vector<DSNodePtr >::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
DopeSheetItemType type = (*it)->getItemType();
if ( (type != eDopeSheetItemTypeReader) &&
( type != eDopeSheetItemTypeGroup) &&
( type != eDopeSheetItemTypeTimeOffset) &&
( type != eDopeSheetItemTypeFrameRange) ) {
//Note that Retime nodes cannot be moved
continue;
}
_nodes.push_back(*it);
nodesSet.insert( (*it)->getInternalNode() );
NodeGroupPtr isGroup = (*it)->getInternalNode()->isEffectNodeGroup();
if (isGroup) {
NodesList recurseNodes;
isGroup->getNodes_recursive(recurseNodes, true);
for (NodesList::iterator it = recurseNodes.begin(); it != recurseNodes.end(); ++it) {
nodesSet.insert(*it);
}
}
}
for (DSKeyPtrList::iterator it = _keys.begin(); it != _keys.end(); ++it) {
KnobHolderPtr holder = (*it)->getContext()->getInternalKnob()->getHolder();
assert(holder);
//.........这里部分代码省略.........
示例11: assert
void
Gui::removeViewerTab(ViewerTab* tab,
bool initiatedFromNode,
bool deleteData)
{
assert(tab);
unregisterTab(tab);
if (tab == _imp->_activeViewer) {
_imp->_activeViewer = 0;
}
NodeGraph* graph = 0;
NodeGroupPtr isGrp;
NodeCollectionPtr collection;
if ( tab->getInternalNode() && tab->getInternalNode()->getNode() ) {
NodeCollectionPtr collection = tab->getInternalNode()->getNode()->getGroup();
isGrp = toNodeGroup(collection);
}
if (isGrp) {
NodeGraphI* graph_i = isGrp->getNodeGraph();
assert(graph_i);
graph = dynamic_cast<NodeGraph*>(graph_i);
} else {
graph = getNodeGraph();
}
assert(graph);
if (!graph) {
throw std::logic_error("");
}
ViewerTab* lastSelectedViewer = graph->getLastSelectedViewer();
if (lastSelectedViewer == tab) {
bool foundOne = false;
NodesList nodes;
if (collection) {
nodes = collection->getNodes();
}
for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) {
ViewerNodePtr isViewer = (*it)->isEffectViewerNode();
if ( !isViewer || ( isViewer == tab->getInternalNode() ) || !(*it)->isActivated() ) {
continue;
}
OpenGLViewerI* viewerI = isViewer->getUiContext();
assert(viewerI);
ViewerGL* glViewer = dynamic_cast<ViewerGL*>(viewerI);
assert(glViewer);
if (glViewer) {
graph->setLastSelectedViewer( glViewer->getViewerTab() );
}
foundOne = true;
break;
}
if (!foundOne) {
graph->setLastSelectedViewer(0);
}
}
ViewerNodePtr viewerNode = tab->getInternalNode();
ViewerInstancePtr internalViewer;
if (viewerNode) {
internalViewer = viewerNode->getInternalViewerNode();
}
if (internalViewer) {
internalViewer->abortAnyEvaluation();
if (getApp()->getLastViewerUsingTimeline() == internalViewer) {
getApp()->discardLastViewerUsingTimeline();
}
}
if (!initiatedFromNode) {
assert(_imp->_nodeGraphArea);
///call the deleteNode which will call this function again when the node will be deactivated.
NodePtr internalNode = tab->getInternalNode()->getNode();
NodeGuiIPtr guiI = internalNode->getNodeGui();
NodeGuiPtr gui = boost::dynamic_pointer_cast<NodeGui>(guiI);
assert(gui);
NodeGraphI* graph_i = internalNode->getGroup()->getNodeGraph();
assert(graph_i);
NodeGraph* graph = dynamic_cast<NodeGraph*>(graph_i);
assert(graph);
if (graph) {
graph->removeNode(gui);
}
} else {
tab->hide();
TabWidget* container = dynamic_cast<TabWidget*>( tab->parentWidget() );
if (container) {
container->removeTab(tab, false);
}
if (deleteData) {
QMutexLocker l(&_imp->_viewerTabsMutex);
std::list<ViewerTab*>::iterator it = std::find(_imp->_viewerTabs.begin(), _imp->_viewerTabs.end(), tab);
if ( it != _imp->_viewerTabs.end() ) {
_imp->_viewerTabs.erase(it);
//.........这里部分代码省略.........
示例12: toNodeGroup
bool
Project::restoreGroupFromSerialization(const SERIALIZATION_NAMESPACE::NodeSerializationList & serializedNodes,
const NodeCollectionPtr& group,
std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >* createdNodesOut)
{
bool mustShowErrorsLog = false;
NodeGroupPtr isGrp = toNodeGroup(group);
QString groupName;
if (isGrp) {
groupName = QString::fromUtf8( isGrp->getNode()->getLabel().c_str() );
} else {
groupName = tr("top-level");
}
group->getApplication()->updateProjectLoadStatus( tr("Creating nodes in group: %1").arg(groupName) );
std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > > createdNodes;
// Loop over all node serialization and create them first
for (SERIALIZATION_NAMESPACE::NodeSerializationList::const_iterator it = serializedNodes.begin(); it != serializedNodes.end(); ++it) {
NodePtr node = appPTR->createNodeForProjectLoading(*it, group);
if (!node) {
QString text( tr("ERROR: The node %1 version %2.%3"
" was found in the script but does not"
" exist in the loaded plug-ins.")
.arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
.arg((*it)->_pluginMajorVersion).arg((*it)->_pluginMinorVersion) );
appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
mustShowErrorsLog = true;
continue;
} else {
if (node->getPluginID() == PLUGINID_NATRON_STUB) {
// If the node could not be created and we made a stub instead, warn the user
QString text( tr("WARNING: The node %1 (%2 version %3.%4) "
"was found in the script but the plug-in could not be found. It has been replaced by a pass-through node instead.")
.arg( QString::fromUtf8( (*it)->_nodeScriptName.c_str() ) )
.arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
.arg((*it)->_pluginMajorVersion)
.arg((*it)->_pluginMinorVersion));
appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
mustShowErrorsLog = true;
} else if ( (*it)->_pluginMajorVersion != -1 && (node->getMajorVersion() != (int)(*it)->_pluginMajorVersion) ) {
// If the node has a IOContainer don't do this check: when loading older projects that had a
// ReadOIIO node for example in version 2, we would now create a new Read meta-node with version 1 instead
QString text( tr("WARNING: The node %1 (%2 version %3.%4) "
"was found in the script but was loaded "
"with version %5.%6 instead.")
.arg( QString::fromUtf8( (*it)->_nodeScriptName.c_str() ) )
.arg( QString::fromUtf8( (*it)->_pluginID.c_str() ) )
.arg((*it)->_pluginMajorVersion)
.arg((*it)->_pluginMinorVersion)
.arg( node->getPlugin()->getPropertyUnsafe<unsigned int>(kNatronPluginPropVersion, 0) )
.arg( node->getPlugin()->getPropertyUnsafe<unsigned int>(kNatronPluginPropVersion, 1) ) );
appPTR->writeToErrorLog_mt_safe(tr("Project"), QDateTime::currentDateTime(), text);
}
}
assert(node);
createdNodes.push_back(std::make_pair(node, *it));
} // for all node serialization
group->getApplication()->updateProjectLoadStatus( tr("Restoring graph links in group: %1").arg(groupName) );
// Connect the nodes together
for (std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >::const_iterator it = createdNodes.begin(); it != createdNodes.end(); ++it) {
// Loop over the inputs map
// This is a map <input label, input node name>
//
// When loading projects before Natron 2.2, the inputs contain both masks and inputs.
//
restoreInputs(it->first, it->second->_inputs, createdNodes, false /*isMasks*/);
// After Natron 2.2, masks are saved separatly
restoreInputs(it->first, it->second->_masks, createdNodes, true /*isMasks*/);
} // for (std::list< NodeSerializationPtr >::const_iterator it = serializedNodes.begin(); it != serializedNodes.end(); ++it) {
if (createdNodesOut) {
*createdNodesOut = createdNodes;
}
// If we created all sub-groups recursively, then we are in the top-level group. We may now restore all links
if (!group->getApplication()->isCreatingNode()) {
// Now that we created all nodes. There may be cross-graph link(s) and they can only be truely restored now.
restoreLinksRecursive(group, serializedNodes, createdNodesOut);
}
//.........这里部分代码省略.........
示例13: mapToScene
void
NodeGraph::mouseMoveEvent(QMouseEvent* e)
{
QPointF newPos = mapToScene( e->pos() );
QPointF lastMousePosScene = mapToScene( _imp->_lastMousePos.x(), _imp->_lastMousePos.y() );
double dx, dy;
{
QPointF newPosRoot = _imp->_root->mapFromScene(newPos);
QPointF lastMousePosRoot = _imp->_root->mapFromScene(lastMousePosScene);
dx = newPosRoot.x() - lastMousePosRoot.x();
dy = newPosRoot.y() - lastMousePosRoot.y();
}
_imp->_hasMovedOnce = true;
bool mustUpdate = true;
NodeCollectionPtr collection = getGroup();
NodeGroupPtr isGroup = toNodeGroup(collection);
bool isGroupEditable = true;
bool groupEdited = true;
if (isGroup) {
isGroupEditable = isGroup->isSubGraphEditable();
groupEdited = isGroup->isSubGraphEditedByUser();
}
if (!groupEdited && isGroupEditable) {
///check if user is nearby unlock
// see NodeGraph::paintEvent()
QPoint pixPos = _imp->getPyPlugUnlockPos();
int pixW = _imp->unlockIcon.width();
int pixH = _imp->unlockIcon.height();
QRect pixRect(pixPos.x(), pixPos.y(), pixW, pixH);
pixRect.adjust(-2, -2, 2, 2);
QRect selRect = pixRect;
selRect.adjust(-3, -3, 3, 3);
if ( selRect.contains( e->pos() ) ) {
assert(isGroup);
QPoint pos = mapToGlobal( e->pos() );
// Unfortunately, the timeout delay for the tooltip is hardcoded in Qt 4, and the last parameter to showText doesn't seem to influence anything
// Can not fix https://github.com/MrKepzie/Natron/issues/1151 (at least in Qt4)
QToolTip::showText( pos, NATRON_NAMESPACE::convertFromPlainText(QCoreApplication::translate("NodeGraph", "Clicking the unlock button will convert the PyPlug to a regular group saved in the project and dettach it from the script.\n"
"Any modification will not be written to the Python script. Subsequent loading of the project will no longer load this group from the python script."), NATRON_NAMESPACE::WhiteSpaceNormal),
this, selRect);
e->accept();
return;
}
}
QRectF sceneR = visibleSceneRect();
bool mustUpdateNavigator = false;
///Apply actions
switch (_imp->_evtState) {
case eEventStateDraggingArrow: {
QPointF np = _imp->_arrowSelected->mapFromScene(newPos);
if ( _imp->_arrowSelected->isOutputEdge() ) {
_imp->_arrowSelected->dragDest(np);
} else {
_imp->_arrowSelected->dragSource(np);
}
checkAndStartAutoScrollTimer(newPos);
mustUpdate = true;
if (_imp->cursorSet) {
_imp->cursorSet = false;
unsetCursor();
}
break;
}
case eEventStateDraggingNode: {
mustUpdate = true;
mustUpdateNavigator = true;
bool controlDown = modifierHasControl(e);
bool shiftdown = modifierHasShift(e);
moveSelectedNodesBy(shiftdown, controlDown, lastMousePosScene, newPos, sceneR, true);
_imp->cursorSet = true;
setCursor( QCursor(Qt::ClosedHandCursor) );
break;
}
case eEventStateMovingArea: {
mustUpdateNavigator = true;
moveRootInternal(dx, dy);
mustUpdate = true;
_imp->cursorSet = true;
setCursor( QCursor(Qt::SizeAllCursor) );
break;
}
case eEventStateResizingBackdrop: {
mustUpdateNavigator = true;
assert(_imp->_backdropResized.lock());
QPointF p = _imp->_backdropResized.lock()->scenePos();
int w = newPos.x() - p.x();
int h = newPos.y() - p.y();
checkAndStartAutoScrollTimer(newPos);
mustUpdate = true;
pushUndoCommand( new ResizeBackdropCommand(_imp->_backdropResized.lock(), w, h) );
_imp->cursorSet = true;
setCursor( QCursor(Qt::SizeFDiagCursor) );
break;
}
case eEventStateSelectionRect: {
QPointF startDrag = _imp->_lastSelectionStartPointScene;
//.........这里部分代码省略.........
示例14: QDialog
PickKnobDialog::PickKnobDialog(DockablePanel* panel,
QWidget* parent)
: QDialog(parent)
, _imp( new PickKnobDialogPrivate(panel) )
{
NodeSettingsPanel* nodePanel = dynamic_cast<NodeSettingsPanel*>(panel);
assert(nodePanel);
if (!nodePanel) {
throw std::logic_error("PickKnobDialog::PickKnobDialog()");
}
NodeGuiPtr nodeGui = nodePanel->getNodeGui();
NodePtr node = nodeGui->getNode();
NodeGroupPtr isGroup = node->isEffectNodeGroup();
NodeCollectionPtr collec = node->getGroup();
NodeGroupPtr isCollecGroup = toNodeGroup(collec);
NodesList collectNodes = collec->getNodes();
for (NodesList::iterator it = collectNodes.begin(); it != collectNodes.end(); ++it) {
if ((*it)->isActivated() && (*it)->getNodeGui() && ( (*it)->getKnobs().size() > 0 ) ) {
_imp->allNodes.push_back(*it);
}
}
if (isCollecGroup) {
_imp->allNodes.push_back( isCollecGroup->getNode() );
}
if (isGroup) {
NodesList groupnodes = isGroup->getNodes();
for (NodesList::iterator it = groupnodes.begin(); it != groupnodes.end(); ++it) {
if ( (*it)->getNodeGui() &&
(*it)->isActivated() &&
( (*it)->getKnobs().size() > 0 ) ) {
_imp->allNodes.push_back(*it);
}
}
}
QStringList nodeNames;
for (NodesList::iterator it = _imp->allNodes.begin(); it != _imp->allNodes.end(); ++it) {
QString name = QString::fromUtf8( (*it)->getLabel().c_str() );
nodeNames.push_back(name);
}
nodeNames.sort();
_imp->mainLayout = new QGridLayout(this);
_imp->selectNodeLabel = new Label( tr("Node:") );
_imp->nodeSelectionCombo = new CompleterLineEdit(nodeNames, nodeNames, false, this);
_imp->nodeSelectionCombo->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Input the name of a node in the current project."), NATRON_NAMESPACE::WhiteSpaceNormal) );
_imp->nodeSelectionCombo->setFocus(Qt::PopupFocusReason);
_imp->knobSelectionCombo = new ComboBox(this);
QObject::connect( _imp->knobSelectionCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onKnobComboIndexChanged(int)) );
QString useAliasTt = NATRON_NAMESPACE::convertFromPlainText(tr("If checked, an alias of the selected parameter will be created, coyping entirely its state. "
"Only the script-name, label and tooltip will be editable.\n"
"For choice parameters this will also "
"dynamically refresh the menu entries when the original parameter's menu is changed.\n"
"When unchecked, a simple expression will be set linking the two parameters, but things such as dynamic menus "
"will be disabled."), NATRON_NAMESPACE::WhiteSpaceNormal);
_imp->useAliasLabel = new Label(tr("Make Alias:"), this);
_imp->useAliasLabel->setToolTip(useAliasTt);
_imp->useAliasCheckBox = new QCheckBox(this);
_imp->useAliasCheckBox->setToolTip(useAliasTt);
_imp->useAliasCheckBox->setChecked(true);
QObject::connect( _imp->nodeSelectionCombo, SIGNAL(itemCompletionChosen()), this, SLOT(onNodeComboEditingFinished()) );
_imp->destPageLabel = new Label(tr("Page:"), this);
QString pagett = NATRON_NAMESPACE::convertFromPlainText(tr("Select the page into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
_imp->destPageLabel->setToolTip(pagett);
_imp->destPageCombo = new ComboBox(this);
_imp->destPageCombo->setToolTip(pagett);
QObject::connect( _imp->destPageCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onPageComboIndexChanged(int)) );
const KnobsVec& knobs = node->getKnobs();
for (std::size_t i = 0; i < knobs.size(); ++i) {
if ( knobs[i]->isUserKnob() ) {
KnobPagePtr isPage = toKnobPage(knobs[i]);
if (isPage) {
_imp->pages.push_back(isPage);
_imp->destPageCombo->addItem( QString::fromUtf8( isPage->getName().c_str() ) );
} else {
KnobGroupPtr isGrp = toKnobGroup(knobs[i]);
if (isGrp) {
_imp->groups.push_back(isGrp);
}
}
}
}
if (_imp->destPageCombo->count() == 0) {
_imp->destPageLabel->hide();
_imp->destPageCombo->hide();
}
_imp->groupLabel = new Label(tr("Group:"), this);
QString grouptt = NATRON_NAMESPACE::convertFromPlainText(tr("Select the group into which the parameter will be created."), NATRON_NAMESPACE::WhiteSpaceNormal);
_imp->groupCombo = new ComboBox(this);
_imp->groupLabel->setToolTip(grouptt);
_imp->groupCombo->setToolTip(grouptt);
onPageComboIndexChanged(0);
_imp->buttons = new DialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel),
Qt::Horizontal, this);
//.........这里部分代码省略.........
示例15: mapToScene
void
NodeGraph::mouseMoveEvent(QMouseEvent* e)
{
QPointF newPos = mapToScene( e->pos() );
QPointF lastMousePosScene = mapToScene( _imp->_lastMousePos.x(), _imp->_lastMousePos.y() );
double dx, dy;
{
QPointF newPosRoot = _imp->_root->mapFromScene(newPos);
QPointF lastMousePosRoot = _imp->_root->mapFromScene(lastMousePosScene);
dx = newPosRoot.x() - lastMousePosRoot.x();
dy = newPosRoot.y() - lastMousePosRoot.y();
}
_imp->_hasMovedOnce = true;
bool mustUpdate = true;
NodeCollectionPtr collection = getGroup();
NodeGroupPtr isGroup = toNodeGroup(collection);
bool isGroupEditable = true;
bool groupEdited = true;
if (isGroup) {
isGroupEditable = isGroup->isSubGraphEditable();
groupEdited = isGroup->getNode()->hasPyPlugBeenEdited();
}
if (!groupEdited && isGroupEditable) {
///check if user is nearby unlock
int iw = _imp->unlockIcon.width();
int ih = _imp->unlockIcon.height();
int w = width();
if ( ( e->x() >= (w - iw - 10 - 15) ) && ( e->x() <= (w - 10 + 15) ) &&
( e->y() >= (10 - 15) ) && ( e->y() <= (10 + ih + 15) ) ) {
assert(isGroup);
QPoint pos = mapToGlobal( e->pos() );
QToolTip::showText( pos, GuiUtils::convertFromPlainText(QCoreApplication::translate("NodeGraph", "Clicking the unlock button will convert the PyPlug to a regular group saved in the project and dettach it from the script.\n"
"Any modification will not be written to the Python script. Subsequent loading of the project will no longer load this group from the python script."), Qt::WhiteSpaceNormal) );
}
}
QRectF sceneR = visibleSceneRect();
if ( groupEdited && (_imp->_evtState != eEventStateSelectionRect) && (_imp->_evtState != eEventStateDraggingArrow) ) {
// Set cursor
std::set<NodeGuiPtr> visibleNodes;
getNodesWithinViewportRect(visibleWidgetRect(), &visibleNodes);
NodeGuiPtr selected;
Edge* selectedEdge = 0;
bool optionalInputsAutoHidden = areOptionalInputsAutoHidden();
for (std::set<NodeGuiPtr>::iterator it = visibleNodes.begin(); it != visibleNodes.end(); ++it) {
QPointF evpt = (*it)->mapFromScene(newPos);
QRectF bbox = (*it)->mapToScene( (*it)->boundingRect() ).boundingRect();
if ( (*it)->isActive() && bbox.intersects(sceneR) ) {
if ( (*it)->contains(evpt) ) {
selected = (*it)->shared_from_this();
if (optionalInputsAutoHidden) {
(*it)->refreshEdgesVisility(true);
} else {
break;
}
} else {
Edge* edge = (*it)->hasEdgeNearbyPoint(newPos);
if (edge) {
selectedEdge = edge;
if (!optionalInputsAutoHidden) {
break;
}
} else if ( optionalInputsAutoHidden && !(*it)->getIsSelected() ) {
(*it)->refreshEdgesVisility(false);
}
}
}
}
if (selected) {
_imp->cursorSet = true;
setCursor( QCursor(Qt::OpenHandCursor) );
} else if (selectedEdge) {
} else if (!selectedEdge && !selected) {
if (_imp->cursorSet) {
_imp->cursorSet = false;
unsetCursor();
}
}
}
bool mustUpdateNavigator = false;
///Apply actions
switch (_imp->_evtState) {
case eEventStateDraggingArrow: {
QPointF np = _imp->_arrowSelected->mapFromScene(newPos);
if ( _imp->_arrowSelected->isOutputEdge() ) {
_imp->_arrowSelected->dragDest(np);
} else {
_imp->_arrowSelected->dragSource(np);
}
checkAndStartAutoScrollTimer(newPos);
mustUpdate = true;
break;
}
case eEventStateDraggingNode: {
//.........这里部分代码省略.........