[TD]prevent spurious recompute on click/drag
This commit is contained in:
committed by
WandererFan
parent
714be34961
commit
3f34fff3c3
@@ -98,6 +98,13 @@ short DrawProjGroupItem::mustExecute() const
|
||||
|
||||
void DrawProjGroupItem::onChanged(const App::Property *prop)
|
||||
{
|
||||
if ((prop == &X) ||
|
||||
(prop == &Y)) {
|
||||
DrawProjGroup* parent = getPGroup();
|
||||
if (parent != nullptr) {
|
||||
parent->touch(false);
|
||||
}
|
||||
}
|
||||
TechDraw::DrawViewPart::onChanged(prop);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ DrawView::DrawView(void):
|
||||
mouseMove(false)
|
||||
{
|
||||
static const char *group = "Base";
|
||||
ADD_PROPERTY_TYPE(X, (0.0), group, (App::PropertyType)(App::Prop_None), "X position");
|
||||
ADD_PROPERTY_TYPE(Y, (0.0), group, (App::PropertyType)(App::Prop_None), "Y position");
|
||||
ADD_PROPERTY_TYPE(X, (0.0), group, (App::PropertyType)(App::Prop_None | App::Prop_NoRecompute), "X position");
|
||||
ADD_PROPERTY_TYPE(Y, (0.0), group, (App::PropertyType)(App::Prop_None | App::Prop_NoRecompute), "Y position");
|
||||
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_Output, "Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_Output, "Rotation in degrees counterclockwise");
|
||||
|
||||
@@ -159,6 +159,7 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
requestPaint();
|
||||
} else if ((prop == &X) ||
|
||||
(prop == &Y)) {
|
||||
// Base::Console().Message("DV::onChanged(X or Y)\n");
|
||||
DrawView::execute();
|
||||
X.purgeTouched();
|
||||
Y.purgeTouched();
|
||||
|
||||
@@ -81,13 +81,18 @@
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
#define NODRAG 0
|
||||
#define DRAGSTARTED 1
|
||||
#define DRAGGING 2
|
||||
|
||||
const float labelCaptionFudge = 0.2f; // temp fiddle for devel
|
||||
|
||||
QGIView::QGIView()
|
||||
:QGraphicsItemGroup(),
|
||||
viewObj(nullptr),
|
||||
m_locked(false),
|
||||
m_innerView(false)
|
||||
m_innerView(false),
|
||||
m_dragState(NODRAG)
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setHandlesChildEvents(false);
|
||||
@@ -200,22 +205,6 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
newPos.setX(item->pos().x());
|
||||
} else if(alignMode == QString::fromLatin1("Horizontal")) {
|
||||
newPos.setY(item->pos().y());
|
||||
} else if(alignMode == QString::fromLatin1("45slash")) {
|
||||
//this logic is wrong since the constrained movement direction is not necessarily 45*
|
||||
// Base::Console().Message("QGIV::itemChange - oblique BL-TR\n");
|
||||
// double dist = ( (newPos.x() - item->pos().x()) +
|
||||
// (item->pos().y() - newPos.y()) ) / 2.0;
|
||||
|
||||
// newPos.setX( item->pos().x() + dist);
|
||||
// newPos.setY( item->pos().y() - dist );
|
||||
} else if(alignMode == QString::fromLatin1("45backslash")) {
|
||||
//this logic is wrong since the constrained movement direction is not necessarily 45*
|
||||
// Base::Console().Message("QGIV::itemChange - oblique TL-BR\n");
|
||||
// double dist = ( (newPos.x() - item->pos().x()) +
|
||||
// (newPos.y() - item->pos().y()) ) / 2.0;
|
||||
|
||||
// newPos.setX( item->pos().x() + dist);
|
||||
// newPos.setY( item->pos().y() + dist );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,30 +233,39 @@ void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIV::mousePressEvent() - %s\n",getViewName());
|
||||
signalSelectPoint(this, event->pos());
|
||||
if (m_dragState == NODRAG) {
|
||||
m_dragState = DRAGSTARTED;
|
||||
}
|
||||
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
//void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
//{
|
||||
// QGraphicsItem::mouseMoveEvent(event);
|
||||
//}
|
||||
void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
if (m_dragState == DRAGSTARTED) {
|
||||
m_dragState = DRAGGING;
|
||||
}
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
//TODO: this should be done in itemChange - item position has changed
|
||||
//TODO: and should check for dragging
|
||||
// Base::Console().Message("QGIV::mouseReleaseEvent() - %s\n",getViewName());
|
||||
// if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
if(!m_locked) {
|
||||
if (!isInnerView()) {
|
||||
double tempX = x(),
|
||||
tempY = getY();
|
||||
getViewObject()->setPosition(Rez::appX(tempX),Rez::appX(tempY));
|
||||
} else {
|
||||
getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y())));
|
||||
if (m_dragState == DRAGGING) {
|
||||
if(!m_locked) {
|
||||
if (!isInnerView()) {
|
||||
double tempX = x(),
|
||||
tempY = getY();
|
||||
getViewObject()->setPosition(Rez::appX(tempX),Rez::appX(tempY));
|
||||
} else {
|
||||
getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y())));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_dragState = NODRAG;
|
||||
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef DRAWINGGUI_QGRAPHICSITEMVIEW_H
|
||||
#define DRAWINGGUI_QGRAPHICSITEMVIEW_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QGraphicsItemGroup>
|
||||
@@ -154,7 +156,7 @@ protected:
|
||||
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
// Mouse handling
|
||||
/* virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;*/
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
// Preselection events:
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
@@ -191,8 +193,8 @@ protected:
|
||||
QPen m_decorPen;
|
||||
double m_lockWidth;
|
||||
double m_lockHeight;
|
||||
int m_dragState;
|
||||
|
||||
// std::vector<QGraphicsItem*> m_randomItems;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user