openBrain wrote: ↑Thu Jul 15, 2021 10:45 am
I didn't actually tried but are you sure 'Type' is a public member variable ?
In this case, yes. Actually, it's for a Part. My idea is to adapt it's ViewProvider so that it returns the standard icon always except if its Type is set to "Assembly". Before submitting a proposal for this I wanted to try it first.
The Type is defined in ~/src/App/Part.h
Code: Select all
public:
/// type of the part
PropertyString Type;
and I would like the ViewProviderPart to test for this property in getIcon():
Code: Select all
QIcon ViewProviderPart::getIcon(void) const
{
// the Type property of the base Part object
// App::DocumentObject* part = this->getObject();
// App::PropertyString* type = this->getObject()->Type.getStrValue();
return mergeGreyableOverlayIcons (Gui::BitmapFactory().pixmap(sPixmap));
}
and return aPixmap (which I have defined in ViewProviderPart.h) if Type=="Assembly" and sPixmap (the standard geofeaturegroup icon) for everything else. But this->getObject() returns an App::DocumentObject and not an App::Part, and thus hasn't the Type property:
Code: Select all
error: ‘class App::DocumentObject’ has no member named ‘Type’
App::PropertyString* type = this->getObject()->Type.getStrValue();
Is there a way to retrieve this "Type" property of Part.h in the ViewProviderPart.cpp ?