[TD]fix secondary view drag goes to origin

This commit is contained in:
wandererfan
2026-01-22 16:14:07 -05:00
parent fd014445fb
commit 3fca5d99ee
4 changed files with 60 additions and 13 deletions

View File

@@ -577,12 +577,7 @@ QGIViewClip* QGIView::getClipGroup()
void QGIView::updateView(bool forceUpdate)
{
//allow/prevent dragging
if (getViewObject()->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
} else {
setFlag(QGraphicsItem::ItemIsMovable, true);
}
setMovableFlag();
if (getViewObject() && forceUpdate) {
setPosition(Rez::guiX(getViewObject()->X.getValue()),
@@ -1140,6 +1135,15 @@ bool QGIView::isExporting() const
return scenePage->getExportingAny();
}
void QGIView::setMovableFlag()
{
if (getViewObject()->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
} else {
setFlag(QGraphicsItem::ItemIsMovable, true);
}
}
//! Retrieves objects of type T with given indexes
template <typename T>
std::vector<T> QGIView::getObjects(std::vector<int> indexes)

View File

@@ -187,6 +187,7 @@ public:
bool isExporting() const;
virtual void setMovableFlag();
protected:
QGIView* getQGIVByName(std::string name) const;

View File

@@ -44,6 +44,8 @@
#include <Mod/TechDraw/App/DrawViewSection.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/DrawBrokenView.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
#include "DrawGuiUtil.h"
#include "MDIViewPage.h"
@@ -65,6 +67,7 @@
#include "PathBuilder.h"
#include "QGIBreakLine.h"
#include "QGSPage.h"
#include "QGIProjGroup.h"
using namespace TechDraw;
using namespace TechDrawGui;
@@ -220,18 +223,23 @@ QPainterPath QGIViewPart::drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const
double rot = getViewObject()->Rotation.getValue();
return m_pathBuilder->geomToPainterPath(baseGeom, rot);
}
void QGIViewPart::updateView(bool update)
{
// Base::Console().message("QGIVP::updateView() - %s\n", getViewObject()->getNameInDocument());
auto viewPart(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
if (!viewPart)
return;
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if (!vp)
if (!viewPart) {
return;
}
if (update)
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if (!vp) {
return;
}
if (update) {
draw();
}
QGIView::updateView(update);
}
@@ -1427,3 +1435,36 @@ bool QGIViewPart::hideCenterMarks() const
return true;
}
void QGIViewPart::setMovableFlag()
{
auto* dvp(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
if (TechDraw::DrawView::isProjGroupItem(dvp)) {
setMovableFlagProjGroupItem();
return;
}
QGIView::setMovableFlag();
}
void QGIViewPart::setMovableFlagProjGroupItem()
{
auto* dpgi(dynamic_cast<TechDraw::DrawProjGroupItem*>(getViewObject()));
if (!dpgi) {
return;
}
if (dpgi->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
return;
}
bool isAutoDist{dpgi->getPGroup()->AutoDistribute.getValue()};
if (isAutoDist) {
setFlag(QGraphicsItem::ItemIsMovable, false);
return;
}
// not locked, not autoDistribute
setFlag(QGraphicsItem::ItemIsMovable, true);
}

View File

@@ -129,7 +129,8 @@ public:
bool hideCenterMarks() const;
void setMovableFlag() override;
void setMovableFlagProjGroupItem();
protected:
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;