[TechDraw] Unify Projection Group parent linking
This commit is contained in:
@@ -181,14 +181,7 @@ void DrawProjGroupItem::onDocumentRestored()
|
||||
|
||||
DrawProjGroup* DrawProjGroupItem::getPGroup() const
|
||||
{
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->isDerivedFrom<DrawProjGroup>()) {
|
||||
DrawProjGroup* result = dynamic_cast<TechDraw::DrawProjGroup *>(*it);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return dynamic_cast<DrawProjGroup *>(getCollection());
|
||||
}
|
||||
|
||||
bool DrawProjGroupItem::isAnchor(void) const
|
||||
|
||||
@@ -409,10 +409,14 @@ DrawView *DrawView::claimParent() const
|
||||
{
|
||||
App::PropertyLink *ownerProp = const_cast<DrawView *>(this)->getOwnerProperty();
|
||||
if (ownerProp) {
|
||||
return dynamic_cast<DrawView *>(ownerProp->getValue());
|
||||
auto ownerView = dynamic_cast<DrawView *>(ownerProp->getValue());
|
||||
if (ownerView) {
|
||||
return ownerView;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
// If there is no parent view we are aware of, return the view collection we may belong to
|
||||
return getCollection();
|
||||
}
|
||||
|
||||
DrawViewClip* DrawView::getClipGroup()
|
||||
@@ -430,6 +434,19 @@ DrawViewClip* DrawView::getClipGroup()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DrawViewCollection *DrawView::getCollection() const
|
||||
{
|
||||
std::vector<App::DocumentObject *> parents = getInList();
|
||||
for (auto it = parents.begin(); it != parents.end(); ++it) {
|
||||
auto parentCollection = dynamic_cast<DrawViewCollection *>(*it);
|
||||
if (parentCollection) {
|
||||
return parentCollection;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double DrawView::autoScale() const
|
||||
{
|
||||
auto page = findParentPage();
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace TechDraw
|
||||
{
|
||||
|
||||
class DrawPage;
|
||||
class DrawViewCollection;
|
||||
class DrawViewClip;
|
||||
class DrawLeaderLine;
|
||||
/*class CosmeticVertex;*/
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
|
||||
bool isInClip();
|
||||
DrawViewClip* getClipGroup();
|
||||
DrawViewCollection *getCollection() const;
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
const char* getViewProviderName() const override {
|
||||
|
||||
Reference in New Issue
Block a user