Merge pull request #13644 from wwmayer/default_material
Gui: expose ViewProviderGeometryObject::getUserDefinedMaterial() to Python
This commit is contained in:
@@ -39,16 +39,15 @@ using namespace App;
|
||||
Material::Material()
|
||||
: shininess {0.9000F}
|
||||
, transparency {}
|
||||
, _matType {USER_DEFINED}
|
||||
, _matType {}
|
||||
{
|
||||
setType(STEEL);
|
||||
setType(USER_DEFINED);
|
||||
setType(DEFAULT);
|
||||
}
|
||||
|
||||
Material::Material(const char* MatName)
|
||||
: shininess {0.9000F}
|
||||
, transparency {}
|
||||
, _matType {USER_DEFINED}
|
||||
, _matType {}
|
||||
{
|
||||
set(MatName);
|
||||
}
|
||||
@@ -56,7 +55,7 @@ Material::Material(const char* MatName)
|
||||
Material::Material(MaterialType MatType)
|
||||
: shininess {0.9000F}
|
||||
, transparency {}
|
||||
, _matType {USER_DEFINED}
|
||||
, _matType {}
|
||||
{
|
||||
setType(MatType);
|
||||
}
|
||||
|
||||
@@ -2632,7 +2632,10 @@ TYPESYSTEM_SOURCE(App::PropertyMaterialList, App::PropertyLists)
|
||||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
|
||||
PropertyMaterialList::PropertyMaterialList() = default;
|
||||
PropertyMaterialList::PropertyMaterialList()
|
||||
{
|
||||
setSizeOne();
|
||||
}
|
||||
|
||||
PropertyMaterialList::~PropertyMaterialList() = default;
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
#include "ViewProviderFeature.h"
|
||||
#include "ViewProviderGeoFeatureGroup.h"
|
||||
#include "ViewProviderGeometryObject.h"
|
||||
#include "ViewProviderGeometryObjectPy.h"
|
||||
#include "ViewProviderGroupExtension.h"
|
||||
#include "ViewProviderSuppressibleExtension.h"
|
||||
#include "ViewProviderImagePlane.h"
|
||||
@@ -469,6 +470,8 @@ Application::Application(bool GUIenabled)
|
||||
Base::Interpreter().addType(&ViewProviderPy::Type, module, "ViewProvider");
|
||||
Base::Interpreter().addType(
|
||||
&ViewProviderDocumentObjectPy::Type, module, "ViewProviderDocumentObject");
|
||||
Base::Interpreter().addType(
|
||||
&ViewProviderGeometryObjectPy::Type, module, "ViewProviderGeometryObject");
|
||||
Base::Interpreter().addType(&ViewProviderLinkPy::Type, module, "ViewProviderLink");
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ const App::PropertyIntegerConstraint::Constraints intPercent = {0, 100, 5};
|
||||
|
||||
ViewProviderGeometryObject::ViewProviderGeometryObject()
|
||||
{
|
||||
App::Material mat = getDefaultMaterial();
|
||||
App::Material mat = getUserDefinedMaterial();
|
||||
long initialTransparency = toPercent(mat.transparency);
|
||||
|
||||
static const char* dogroup = "Display Options";
|
||||
@@ -115,7 +115,7 @@ ViewProviderGeometryObject::~ViewProviderGeometryObject()
|
||||
pcBoundColor->unref();
|
||||
}
|
||||
|
||||
App::Material ViewProviderGeometryObject::getDefaultMaterial() const
|
||||
App::Material ViewProviderGeometryObject::getUserDefinedMaterial()
|
||||
{
|
||||
ParameterGrp::handle hGrp =
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
@@ -96,6 +96,7 @@ public:
|
||||
|
||||
/// Get the python wrapper for that ViewProvider
|
||||
PyObject* getPyObject() override;
|
||||
static App::Material getUserDefinedMaterial();
|
||||
|
||||
protected:
|
||||
/// get called by the container whenever a property has been changed
|
||||
@@ -110,7 +111,6 @@ protected:
|
||||
|
||||
private:
|
||||
void setSoMaterial(const App::Material& source);
|
||||
App::Material getDefaultMaterial() const;
|
||||
bool isSelectionEnabled() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,5 +13,13 @@
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>This is the ViewProvider geometry class</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="getUserDefinedMaterial" Static="true" NoArgs="true">
|
||||
<Documentation>
|
||||
<UserDocu>getUserDefinedMaterial() -> object
|
||||
|
||||
Get a material object with the user-defined colors.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include <App/GeoFeature.h>
|
||||
#include <App/MaterialPy.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
|
||||
#include "ViewProviderGeometryObjectPy.h"
|
||||
@@ -68,6 +69,12 @@ PyObject* ViewProviderGeometryObjectPy::getCustomAttributes(const char* attr) co
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderGeometryObjectPy::getUserDefinedMaterial()
|
||||
{
|
||||
App::Material mat = ViewProviderGeometryObject::getUserDefinedMaterial();
|
||||
return new App::MaterialPy(new App::Material(mat));
|
||||
}
|
||||
|
||||
int ViewProviderGeometryObjectPy::setCustomAttributes(const char* attr, PyObject* obj)
|
||||
{
|
||||
ViewProviderGeometryObject* vp = getViewProviderGeometryObjectPtr();
|
||||
|
||||
Reference in New Issue
Block a user