QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
diagrameventaddpath.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef DIAGRAMEVENTADDPATH_H
19#define DIAGRAMEVENTADDPATH_H
20
23
24class QGraphicsLineItem;
25
47{
48 Q_OBJECT
49
50 public:
52 ~DiagramEventAddPath() override;
53
54 void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
55 void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
56 void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
57 void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
58 void keyPressEvent (QKeyEvent *event) override;
59 void init() override;
60
61 private:
62 void updateHelpCross (const QPointF &p);
63 void showHint () const;
64 void finishPath (bool closed);
65 void cancelPath ();
66 bool nearFirstNode (const QPointF &scenePos) const;
67 int confirmedNodeCount () const; // m_nodes always carries one trailing "preview" node while running; this excludes it
68 QPointF snapped (const QPointF &scenePos, Qt::KeyboardModifiers mods) const;
69
71 QVector<QetShapeItem::PathNode> m_nodes;
73 QGraphicsLineItem *m_help_horiz, *m_help_verti;
74
75 // Scene units within which a click on an existing path is
76 // treated as "on the first node" and closes the shape, rather
77 // than adding yet another node right next to it.
78 static constexpr qreal CLOSE_THRESHOLD = 12.0;
79};
80
81#endif // DIAGRAMEVENTADDPATH_H
void showHint() const
DiagramEventAddPath::showHint Re-asserted on every move within the canvas (see mouseMoveEvent),...
Definition diagrameventaddpath.cpp:87
int m_dragging_node
Definition diagrameventaddpath.h:72
QGraphicsLineItem * m_help_horiz
Definition diagrameventaddpath.h:73
QGraphicsLineItem * m_help_verti
Definition diagrameventaddpath.h:73
void keyPressEvent(QKeyEvent *event) override
DiagramEventAddPath::keyPressEvent Escape or Enter finish the path open once at least two real points...
Definition diagrameventaddpath.cpp:305
QPointF snapped(const QPointF &scenePos, Qt::KeyboardModifiers mods) const
Definition diagrameventaddpath.cpp:103
QVector< QetShapeItem::PathNode > m_nodes
Definition diagrameventaddpath.h:71
~DiagramEventAddPath() override
Definition diagrameventaddpath.cpp:53
DiagramEventAddPath(Diagram *diagram)
DiagramEventAddPath::DiagramEventAddPath.
Definition diagrameventaddpath.cpp:37
QetShapeItem * m_shape_item
Definition diagrameventaddpath.h:70
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddPath::mouseMoveEvent Two mutually exclusive behaviours, matching whether a button is h...
Definition diagrameventaddpath.cpp:198
int confirmedNodeCount() const
Definition diagrameventaddpath.cpp:108
static constexpr qreal CLOSE_THRESHOLD
Definition diagrameventaddpath.h:78
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddPath::mouseDoubleClickEvent A double-click is a press, release, press,...
Definition diagrameventaddpath.cpp:289
bool nearFirstNode(const QPointF &scenePos) const
DiagramEventAddPath::nearFirstNode m_shape_item's pos()/transform() stay at their identity defaults f...
Definition diagrameventaddpath.cpp:383
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddPath::mouseReleaseEvent Left release just ends the current node's drag phase (the trai...
Definition diagrameventaddpath.cpp:250
void finishPath(bool closed)
DiagramEventAddPath::finishPath Strips the trailing live-preview node, commits the in-progress path o...
Definition diagrameventaddpath.cpp:335
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddPath::mousePressEvent Left click: on the very first click, creates the shape with a re...
Definition diagrameventaddpath.cpp:125
void updateHelpCross(const QPointF &p)
DiagramEventAddPath::updateHelpCross Same crosshair guide as every other shape tool (see DiagramEvent...
Definition diagrameventaddpath.cpp:397
void init() override
Definition diagrameventaddpath.cpp:97
void cancelPath()
DiagramEventAddPath::cancelPath Discards the in-progress path entirely – nothing worth keeping (an em...
Definition diagrameventaddpath.cpp:364
DiagramEventInterface(Diagram *diagram)
Definition diagrameventinterface.cpp:25
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:54
The QetShapeItem class this class is used to draw a basic shape (line, rectangle, ellipse,...
Definition qetshapeitem.h:42