QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
diagramview.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 DIAGRAMVIEW_H
19#define DIAGRAMVIEW_H
20
21#include "../ElementsCollection/elementslocation.h"
23
24#include <QClipboard>
25#include <QGraphicsView>
26
27class Conductor;
28class Diagram;
31class QInputEvent;
32class QGestureEvent;
33
38class DiagramView : public QGraphicsView
39{
40 Q_OBJECT
41
42 // constructors, destructor
43 public:
44 DiagramView(Diagram *diagram, QWidget * = nullptr);
45 ~DiagramView() override;
46
47 private:
49
50 // attributes
51
52 Diagram *m_diagram = nullptr;
54 QAction *m_paste_here = nullptr;
55 QAction *m_multi_paste = nullptr;
56 QAction *m_create_template = nullptr;
61 QList<QAction *> m_separators;
64
65
66 public:
67 QString title() const;
69 Diagram *diagram() { return(m_diagram); }
71 void editSelection();
72 void setEventInterface (DVEventInterface *event_interface);
73 QList<QAction *> contextMenuActions() const;
74
75 protected:
76 void mouseDoubleClickEvent(QMouseEvent *) override;
77 void contextMenuEvent(QContextMenuEvent *) override;
78 void wheelEvent(QWheelEvent *) override;
79 void focusInEvent(QFocusEvent *) override;
80 void keyPressEvent(QKeyEvent *) override;
81 void keyReleaseEvent(QKeyEvent *) override;
82 bool event(QEvent *) override;
83 void paintEvent(QPaintEvent *event) override;
84 void mousePressEvent(QMouseEvent *) override;
85 void mouseMoveEvent(QMouseEvent *) override;
86 void mouseReleaseEvent(QMouseEvent *) override;
87 void dragEnterEvent(QDragEnterEvent *) override;
88 void dragMoveEvent(QDragMoveEvent *) override;
89 void dropEvent(QDropEvent *) override;
90
91 virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e);
92 virtual bool switchToSelectionModeIfNeeded(QInputEvent *e);
93 virtual bool isCtrlShifting(QInputEvent *);
94 virtual bool selectedItemHasFocus();
95
96 private:
97 void handleElementDrop(QDropEvent *);
98 void handleTitleBlockDrop(QDropEvent *);
99 void handleTextDrop(QDropEvent *);
100 void scrollOnMovement(QKeyEvent *);
101 bool gestureEvent(QGestureEvent *event);
102 QRectF viewedSceneRect() const;
104 bool gestures() const;
105
109 static constexpr qreal m_min_zoom = 0.01;
110 static constexpr qreal m_max_zoom = 200.0;
111
112 signals:
116 void titleChanged(DiagramView *, const QString &);
123 void freeRubberBandChanged(QPolygonF polygon);
124
125 public slots:
127 void setSelectionMode();
128 void zoom(const qreal zoom_factor);
129 void zoomFit();
130 void zoomContent();
131 void zoomReset();
132 void cut();
133 void copy();
134 void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
135 void pasteHere();
136 void adjustSceneRect();
137 void updateWindowTitle();
138 void resetConductors();
139
140 private slots:
141 void adjustGridToZoom();
142 void applyReadOnly();
144};
145#endif
Definition conductor.h:44
The DVEventInterface class This class is the main interface for manage event of a Diagram View....
Definition dveventinterface.h:43
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:54
DVEventInterface * m_event_interface
Definition diagramview.h:53
void paste(const QPointF &=QPointF(), QClipboard::Mode=QClipboard::Clipboard)
DiagramView::paste Import the element stored in the clipboard to the diagram.
Definition diagramview.cpp:421
void editSelection()
DiagramView::editSelection Edit the selected item if he can be edited and if only one item is selecte...
Definition diagramview.cpp:1145
~DiagramView() override
Definition diagramview.cpp:154
void mouseReleaseEvent(QMouseEvent *) override
DiagramView::mouseReleaseEvent Manage event release click mouse.
Definition diagramview.cpp:574
void dragEnterEvent(QDragEnterEvent *) override
Definition diagramview.cpp:161
void contextMenuEvent(QContextMenuEvent *) override
DiagramView::contextMenuEvent.
Definition diagramview.cpp:1223
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const
Definition diagramview.cpp:973
void showDiagram(Diagram *)
Signal emitted when diagram must be show.
void cut()
Definition diagramview.cpp:395
void resetConductors()
Definition diagramview.cpp:998
Diagram * m_diagram
Definition diagramview.h:52
void zoomReset()
Definition diagramview.cpp:385
void zoomContent()
Definition diagramview.cpp:376
void createTemplateFromSelection()
DiagramView::createTemplateFromSelection Triggered from the context menu to create a new template (ma...
Definition diagramview.cpp:1266
void wheelEvent(QWheelEvent *) override
DiagramView::wheelEvent Manage wheel event of mouse.
Definition diagramview.cpp:647
void zoomFit()
Definition diagramview.cpp:366
QPolygonF m_free_rubberband
Definition diagramview.h:62
bool gestureEvent(QGestureEvent *event)
DiagramView::gestureEvent Use the pinch of the trackpad for zoom.
Definition diagramview.cpp:682
void adjustGridToZoom()
Definition diagramview.cpp:939
Diagram * diagram()
Definition diagramview.h:69
void editDiagramProperties()
DiagramView::editDiagramProperties Edit the properties of the viewed digram.
Definition diagramview.cpp:902
bool m_fresh_focus_in
Definition diagramview.h:59
QList< QAction * > m_separators
Definition diagramview.h:61
QAction * m_paste_here
Definition diagramview.h:54
bool m_first_activation
Definition diagramview.h:60
void copy()
Definition diagramview.cpp:407
void pasteHere()
Definition diagramview.cpp:446
virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e)
Definition diagramview.cpp:1087
static constexpr qreal m_min_zoom
Definition diagramview.h:109
QList< QAction * > contextMenuActions() const
DiagramView::contextMenuActions.
Definition diagramview.cpp:1180
QPointF m_drag_last_pos
Definition diagramview.h:58
QETDiagramEditor * diagramEditor() const
Definition diagramview.cpp:1362
void handleTitleBlockDrop(QDropEvent *)
DiagramView::handleTitleBlockDrop Handle the dropEvent that contain data of a titleblock.
Definition diagramview.cpp:235
bool gestures() const
DiagramView::gestures.
Definition diagramview.cpp:636
void scrollOnMovement(QKeyEvent *)
Definition diagramview.cpp:812
void paintEvent(QPaintEvent *event) override
DiagramView::paintEvent Reimplemented from QGraphicsView.
Definition diagramview.cpp:1063
void modeChanged()
Signal emitted after the selection mode changed.
virtual bool selectedItemHasFocus()
Definition diagramview.cpp:1132
QPoint m_paste_here_pos
Definition diagramview.h:57
QAction * m_create_template
Definition diagramview.h:56
void titleChanged(DiagramView *, const QString &)
Signal emitted after the diagram title changed.
virtual bool switchToSelectionModeIfNeeded(QInputEvent *e)
Definition diagramview.cpp:1102
void mouseMoveEvent(QMouseEvent *) override
DiagramView::mouseMoveEvent Manage the event move mouse.
Definition diagramview.cpp:512
void setVisualisationMode()
Definition diagramview.cpp:309
DiagramView(const DiagramView &)
void updateWindowTitle()
Definition diagramview.cpp:931
QString title() const
Definition diagramview.cpp:886
void adjustSceneRect()
DiagramView::adjustSceneRect Calcul and set the area of the scene visualized by this view.
Definition diagramview.cpp:911
void mousePressEvent(QMouseEvent *) override
Definition diagramview.cpp:455
void mouseDoubleClickEvent(QMouseEvent *) override
DiagramView::mouseDoubleClickEvent.
Definition diagramview.cpp:1377
DiagramView(Diagram *diagram, QWidget *=nullptr)
Definition diagramview.cpp:48
void focusInEvent(QFocusEvent *) override
Definition diagramview.cpp:703
QRectF viewedSceneRect() const
Definition diagramview.cpp:951
void dropEvent(QDropEvent *) override
Definition diagramview.cpp:186
bool event(QEvent *) override
DiagramView::event Manage the event on this diagram view. -At first activation (QEvent::WindowActivat...
Definition diagramview.cpp:1032
void handleElementDrop(QDropEvent *)
DiagramView::handleElementDrop Handle the drop of an element.
Definition diagramview.cpp:202
void handleTextDrop(QDropEvent *)
Definition diagramview.cpp:284
void keyReleaseEvent(QKeyEvent *) override
Definition diagramview.cpp:800
void dragMoveEvent(QDragMoveEvent *) override
Definition diagramview.cpp:177
bool m_free_rubberbanding
Definition diagramview.h:63
void keyPressEvent(QKeyEvent *) override
DiagramView::keyPressEvent Handles "key press" events. Reimplemented here to switch to visualisation ...
Definition diagramview.cpp:715
void applyReadOnly()
Definition diagramview.cpp:986
void setEventInterface(DVEventInterface *event_interface)
DiagramView::setEventInterface Set an event interface to diagram view. If diagram view already have a...
Definition diagramview.cpp:1168
virtual bool isCtrlShifting(QInputEvent *)
Definition diagramview.cpp:1113
void setSelectionMode()
Definition diagramview.cpp:320
void findElementRequired(const ElementsLocation &)
Signal emitted when users wish to locate an element from the diagram within elements collection.
static constexpr qreal m_max_zoom
Definition diagramview.h:110
QAction * m_multi_paste
Definition diagramview.h:55
void freeRubberBandChanged(QPolygonF polygon)
void zoom(const qreal zoom_factor)
DiagramView::zoom Zomm the view. A zoom_factor > 1 zoom in. A zoom_factor < 1 zoom out.
Definition diagramview.cpp:335
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
Definition qetdiagrameditor.h:53
Definition templatelocation.h:29