QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
diagramview.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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
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;
60 QList<QAction *> m_separators;
63
64
65 public:
66 QString title() const;
68 Diagram *diagram() { return(m_diagram); }
70 void editSelection();
71 void setEventInterface (DVEventInterface *event_interface);
72 QList<QAction *> contextMenuActions() const;
73
74 protected:
75 void mouseDoubleClickEvent(QMouseEvent *) override;
76 void contextMenuEvent(QContextMenuEvent *) override;
77 void wheelEvent(QWheelEvent *) override;
78 void focusInEvent(QFocusEvent *) override;
79 void keyPressEvent(QKeyEvent *) override;
80 void keyReleaseEvent(QKeyEvent *) override;
81 bool event(QEvent *) override;
82 void paintEvent(QPaintEvent *event) override;
83 void mousePressEvent(QMouseEvent *) override;
84 void mouseMoveEvent(QMouseEvent *) override;
85 void mouseReleaseEvent(QMouseEvent *) override;
86 void dragEnterEvent(QDragEnterEvent *) override;
87 void dragMoveEvent(QDragMoveEvent *) override;
88 void dropEvent(QDropEvent *) override;
89
90 virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e);
91 virtual bool switchToSelectionModeIfNeeded(QInputEvent *e);
92 virtual bool isCtrlShifting(QInputEvent *);
93 virtual bool selectedItemHasFocus();
94
95 private:
96 void handleElementDrop(QDropEvent *);
97 void handleTitleBlockDrop(QDropEvent *);
98 void handleTextDrop(QDropEvent *);
99 void scrollOnMovement(QKeyEvent *);
100 bool gestureEvent(QGestureEvent *event);
101 QRectF viewedSceneRect() const;
103 bool gestures() const;
104
105 signals:
109 void titleChanged(DiagramView *, const QString &);
116 void freeRubberBandChanged(QPolygonF polygon);
117
118 public slots:
120 void setSelectionMode();
121 void zoom(const qreal zoom_factor);
122 void zoomFit();
123 void zoomContent();
124 void zoomReset();
125 void cut();
126 void copy();
127 void paste(const QPointF & = QPointF(), QClipboard::Mode = QClipboard::Clipboard);
128 void pasteHere();
129 void adjustSceneRect();
130 void updateWindowTitle();
131 void resetConductors();
132
133 private slots:
134 void adjustGridToZoom();
135 void applyReadOnly();
136};
137#endif
Definition conductor.h:43
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:56
Definition diagramview.h:39
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:405
void editSelection()
DiagramView::editSelection Edit the selected item if he can be edited and if only one item is selecte...
Definition diagramview.cpp:1143
~DiagramView() override
Definition diagramview.cpp:147
void mouseReleaseEvent(QMouseEvent *) override
DiagramView::mouseReleaseEvent Manage event release click mouse.
Definition diagramview.cpp:571
void dragEnterEvent(QDragEnterEvent *) override
Definition diagramview.cpp:154
void contextMenuEvent(QContextMenuEvent *) override
DiagramView::contextMenuEvent.
Definition diagramview.cpp:1220
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const
Definition diagramview.cpp:971
void showDiagram(Diagram *)
Signal emitted when diagram must be show.
void cut()
Definition diagramview.cpp:380
void resetConductors()
Definition diagramview.cpp:996
Diagram * m_diagram
Definition diagramview.h:52
void zoomReset()
Definition diagramview.cpp:371
void zoomContent()
Definition diagramview.cpp:362
void wheelEvent(QWheelEvent *) override
DiagramView::wheelEvent Manage wheel event of mouse.
Definition diagramview.cpp:651
void zoomFit()
Definition diagramview.cpp:352
QPolygonF m_free_rubberband
Definition diagramview.h:61
bool gestureEvent(QGestureEvent *event)
DiagramView::gestureEvent Use the pinch of the trackpad for zoom.
Definition diagramview.cpp:686
void adjustGridToZoom()
Definition diagramview.cpp:937
Diagram * diagram()
Definition diagramview.h:68
void editDiagramProperties()
DiagramView::editDiagramProperties Edit the properties of the viewed digram.
Definition diagramview.cpp:900
bool m_fresh_focus_in
Definition diagramview.h:58
QList< QAction * > m_separators
Definition diagramview.h:60
QAction * m_paste_here
Definition diagramview.h:54
bool m_first_activation
Definition diagramview.h:59
void copy()
Definition diagramview.cpp:391
void pasteHere()
Definition diagramview.cpp:429
virtual bool switchToVisualisationModeIfNeeded(QInputEvent *e)
Definition diagramview.cpp:1085
QList< QAction * > contextMenuActions() const
DiagramView::contextMenuActions.
Definition diagramview.cpp:1178
QPointF m_drag_last_pos
Definition diagramview.h:57
QETDiagramEditor * diagramEditor() const
Definition diagramview.cpp:1262
void handleTitleBlockDrop(QDropEvent *)
DiagramView::handleTitleBlockDrop Handle the dropEvent that contain data of a titleblock.
Definition diagramview.cpp:228
bool gestures() const
DiagramView::gestures.
Definition diagramview.cpp:640
void scrollOnMovement(QKeyEvent *)
Definition diagramview.cpp:816
void paintEvent(QPaintEvent *event) override
DiagramView::paintEvent Reimplemented from QGraphicsView.
Definition diagramview.cpp:1061
void modeChanged()
Signal emitted after the selection mode changed.
virtual bool selectedItemHasFocus()
Definition diagramview.cpp:1130
QPoint m_paste_here_pos
Definition diagramview.h:56
void titleChanged(DiagramView *, const QString &)
Signal emitted after the diagram title changed.
virtual bool switchToSelectionModeIfNeeded(QInputEvent *e)
Definition diagramview.cpp:1100
void mouseMoveEvent(QMouseEvent *) override
DiagramView::mouseMoveEvent Manage the event move mouse.
Definition diagramview.cpp:502
void setVisualisationMode()
Definition diagramview.cpp:302
DiagramView(const DiagramView &)
void updateWindowTitle()
Definition diagramview.cpp:929
QString title() const
Definition diagramview.cpp:884
void adjustSceneRect()
DiagramView::adjustSceneRect Calcul and set the area of the scene visualized by this view.
Definition diagramview.cpp:909
void mousePressEvent(QMouseEvent *) override
Definition diagramview.cpp:438
void mouseDoubleClickEvent(QMouseEvent *) override
DiagramView::mouseDoubleClickEvent.
Definition diagramview.cpp:1277
void focusInEvent(QFocusEvent *) override
Definition diagramview.cpp:707
QRectF viewedSceneRect() const
Definition diagramview.cpp:949
void dropEvent(QDropEvent *) override
Definition diagramview.cpp:179
bool event(QEvent *) override
DiagramView::event Manage the event on this diagram view. -At first activation (QEvent::WindowActivat...
Definition diagramview.cpp:1030
void handleElementDrop(QDropEvent *)
DiagramView::handleElementDrop Handle the drop of an element.
Definition diagramview.cpp:195
void handleTextDrop(QDropEvent *)
Definition diagramview.cpp:277
void keyReleaseEvent(QKeyEvent *) override
Definition diagramview.cpp:804
void dragMoveEvent(QDragMoveEvent *) override
Definition diagramview.cpp:170
bool m_free_rubberbanding
Definition diagramview.h:62
void keyPressEvent(QKeyEvent *) override
DiagramView::keyPressEvent Handles "key press" events. Reimplemented here to switch to visualisation ...
Definition diagramview.cpp:719
void applyReadOnly()
Definition diagramview.cpp:984
void setEventInterface(DVEventInterface *event_interface)
DiagramView::setEventInterface Set an event interface to diagram view. If diagram view already have a...
Definition diagramview.cpp:1166
virtual bool isCtrlShifting(QInputEvent *)
Definition diagramview.cpp:1111
void setSelectionMode()
Definition diagramview.cpp:313
void findElementRequired(const ElementsLocation &)
Signal emitted when users wish to locate an element from the diagram within elements collection.
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:328
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
Definition qetdiagrameditor.h:55
Definition templatelocation.h:29