wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
SceneInteraction.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <utility>
11
12#include <QElapsedTimer>
13#include <QGraphicsRectItem>
14#include <QList>
15#include <QPointer>
16#include <QPointF>
17
18class GraphicElement;
19class QGraphicsSceneMouseEvent;
20class Scene;
21class ThemeAttributes;
22
38{
39public:
40 explicit SceneInteraction(Scene *scene);
41
44 void attachToScene();
45
47 bool mousePress(QGraphicsSceneMouseEvent *event);
49 bool mouseMove(QGraphicsSceneMouseEvent *event);
51 bool mouseRelease(QGraphicsSceneMouseEvent *event);
53 bool mouseDoubleClick(QGraphicsSceneMouseEvent *event);
54
56 [[nodiscard]] QPointF lastMousePos() const { return m_mousePos; }
57
59 [[nodiscard]] bool isDraggingElement() const { return m_draggingElement; }
60
62 void applyTheme(const ThemeAttributes &theme);
63
64private:
66 void startSelectionRect();
67
68 Scene *m_scene;
69
70 QGraphicsRectItem m_selectionRect;
71 QElapsedTimer m_timer;
72 QPointF m_mousePos;
73 QPointF m_selectionStartPoint;
74
77 QList<std::pair<QPointer<GraphicElement>, QPointF>> m_dragSnapshot;
78 bool m_draggingElement = false;
79 bool m_markingSelectionBox = false;
80};
Abstract base class for all graphical circuit elements in wiRedPanda.
bool mouseMove(QGraphicsSceneMouseEvent *event)
bool mousePress(QGraphicsSceneMouseEvent *event)
SceneInteraction(Scene *scene)
void applyTheme(const ThemeAttributes &theme)
Applies the theme's selection-rectangle brush and pen.
bool mouseRelease(QGraphicsSceneMouseEvent *event)
bool isDraggingElement() const
true while an element drag is in progress (drives Scene::resizeScene's expand-only mode).
QPointF lastMousePos() const
Last known cursor position in scene coordinates.
bool mouseDoubleClick(QGraphicsSceneMouseEvent *event)
Main circuit editing scene.
Definition Scene.h:56
Contains all color attributes for a theme.