0000535: request for python editible Properties panels
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5271 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
bde949f7e4
commit
3a4bb6ec4f
|
@ -103,6 +103,16 @@ short PropertyContainer::getPropertyType(const char *name) const
|
||||||
return getPropertyData().getType(this,name);
|
return getPropertyData().getType(this,name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyContainer::setPropertyType(const Property* prop, short attr)
|
||||||
|
{
|
||||||
|
getPropertyData().setType(this,prop,attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyContainer::setPropertyType(const char *name, short attr)
|
||||||
|
{
|
||||||
|
getPropertyData().setType(this,name,attr);
|
||||||
|
}
|
||||||
|
|
||||||
const char* PropertyContainer::getPropertyGroup(const Property* prop) const
|
const char* PropertyContainer::getPropertyGroup(const Property* prop) const
|
||||||
{
|
{
|
||||||
return getPropertyData().getGroup(this,prop);
|
return getPropertyData().getGroup(this,prop);
|
||||||
|
@ -359,6 +369,22 @@ short PropertyData::getType(const PropertyContainer *container,const char* name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyData::setType(const PropertyContainer *container,const Property* prop, short attr) const
|
||||||
|
{
|
||||||
|
const PropertyData::PropertySpec* Spec = findProperty(container,prop);
|
||||||
|
|
||||||
|
if (Spec)
|
||||||
|
const_cast< PropertyData::PropertySpec*>(Spec)->Type = attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyData::setType(const PropertyContainer *container,const char* name, short attr) const
|
||||||
|
{
|
||||||
|
const PropertyData::PropertySpec* Spec = findProperty(container,name);
|
||||||
|
|
||||||
|
if (Spec)
|
||||||
|
const_cast< PropertyData::PropertySpec*>(Spec)->Type = attr;
|
||||||
|
}
|
||||||
|
|
||||||
const char* PropertyData::getGroup(const PropertyContainer *container,const Property* prop) const
|
const char* PropertyData::getGroup(const PropertyContainer *container,const Property* prop) const
|
||||||
{
|
{
|
||||||
const PropertyData::PropertySpec* Spec = findProperty(container,prop);
|
const PropertyData::PropertySpec* Spec = findProperty(container,prop);
|
||||||
|
|
|
@ -70,6 +70,8 @@ struct AppExport PropertyData
|
||||||
short getType (const PropertyContainer *container,const char* name) const;
|
short getType (const PropertyContainer *container,const char* name) const;
|
||||||
const char* getGroup (const PropertyContainer *container,const char* name) const;
|
const char* getGroup (const PropertyContainer *container,const char* name) const;
|
||||||
const char* getGroup (const PropertyContainer *container,const Property* prop) const;
|
const char* getGroup (const PropertyContainer *container,const Property* prop) const;
|
||||||
|
void setType (const PropertyContainer *container,const Property* prop, short) const;
|
||||||
|
void setType (const PropertyContainer *container,const char* name, short) const;
|
||||||
const char* getDocumentation(const PropertyContainer *container,const char* name) const;
|
const char* getDocumentation(const PropertyContainer *container,const char* name) const;
|
||||||
const char* getDocumentation(const PropertyContainer *container,const Property* prop) const;
|
const char* getDocumentation(const PropertyContainer *container,const Property* prop) const;
|
||||||
|
|
||||||
|
@ -116,6 +118,10 @@ public:
|
||||||
virtual short getPropertyType(const Property* prop) const;
|
virtual short getPropertyType(const Property* prop) const;
|
||||||
/// get the Type of a named Property
|
/// get the Type of a named Property
|
||||||
virtual short getPropertyType(const char *name) const;
|
virtual short getPropertyType(const char *name) const;
|
||||||
|
/// set the Type of a Property
|
||||||
|
virtual void setPropertyType(const Property* prop, short);
|
||||||
|
/// set the Type of a named Property
|
||||||
|
virtual void setPropertyType(const char *name, short);
|
||||||
/// get the Group of a Property
|
/// get the Group of a Property
|
||||||
virtual const char* getPropertyGroup(const Property* prop) const;
|
virtual const char* getPropertyGroup(const Property* prop) const;
|
||||||
/// get the Group of a named Property
|
/// get the Group of a named Property
|
||||||
|
@ -218,7 +224,7 @@ void _class_::init(void){\
|
||||||
initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
|
initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
|
||||||
_class_::propertyData.parentPropertyData = _parentclass_::getPropertyDataPtr();\
|
_class_::propertyData.parentPropertyData = _parentclass_::getPropertyDataPtr();\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TYPESYSTEM_SOURCE_TEMPLATE(_class_) \
|
#define TYPESYSTEM_SOURCE_TEMPLATE(_class_) \
|
||||||
template<> Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
|
template<> Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
|
||||||
template<> Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
|
template<> Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
|
||||||
|
@ -226,7 +232,7 @@ template<> Base::Type _class_::classTypeId = Base::Type::badType(); \
|
||||||
template<> void * _class_::create(void){\
|
template<> void * _class_::create(void){\
|
||||||
return new _class_ ();\
|
return new _class_ ();\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROPERTY_SOURCE_TEMPLATE(_class_, _parentclass_) \
|
#define PROPERTY_SOURCE_TEMPLATE(_class_, _parentclass_) \
|
||||||
TYPESYSTEM_SOURCE_TEMPLATE(_class_);\
|
TYPESYSTEM_SOURCE_TEMPLATE(_class_);\
|
||||||
template<> const App::PropertyData * _class_::getPropertyDataPtr(void){return &propertyData;} \
|
template<> const App::PropertyData * _class_::getPropertyDataPtr(void){return &propertyData;} \
|
||||||
|
|
|
@ -23,7 +23,12 @@
|
||||||
<UserDocu>Return the type of a named property. This can be (Hidden,ReadOnly,Output) or any combination. </UserDocu>
|
<UserDocu>Return the type of a named property. This can be (Hidden,ReadOnly,Output) or any combination. </UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
<Methode Name="getGroupOfProperty">
|
<Methode Name="setTypeOfProperty">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>Set the type of a named property. This can be (Hidden,ReadOnly,Output) or any combination. </UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
</Methode>
|
||||||
|
<Methode Name="getGroupOfProperty">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>Return the name of the group which the property belongs to in this class. The properties sorted in differnt named groups for convenience.</UserDocu>
|
<UserDocu>Return the name of the group which the property belongs to in this class. The properties sorted in differnt named groups for convenience.</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
|
@ -41,4 +46,4 @@
|
||||||
</Attribute>
|
</Attribute>
|
||||||
<CustomAttributes />
|
<CustomAttributes />
|
||||||
</PythonExport>
|
</PythonExport>
|
||||||
</GenerateModel>
|
</GenerateModel>
|
||||||
|
|
|
@ -78,6 +78,17 @@ PyObject* PropertyContainerPy::getTypeOfProperty(PyObject *args)
|
||||||
return Py::new_reference_to(ret);
|
return Py::new_reference_to(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* PropertyContainerPy::setTypeOfProperty(PyObject *args)
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
short type;
|
||||||
|
if (!PyArg_ParseTuple(args, "sh", &name, &type)) // convert args: Python->C
|
||||||
|
return NULL; // NULL triggers exception
|
||||||
|
|
||||||
|
getPropertyContainerPtr()->setPropertyType(name, type);
|
||||||
|
Py_Return;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args)
|
PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args)
|
||||||
{
|
{
|
||||||
char *pstr;
|
char *pstr;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user