Beispiel #1
0
bool PanelCreator::SaveToXML( GuiObjectCPtr _spObject, CFoundation::XMLDocumentPtr _spDoc, CFoundation::XMLElementPtr _spXMLElement ) const
{
	GuiObjectCreator::SaveToXML( _spObject, _spDoc, _spXMLElement );

	PanelCPtr spPanel = static_pointer_cast< const Panel >( _spObject );

	// save children
	ChildIterator clIterator = spPanel->GetChildIterator();
	GuiObjectPtr pChild = clIterator.GetFirst();
	while( !clIterator.IsDone() )
	{
		// Create new XML node
		CFoundation::XMLElementPtr spChildXMLElement = _spDoc->CreateElement( pChild->GetTypeId() );

		// Add as child
		_spXMLElement->InsertChildLast( spChildXMLElement );

        // Save child
		GuiMain::GetInstance().SaveToXML( pChild, _spDoc, spChildXMLElement );

		pChild = clIterator.GetNext();
	}

    return true;
}
    OverlayElement* OverlayContainer::findElementAt(Real x, Real y)         // relative to parent
    {

        OverlayElement* ret = NULL;

        int currZ = -1;

        if (mVisible)
        {
            ret = OverlayElement::findElementAt(x,y);   //default to the current container if no others are found
            if (ret && mChildrenProcessEvents)
            {
                ChildIterator it = getChildIterator();
                while (it.hasMoreElements())
                {
                    OverlayElement* currentOverlayElement = it.getNext();
                    if (currentOverlayElement->isVisible() && currentOverlayElement->isEnabled())
                    {
                        int z = currentOverlayElement->getZOrder();
                        if (z > currZ)
                        {
                            OverlayElement* elementFound = currentOverlayElement->findElementAt(x ,y );
                            if (elementFound)
                            {
                                currZ = z;
                                ret = elementFound;
                            }
                        }
                    }
                }
            }
        }
        return ret;
    }
Beispiel #3
0
/// Get parent node (or NULL if no hierarchy or for root node)
sofa::core::objectmodel::BaseNode::Children Node::getChildren() const
{
    Children list_children;
    list_children.reserve(child.size());
    for (ChildIterator it = child.begin(), itend = child.end(); it != itend; ++it)
        list_children.push_back(it->get());
    return list_children;
}
Beispiel #4
0
void SymbolNode::removeChild(const SymbolInfo &inf)
{
	ChildIterator pChild = m_childList.find(inf);
	if (pChild != m_childList.end())
	{
		pChild.value()->m_parent = WeakPtr();
		m_childList.remove(inf);
	}
}
    //---------------------------------------------------------------------
    void OverlayContainer::_positionsOutOfDate(void)
    {
        OverlayElement::_positionsOutOfDate();

        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            it.getNext()->_positionsOutOfDate();
        }
    }
    //---------------------------------------------------------------------
    void OverlayContainer::_notifyWorldTransforms(const Matrix4& xform)
    {
        OverlayElement::_notifyWorldTransforms(xform);

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            it.getNext()->_notifyWorldTransforms(xform);
        }
    }
Beispiel #7
0
/// Find a child node given its name
Node* Node::getChild(const std::string& name) const
{
//    cerr<<"Node::getChild, in "<< getName() << ", looking for " << name << endl;
    for (ChildIterator it = child.begin(), itend = child.end(); it != itend; ++it)
    {
//        cerr<<"Node::getChild, see " << (*it)->getName() << endl;
        if ((*it)->getName() == name)
            return it->get();
    }
    return NULL;
}
    //---------------------------------------------------------------------
    void OverlayContainer::_notifyViewport()
    {
        OverlayElement::_notifyViewport();

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            it.getNext()->_notifyViewport();
        }
    }
Beispiel #9
0
    void recursivelyMarkIf(Node* start, const NodeConditional& nc) {
        if (nc(&*start)) {
            start->mark |= MARK_KEEP | MARK_KEEP_KIDS;

            for (ChildIterator ci = childBegin(start); !ci.done(); ++ci) {
                recursivelyMarkIf(&*ci, nc);
            }
        } else {
            start->mark |= MARK_KEEP;
        }
    }
Beispiel #10
0
    //---------------------------------------------------------------------
    void OverlayContainer::_update(void)
    {
        // call superclass
        OverlayElement::_update();

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            it.getNext()->_update();
        }
    }
    //---------------------------------------------------------------------
    void OverlayContainer::_notifyZOrder(ushort newZOrder)
    {
        OverlayElement::_notifyZOrder(newZOrder);

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            // Give children ZOrder 1 higher than this
            it.getNext()->_notifyZOrder(newZOrder + 1);
        }
    }
Beispiel #12
0
    //---------------------------------------------------------------------
    void OverlayContainer::_notifyParent(OverlayContainer* parent, Overlay* overlay)
    {
        OverlayElement::_notifyParent(parent, overlay);

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            // Notify the children of the overlay 
            it.getNext()->_notifyParent(this, overlay);
        }
    }
Beispiel #13
0
int ProtoNode::childrenCount() const
{
    if (!node_) return 0;

    int row_count = 0;
    ChildIterator kids = children();
    while ( kids.element().isValid() )
    {
        row_count++;
        kids.next();
    }

    return row_count;
}
Beispiel #14
0
    //---------------------------------------------------------------------
    ushort OverlayContainer::_notifyZOrder(ushort newZOrder)
    {
        OverlayElement::_notifyZOrder(newZOrder);
        // One for us
        newZOrder++; 

        // Update children
        ChildIterator it = getChildIterator();
        while (it.hasMoreElements())
        {
            // Children "consume" Z-order values, so keep track of them
            newZOrder = it.getNext()->_notifyZOrder(newZOrder);
        }

        return newZOrder;
    }
Beispiel #15
0
    //---------------------------------------------------------------------
    void OverlayContainer::_updateRenderQueue(RenderQueue* queue)
    {
        if (mVisible)
        {

            OverlayElement::_updateRenderQueue(queue);

            // Also add children
            ChildIterator it = getChildIterator();
            while (it.hasMoreElements())
            {
                // Give children Z-order 1 higher than this
                it.getNext()->_updateRenderQueue(queue);
            }
        }

    }
/** Overridden from OverlayContainer */
void cCompassOverlay::_updateRenderQueue(RenderQueue* queue) {
	if (mVisible)
	{

		if (!mTransparent && !mpMaterial.isNull())
		{
			OverlayElement::_updateRenderQueue(queue);
		}

		// Also add children
		ChildIterator it = getChildIterator();
		while (it.hasMoreElements())
		{
			// Give children ZOrder 1 higher than this
			it.getNext()->_updateRenderQueue(queue);
		}
	}
}
Beispiel #17
0
    OverlayElement* OverlayContainer::clone(const String& instanceName)
    {
        OverlayContainer *newContainer;

        newContainer = static_cast<OverlayContainer*>(OverlayElement::clone(instanceName));

          ChildIterator it = getChildIterator();
          while (it.hasMoreElements())
              {
                    OverlayElement* oldChildElement = it.getNext();
                    if (oldChildElement->isCloneable())
                    {
                OverlayElement* newChildElement = oldChildElement->clone(instanceName);
                newContainer->_addChild(newChildElement);
            }
        }

        return newContainer;
    }
Beispiel #18
0
    /*!
        Destroys children of nodes that are not marked,
        defragments the node array
        always keeps the root

        Note: invalidates all pointers to nodes of the tree, and all
              iterators.
    */
    void eraseChildrenOfUnmarkedNodes() {
        unsigned int write = 0;

        nodes[root_index].mark = MARK_KEEP;

        assert(root_index < allocation_index);

        for (unsigned int read = root_index; read != allocation_index; read++) {
               Node *node = &nodes[read];
            char mark = node->mark;

            if (mark) {
                // TODO: could handle read == write as a special case
                Node *write_node  = &nodes[write];
                *write_node = *node; // copy
                write_node->mark = 0; // clear mark

                if (mark & MARK_KEEP_KIDS) {
                    // adjust children's parent pointers
                    for (ChildIterator it = childBegin(write_node); !it.done(); ++it) {
                        it->parent = write;
                    }
                } else {
                    write_node->num_children = 0;
                }

                // adjust parent's first_child "pointer" if this is its first child
                if (read != root_index) {
                    Node* parent_node = getParent(node);
                    if (write < parent_node->first_child) {
                        parent_node->first_child = write;
                    }
                 }


                   write++;
            }
        }
        root_index = 0;
        nodes[root_index].parent = 0;
        allocation_index = write;
    }
Beispiel #19
0
void Box::exportForReference( const std::string &fileName ) const
{
	const ScriptNode *script = scriptNode();
	if( !script )
	{
		throw IECore::Exception( "Box::exportForReference called without ScriptNode" );
	}

	// we only want to save out our child nodes and plugs that are visible in the UI, so we build a filter
	// to specify just the things to export.

	boost::regex invisiblePlug( "^__.*$" );
	StandardSetPtr toExport = new StandardSet;
	for( ChildIterator it = children().begin(), eIt = children().end(); it != eIt; ++it )
	{
		if( (*it)->isInstanceOf( Node::staticTypeId() ) )
		{
			toExport->add( *it );
		}
		else if( const Plug *plug = IECore::runTimeCast<Plug>( it->get() ) )
		{
			if( !boost::regex_match( plug->getName().c_str(), invisiblePlug ) )
			{
				toExport->add( *it );
			}
		}
	}

	ContextPtr context = new Context;
	context->set( "valuePlugSerialiser:resetParentPlugDefaults", true );
	context->set( "serialiser:includeParentMetadata", true );
	context->set( "serialiser:includeVersionMetadata", true );
	Context::Scope scopedContext( context.get() );

	script->serialiseToFile( fileName, this, toExport.get() );
}