QElectroTech  0.8-dev
elementview.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 ELEMENT_VIEW_H
19 #define ELEMENT_VIEW_H
20 #include <QGraphicsView>
21 #include "elementscene.h"
22 
27 class ElementView : public QGraphicsView {
28  Q_OBJECT
29  friend class PastePartsCommand;
30 
31  // constructors, destructor
32  public:
33  ElementView(ElementScene *, QWidget * = nullptr);
34  ~ElementView() override;
35 
36  private:
38 
39  // methods
40  public:
41  ElementScene *scene() const;
42  void setScene(ElementScene *);
43  QRectF viewedSceneRect() const;
44 
45  protected:
46  void mousePressEvent(QMouseEvent *) override;
47  void mouseMoveEvent(QMouseEvent *) override;
48  void mouseReleaseEvent(QMouseEvent *) override;
49  bool gestureEvent(QGestureEvent *event);
50  bool event(QEvent *event) override;
51  void wheelEvent(QWheelEvent *) override;
52  void drawBackground(QPainter *, const QRectF &) override;
53 
54  private:
55  QRectF applyMovement(const QRectF &, const QPointF &);
56 
57  public slots:
58  void setVisualisationMode();
59  void setSelectionMode();
60  void zoomIn();
61  void zoomOut();
62  void zoomInSlowly();
63  void zoomOutSlowly();
64  void zoomFit();
65  void zoomReset();
66  void adjustSceneRect();
67  void resetSceneRect ();
68  void cut();
69  void copy();
70  void paste();
71  void pasteInArea();
72 
73  signals:
75  void modeChanged();
76 
77  private slots:
78  void getPasteArea(const QRectF &);
79  ElementContent pasteAreaDefined(const QRectF &);
80  ElementContent paste(const QPointF &);
81  ElementContent paste(const QDomDocument &, const QPointF &);
82  ElementContent pasteWithOffset(const QDomDocument &);
83 
84  // attributes
85  private:
90  QPointF reference_view_;
91  bool gestures() const;
92 };
93 #endif
ElementView::pasteInArea
void pasteInArea()
Definition: elementview.cpp:221
ElementView::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *) override
ElementView::mouseReleaseEvent Manage event release click mouse.
Definition: elementview.cpp:390
ElementContent
QList< QGraphicsItem * > ElementContent
Definition: elementcontent.h:21
ElementView
Definition: elementview.h:27
pastepartscommand.h
ElementView::m_scene
ElementScene * m_scene
Definition: elementview.h:86
ElementView::start_top_left_corner_
QPointF start_top_left_corner_
Definition: elementview.h:89
ElementView::gestureEvent
bool gestureEvent(QGestureEvent *event)
ElementView::gestureEvent.
Definition: elementview.cpp:447
ElementView::mousePressEvent
void mousePressEvent(QMouseEvent *) override
Definition: elementview.cpp:358
ElementView::zoomIn
void zoomIn()
Definition: elementview.cpp:100
ElementView::setSelectionMode
void setSelectionMode()
Definition: elementview.cpp:91
ElementView::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *) override
ElementView::mouseMoveEvent Manage the event move mouse.
Definition: elementview.cpp:372
ElementView::pasteAreaDefined
ElementContent pasteAreaDefined(const QRectF &)
Definition: elementview.cpp:274
ElementView::zoomOutSlowly
void zoomOutSlowly()
Definition: elementview.cpp:123
ElementView::~ElementView
~ElementView() override
Destructeur.
Definition: elementview.cpp:44
ElementView::paste
void paste()
Definition: elementview.cpp:197
ElementView::ElementView
ElementView(ElementScene *, QWidget *=nullptr)
Definition: elementview.cpp:27
ElementView::gestures
bool gestures() const
ElementView::gestures.
Definition: elementview.cpp:403
ElementView::adjustSceneRect
void adjustSceneRect()
ElementView::adjustSceneRect Adjust the scenRect, so that he include all primitives of element plus t...
Definition: elementview.cpp:151
ElementScene::setGrid
virtual void setGrid(int, int)
ElementScene::setGrid.
Definition: elementscene.cpp:381
ElementView::zoomReset
void zoomReset()
Definition: elementview.cpp:140
ElementView::applyMovement
QRectF applyMovement(const QRectF &, const QPointF &)
ElementView::applyMovement Applique le decalage offset dans le sens movement au rectangle start.
Definition: elementview.cpp:550
qetapp.h
qetelementeditor.h
ElementView::setScene
void setScene(ElementScene *)
Definition: elementview.cpp:74
ElementView::offset_paste_count_
int offset_paste_count_
Definition: elementview.h:88
ElementView::modeChanged
void modeChanged()
Signal emitted after the mode changed.
ElementView::viewedSceneRect
QRectF viewedSceneRect() const
Definition: elementview.cpp:55
QETElementEditor::pasteOffset
static QPointF pasteOffset()
Definition: qetelementeditor.cpp:1520
ElementView::setVisualisationMode
void setVisualisationMode()
Definition: elementview.cpp:82
elementscene.h
ElementView::cut
void cut()
Definition: elementview.cpp:171
ElementView::reference_view_
QPointF reference_view_
Definition: elementview.h:90
elementview.h
ElementView::zoomFit
void zoomFit()
Definition: elementview.cpp:132
ElementView::to_paste_in_area_
QString to_paste_in_area_
Definition: elementview.h:87
ElementView::copy
void copy()
Definition: elementview.cpp:181
ElementView::wheelEvent
void wheelEvent(QWheelEvent *) override
ElementView::wheelEvent.
Definition: elementview.cpp:414
ElementView::PastePartsCommand
friend class PastePartsCommand
Definition: elementview.h:29
ElementView::zoomOut
void zoomOut()
Definition: elementview.cpp:108
ElementView::event
bool event(QEvent *event) override
Definition: elementview.cpp:430
ElementView::pasteWithOffset
ElementContent pasteWithOffset(const QDomDocument &)
Definition: elementview.cpp:309
ElementView::scene
ElementScene * scene() const
Definition: elementview.cpp:48
ElementEditionCommand::m_scene
ElementScene * m_scene
Element editor/view/scene the command should take place on.
Definition: editorcommands.h:57
ElementView::ElementView
ElementView(const ElementView &)
ElementScene
The ElementScene class This class is the canvas allowing the visual edition of an electrial element....
Definition: elementscene.h:40
ElementView::zoomInSlowly
void zoomInSlowly()
Definition: elementview.cpp:116
ElementView::resetSceneRect
void resetSceneRect()
ElementView::resetSceneRect reset le sceneRect (zone du schéma visualisée par l'ElementView) afin que...
Definition: elementview.cpp:163
PastePartsCommand
The PastePartsCommand class Undo command for paste element primitive in an element editor.
Definition: pastepartscommand.h:31
ElementView::getPasteArea
void getPasteArea(const QRectF &)
Definition: elementview.cpp:257
ElementView::drawBackground
void drawBackground(QPainter *, const QRectF &) override
Definition: elementview.cpp:468