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())));
    }
}
void SceneGraphTreeModel::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & InternalRootFieldMask)
    {
        produceTreeStructureChanged(createPath(getRootNode()),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, boost::any(getRootNode())));
    }
}
void ComponentTreeModel::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & InternalRootComponentFieldMask)
    {
        produceTreeStructureChanged(getPath(getInternalRootComponent()),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, boost::any(getInternalRootComponent())));
    }
}
void SceneTreeModel::setRoot(Scene* const root)
{
    dettachChangedFunctors();
    _ViewportFieldsChangedContainer = root->getPrimaryViewport();
    _SceneFieldsChangedContainer = root;
    attachChangedFunctors();

    setInternalRoot(root);
    std::vector<UInt32> ChildIndices;
    std::vector<boost::any> Children;
    produceTreeStructureChanged(getRootPath(), ChildIndices, Children);
}
void ComponentTreeModel::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    //Do not respond to changes that have a Sync origin
    if(origin & ChangedOrigin::Sync)
    {
        return;
    }

    if(whichField & InternalRootComponentFieldMask)
    {
        produceTreeStructureChanged(getRootPath(),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, getRoot()));
    }
}
void FieldContainerTreeModel::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & (InternalRootFieldContainerFieldMask |
                     ShowInternalFieldsFieldMask |
                     ShowMultiFieldsFieldMask |
                     ShowSingleFieldsFieldMask |
                     ShowPtrFieldsFieldMask |
                     ShowDataFieldsFieldMask |
                     ShowParentPtrFieldsFieldMask |
                     ShowChildPtrFieldsFieldMask |
                     ShowAttachmentsFieldMask |
                     ShowCallbackFunctorsFieldMask)
        )
    {
        produceTreeStructureChanged(getRootPath(),std::vector<UInt32>(1, 0),std::vector<boost::any>(1, getRoot()));
    }
}
void SceneGraphTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue)
{
    try
    {
        NodeUnrecPtr NewNode = boost::any_cast<NodeUnrecPtr>(newValue);
        NodeUnrecPtr OldNode = boost::any_cast<NodeUnrecPtr>(path.getLastPathComponent());
        if(NewNode != NULL &&
           OldNode  != NULL &&
           NewNode != OldNode &&
           OldNode->getParent() != NULL)
        {
            NodeUnrecPtr ParentNode(OldNode->getParent());
            if(ParentNode->replaceChildBy(OldNode, NewNode))
            {
                UInt32 ChildIndex(ParentNode->findChild(NewNode));
                produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue));
            }
        }
    }
    catch(boost::bad_any_cast &ex)
    {
        SWARNING << "Bad any cast: " << ex.what() << std::endl;
    }
}
void ComponentTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue)
{
    try
    {
        ComponentWeakPtr NewComponent = boost::any_cast<ComponentWeakPtr>(newValue);
        ComponentWeakPtr OldComponent = boost::any_cast<ComponentWeakPtr>(path.getLastPathComponent());
        if(NewComponent != NULL &&
           OldComponent  != NULL &&
           NewComponent != OldComponent &&
           OldComponent->getParentContainer() != NULL)
        {
            ComponentContainerRefPtr ParentContainer(OldComponent->getParentContainer());
            Int32 ChildIndex(ParentContainer->getChildIndex(OldComponent));
            if(ChildIndex >= 0)
            {
                (*ParentContainer->editMFChildren())[ChildIndex] = NewComponent;
                produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue));
            }
        }
    }
    catch(boost::bad_any_cast &)
    {
    }
}