示例#1
0
void Node::output(ostream& printStream, int indentLevet) 
{
	char *indentString = getIndentLevelString(indentLevet);

	if (isInstanceNode() == false) {
		outputHead(printStream, indentString);
		outputContext(printStream, indentString);
	
		if (!isElevationGridNode() && !isShapeNode() && !isSoundNode() && !isPointSetNode() && !isIndexedFaceSetNode() && 
			!isIndexedLineSetNode() && !isTextNode() && !isAppearanceNode()) {
			if (getChildNodes() != NULL) {
				if (isLodNode()) 
					printStream << indentString << "\tlevel [" << endl;
				else if (isSwitchNode()) 
					printStream << indentString << "\tchoice [" << endl;
				else
					printStream << indentString <<"\tchildren [" << endl;
			
				for (Node *node = getChildNodes(); node; node = node->next()) {
					if (node->isInstanceNode() == false) 
						node->output(printStream, indentLevet+2);
					else
						node->output(printStream, indentLevet+2);
				}
			
				printStream << indentString << "\t]" << endl;
			}
		}
		outputTail(printStream, indentString);
	}
	else 
		printStream << indentString << "USE " << getName() << endl;

	delete indentString;
}
示例#2
0
void Node::setSceneGraph(SceneGraph *sceneGraph)	
{
	mSceneGraph = sceneGraph;
	for (Node *node = getChildNodes(); node; node = node->next()) {
			node->setSceneGraph(sceneGraph);
	}
}
示例#3
0
  void DOMElement::dumpInfo(FILE * f, int recursion)
  {
    NodeList nodes = getChildNodes();

    addSpace(f, recursion);
    fprintf(f, "NODE <%s> (%d children, %d deep)",
	    getTagName().c_str(), (int) nodes.size(), recursion);

    std::string str = getTextContent();
    if(str.size() > 0 && str.size() < 100) {
      fprintf(f, " TEXT = \"%s\"", str.c_str());
    }

    fprintf(f, "\n");

    int i = 1;

    fflush(f);

    for(NodeList::iterator it = nodes.begin(); it != nodes.end(); it++) {
      addSpace(f, recursion);
      fprintf(f, "Child %d/%d\n", i, (int) nodes.size());
      (*it).dumpInfo(f, recursion + 1);
      i++;
    }
  }
示例#4
0
std::string	xbnode::getText()
{
	std::string ret;
	switch( m_Type )
	{
	case xbn_attribute:
		ret = getValue();
		if( ret.find_first_of("\"'")==0 &&
			ret.find_last_of("\"'")==ret.size()-1 )
		{
			ret=ret.substr(1,ret.size()-2);
		}
		break;
	case xbn_cdata:
	case xbn_comment:
	case xbn_text:
	case xbn_temp:
		ret = getValue();
		break;
	case xbn_node:
		{
			xbnode_list list;
			getChildNodes( list, false, xbnode::xbn_text|xbnode::xbn_cdata );
			for(xbnode_list::iterator pc=list.begin(), pe=list.end(); pc!=pe; ++pc )
			{
				ret+=(*pc)->getValue();
			}
		}break;
	default:
		raiseError( "getText() cant convert", __FILE__,__LINE__);
		break;
	}

	return Xml2Text( ret );
}
示例#5
0
static void willRemoveChildren(ContainerNode* container)
{
    NodeVector children;
    getChildNodes(container, children);

    container->document()->nodeChildrenWillBeRemoved(container);

#if ENABLE(MUTATION_OBSERVERS)
    ChildListMutationScope mutation(container);
#endif

    for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) {
        Node* child = it->get();

#if ENABLE(MUTATION_OBSERVERS)
        mutation.willRemoveChild(child);
        child->notifyMutationObserversNodeWillDetach();
#endif
#if ENABLE(UNDO_MANAGER)
        if (UndoManager::isRecordingAutomaticTransaction(container))
            UndoManager::addTransactionStep(NodeRemovingDOMTransactionStep::create(container, child));
#endif

        // fire removed from document mutation events.
        dispatchChildRemovalEvents(child);
    }

    ChildFrameDisconnector(container, ChildFrameDisconnector::DoNotIncludeRoot).disconnect();
}
示例#6
0
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
    NodeVector children;
    getChildNodes(oldParent, children);

    if (oldParent->document()->hasMutationObserversOfType(MutationObserver::ChildList)) {
        ChildListMutationScope mutation(oldParent);
        for (unsigned i = 0; i < children.size(); ++i)
            mutation.willRemoveChild(children[i].get());
    }

    // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child,
    // probably inside removeDetachedChildrenInContainer.

    oldParent->removeDetachedChildren();

    for (unsigned i = 0; i < children.size(); ++i) {
        if (children[i]->attached())
            children[i]->detach();
        // FIXME: We need a no mutation event version of adoptNode.
        RefPtr<Node> child = document()->adoptNode(children[i].release(), ASSERT_NO_EXCEPTION);
        parserAppendChild(child.get());
        // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
        // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
        // Can we do better?
        treeScope()->adoptIfNeeded(child.get());
        if (attached() && !child->attached())
            child->attach();
    }
}
示例#7
0
void Exporter::getChildNodes(INode *node, vector<NiNodeRef>& list)
{
	for (int i = 0; i < node->NumberOfChildren(); i++)
	{
		INode * child = node->GetChildNode(i);
		ObjectState os = node->EvalWorldState(0);
		bool addBone = false;
		bool local = !mFlattenHierarchy;
		bool meshGroup = isMeshGroup(node);

		TSTR nodeName = node->GetName();

		if (wildmatch(TEXT("Bip?? Footsteps"), nodeName))
		{
			addBone = false;
		}
		else if (node->IsBoneShowing())
		{
			addBone = true;
		}
		else if (os.obj && os.obj->SuperClassID() == GEOMOBJECT_CLASS_ID)
		{
			Class_ID clsid = os.obj->ClassID();
			if (os.obj
				&& (clsid == BONE_OBJ_CLASSID
					|| clsid == Class_ID(BONE_CLASS_ID, 0)
					|| clsid == Class_ID(0x00009125, 0) /* Biped Twist Helpers */
					)
				)
			{
				// skip mesh groups in skeleton only situations
				if (!meshGroup || !local || !mSkeletonOnly)
					addBone = true;
			}
			else if (!mSkeletonOnly)
			{
				if (mExportType != NIF_WO_ANIM && isNodeTracked(node)) {
					addBone = true;
				}
				else if (mExportExtraNodes || (mExportType != NIF_WO_ANIM && isNodeKeyed(node))) {
					addBone = true;
				}
			}
			else if (mExportCameras && os.obj && os.obj->SuperClassID() == CAMERA_CLASS_ID)
			{
				addBone = true;
			}
			else if (meshGroup && local && !mSkeletonOnly) // only create node if local
			{
				addBone = true;
			}
		}
		if (addBone)
		{
			list.push_back(getNode(child));
		}
		getChildNodes(child, list);
	}
}
示例#8
0
TextureNode *Node::getTextureNode() 
{
	for (Node *node = getChildNodes(); node != NULL; node = node->next()) {
		if (node->isTextureNode())
			return (TextureNode *)node;
	}
	return NULL;
}
示例#9
0
static void collectTargetNodes(Node* node, NodeVector& nodes)
{
    if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
        nodes.append(node);
        return;
    }
    getChildNodes(node, nodes);
}
示例#10
0
//! Delete the attribute from the node and its child nodes.
static void deleteAttribute(double /*value*/, const Util::StringIdentifier & attributeId, Node * node, FrameContext & /*context*/) {
	node->unsetAttribute(attributeId);

	const auto children = getChildNodes(node);
	for(const auto & child : children) {
		child->unsetAttribute(attributeId);
	}
}
示例#11
0
Node *Node::getGeometryNode() 
{
	for (Node *node = getChildNodes(); node != NULL; node = node->next()) {
		if (node->isGeometryNode())
			return node;
	}
	return NULL;
}
示例#12
0
GroupingNode *Node::getGroupingNodes() 
{
	for (Node *node = getChildNodes(); node != NULL; node = node->next()) {
		if (node->isGroupingNode())
			return (GroupingNode *)node;
	}
	return NULL;
}
示例#13
0
bool Node::isChildNode(Node *node) 
{
	for (Node *cnode = getChildNodes(); cnode != NULL; cnode = cnode->next()) {
		if (isChildNode(cnode, node) == true)
			return true;
	}
	return false;
}
示例#14
0
  Element* Document::getDocumentElement()  
  {
    if(getChildNodes().getLength() > 0) {
		for (int i = 0; i < getChildNodes().getLength(); i++)
		{
			if(Node::COMMENT_NODE == getChildNodes().item(i)->getNodeType())
			{
				continue;
			}
			else
			{
				return dynamic_cast<Element*>(getChildNodes().item(i));
      //return dynamic_cast<Element*>(getChildNodes().item(0));
    }
		} 
    }
    return NULL;
  }
void WrapContentsInDummySpanCommand::executeApply() {
  NodeVector children;
  getChildNodes(*m_element, children);

  for (auto& child : children)
    m_dummySpan->appendChild(child.release(), IGNORE_EXCEPTION);

  m_element->appendChild(m_dummySpan.get(), IGNORE_EXCEPTION);
}
示例#16
0
void Node::deleteChildNodes(void)
{
	Node *node=getChildNodes();
	while (node) {
		Node *nextNode = node->next();
		delete node;
		node = nextNode;
	}
}
示例#17
0
static void collectChildrenAndRemoveFromOldParent(Node* node, NodeVector& nodes, ExceptionCode& ec)
{
    if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
        nodes.append(node);
        if (ContainerNode* oldParent = node->parentNode())
            oldParent->removeChild(node, ec);
        return;
    }
    getChildNodes(node, nodes);
    toContainerNode(node)->removeChildren();
}
示例#18
0
Node *Node::getChildNode(const char *typeString) 
{

	String type(typeString);
		
	for (Node *node = getChildNodes(); node != NULL; node = node->next()) {
		if (type.compareTo(node->getType()) == 0)
			return node;
	}
	return NULL;
}
示例#19
0
static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionCode& ec)
{
    if (!node.isDocumentFragment()) {
        nodes.append(node);
        if (ContainerNode* oldParent = node.parentNode())
            oldParent->removeChild(&node, ec);
        return;
    }

    getChildNodes(node, nodes);
    toContainerNode(node).removeChildren();
}
示例#20
0
  DOMElement DOMElement::getChildNode(const char * tagname)
  {
    NodeList nodes = getChildNodes();
    
    for(NodeList::iterator it = nodes.begin(); it != nodes.end(); it++) {
      DOMElement e = *it;
      if(e.getTagName() == tagname)
	return e;
    }

    return DOMElement(0);
  }
void ControllerAnnotations::setPlayerParameters(playerParameters* parameters)
{
	auto model = static_cast<Annotations*>(getModel());
	model->setCurrentFrame(parameters->m_CurrentFrameNumber);

	IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::TRACKEDCOMPONENTCORE);
	auto trackedComponentCoreController = qobject_cast<ControllerTrackedComponentCore*>(ctr);
	auto trackedTrajectoryModel = dynamic_cast<IModelTrackedTrajectory *>(trackedComponentCoreController->getModel());
	if (trackedTrajectoryModel != nullptr)
		model->updateTrackedAnnotations(trackedTrajectoryModel->getChildNodes());
	updateView();
}
示例#22
0
void ContainerNode::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    Node::reportMemoryUsage(memoryObjectInfo);
    info.ignoreMember(m_firstChild);
    info.ignoreMember(m_lastChild);

    // Report child nodes as direct members to make them look like a tree in the snapshot.
    NodeVector children;
    getChildNodes(const_cast<ContainerNode*>(this), children);
    for (size_t i = 0; i < children.size(); ++i)
        info.addMember(children[i], "child");
}
示例#23
0
文件: USETREE.C 项目: coder03/ldd
void printlist(TreeNode *node){
	TreeNode **list,*nodeptr;
	int ccount,i;
	ccount = getChildCount(node);
	list = getChildNodes(node);
	if(list == NULL)
		return;
	nodeptr = *list;
	for(i=0;i<ccount; i++){
		printf(" Data in Node = %d\n",nodeptr->data);
		nodeptr++;
	}
}
void WrapContentsInDummySpanCommand::doUnapply() {
  DCHECK(m_element);

  if (!m_dummySpan || !hasEditableStyle(*m_element))
    return;

  NodeVector children;
  getChildNodes(*m_dummySpan, children);

  for (auto& child : children)
    m_element->appendChild(child.release(), IGNORE_EXCEPTION);

  m_dummySpan->remove(IGNORE_EXCEPTION);
}
示例#25
0
		NodeVisitor::status leave(Node * _node) override {
			auto geoNode = dynamic_cast<GeometryNode *>(_node);
			uint32_t primitiveCount = 0;
			if(geoNode != nullptr) {
				const auto mesh = geoNode->getMesh();
				primitiveCount = mesh == nullptr ? 0 : mesh->getPrimitiveCount();
			} else {
				const auto children = getChildNodes(_node);
				for(const auto & child : children) {
					primitiveCount += child->getAttribute(m_primitiveCountId)->toUnsignedInt();
				}
			}
			_node->setAttribute(m_primitiveCountId, Util::GenericAttribute::createNumber(primitiveCount));
			return CONTINUE_TRAVERSAL;
		}
void MergeIdenticalElementsCommand::doApply()
{
    if (m_element1->nextSibling() != m_element2 || !m_element1->hasEditableStyle() || !m_element2->hasEditableStyle())
        return;

    m_atChild = m_element2->firstChild();

    NodeVector children;
    getChildNodes(*m_element1, children);

    for (auto& child : children)
        m_element2->insertBefore(child.release(), m_atChild.get(), IGNORE_EXCEPTION);

    m_element1->remove(IGNORE_EXCEPTION);
}
Annotations::TrackedPoint ControllerAnnotations::snapToTrajectory(const QPoint &originalPoint)
{
	auto model = static_cast<Annotations*>(getModel());
	IController* ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::TRACKEDCOMPONENTCORE);
	auto trackedComponentCoreController = qobject_cast<ControllerTrackedComponentCore*>(ctr);
	auto trackedTrajectoryModel = dynamic_cast<IModelTrackedTrajectory *>(trackedComponentCoreController->getModel());

	if (trackedTrajectoryModel && QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier))
	{
		auto minDistance = std::numeric_limits<float>::infinity();
		QPoint closestPoint {0, 0};
		int closestTrackID { 0 };
		auto allChildren = trackedTrajectoryModel->getChildNodes();

		for (const auto &childNode : allChildren)
		{
			// Top level nodes are likely trajectories.
			const auto childTrajectory = dynamic_cast<IModelTrackedTrajectory *> (childNode);
			// Not a trajectory? Don't know how to handle.
			if (childTrajectory == nullptr)
				continue;
			
			for (size_t i = 0; i < childTrajectory->size(); ++i)
			{
				if (i != model->getCurrentFrame())
					continue;
				const auto &childComponent = childTrajectory->getChild(i);
				const auto point = dynamic_cast<IModelComponentEuclidian2D*> (childComponent);
				if (point == nullptr)
					continue;
				float distance = std::sqrt(std::pow(point->getXpx() - originalPoint.x(), 2) + std::pow(point->getYpx() - originalPoint.y(), 2));
				if (distance < minDistance)
				{
					minDistance = distance;
					closestPoint = QPoint(static_cast<int>(point->getXpx()), static_cast<int>(point->getYpx()));
					closestTrackID = childTrajectory->getId();
				}
			}
		}

		if (minDistance < 100.0f)
		{
			return Annotations::TrackedPoint(closestPoint, closestTrackID);
		}
	}
	return Annotations::TrackedPoint(originalPoint);
}
示例#28
0
		// ---|> NodeVisitor
		NodeVisitor::status leave(Node * node) override {
			if (node->getWorldBB().getExtentMax() <= 0.0f) // there are boxes with zero-extension (e.g. looseOctree/octree)
				return CONTINUE_TRAVERSAL;
			if (processed) {
				processed = false;
				return CONTINUE_TRAVERSAL;
			}

			deque<Node*> children;
			bool drawgeometry = fulfillsProcessingConditions(node, maxNodeCount, maxTriangleCount );
			if (!node->isClosed() && !drawgeometry) {
				const auto newChildren = getChildNodes(node);
				children.insert(children.end(), newChildren.begin(), newChildren.end());
			}
			ccpro.processColorCube(rc, node, children);
			return CONTINUE_TRAVERSAL;
		}
示例#29
0
Node *Node::nextTraversal() 
{
	Node *nextNode = getChildNodes();
	if (nextNode != NULL)
		return nextNode;
	nextNode = next();
	if (nextNode == NULL) {
		Node *parentNode = getParentNode();
		while (parentNode != NULL) { 
			Node *parentNextNode = parentNode->next();
			if (parentNextNode != NULL)
				return parentNextNode;
			parentNode = parentNode->getParentNode();
		}
	}
	return nextNode;
}
示例#30
0
static void willRemoveChildren(ContainerNode* container)
{
    NodeVector children;
    getChildNodes(container, children);

    container->document()->nodeChildrenWillBeRemoved(container);

    ChildListMutationScope mutation(container);
    for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) {
        Node* child = it->get();
        mutation.willRemoveChild(child);
        child->notifyMutationObserversNodeWillDetach();

        // fire removed from document mutation events.
        dispatchChildRemovalEvents(child);
    }

    ChildFrameDisconnector(container).disconnect(ChildFrameDisconnector::DescendantsOnly);
}