diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index a5023a67d8..291368e355 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -32,17 +32,15 @@ #include #include "QGIProjGroup.h" -#include "QGIViewDimension.h" #include "QGIViewPart.h" -#include "Rez.h" - +#include "QGSPage.h" using namespace TechDrawGui; using namespace TechDraw; QGIProjGroup::QGIProjGroup() { - m_origin = new QGraphicsItemGroup(); //QGIG added to this QGIG?? + m_origin = new QGraphicsItemGroup(); m_origin->setParentItem(this); setFlag(ItemIsSelectable, false); @@ -50,7 +48,7 @@ QGIProjGroup::QGIProjGroup() setFiltersChildEvents(true); } -TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const +TechDraw::DrawProjGroup * QGIProjGroup::getPGroupFeature() const { App::DocumentObject *obj = getViewObject(); return dynamic_cast(obj); @@ -58,7 +56,7 @@ TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const bool QGIProjGroup::autoDistributeEnabled() const { - return getDrawView() && getDrawView()->AutoDistribute.getValue(); + return getPGroupFeature() && getPGroupFeature()->AutoDistribute.getValue(); } @@ -85,13 +83,6 @@ bool QGIProjGroup::sceneEventFilter(QGraphicsItem* watched, QEvent *event) auto *mEvent = dynamic_cast(event); // Disable moves on the view to prevent double drag - std::vector modifiedChildren; - for (auto* child : childItems()) { - if (child->isSelected() && (child->flags() & QGraphicsItem::ItemIsMovable)) { - child->setFlag(QGraphicsItem::ItemIsMovable, false); - modifiedChildren.push_back(child); - } - } switch (event->type()) { case QEvent::GraphicsSceneMousePress: @@ -106,9 +97,6 @@ bool QGIProjGroup::sceneEventFilter(QGraphicsItem* watched, QEvent *event) default: break; } - for (auto* child : modifiedChildren) { - child->setFlag(QGraphicsItem::ItemIsMovable, true); - } return false; } @@ -168,7 +156,6 @@ void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event) void QGIProjGroup::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { QGIView *qAnchor = getAnchorQItem(); - // this is obsolete too? if(scene() && qAnchor && (qAnchor == scene()->mouseGrabberItem() || autoDistributeEnabled())) { if((mousePos - event->screenPos()).manhattanLength() > 5) { //if the mouse has moved more than 5, process the mouse event QGIViewCollection::mouseMoveEvent(event); @@ -201,7 +188,7 @@ void QGIProjGroup::mouseReleaseEvent(QGIView* originator, QGraphicsSceneMouseEve QGIView * QGIProjGroup::getAnchorQItem() const { // Get the currently assigned anchor view - App::DocumentObject *anchorObj = getDrawView()->Anchor.getValue(); + App::DocumentObject *anchorObj = getPGroupFeature()->Anchor.getValue(); auto anchorView( dynamic_cast(anchorObj) ); if (!anchorView) { return nullptr; @@ -243,4 +230,23 @@ bool QGIProjGroup::isMember(App::DocumentObject* dvpObj) const return itMatch != groupOutlist.end(); } +QList QGIProjGroup::secondaryQViews() const +{ + auto* qgspage = static_cast(scene()); + if (!qgspage) { + return {}; + } + DrawProjGroup* pgFeature = getPGroupFeature(); + auto pgViewsAll = pgFeature->getViewsAsDPGI(); + QList result; + + for (auto& pgView : pgViewsAll) { + auto* qview = dynamic_cast(qgspage->findQViewForDocObj(pgView)); + if (!qview) { + continue; + } + result.emplace_back(qview); + } + return result; +} diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.h b/src/Mod/TechDraw/Gui/QGIProjGroup.h index eb78b64258..4d3a3a6a31 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.h +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.h @@ -41,6 +41,7 @@ namespace TechDraw { namespace TechDrawGui { +class QGIViewPart; class TechDrawGuiExport QGIProjGroup : public QGIViewCollection { @@ -60,6 +61,9 @@ public: void drawBorder() override; bool isMember(App::DocumentObject* dvpObj) const; + QGIView* getAnchorQItem() const; + TechDraw::DrawProjGroup* getPGroupFeature() const; + QList secondaryQViews() const; protected: bool sceneEventFilter(QGraphicsItem* watched, QEvent *event) override; @@ -70,11 +74,9 @@ protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent * event) override; void mouseReleaseEvent(QGIView* originator, QGraphicsSceneMouseEvent* event); - QGIView* getAnchorQItem() const; private: /// Convenience function - TechDraw::DrawProjGroup* getDrawView() const; bool autoDistributeEnabled() const; QGraphicsItem* m_origin;