From b829ba639bc4ab3edc76eaafe2e0d851d14f3d01 Mon Sep 17 00:00:00 2001 From: parker Date: Fri, 20 Jun 2025 02:07:11 +0100 Subject: [PATCH] refactor: change pan method --- src/gui/network/NetworkGraphicsScene.cpp | 4 ++++ src/gui/network/NetworkGraphicsScene.h | 2 ++ src/gui/network/NetworkGraphicsView.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/network/NetworkGraphicsScene.cpp b/src/gui/network/NetworkGraphicsScene.cpp index ea5c85d..6517739 100644 --- a/src/gui/network/NetworkGraphicsScene.cpp +++ b/src/gui/network/NetworkGraphicsScene.cpp @@ -7,6 +7,10 @@ NetworkGraphicsScene::NetworkGraphicsScene() : QGraphicsScene() { + sceneWidth_ = 64000; + sceneHeight_ = 64000; + setSceneRect(sceneWidth_/-2.0f, sceneHeight_/-2.0f, sceneWidth_, sceneHeight_); + } diff --git a/src/gui/network/NetworkGraphicsScene.h b/src/gui/network/NetworkGraphicsScene.h index 93927b2..7fa5101 100644 --- a/src/gui/network/NetworkGraphicsScene.h +++ b/src/gui/network/NetworkGraphicsScene.h @@ -8,5 +8,7 @@ class NetworkGraphicsScene public: NetworkGraphicsScene(); private: + uint sceneWidth_; + uint sceneHeight_; protected: }; diff --git a/src/gui/network/NetworkGraphicsView.cpp b/src/gui/network/NetworkGraphicsView.cpp index ec304cf..b048aec 100644 --- a/src/gui/network/NetworkGraphicsView.cpp +++ b/src/gui/network/NetworkGraphicsView.cpp @@ -58,7 +58,8 @@ void NetworkGraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent) std::cout << "delta: " << delta.x() << " " << delta.y() << "\n"; float speed = 1.0f; - setSceneRect(sceneRect().translated(-delta.x()*speed, -delta.y()*speed)); + horizontalScrollBar()->setValue(horizontalScrollBar()->value() - delta.x()); + verticalScrollBar()->setValue(verticalScrollBar()->value() - delta.y()); panStartPos = mouseEvent->pos(); mouseEvent->accept(); return;