Gui: Add getObject<T>() helpers to various classes
Obtaining specific kind of document object is very common task. This commit introduces handy helper which makes that a lot easier.
This commit is contained in:
@@ -65,10 +65,15 @@ protected:
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
Fem::FemPostFunction* getObject()
|
||||
Fem::FemPostFunction* getObject() const
|
||||
{
|
||||
return m_object;
|
||||
}
|
||||
template<class T>
|
||||
T* getObject() const
|
||||
{
|
||||
return dynamic_cast<T*>(getObject());
|
||||
}
|
||||
|
||||
bool blockObjectUpdates()
|
||||
{
|
||||
|
||||
@@ -178,6 +178,9 @@ protected:
|
||||
*/
|
||||
PartDesign::Transformed* getObject() const;
|
||||
|
||||
template <class T>
|
||||
T* getObject() const { return dynamic_cast<T*>(getObject()); }
|
||||
|
||||
/// Get the sketch object of the first original either of the object associated with this
|
||||
/// feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
bool operator== (const ReferenceEntry& otherRef) const;
|
||||
|
||||
App::DocumentObject* getObject() const;
|
||||
template <class T> T* getObject() const { return dynamic_cast<T*>(getObject()); }
|
||||
void setObject(App::DocumentObject* docObj) { m_object = docObj; }
|
||||
std::string getSubName(bool longForm = false) const;
|
||||
void setSubName(const std::string& subName) { m_subName = subName; }
|
||||
|
||||
Reference in New Issue
Block a user