QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
diagrameventaddshape.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 DIAGRAMEVENTADDSHAPE_H
19#define DIAGRAMEVENTADDSHAPE_H
20
23
24class QGraphicsEllipseItem;
25
31{
32 Q_OBJECT
33
34 public:
36
37 ~DiagramEventAddShape() override;
38 void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
39 void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
40 void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
41 void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
42 void keyPressEvent (QKeyEvent *event) override;
43 void keyReleaseEvent (QKeyEvent *event) override;
44 void init() override;
45
46 private:
47 void updateHelpCross (const QPointF &p);
48 void applyPosition (const QPointF &pos, Qt::KeyboardModifiers mods);
49 void updateCreationHint () const;
50 QString beforeClickHint () const;
51 QString afterClickHint () const;
52 void showCenterMarker (const QPointF &scenePos);
53 void hideCenterMarker ();
54 void reapplyLastPosition (QKeyEvent *event);
55
56 protected:
59 QGraphicsLineItem *m_help_horiz, *m_help_verti;
60 QPointF m_anchor_point; // the shape's first-click point -- meaningful once m_shape_item exists
61 QGraphicsEllipseItem *m_center_marker = nullptr; // shown only while Ctrl-anchoring is actually in effect, so it doubles as confirmation that it is
62 bool m_center_anchored = false; // decided once, at the first click -- see applyPosition()'s doc comment for why
63 QPointF m_last_mouse_scene_pos; // raw, unsnapped -- lets a modifier-only change re-snap correctly when reapplied
64};
65
66#endif // DIAGRAMEVENTADDSHAPE_H
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddShape::mousePressEvent Action when mouse is pressed.
Definition diagrameventaddshape.cpp:195
QetShapeItem::ShapeType m_shape_type
Definition diagrameventaddshape.h:57
QString beforeClickHint() const
Definition diagrameventaddshape.cpp:446
void reapplyLastPosition(QKeyEvent *event)
Definition diagrameventaddshape.cpp:331
~DiagramEventAddShape() override
DiagramEventAddShape::~DiagramEventAddShape.
Definition diagrameventaddshape.cpp:64
QetShapeItem * m_shape_item
Definition diagrameventaddshape.h:58
void init() override
Definition diagrameventaddshape.cpp:423
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddShape::mouseReleaseEvent Action when mouse button is released.
Definition diagrameventaddshape.cpp:354
void showCenterMarker(const QPointF &scenePos)
DiagramEventAddShape::showCenterMarker Small, filled marker at the anchor point, shown only while Ctr...
Definition diagrameventaddshape.cpp:170
void updateHelpCross(const QPointF &p)
DiagramEventAddShape::updateHelpCross Create and update the position of the cross to help user for dr...
Definition diagrameventaddshape.cpp:487
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddShape::mouseMoveEvent Action when mouse move.
Definition diagrameventaddshape.cpp:275
QGraphicsEllipseItem * m_center_marker
Definition diagrameventaddshape.h:61
QGraphicsLineItem * m_help_horiz
Definition diagrameventaddshape.h:59
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddShape::mouseDoubleClickEvent Action when mouse button is double clicked.
Definition diagrameventaddshape.cpp:398
void updateCreationHint() const
DiagramEventAddShape::updateCreationHint Shows whichever of beforeClickHint()/afterClickHint() matche...
Definition diagrameventaddshape.cpp:438
bool m_center_anchored
Definition diagrameventaddshape.h:62
QPointF m_last_mouse_scene_pos
Definition diagrameventaddshape.h:63
QPointF m_anchor_point
Definition diagrameventaddshape.h:60
DiagramEventAddShape(Diagram *diagram, QetShapeItem::ShapeType shape_type)
DiagramEventAddShape::DiagramEventAddShape Default constructor.
Definition diagrameventaddshape.cpp:38
QString afterClickHint() const
Definition diagrameventaddshape.cpp:462
void hideCenterMarker()
Definition diagrameventaddshape.cpp:184
QGraphicsLineItem * m_help_verti
Definition diagrameventaddshape.h:59
void keyReleaseEvent(QKeyEvent *event) override
Definition diagrameventaddshape.cpp:326
void keyPressEvent(QKeyEvent *event) override
DiagramEventAddShape::keyPressEvent / keyReleaseEvent Pressing or releasing Shift (the square/circle ...
Definition diagrameventaddshape.cpp:321
void applyPosition(const QPointF &pos, Qt::KeyboardModifiers mods)
DiagramEventAddShape::applyPosition Applies a drag/click position to the in-progress shape,...
Definition diagrameventaddshape.cpp:110
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
ShapeType
Definition qetshapeitem.h:79