Skip to content

Commit

Permalink
Fixed issues #3902 and #3639 by removing seemingly unnecessary conver…
Browse files Browse the repository at this point in the history
…sion to int and back.
  • Loading branch information
Kjell Morgenstern authored and KjellMorgenstern committed Apr 25, 2023
1 parent 2cccaf2 commit 704c1c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/sketch/sketchwidget.cpp
Expand Up @@ -2181,9 +2181,7 @@ bool SketchWidget::moveByArrow(double dx, double dy, QKeyEvent * event) {
m_arrowTotalX += dx;
m_arrowTotalY += dy;

QPoint globalPos = mapFromScene(m_mousePressScenePos + QPointF(m_arrowTotalX, m_arrowTotalY));
globalPos = mapToGlobal(globalPos);
moveItems(globalPos, false, rubberBandLegEnabled);
moveItemsScene(m_mousePressScenePos + QPointF(m_arrowTotalX, m_arrowTotalY), false, rubberBandLegEnabled);
m_moveEventCount++;
return true;
}
Expand Down Expand Up @@ -3072,15 +3070,27 @@ QString SketchWidget::makeMoveSVG(double printerScale, double dpi, QPointF & off


void SketchWidget::moveItems(QPoint globalPos, bool checkAutoScrollFlag, bool rubberBandLegEnabled)
{
QPoint q = mapFromGlobal(globalPos);
QPointF scenePos = mapToScene(q);
moveItemsAux(scenePos, globalPos, checkAutoScrollFlag, rubberBandLegEnabled);
}


void SketchWidget::moveItemsScene(QPointF scenePos, bool checkAutoScrollFlag, bool rubberBandLegEnabled)
{
QPoint globalPos = mapFromScene(scenePos);
globalPos = mapToGlobal(globalPos);
moveItemsAux(scenePos, globalPos, checkAutoScrollFlag, rubberBandLegEnabled);
}

void SketchWidget::moveItemsAux(QPointF scenePos, QPoint globalPos, bool checkAutoScrollFlag, bool rubberBandLegEnabled)
{
if (checkAutoScrollFlag) {
bool result = checkAutoscroll(globalPos);
if (!result) return;
}

QPoint q = mapFromGlobal(globalPos);
QPointF scenePos = mapToScene(q);

if (m_alignToGrid && (m_alignmentItem)) {
QPointF currentParentPos = m_alignmentItem->mapToParent(m_alignmentItem->mapFromScene(scenePos));
QPointF buttonDownParentPos = m_alignmentItem->mapToParent(m_alignmentItem->mapFromScene(m_mousePressScenePos));
Expand Down
2 changes: 2 additions & 0 deletions src/sketch/sketchwidget.h
Expand Up @@ -404,6 +404,8 @@ class SketchWidget : public InfoGraphicsView
void clearDragWireTempCommand();
bool draggingWireEnd();
void moveItems(QPoint globalPos, bool checkAutoScroll, bool rubberBandLegEnabled);
void moveItemsScene(QPointF scenePos, bool checkAutoScrollFlag, bool rubberBandLegEnabled);
void moveItemsAux(QPointF scenePos, QPoint globalPos, bool checkAutoScrollFlag, bool rubberBandLegEnabled);
virtual ViewLayer::ViewLayerID multiLayerGetViewLayerID(ModelPart * modelPart, ViewLayer::ViewID, ViewLayer::ViewLayerPlacement, LayerList &);
virtual BaseCommand::CrossViewType wireSplitCrossView();
virtual bool canChainMultiple();
Expand Down

0 comments on commit 704c1c3

Please sign in to comment.