Exemplo n.º 1
0
UInt32 SceneTreeModel::getChildCount(const boost::any& parent) const
{
    if(parent.type() == typeid(Scene* const))
    {
        return SceneComponentsLast;
    }
    else if(parent.type() == typeid(UInt32))
    {
        UInt32 Value(boost::any_cast<UInt32>(parent));
        switch(Value)
        {
        case BasicComponent:              //Basic
        case BackgroundComponent:              //Background
        case CameraComponent:              //Camera
            return 0;
            break;
        case ForegroundsComponent:              //Foregrounds
            return getInternalRoot()->getPrimaryViewport()->getMFForegrounds()->size();
            break;
        case SceneObjectsComponent:              //Models
            return getInternalRoot()->getMFSceneObjects()->size();
            break;
        case LightsComponent:              //Lights
            {
                NodeRecPtr LightNode(getInternalRoot()->getPrimaryViewport()->getRoot());
                UInt32 NumLights(0);

                while(LightNode->getNChildren() > 0 &&
                      LightNode->getChild(0)->getCore()->getType().isDerivedFrom(Light::getClassType()))
                {
                    LightNode = LightNode->getChild(0);

                    ++NumLights;
                }
                return NumLights;
            }
            break;
        case DynamicsComponent:              //Dynamics
            return DynamicsComponentsLast - DynamicsComponentsFirst;
            break;
        case ScriptsComponent:              //Scripts
            return 0;
            break;
        case BehavioursComponent:              //Behaviours
            return 0;
            break;
        case AnimationsComponent:              //Animations
            return 0;
            break;
        }
    }
    else
    {
        return 0;
    }
}
boost::any DefaultTreeModel::getRoot(void) const
{
    if(getInternalRoot() != NULL)
    {
        return boost::any(ModelTreeNodeRefPtr(getInternalRoot()));
    }
    else
    {
        return boost::any();
    }
}
Exemplo n.º 3
0
boost::any LuaGraphTreeModel::getRoot(void) const
{
    if(boost::filesystem::exists(getInternalRoot()))
    {
        return boost::any(getInternalRoot());
    }
    else
    {
        SWARNING << "Root doesn't exist." << std::endl;
        return boost::any(getInternalRoot());
        //return boost::any();
    }
}
boost::any GenericMissionTreeModel::getParent(const boost::any& node) const
{
    //try
    //{
        //NodePtr TheNode = boost::any_cast<NodePtr>(node);
        //if(TheNode != NullFC &&
            //TheNode != getInternalRoot() &&
            //TheNode->getParent() != NullFC)
        //{
            //return boost::any(TheNode->getParent());
        //}
    //}
    //catch(boost::bad_any_cast &)
    //{
    //}

	if(boost::any_cast<MissionPtr>(node) != NullFC && 
		boost::any_cast<MissionPtr>(node) != boost::any_cast<MissionPtr>(getInternalRoot()) &&
		boost::any_cast<MissionPtr>(node)->getParent() != NullFC)
	{
		return boost::any_cast<MissionPtr>(node)->getParent();
	}

    return boost::any();
}
void GenericMissionTreeModel::changed(BitVector whichField, UInt32 origin)
{
    Inherited::changed(whichField, origin);

    if(whichField & InternalRootFieldMask)
    {
        produceTreeStructureChanged(getPath(getInternalRoot()),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, boost::any(getInternalRoot())));
    }
}
Exemplo n.º 6
0
boost::any LuaGraphTreeModel::getParent(const boost::any& node) const
{
    try
    {
        BoostPath ThePath = boost::any_cast<BoostPath>(node);

        if((!ThePath.empty() ||
            ThePath == getInternalRoot() ||
            boost::filesystem::equivalent(ThePath, getInternalRoot())) &&
           (boost::filesystem::exists(ThePath) && boost::filesystem::exists(getInternalRoot())))
        {
            return boost::any(ThePath.parent_path());
        }

    }
    catch(boost::bad_any_cast &)
    {
    }
    return boost::any();
}
void DefaultTreeModel::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & InternalRootFieldMask)
    {
        nodeChanged(getInternalRoot());
    }
}
TreePath SceneGraphTreeModel::getPathForNode(NodeUnrecPtr theNode) const
{
    std::deque<boost::any> ResultPath;

    if(theNode != NULL &&
       getInternalRoot() != NULL &&
       theNode != getInternalRoot())
    {

        NodeUnrecPtr parentNode(theNode);
        while(parentNode != NULL &&
              parentNode != getInternalRoot())
        {
            ResultPath.push_front(boost::any(parentNode));
            parentNode = parentNode->getParent();
        }

        ResultPath.push_front(boost::any(getRootNode()));
    }

    return TreePath(ResultPath, TreeModelUnrecPtr(const_cast<SceneGraphTreeModel*>(this)));
}
boost::any DefaultTreeModel::getParent(const boost::any& node) const
{
    try
    {
        ModelTreeNodeRefPtr Node = boost::any_cast<ModelTreeNodeRefPtr>(node);
        if(Node != NULL &&
           Node != getInternalRoot()  &&
           Node->getParent() != NULL)
        {
            return boost::any(Node->getParent());
        }
    }
    catch(boost::bad_any_cast &)
    {
    }
    return boost::any();
}
NodeUnrecPtr SceneGraphTreeModel::getRootNode(void) const
{
    return getInternalRoot();
}
Exemplo n.º 11
0
Scene* SceneTreeModel::getRootScene(void) const
{
    return getInternalRoot();
}
MissionPtr GenericMissionTreeModel::getRootMission(void) const
{
    return getInternalRoot();
}
boost::any GenericMissionTreeModel::getRoot(void) const
{
    return boost::any(getInternalRoot());
}
Exemplo n.º 14
0
/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/
boost::any SceneTreeModel::getChild(const boost::any& parent, const UInt32& index) const
{
    if(parent.type() == typeid(Scene* const))
    {
        switch(index)
        {
        case BasicComponent:              //Basic
            return boost::any(UInt32(BasicComponent));
            break;
        case ForegroundsComponent:              //Foregrounds
            return boost::any(UInt32(ForegroundsComponent));
            break;
        case BackgroundComponent:              //Background
            return boost::any(UInt32(BackgroundComponent));
            break;
        case CameraComponent:              //Camera
            return boost::any(UInt32(CameraComponent));
            break;
        case SceneObjectsComponent:              //Models
            return boost::any(UInt32(SceneObjectsComponent));
            break;
        case LightsComponent:              //Models
            return boost::any(UInt32(LightsComponent));
            break;
        case DynamicsComponent:              //Dynamics
            return boost::any(UInt32(DynamicsComponent));
            break;
        }
    }
    else if(parent.type() == typeid(UInt32))
    {
        UInt32 Value(boost::any_cast<UInt32>(parent));
        switch(Value)
        {
        case BasicComponent:              //Basic
        case BackgroundComponent:              //Background
        case CameraComponent:              //Camera
            return boost::any();
            break;
        case ForegroundsComponent:              //Foregrounds
            if(index < getInternalRoot()->getPrimaryViewport()->getMFForegrounds()->size())
            {
                return boost::any(getInternalRoot()->getPrimaryViewport()->getForegrounds(index));
            }
            break;
        case SceneObjectsComponent:              //Models
            if(index < getInternalRoot()->getMFSceneObjects()->size())
            {
                return boost::any(getInternalRoot()->getSceneObjects(index));
            }
            break;
        case LightsComponent:              //Lights
            {
                NodeRecPtr LightNode(getInternalRoot()->getPrimaryViewport()->getRoot());

                for(UInt32 i(0) ; i<=index ; ++i)
                {
                    if(LightNode->getNChildren() > 0 &&
                        LightNode->getChild(0)->getCore()->getType().isDerivedFrom(Light::getClassType()))
                    {
                        LightNode = LightNode->getChild(0);
                    }
                }

                if(LightNode != NULL)
                {
                    return boost::any(dynamic_cast<Light*>(LightNode->getCore()));
                }
                else
                {
                    return boost::any();
                }
            }
            break;
        case DynamicsComponent:              //Dynamics
            switch(index+DynamicsComponentsFirst)
            {
            case ScriptsComponent:              //Scripts
                return boost::any(UInt32(ScriptsComponent));
                break;
            case BehavioursComponent:              //Behaviours
                return boost::any(UInt32(BehavioursComponent));
                break;
            case AnimationsComponent:              //Animations
                return boost::any(UInt32(AnimationsComponent));
                break;
            }
            break;
        }
    }
    return boost::any();
}
Exemplo n.º 15
0
const BoostPath& LuaGraphTreeModel::getRootPath(void) const
{
    return getInternalRoot();
}
Exemplo n.º 16
0
UInt32 SceneTreeModel::getIndexOfChild(const boost::any& parent, const boost::any& child) const
{
    if(parent.type() == typeid(Scene* const))
    {
        UInt32 Value(boost::any_cast<UInt32>(child));
        switch(Value)
        {
        case BasicComponent:              //Basic
            return BasicComponent;
            break;
        case ForegroundsComponent:              //Foregrounds
            return ForegroundsComponent;
            break;
        case BackgroundComponent:              //Background
            return BackgroundComponent;
            break;
        case CameraComponent:              //Camera
            return CameraComponent;
            break;
        case SceneObjectsComponent:              //Models
            return SceneObjectsComponent;
            break;
        case DynamicsComponent:              //Dynamics
            return DynamicsComponent;
            break;
        }
    }
    else if(parent.type() == typeid(UInt32))
    {
        UInt32 Value(boost::any_cast<UInt32>(parent));
        switch(Value)
        {
        case BasicComponent:              //Basic
        case BackgroundComponent:              //Background
        case CameraComponent:              //Camera
            return 0;
            break;
        case ForegroundsComponent:              //Foregrounds
            for(UInt32 i(0) ; i<getInternalRoot()->getPrimaryViewport()->getMFForegrounds()->size() ; ++i)
            {
                if(getInternalRoot()->getPrimaryViewport()->getForegrounds(i) == boost::any_cast<Foreground* const>(child))
                {
                    return i;
                }
            }
            return 0;
            break;
        case SceneObjectsComponent:              //Models
            for(UInt32 i(0) ; i<getInternalRoot()->getMFSceneObjects()->size() ; ++i)
            {
                if(getInternalRoot()->getSceneObjects(i) == boost::any_cast<SceneObject* const>(child))
                {
                    return i;
                }
            }
            break;
        case LightsComponent:              //Lights
            {
                UInt32 NumLights(getChildCount(parent));
                UInt32 FoundLights(0);

                NodeRecPtr LightNode(getInternalRoot()->getPrimaryViewport()->getRoot());
                while(FoundLights < NumLights &&
                      LightNode->getNChildren() > 0 &&
                      LightNode->getChild(0)->getCore()->getType().isDerivedFrom(Light::getClassType()))
                {
                    LightNode = LightNode->getChild(0);

                    if(LightNode ==boost::any_cast<Light* const>(child)->getParents().front() )
                    {
                        return FoundLights;
                    }

                    ++FoundLights;
                }
            }
            break;
        case DynamicsComponent:              //Dynamics
            UInt32 Value(boost::any_cast<UInt32>(child));
            switch(Value)
            {
                case ScriptsComponent:              //Scripts
                    return ScriptsComponent - DynamicsComponentsFirst;
                    break;
                case BehavioursComponent:              //Behaviours
                    return BehavioursComponent - DynamicsComponentsFirst;
                    break;
                case AnimationsComponent:              //Animations
                    return AnimationsComponent - DynamicsComponentsFirst;
                    break;
            }
        }
    }
    else
    {
        return 0;
    }
}
Exemplo n.º 17
0
ModelTreeNodeRefPtr DefaultTreeModel::getRootNode(void) const
{
    return getInternalRoot();
}