Beispiel #1
0
NodePtr
AnimationModulePrivate::getNearestTimeNodeFromOutputs_recursive(const NodePtr& node,
                                                                const NodeCollectionPtr& collection,
                                                                std::list<NodePtr>& markedNodes) const
{
    const NodesWList &outputs = node->getOutputs();

    if ( std::find(markedNodes.begin(), markedNodes.end(), node) != markedNodes.end() ) {
        return NodePtr();
    }

    // If we go outside of the initial node group scope, return
    if (node->getGroup() != collection) {
        return NodePtr();
    }
    markedNodes.push_back(node);
    for (NodesWList::const_iterator it = outputs.begin(); it != outputs.end(); ++it) {
        NodePtr output = it->lock();
        std::string pluginID = output->getPluginID();

        if ( (pluginID == PLUGINID_OFX_RETIME) || ( pluginID == PLUGINID_OFX_TIMEOFFSET) || ( pluginID == PLUGINID_OFX_FRAMERANGE) ) {
            return output;
        } else {
            NodePtr ret =  getNearestTimeNodeFromOutputs_recursive(output, collection, markedNodes);
            if (ret) {
                return ret;
            }
        }
    }

    return NodePtr();
}
Beispiel #2
0
NodePtr
AnimationModulePrivate::getNearestReaderFromInputs_recursive(const NodePtr& node,
                                                       std::list<NodePtr>& markedNodes) const
{
    const std::vector<NodeWPtr > &inputs = node->getInputs();

    if ( std::find(markedNodes.begin(), markedNodes.end(), node) != markedNodes.end() ) {
        return NodePtr();
    }
    markedNodes.push_back(node);
    for (std::vector<NodeWPtr >::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
        NodePtr input = it->lock();

        if (!input) {
            continue;
        }

        if (input->getEffectInstance()->isReader()) {
            return input;
        } else {
            NodePtr ret = getNearestReaderFromInputs_recursive(input, markedNodes);
            if (ret) {
                return ret;
            }
        }
    }

    return NodePtr();
}
Beispiel #3
0
NodePtr
NodeAnim::getInternalNode() const
{
    NodeGuiPtr node = getNodeGui();

    return node ? node->getNode() : NodePtr();
}
Beispiel #4
0
/**
 * Returns the intersection between the TypeSet and the other node. The other
 * node may also be a type set, in which case this function is called
 * recursively to resolve the intersect.
 */
NodePtr intersect(const TypeSet::Ptr& typeSet, const NodePtr& other)
{
	// Intersect all types in the type set with the other type.
	NodeVector newTypes;
	const NodeVector& types = typeSet->getTypes();
	for (NodeVector::const_iterator it = types.begin(); it != types.end(); it++) {
		NodePtr type = intersect(*it, other);
		if (type->isKindOf(kInvalidType)) continue; // skip if the intersect was impossible
		bool exists = false;
		for (NodeVector::iterator is = newTypes.begin(); is != newTypes.end(); is++) {
			if (equal(type, *is)) {
				exists = true;
				break;
			}
		}
		if (!exists) newTypes.push_back(type);
	}

	// Return the new type set if it contains multiple types, a single type if
	// there's only one left after the intersect, or InvalidType if the
	// intersect yielded no types in the set.
	if (newTypes.empty()) {
		return NodePtr(new InvalidType);
	} else if (newTypes.size() == 1) {
		return newTypes.front();
	} else {
		TypeSet::Ptr ts(new TypeSet);
		ts->setTypes(newTypes);
		return ts;
	}
}
Beispiel #5
0
void
TimeLine::seekFrame(SequenceTime frame,
                    bool updateLastCaller,
                    const EffectInstancePtr& caller,
                    TimelineChangeReasonEnum reason)
{
    if (reason != eTimelineChangeReasonPlaybackSeek) {
        Q_EMIT frameAboutToChange();
    }
    bool changed = false;
    {
        QMutexLocker l(&_lock);
        if (_currentFrame != frame) {
            _currentFrame = frame;
            changed = true;
        }
        _lastSeekReason = reason;
    }

    if (_project && updateLastCaller) {
        _project->getApp()->setLastViewerUsingTimeline( caller ? caller->getNode() : NodePtr() );
    }
    if (changed) {
        Q_EMIT frameChanged(frame, (int)reason);
    }
}
ClipPlaneChunkBase::ClipPlaneChunkBase(void) :
    _sfEquation               (Vec4f(0, 0, 1, 0)), 
    _sfEnable                 (bool(GL_TRUE)), 
    _sfBeacon                 (NodePtr(NullFC)), 
    Inherited() 
{
}
Beispiel #7
0
	NodePtr trySequentialize(NodeManager& manager, const NodePtr& stmt, bool removeSyncOps) {
		try {
			return sequentialize(manager, stmt, removeSyncOps);
		} catch (const NotSequentializableException& nse) {
			LOG(INFO) << "Unable to sequentialize: " << nse.what();
		}
		return NodePtr();
	}
Beispiel #8
0
 void cb(const NodePtr& node) {
   if (!_cb)
     return;
   if (_parents.size())
     _cb(_parents.back(), node);
   else
     _cb(NodePtr(), node);
 }
Beispiel #9
0
NodePtr Canvas::getElementByID(const std::string& id)
{
    if (m_IDMap.find(id) != m_IDMap.end()) {
        return m_IDMap.find(id)->second;
    } else {
        return NodePtr();
    }
}
Beispiel #10
0
void Database::loadRoomNodeScripts(Common::SeekableSubReadStreamEndian *file, Common::Array<NodePtr> &nodes) {
	uint zipIndex = 0;
	while (1) {
		int16 id = file->readUint16();

		// End of list
		if (id == 0)
			break;

		if (id <= -10)
			error("Unimplemented node list command");

		if (id > 0) {
			// Normal node
			NodePtr node = NodePtr(new NodeData());
			node->id = id;
			node->zipBitIndex = zipIndex;
			node->scripts = loadCondScripts(*file);
			node->hotspots = loadHotspots(*file);

			nodes.push_back(node);
		} else {
			// Several nodes sharing the same scripts
			Common::Array<int16> nodeIds;

			for (int i = 0; i < -id; i++) {
				nodeIds.push_back(file->readUint16());
			}

			Common::Array<CondScript> scripts = loadCondScripts(*file);
			Common::Array<HotSpot> hotspots = loadHotspots(*file);

			for (int i = 0; i < -id; i++) {
				NodePtr node = NodePtr(new NodeData());
				node->id = nodeIds[i];
				node->zipBitIndex = zipIndex;
				node->scripts = scripts;
				node->hotspots = hotspots;

				nodes.push_back(node);
			}
		}

		zipIndex++;
	}
}
Beispiel #11
0
NodePtr Canvas::getElementByID(const std::string& id)
{
    if (m_IDMap.find(id) != m_IDMap.end()) {
        return m_IDMap.find(id)->second;
    } else {
        AVG_TRACE(Logger::WARNING, "getElementByID(\"" << id << "\") failed.");
        return NodePtr();
    }
}
Beispiel #12
0
NodePtr
ViewerNode::getCurrentAInput() const
{
    ChoiceOption curLabel = _imp->aInputNodeChoiceKnob.lock()->getCurrentEntry();
    if (curLabel.id == "-") {
        return NodePtr();
    }
    int inputIndex = QString::fromUtf8(curLabel.id.c_str()).toInt();
    return getNode()->getInput(inputIndex);
}
Beispiel #13
0
void Contact::addEvent(CursorEventPtr pEvent)
{
    pEvent->setCursorID(m_CursorID);
    pEvent->setContact(boost::dynamic_pointer_cast<Contact>(shared_from_this()));
    calcSpeed(pEvent, m_Events.back());
    updateDistanceTravelled(m_Events.back(), pEvent);
    m_Events.back()->removeBlob();
    m_Events.back()->setNode(NodePtr());
    m_Events.push_back(pEvent);
}
Beispiel #14
0
StatCache::NodePtr StatCache::getNode(const std::string& path, bool follow) {
#ifdef __linux__
  int wd = inotify_add_watch(m_ifd, path.c_str(),
                             0
                             | IN_MODIFY
                             | IN_ATTRIB
                             | IN_MOVED_FROM
                             | IN_MOVED_TO
                             | IN_CREATE
                             | IN_DELETE
                             | (follow ? 0 : IN_DONT_FOLLOW)
                             | IN_ONLYDIR);
  if (wd == -1 && errno != ENOTDIR) {
    TRACE(2, "StatCache: getNode('%s', follow=%s) failed\n",
             path.c_str(), follow ? "true" : "false");
    return NodePtr(nullptr);
  }
  NodePtr node;
  if (wd != -1) {
    node = folly::get_default(m_watch2Node, wd);
    if (!node.get()) {
      node = new Node(*this, wd);
      if (!m_watch2Node.insert(std::make_pair(wd, node)).second) {
        assertx(0); // should not already exist in the map
      }
      TRACE(2, "StatCache: getNode('%s', follow=%s) --> %p (wd=%d)\n",
               path.c_str(), follow ? "true" : "false", node.get(), wd);
    } else {
      TRACE(3, "StatCache: getNode('%s', follow=%s) --> alias %p (wd=%d)\n",
               path.c_str(), follow ? "true" : "false", node.get(), wd);
    }
  } else {
    node = new Node(*this);
    TRACE(3, "StatCache: getNode('%s', follow=%s) --> %p\n",
             path.c_str(), follow ? "true" : "false", node.get());
  }
  node->setPath(path);
  return node;
#else
  return NodePtr(nullptr);
#endif
}
Beispiel #15
0
NodePtr AnnotationValue::GetValueAsNode() const
{
	if (!IsNode())
	{
		std::stringstream ss;
		ss << "Attempted to access " << GetTypeString() 
			<< " annotation as a node.";
		throw AnnotationValueTypeException(ss.str());
	}
	Node & node = boost::get<Node &>(value);
	return NodePtr(&node);
}
Beispiel #16
0
bool
NodeGraph::tryReadClipboard(const QPointF& pos, std::istream& ss)
{

    
    // Check if this is a regular clipboard
    // This will also check if this is a single node
    try {
        SERIALIZATION_NAMESPACE::NodeClipBoard cb;
        SERIALIZATION_NAMESPACE::read(std::string(), ss, &cb);

        std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > > nodesToPaste;
        for (SERIALIZATION_NAMESPACE::NodeSerializationList::const_iterator it = cb.nodes.begin(); it != cb.nodes.end(); ++it) {
            nodesToPaste.push_back(std::make_pair(NodePtr(), *it));
        }
        _imp->pasteNodesInternal(nodesToPaste, pos, NodeGraphPrivate::PasteNodesFlags(NodeGraphPrivate::ePasteNodesFlagRelativeToCentroid | NodeGraphPrivate::ePasteNodesFlagUseUndoCommand));
    } catch (...) {
        
        // Check if this was copy/pasted from a project directly
        try {
            ss.seekg(0);
            SERIALIZATION_NAMESPACE::ProjectSerialization isProject;
            SERIALIZATION_NAMESPACE::read(std::string(), ss, &isProject);

            std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > > nodesToPaste;
            for (SERIALIZATION_NAMESPACE::NodeSerializationList::const_iterator it = isProject._nodes.begin(); it != isProject._nodes.end(); ++it) {
                nodesToPaste.push_back(std::make_pair(NodePtr(), *it));
            }

            _imp->pasteNodesInternal(nodesToPaste, pos, NodeGraphPrivate::PasteNodesFlags(NodeGraphPrivate::ePasteNodesFlagRelativeToCentroid | NodeGraphPrivate::ePasteNodesFlagUseUndoCommand));
        } catch (...) {
            
            return false;
        }
    }
    

    return true;

}
Beispiel #17
0
NodePtr
Project::findNodeWithScriptName(const std::string& nodeScriptName, const std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >& allCreatedNodesInGroup)
{
    for (std::list<std::pair<NodePtr, SERIALIZATION_NAMESPACE::NodeSerializationPtr > >::const_iterator it = allCreatedNodesInGroup.begin(); it!=allCreatedNodesInGroup.end(); ++it) {
        if (!it->second) {
            continue;
        }
        if (it->second->_nodeScriptName == nodeScriptName) {
            return it->first;
        }
    }
    return NodePtr();
}
Beispiel #18
0
NodePtr GeometryConverter::_createNode(const OsmMapPtr& map, const Coordinate& c,
  Status s, double circularError)
{
  if (_nf == 0)
  {
    NodePtr n = NodePtr(new Node(s, map->createNextNodeId(), c, circularError));
    map->addNode(n);
    return n;
  }
  else
  {
    return _nf->createNode(map, c, s, circularError);
  }
}
Beispiel #19
0
Node::EnumeratorPtr Directory::GetChildren()
{
    if (m_children.empty())
    {
	GetInfo();
	std::vector<unsigned int> vec;
	mediadb::ChildrenToVector(m_info->GetString(mediadb::CHILDREN), &vec);
	m_children.resize(vec.size());
	for (unsigned int i=0; i<vec.size(); ++i)
	    m_children[i] = NodePtr(new Directory(m_db, vec[i]));
    }

    return Node::EnumeratorPtr(new ContainerEnumerator<std::vector<NodePtr> >(m_children));
}
Beispiel #20
0
    void Node::orphan()
    {
      NodePtr parent = getParent();

      if (parent)
      {
        if (parent->mFirstChild.get() == this)
          parent->mFirstChild = mNextSibling;

        if (parent->mLastChild.get() == this)
          parent->mLastChild = mPreviousSibling;
      }

      if (mNextSibling)
        mNextSibling->mPreviousSibling = mPreviousSibling;

      if (mPreviousSibling)
        mPreviousSibling->mNextSibling = mNextSibling;

      // leave this node as an orphan
      mParent = NodePtr();
      mNextSibling = NodePtr();
      mPreviousSibling = NodePtr();
    }
Beispiel #21
0
NodePtr Database::getNodeData(uint16 nodeID, uint32 roomID, uint32 ageID) {
	Common::Array<NodePtr> nodes;

	if (roomID == 0)
		roomID = _currentRoomID;

	nodes = getRoomNodes(roomID);

	for (uint i = 0; i < nodes.size(); i++) {
		if (nodes[i]->id == nodeID)
			return nodes[i];
	}

	return NodePtr();
}
Beispiel #22
0
	NodePtr LinkedNode::RemoveChild(const string& node_name)
	{
		Assert(node_name.length()>0);
		SceneObjectMap::iterator it_find = scene_objects_.find(node_name);
		NodePtr ret;
		if (it_find==scene_objects_.end())
			return NodePtr(NULL);
		else
		{
			(*it_find).second->father_ = NULL;
			ret.assign((*it_find).second);
			scene_objects_.erase(node_name);
		}
		return ret;
	}
        void init() {
            clear();
            this->flit_size_in_bytes = network->flit_size_in_bytes;

            slowestClock = 0.0;
            for(auto node : network->nodes) {
                simulatedNodes.insert(std::make_pair(node.get(), new SimulatedNode(this, node.get())));
                if (slowestClock < node->latency)
                    slowestClock = node->latency;
            }

            for(auto link: network->links) {
                if (slowestClock < link->latency)
                    slowestClock = link->latency;
                simulatedLinks.insert(std::make_pair(link.get(), new SimulatedLink(this, link.get())));
                SimulatedLink* slink = simulatedLinks.find(link.get())->second;
                SimulatedNode* n;

                n = getNode(link->a.get());
                assert(n != NULL);
                n->notifyLink(link->b.get(), slink);

                n = getNode(link->b.get());
                assert(n != NULL);
                n->notifyLink(link->a.get(), slink);
            }

            Time largestPeriod = 0.0;
            this->longestPath = 0;
            for (auto path: network->paths){
                // Time period = 1.0 / (path->requested_bw / flit_size_in_bytes);
                Time period = 1.0 / (path->requested_bw / flit_size_in_bytes);
                if (largestPeriod < period)
                    largestPeriod = period;
                if (path->path.size() > longestPath)
                    longestPath = path->path.size();
                Link* vlink = network->findLink(path->src, NodePtr()).get();
                assert(vlink != NULL);
                auto flink = simulatedLinks.find(vlink);
                assert(flink != simulatedLinks.end());
                SimulatedLink* slink = flink->second;
                SimulatedNode* dst = simulatedNodes[path->dst.get()];
                injectionPorts.insert(std::make_pair(path.get(),
                    new InjectionPort(this, period, path.get(), slink, dst)));
            }

            this->longestPeriod = largestPeriod;
        }
Beispiel #24
0
/**
 * @brief Tries to find the largest common type between types %a and %b.
 *
 * Returns an InvalidType if the intersect is impossible.
 */
NodePtr intersect(const NodePtr& a, const NodePtr& b)
{
	// Shortcut if both types are equal.
	if (equal(a,b)) return a;

	// Intersection between TypeSets or a TypeSet and other type.
	TypeSet::Ptr typeSetA = TypeSet::from(a), typeSetB = TypeSet::from(b);
	if (typeSetA && typeSetB) {
		return intersect(typeSetA, typeSetB);
	} else if (typeSetA && !typeSetB) {
		return intersect(typeSetA, b);
	} else if (!typeSetA && typeSetB) {
		return intersect(typeSetB, a);
	}

	return NodePtr(new InvalidType);
}
Beispiel #25
0
	RETURN_CODE LinkedNode::InsertChild(LinkedNode* pnode)
	{
		string node_name = pnode->GetName();
		Assert(node_name.length()>0);
		SceneObjectMap::iterator it_find = scene_objects_.find(node_name);
		if (it_find!=scene_objects_.end())
			if ((*it_find).second.get()==pnode)
				return RETURN_OPERATOR_DUPLICATE;
			else
				return RETURN_NAME_DUPLICATE;
		else
		{
			scene_objects_.insert(std::pair<string,AutoPtr<LinkedNode> >(node_name,NodePtr(pnode)));
			pnode->father_ = this;
			return RETURN_SUCCESS;
		}
	}
Beispiel #26
0
NodePtr Database::getNodeData(uint16 nodeID, uint32 roomID, uint32 ageID) {
	Common::Array<NodePtr> nodes;

	if (roomID == 0)
		roomID = _currentRoomID;

	if (_roomNodesCache.contains(roomID)) {
		nodes = _roomNodesCache.getVal(roomID);
	} else {
		RoomData *data = findRoomData(roomID);
		nodes = loadRoomScripts(data);
	}

	for (uint i = 0; i < nodes.size(); i++) {
		if (nodes[i]->id == nodeID)
			return nodes[i];
	}

	return NodePtr();
}
Beispiel #27
0
  NodePtr pop() {
    NodePtr lhead = head;
    //if (lhead.ptr<0) return NodePtr();
    //NodePtr prev = node(lhead)->prev;
    //while (!head.compare_exchange_weak(lhead,prev)) { if(lhead.ptr<0) return NodePtr(); prev = node(lhead)->prev;}
    while (lhead && !head.compare_exchange_weak(lhead,nodes[lhead.ptr]->prev));
    if (lhead.ptr>=0) {
#ifdef VICONC_DEBUG      
      assert(node(lhead)->prev.ptr!=lhead.ptr);
      // assert(node(lhead)->prev==prev);  // usually fails in case of aba
      node(lhead)->prev=NodePtr(); // not needed
#endif
      nel-=1;
#ifdef VICONC_DEBUG      
      // assert(nel>=0);  // may fail 
      verify[lhead.ptr].v-=1;
      assert(0==verify[lhead.ptr].v);
#endif
    }
    return lhead;
  }
Beispiel #28
0
/**
 * @brief Returns the last node connected to a GroupInput node following the main-input branch of the graph
 **/
NodePtr
ViewerNodePrivate::getInputRecursive(int inputIndex) const
{
    NodePtr viewerProcess = internalViewerProcessNode[inputIndex].lock();
    if (!viewerProcess) {
        return NodePtr();
    }
    NodePtr input = viewerProcess->getRealInput(inputIndex);
    if (!input) {
        return viewerProcess;
    }
    GroupInput* isInput = dynamic_cast<GroupInput*>(input->getEffectInstance().get());
    if (isInput) {
        return viewerProcess;
    }
    NodePtr inputRet = getMainInputRecursiveInternal(input);
    if (!inputRet) {
        return input;
    } else {
        return inputRet;
    }
}
Beispiel #29
0
NodePtr
Gui::createWriter()
{
    NodePtr ret;
    std::vector<std::string> filters;

    appPTR->getSupportedWriterFileFormats(&filters);

    std::string file;
    bool useDialogForWriters = appPTR->getCurrentSettings()->isFileDialogEnabledForNewWriters();
    if (useDialogForWriters) {
        file = popSaveFileDialog( true, filters, _imp->_lastSaveSequenceOpenedDir.toStdString(), true );
        if ( file.empty() ) {
            return NodePtr();
        }
    }


    if ( !file.empty() ) {
        std::string patternCpy = file;
        std::string path = SequenceParsing::removePath(patternCpy);
        _imp->_lastSaveSequenceOpenedDir = QString::fromUtf8( path.c_str() );
    }

    NodeGraph* graph = 0;
    if (_imp->_lastFocusedGraph) {
        graph = _imp->_lastFocusedGraph;
    } else {
        graph = _imp->_nodeGraphArea;
    }
    NodeCollectionPtr group = graph->getGroup();
    assert(group);

    CreateNodeArgsPtr args(CreateNodeArgs::create(PLUGINID_NATRON_WRITE, group));
    ret =  getApp()->createWriter(file, args);


    return ret;
}
Beispiel #30
0
void
CreateNodeArgs::initializeProperties() const
{
    createProperty<std::string>(kCreateNodeArgsPropPluginID, std::string());
    createProperty<int>(kCreateNodeArgsPropPluginVersion, -1, -1);
    createProperty<double>(kCreateNodeArgsPropNodeInitialPosition, (double)INT_MIN, (double)INT_MIN);
    createProperty<std::string>(kCreateNodeArgsPropNodeInitialName, std::string());
    createProperty<std::string>(kCreateNodeArgsPropPreset, std::string());
    createProperty<std::string>(kCreateNodeArgsPropPyPlugID, std::string());
    createProperty<std::string>(kCreateNodeArgsPropNodeInitialParamValues, std::vector<std::string>());
    createProperty<SERIALIZATION_NAMESPACE::NodeSerializationPtr>(kCreateNodeArgsPropNodeSerialization, SERIALIZATION_NAMESPACE::NodeSerializationPtr());
    createProperty<bool>(kCreateNodeArgsPropVolatile, false);
    createProperty<bool>(kCreateNodeArgsPropNoNodeGUI, false);
    createProperty<bool>(kCreateNodeArgsPropSettingsOpened, true);
    createProperty<bool>(kCreateNodeArgsPropSubGraphOpened, true);
    createProperty<bool>(kCreateNodeArgsPropAutoConnect, true);
    createProperty<bool>(kCreateNodeArgsPropAllowNonUserCreatablePlugins, false);
    createProperty<bool>(kCreateNodeArgsPropSilent, false);
    createProperty<bool>(kCreateNodeArgsPropNodeGroupDisableCreateInitialNodes, false);
    createProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, true);
    createProperty<NodeCollectionPtr>(kCreateNodeArgsPropGroupContainer, NodeCollectionPtr());
    createProperty<NodePtr>(kCreateNodeArgsPropMetaNodeContainer, NodePtr());
}