QElectroTech  0.70
elementview.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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:
37  ElementView(const ElementView &);
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
QRectF viewedSceneRect() const
Definition: elementview.cpp:55
ElementScene * scene() const
Definition: elementview.cpp:48
void zoomOut()
void wheelEvent(QWheelEvent *) override
ElementView::wheelEvent.
QPointF reference_view_
Definition: elementview.h:90
int offset_paste_count_
Definition: elementview.h:88
void setScene(ElementScene *)
Definition: elementview.cpp:74
void modeChanged()
Signal emitted after the mode changed.
void mouseReleaseEvent(QMouseEvent *) override
ElementView::mouseReleaseEvent Manage event release click mouse.
void setVisualisationMode()
Definition: elementview.cpp:82
void zoomFit()
bool gestures() const
ElementView::gestures.
void resetSceneRect()
ElementView::resetSceneRect reset le sceneRect (zone du schéma visualisée par l&#39;ElementView) afin que...
bool gestureEvent(QGestureEvent *event)
ElementView::gestureEvent.
void adjustSceneRect()
ElementView::adjustSceneRect Adjust the scenRect, so that he include all primitives of element plus t...
void zoomReset()
~ElementView() override
Destructeur.
Definition: elementview.cpp:44
void mousePressEvent(QMouseEvent *) override
void pasteInArea()
void getPasteArea(const QRectF &)
ElementContent pasteAreaDefined(const QRectF &)
void zoomInSlowly()
void drawBackground(QPainter *, const QRectF &) override
ElementView(ElementScene *, QWidget *=nullptr)
Definition: elementview.cpp:27
QPointF start_top_left_corner_
Definition: elementview.h:89
ElementScene * m_scene
Definition: elementview.h:86
QList< QGraphicsItem * > ElementContent
ElementContent pasteWithOffset(const QDomDocument &)
void setSelectionMode()
Definition: elementview.cpp:91
void zoomOutSlowly()
QRectF applyMovement(const QRectF &, const QPointF &)
void mouseMoveEvent(QMouseEvent *) override
ElementView::mouseMoveEvent Manage the event move mouse.
bool event(QEvent *event) override
QString to_paste_in_area_
Definition: elementview.h:87