Code Search for Developers
 
 
  

CValueModel.h from osgDesigner at Krugle


Show CValueModel.h syntax highlighted

#ifndef __CVALUEMODEL_H__
#define __CVALUEMODEL_H__ 1


#include <osgIntrospectionToolKit/signalslib.hpp>

#include <QtCore/QAbstractItemModel>
#include <QtCore/QMimeData>

#include <osg/Node>
#include <osgDesigner/core/ITreeModel.h>
#include <osgIntrospectionToolKit/CValueTree.h>


class osgIntrospectionToolKit::CReflectedRefPointer;

namespace osgDesigner
{
    class CValueModel : public ITreeModel< osgIntrospectionToolKit::CValueTree >
    {
        public:
            Q_OBJECT
        
        public:
            typedef ITreeModel<osgIntrospectionToolKit::CValueTree>                             Base;
            typedef Base::Tree                                              Tree;
            typedef Base::descriptor                                        descriptor;
        
            enum Column
            { 
                e_TypeColumn = 0,
                e_NameColumn = 1,
                e_ValueColumn = 2,
                e_NbColumn = 3
            };
        
        public:
        	CValueModel(osgIntrospectionToolKit::CValueTree* valueTree);
        	virtual ~CValueModel();
            
            
            // ** Qt4 Interface
            virtual QVariant                            data(const QModelIndex& index, int role = Qt::DisplayRole ) const;
            virtual bool                                setData(const QModelIndex & index, const QVariant& value, int role = Qt::EditRole);
            virtual QVariant                            headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
        //  virtual bool                                setHeaderData( int section, Qt::Orientation orientation, const QVariant& value, int role = Qt::EditRole);
    
            virtual int                                 columnCount(const QModelIndex & ) const
            { return (e_NbColumn); }








            // ** osgIntrospectionToolKit interface
            void                                        resetModel();
//            void                                        setToModel(osg::Referenced* refPtr, std::string name);
            void                                        setToModel(osgIntrospection::Value & val);
           

            const std::string&                          name();
            QModelIndex                                 valueTreeIndexToQModelIndex(descriptor vd);

            const osgIntrospectionToolKit::CReflectedRefPointer*            getReflectedRefPointer(const QModelIndex& index) const; 
            osgIntrospectionToolKit::CReflectedRefPointer*                  getReflectedRefPointer(const QModelIndex& index); 
            osg::Node*                                  getRootNode(size_t idx);
            
            
            // ** Manipulator ** //
            bool                                        setValue(const QModelIndex& index, osgIntrospection::Value& newValue);
            bool                                        addArrayValue(const QModelIndex& index, const osgIntrospection::PropertyInfo& pi, osgIntrospection::Value& newValue);
            bool                                        addIndexedValue(const QModelIndex& index, const osgIntrospection::PropertyInfo& pi, osgIntrospection::ValueList& indexValueList, osgIntrospection::Value& newValue);
            bool                                        removeValue(const QModelIndex& index);
            
            // ** Accessor ** //
            bool                                        canSetValue(const QModelIndex& index) const;
            bool                                        canAddValue(const QModelIndex& index) const;
            bool                                        canRemoveValue(const QModelIndex& index) const;
            bool                                        isSimple(const QModelIndex& index) const;
            bool                                        isArray(const QModelIndex& index) const;
            bool                                        isIndexed(const QModelIndex& index) const;
            bool                                        isRefPointer(const QModelIndex& index) const;
            
            void                                        getTypeName(const QModelIndex& index, std::string& typeName) const;
            void                                        getInstanceTypeName(const QModelIndex& index, std::string& typeName) const;
            void                                        getPointedTypeName(const QModelIndex& index, std::string& typeName) const;
            
            const osgIntrospection::Type*               getType(const QModelIndex& index) const;
            const osgIntrospection::Type*               getInstanceType(const QModelIndex& index) const;
            const osgIntrospection::Type*               getPointedType(const QModelIndex& index) const;
            

            std::size_t                                 getSimplePropertyInfoList(const QModelIndex& index, osgIntrospection::PropertyInfoList& pil) const;
            std::size_t                                 getArrayPropertyInfoList(const QModelIndex& index, osgIntrospection::PropertyInfoList& pil) const;
            std::size_t                                 getIndexedPropertyInfoList(const QModelIndex& index, osgIntrospection::PropertyInfoList& pil) const;
            
            std::size_t                                 getSimplePropertyNameList(const QModelIndex& index, osgIntrospectionToolKit::NameList& nameList) const;
            std::size_t                                 getArrayPropertyNameList(const QModelIndex& index, osgIntrospectionToolKit::NameList& nameList) const;
            std::size_t                                 getIndexedPropertyNameList(const QModelIndex& index, osgIntrospectionToolKit::NameList& nameList) const;
            
            
            
            
            void                                        beginAddSlot(descriptor vd, int first, int last);
            void                                        endAddSlot(descriptor vd, int first, int last);
            void                                        beginRemoveSlot(descriptor vd, int first, int last);
            void                                        endRemoveSlot(descriptor vd, int first, int last);
            void                                        updateSlot(descriptor vd, int first, int last);
            void                                        resetSlot();


        protected :
            void                                        _connectSlot();
            void                                        _disconnectSlot();
    };
    
    inline void                                 CValueModel::setToModel(osgIntrospection::Value & val)
    {
        _tree->clearTree();
        
        _tree->add(val);
    }
    
    inline const std::string&                   CValueModel::name()
    { 
        return (_tree->name()); 
    }
    
    inline QModelIndex                          CValueModel::valueTreeIndexToQModelIndex(descriptor vd)
    { 
        if (vd == _tree->root())
            return(QModelIndex());
        else
            return (createIndex(_tree->find_child(_tree->parent(vd), vd), 0, vd)); 
    }

    inline bool                                 CValueModel::canSetValue(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->canSet(getIndexInfo(index))) : (false));
    }
    inline bool                                 CValueModel::canAddValue(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->canAdd(getIndexInfo(index))) : (false));
    }
    inline bool                                 CValueModel::canRemoveValue(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->canRemove(getIndexInfo(index))) : (false));
    }
    
    inline bool                                 CValueModel::isSimple(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->isSimple(getIndexInfo(index))) : (false));
    }
    inline bool                                 CValueModel::isArray(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->isArray(getIndexInfo(index))) : (false));
    }
    inline bool                                 CValueModel::isIndexed(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->isIndexed(getIndexInfo(index))) : (false));
    }
    
    inline bool                                 CValueModel::isRefPointer(const QModelIndex& index) const
    {
        return ((index.isValid()) ? (_tree->isRefPointer(getIndexInfo(index))) : (false));
    }
}
#endif // ** __CVALUEMODEL_H__ ** //




See more files for this project here

osgDesigner

osgDesigner is a graphical tool used to modify an OpenSceneGraph (OSG) scene using the osgIntrospection framework. OpenSceneGraph developpers will be able to extend osgDesigner at need using (editor | render | osgIntrospection wrapper) plugin system.

Project homepage: http://sourceforge.net/projects/osgdesigner
Programming language(s): C++,Shell Script
License: other

  CConfig.h
  CFileMenu.h
  CMainWindow.h
  CPropertiesModel.h
  CPropertiesView.h
  CPropertiesWidget.h
  CPropertyInfoModel.h
  CSceneGraphEditMenu.h
  CSceneGraphModel.h
  CSceneGraphView.h
  CSceneGraphWidget.h
  CTypeModel.h
  CTypeWidget.h
  CValueMimeData.h
  CValueModel.h
  CValueView.h
  Export.h
  FlagsConstructorDialog.h
  FlowLayout.h
  IEditorWidgetABC.h
  IListModel.h
  ITreeModel.h
  MACRO.h
  PluginManagerDialog.h
  SConfigManager.h
  SWorkSpace.h