本文整理汇总了C++中NodeGuiPtr::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeGuiPtr::getNode方法的具体用法?C++ NodeGuiPtr::getNode怎么用?C++ NodeGuiPtr::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeGuiPtr
的用法示例。
在下文中一共展示了NodeGuiPtr::getNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
NodeAnimPrivate::computeReaderRange()
{
NodeGuiPtr nodeUI = nodeGui.lock();
NodePtr node = nodeUI->getNode();
if (!node) {
return;
}
KnobIntBase *startingTimeKnob = dynamic_cast<KnobIntBase *>( node->getKnobByName(kReaderParamNameStartingTime).get() );
if (!startingTimeKnob) {
return;
}
KnobIntBase *firstFrameKnob = dynamic_cast<KnobIntBase *>( node->getKnobByName(kReaderParamNameFirstFrame).get() );
if (!firstFrameKnob) {
return;
}
KnobIntBase *lastFrameKnob = dynamic_cast<KnobIntBase *>( node->getKnobByName(kReaderParamNameLastFrame).get() );
if (!lastFrameKnob) {
return;
}
int startingTimeValue = startingTimeKnob->getValue();
int firstFrameValue = firstFrameKnob->getValue();
int lastFrameValue = lastFrameKnob->getValue();
frameRange.min = startingTimeValue;
frameRange.max = startingTimeValue + (lastFrameValue - firstFrameValue) + 1;
} // computeReaderRange
示例2: knobAnimObject
void
NodeAnim::initializeKnobsAnim()
{
// Create dope sheet knobs
NodeGuiPtr nodeUI = _imp->nodeGui.lock();
assert(nodeUI);
const KnobsVec& knobs = nodeUI->getNode()->getKnobs();
NodeAnimPtr thisShared = shared_from_this();
for (KnobsVec::const_iterator it = knobs.begin(); it != knobs.end(); ++it) {
// If the knob is not animted, don't create an item
if ( !(*it)->canAnimate() || !(*it)->isAnimationEnabled() ) {
continue;
}
KnobAnimPtr knobAnimObject(KnobAnim::create(getModel(), thisShared, _imp->nameItem, *it));
_imp->knobs.push_back(knobAnimObject);
} // for all knobs
} // initializeKnobsAnim
示例3: getNodeGui
NodePtr
NodeAnim::getInternalNode() const
{
NodeGuiPtr node = getNodeGui();
return node ? node->getNode() : NodePtr();
}
示例4: 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
示例5: toAnimationModule
void
NodeAnimPrivate::computeTimeOffsetRange()
{
NodeGuiPtr nodeUI = nodeGui.lock();
NodePtr node = nodeUI->getNode();
if (!node) {
return;
}
// Retrieve nearest reader useful values
{
AnimationModulePtr isAnimModel = toAnimationModule(model.lock());
NodeAnimPtr nearestReader = isAnimModel->getNearestReaderInternal(node);
if (nearestReader) {
// Retrieve the time offset values
KnobIntBasePtr timeOffsetKnob = toKnobIntBase(node->getKnobByName(kReaderParamNameTimeOffset));
assert(timeOffsetKnob);
int timeOffsetValue = timeOffsetKnob->getValue();
frameRange = nearestReader->getFrameRange();
frameRange.min += timeOffsetValue;
frameRange.max += timeOffsetValue;
}
}
} // computeTimeOffsetRange
示例6: getModel
void
NodeAnim::refreshVisibility()
{
AnimationModulePtr animModule = getModel();
QTreeWidgetItem *nodeItem = getTreeItem();
bool showNode = false;
int nChildren = nodeItem->childCount();
// Refresh children, which will recursively refresh their children
for (int i = 0; i < nChildren; ++i) {
QTreeWidgetItem* child = nodeItem->child(i);
AnimatedItemTypeEnum type;
KnobAnimPtr isKnob;
TableItemAnimPtr isTableItem;
NodeAnimPtr isNodeItem;
ViewSetSpec view;
DimSpec dim;
bool found = animModule->findItem(child, &type, &isKnob, &isTableItem, &isNodeItem, &view, &dim);
if (!found) {
continue;
}
if (isTableItem) {
isTableItem->refreshVisibilityConditional(false /*refreshParent*/);
} else if (isNodeItem) {
isNodeItem->refreshVisibility();
} else if (isKnob) {
isKnob->refreshVisibilityConditional(false /*refreshHolder*/);
}
if (!child->isHidden()) {
showNode = true;
}
}
if (!showNode) {
// If so far none of the children should be displayed, still check if the node has a range
if (isRangeDrawingEnabled()) {
showNode = true;
}
}
// If settings panel is not opened and the "Keep in Animation Module" knob is not checked, hide the node.
NodeGuiPtr nodeGui = getNodeGui();
bool keepInAnimationModule = nodeGui->getNode()->isKeepInAnimationModuleButtonDown();
if (!keepInAnimationModule && !nodeGui->isSettingsPanelVisible()) {
showNode = false;
}
refreshFrameRange();
nodeItem->setData(0, QT_ROLE_CONTEXT_IS_ANIMATED, showNode);
nodeItem->setHidden(!showNode);
} // refreshVisibility
示例7:
bool
AnimationModule::isNodeAnimated(const NodeGuiPtr &nodeGui)
{
NodePtr internalNode = nodeGui->getNode();
if (!internalNode) {
return false;
}
return internalNode->getEffectInstance()->getHasAnimation();
}
示例8: anim
void
AnimationModule::addNode(const NodeGuiPtr& nodeGui)
{
// Check if it already exists
for (std::list<NodeAnimPtr>::const_iterator it = _imp->nodes.begin(); it != _imp->nodes.end(); ++it) {
if ((*it)->getNodeGui() == nodeGui) {
(*it)->refreshVisibility();
return;
}
}
// Determinate the node type
// It will be useful to identify and sort tree items
AnimatedItemTypeEnum nodeType = eAnimatedItemTypeCommon;
NodePtr node = nodeGui->getNode();
assert(node && node->getGroup());
if ( !node || !node->getGroup() ) {
return;
}
EffectInstancePtr effectInstance = node->getEffectInstance();
// Don't add an item for this node if it doesn't have any knob that may animate
//if ( !getNodeCanAnimate(node) ) {
// return;
//}
std::string pluginID = node->getPluginID();
NodeGroupPtr isGroup = toNodeGroup(effectInstance);
if (effectInstance->isReader()) {
nodeType = eAnimatedItemTypeReader;
} else if (isGroup) {
nodeType = eAnimatedItemTypeGroup;
} else if (pluginID == PLUGINID_OFX_RETIME) {
nodeType = eAnimatedItemTypeRetime;
} else if (pluginID == PLUGINID_OFX_TIMEOFFSET) {
nodeType = eAnimatedItemTypeTimeOffset;
} else if (pluginID == PLUGINID_OFX_FRAMERANGE) {
nodeType = eAnimatedItemTypeFrameRange;
}
// The NodeAnim should not be created if there's no settings panel.
assert(nodeGui->getSettingPanel());
NodeAnimPtr anim(NodeAnim::create(toAnimationModule(shared_from_this()), nodeType, nodeGui) );
_imp->nodes.push_back(anim);
Q_EMIT nodeAdded(anim);
} // AnimationModule::addNode
示例9: mediumBSize
NodeSettingsPanel::NodeSettingsPanel(const boost::shared_ptr<MultiInstancePanel> & multiPanel,
Gui* gui,
const NodeGuiPtr &NodeUi,
QVBoxLayout* container,
QWidget *parent)
: DockablePanel(gui,
multiPanel.get() != NULL ? dynamic_cast<KnobHolder*>( multiPanel.get() ) : NodeUi->getNode()->getEffectInstance().get(),
container,
DockablePanel::eHeaderModeFullyFeatured,
false,
NodeUi->getUndoStack(),
QString::fromUtf8( NodeUi->getNode()->getLabel().c_str() ),
QString::fromUtf8( NodeUi->getNode()->getPluginDescription().c_str() ),
false,
QString::fromUtf8("Settings"),
parent)
, _nodeGUI(NodeUi)
, _selected(false)
, _settingsButton(0)
, _multiPanel(multiPanel)
{
if (multiPanel) {
multiPanel->initializeKnobsPublic();
}
QObject::connect( this, SIGNAL(closeChanged(bool)), NodeUi.get(), SLOT(onSettingsPanelClosedChanged(bool)) );
const QSize mediumBSize( TO_DPIX(NATRON_MEDIUM_BUTTON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_SIZE) );
const QSize mediumIconSize( TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_ICON_SIZE) );
QPixmap pixSettings;
appPTR->getIcon(NATRON_PIXMAP_SETTINGS, TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), &pixSettings);
_settingsButton = new Button( QIcon(pixSettings), QString(), getHeaderWidget() );
_settingsButton->setFixedSize(mediumBSize);
_settingsButton->setIconSize(mediumIconSize);
_settingsButton->setToolTip( GuiUtils::convertFromPlainText(tr("Settings and presets."), Qt::WhiteSpaceNormal) );
_settingsButton->setFocusPolicy(Qt::NoFocus);
QObject::connect( _settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsButtonClicked()) );
insertHeaderWidget(1, _settingsButton);
}
示例10: toKnobIntBase
void
NodeAnimPrivate::computeFRRange()
{
NodeGuiPtr nodeUI = nodeGui.lock();
NodePtr node = nodeUI->getNode();
if (!node) {
return;
}
KnobIntBasePtr frameRangeKnob = toKnobIntBase(node->getKnobByName(kFrameRangeParamNameFrameRange));
assert(frameRangeKnob);
frameRange.min = frameRangeKnob->getValue(DimIdx(0));
frameRange.max = frameRangeKnob->getValue(DimIdx(1));
}
示例11:
void
NodeAnimPrivate::computeCommonNodeRange()
{
NodeGuiPtr nodeUI = nodeGui.lock();
NodePtr node = nodeUI->getNode();
if (!node) {
return;
}
int first,last;
bool lifetimeEnabled = node->isLifetimeActivated(&first, &last);
if (lifetimeEnabled) {
frameRange.min = first;
frameRange.max = last;
}
}
示例12: assert
void
NodeGraph::selectNode(const NodeGuiPtr & n,
bool addToSelection)
{
if ( !n->isVisible() ) {
return;
}
bool alreadyInSelection = std::find(_imp->_selection.begin(),_imp->_selection.end(),n) != _imp->_selection.end();
assert(n);
if (addToSelection && !alreadyInSelection) {
_imp->_selection.push_back(n);
} else if (!addToSelection) {
clearSelection();
_imp->_selection.push_back(n);
}
n->setUserSelected(true);
ViewerInstance* isViewer = n->getNode()->isEffectViewer();
if (isViewer) {
OpenGLViewerI* viewer = isViewer->getUiContext();
const std::list<ViewerTab*> & viewerTabs = getGui()->getViewersList();
for (std::list<ViewerTab*>::const_iterator it = viewerTabs.begin(); it != viewerTabs.end(); ++it) {
if ( (*it)->getViewer() == viewer ) {
setLastSelectedViewer( (*it) );
}
}
}
bool magnifiedNodeSelected = false;
if (_imp->_magnifiedNode) {
magnifiedNodeSelected = std::find(_imp->_selection.begin(),_imp->_selection.end(),_imp->_magnifiedNode)
!= _imp->_selection.end();
}
if (magnifiedNodeSelected && _imp->_magnifOn) {
_imp->_magnifOn = false;
_imp->_magnifiedNode->setScale_natron(_imp->_nodeSelectedScaleBeforeMagnif);
}
}
示例13: menu
void
NodeSettingsPanel::onSettingsButtonClicked()
{
Menu menu(this);
//menu.setFont(QFont(appFont,appFontSize));
NodeGuiPtr node = getNode();
NodePtr master = node->getNode()->getMasterNode();
QAction* importPresets = new QAction(tr("Import presets"), &menu);
QObject::connect( importPresets, SIGNAL(triggered()), this, SLOT(onImportPresetsActionTriggered()) );
QAction* exportAsPresets = new QAction(tr("Export as presets"), &menu);
QObject::connect( exportAsPresets, SIGNAL(triggered()), this, SLOT(onExportPresetsActionTriggered()) );
menu.addAction(importPresets);
menu.addAction(exportAsPresets);
menu.addSeparator();
QAction* manageUserParams = new QAction(tr("Manage user parameters..."), &menu);
QObject::connect( manageUserParams, SIGNAL(triggered()), this, SLOT(onManageUserParametersActionTriggered()) );
menu.addAction(manageUserParams);
menu.addSeparator();
QAction* setKeyOnAll = new QAction(tr("Set key on all parameters"), &menu);
QObject::connect( setKeyOnAll, SIGNAL(triggered()), this, SLOT(setKeyOnAllParameters()) );
QAction* removeAnimationOnAll = new QAction(tr("Remove animation on all parameters"), &menu);
QObject::connect( removeAnimationOnAll, SIGNAL(triggered()), this, SLOT(removeAnimationOnAllParameters()) );
menu.addAction(setKeyOnAll);
menu.addAction(removeAnimationOnAll);
if ( master || !node->getDagGui() || !node->getDagGui()->getGui() || node->getDagGui()->getGui()->isGUIFrozen() ) {
importPresets->setEnabled(false);
exportAsPresets->setEnabled(false);
setKeyOnAll->setEnabled(false);
removeAnimationOnAll->setEnabled(false);
}
menu.exec( _settingsButton->mapToGlobal( _settingsButton->pos() ) );
}
示例14: if
void
NodeGraph::checkForHints(bool shiftdown,
bool controlDown,
const NodeGuiPtr& selectedNode,
const QRectF& visibleSceneR)
{
NodePtr internalNode = selectedNode->getNode();
bool doMergeHints = shiftdown && controlDown;
bool doConnectionHints = appPTR->getCurrentSettings()->isConnectionHintEnabled();
//Ignore hints for backdrops
BackdropGui* isBd = dynamic_cast<BackdropGui*>( selectedNode.get() );
if (isBd) {
return;
}
if (!doMergeHints) {
///for nodes already connected don't show hint
if ( ( internalNode->getMaxInputCount() == 0) && internalNode->hasOutputConnected() ) {
doConnectionHints = false;
} else if ( ( internalNode->getMaxInputCount() > 0) && internalNode->hasAllInputsConnected() && internalNode->hasOutputConnected() ) {
doConnectionHints = false;
}
}
if (!doConnectionHints) {
return;
}
QRectF selectedNodeBbox = selectedNode->boundingRectWithEdges(); //selectedNode->mapToParent( selectedNode->boundingRect() ).boundingRect();
double tolerance = 10;
selectedNodeBbox.adjust(-tolerance, -tolerance, tolerance, tolerance);
NodeGuiPtr nodeToShowMergeRect;
NodePtr selectedNodeInternalNode = selectedNode->getNode();
bool selectedNodeIsReader = selectedNodeInternalNode->getEffectInstance()->isReader() || selectedNodeInternalNode->getMaxInputCount() == 0;
Edge* edge = 0;
std::set<NodeGui*> nodesWithinRect;
getNodesWithinViewportRect(visibleWidgetRect(), &nodesWithinRect);
{
for (std::set<NodeGui*>::iterator it = nodesWithinRect.begin(); it != nodesWithinRect.end(); ++it) {
bool isAlreadyAnOutput = false;
const NodesWList& outputs = internalNode->getGuiOutputs();
for (NodesWList::const_iterator it2 = outputs.begin(); it2 != outputs.end(); ++it2) {
NodePtr node = it2->lock();
if (!node) {
continue;
}
if ( node == (*it)->getNode() ) {
isAlreadyAnOutput = true;
break;
}
}
if (isAlreadyAnOutput) {
continue;
}
QRectF nodeBbox = (*it)->boundingRectWithEdges();
if ( ( (*it) != selectedNode.get() ) && (*it)->isVisible() && nodeBbox.intersects(visibleSceneR) ) {
if (doMergeHints) {
//QRectF nodeRect = (*it)->mapToParent((*it)->boundingRect()).boundingRect();
NodePtr internalNode = (*it)->getNode();
if ( !internalNode->isOutputNode() && nodeBbox.intersects(selectedNodeBbox) ) {
bool nHasInput = internalNode->hasInputConnected();
int nMaxInput = internalNode->getMaxInputCount();
bool selectedHasInput = selectedNodeInternalNode->hasInputConnected();
int selectedMaxInput = selectedNodeInternalNode->getMaxInputCount();
double nPAR = internalNode->getEffectInstance()->getAspectRatio(-1);
double selectedPAR = selectedNodeInternalNode->getEffectInstance()->getAspectRatio(-1);
double nFPS = internalNode->getEffectInstance()->getFrameRate();
double selectedFPS = selectedNodeInternalNode->getEffectInstance()->getFrameRate();
bool isValid = true;
if ( (selectedPAR != nPAR) || (std::abs(nFPS - selectedFPS) > 0.01) ) {
if (nHasInput || selectedHasInput) {
isValid = false;
} else if ( !nHasInput && (nMaxInput == 0) && !selectedHasInput && (selectedMaxInput == 0) ) {
isValid = false;
}
}
if (isValid) {
nodeToShowMergeRect = (*it)->shared_from_this();
}
} else {
(*it)->setMergeHintActive(false);
}
} else { //!doMergeHints
edge = (*it)->hasEdgeNearbyRect(selectedNodeBbox);
///if the edge input is the selected node don't continue
if ( edge && ( edge->getSource() == selectedNode) ) {
edge = 0;
}
if ( edge && edge->isOutputEdge() ) {
if (selectedNodeIsReader) {
//.........这里部分代码省略.........
示例15: if
void
NodeGraph::moveNodesForIdealPosition(const NodeGuiPtr &node,
const NodeGuiPtr &selected,
bool autoConnect)
{
BackdropGuiPtr isBd = toBackdropGui(node);
if (isBd) {
return;
}
QRectF viewPos = visibleSceneRect();
///3 possible values:
/// 0 = default , i.e: we pop the node in the middle of the graph's current view
/// 1 = pop the node above the selected node and move the inputs of the selected node a little
/// 2 = pop the node below the selected node and move the outputs of the selected node a little
int behavior = 0;
if (!selected || !autoConnect) {
behavior = 0;
} else {
///this function is redundant with Project::autoConnect, depending on the node selected
///and this node we make some assumptions on to where we could put the node.
// 1) selected is output
// a) created is output --> fail
// b) created is input --> connect input
// c) created is regular --> connect input
// 2) selected is input
// a) created is output --> connect output
// b) created is input --> fail
// c) created is regular --> connect output
// 3) selected is regular
// a) created is output--> connect output
// b) created is input --> connect input
// c) created is regular --> connect output
///1)
if ( selected->getNode()->isOutputNode() ) {
///case 1-a) just do default we don't know what else to do
if ( node->getNode()->isOutputNode() ) {
behavior = 0;
} else {
///for either cases 1-b) or 1-c) we just connect the created node as input of the selected node.
behavior = 1;
}
}
///2) and 3) are similar except for case b)
else {
///case 2 or 3- a): connect the created node as output of the selected node.
if ( node->getNode()->isOutputNode() ) {
behavior = 2;
}
///case b)
else if ( node->getNode()->isInputNode() ) {
if ( selected->getNode()->getEffectInstance()->isReader() ) {
///case 2-b) just do default we don't know what else to do
behavior = 0;
} else {
///case 3-b): connect the created node as input of the selected node
behavior = 1;
}
}
///case c) connect created as output of the selected node
else {
behavior = 2;
}
}
}
NodePtr createdNodeInternal = node->getNode();
NodePtr selectedNodeInternal;
if (selected) {
selectedNodeInternal = selected->getNode();
}
///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;
//.........这里部分代码省略.........