2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2024-03-29 10:09:48 +01:00
|
|
|
Copyright 2006-2024 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
#ifndef ELEMENT_VIEW_H
|
|
|
|
#define ELEMENT_VIEW_H
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include "elementscene.h"
|
2013-11-14 10:11:22 +00:00
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class provides a widget to render an ElementScene instance, i.e. the
|
|
|
|
edition class for electrical elements.
|
2007-10-21 16:10:21 +00:00
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
class ElementView : public QGraphicsView {
|
|
|
|
Q_OBJECT
|
2009-04-03 19:30:25 +00:00
|
|
|
friend class PastePartsCommand;
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructors, destructor
|
2007-08-25 03:43:05 +00:00
|
|
|
public:
|
2017-08-05 02:06:59 +00:00
|
|
|
ElementView(ElementScene *, QWidget * = nullptr);
|
2017-08-05 02:10:01 +00:00
|
|
|
~ElementView() override;
|
2007-08-25 03:43:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ElementView(const ElementView &);
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-08-25 03:43:05 +00:00
|
|
|
public:
|
|
|
|
ElementScene *scene() const;
|
|
|
|
void setScene(ElementScene *);
|
2009-04-03 19:30:25 +00:00
|
|
|
QRectF viewedSceneRect() const;
|
|
|
|
|
2007-10-12 10:58:57 +00:00
|
|
|
protected:
|
2017-08-05 02:10:01 +00:00
|
|
|
void mousePressEvent(QMouseEvent *) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *) override;
|
2014-12-06 17:56:07 +00:00
|
|
|
bool gestureEvent(QGestureEvent *event);
|
2017-08-05 02:10:01 +00:00
|
|
|
bool event(QEvent *event) override;
|
|
|
|
void wheelEvent(QWheelEvent *) override;
|
|
|
|
void drawBackground(QPainter *, const QRectF &) override;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
private:
|
2013-11-14 10:11:22 +00:00
|
|
|
QRectF applyMovement(const QRectF &, const QPointF &);
|
2008-01-07 19:40:08 +00:00
|
|
|
|
|
|
|
public slots:
|
2013-04-16 12:00:41 +00:00
|
|
|
void setVisualisationMode();
|
|
|
|
void setSelectionMode();
|
2008-01-07 19:40:08 +00:00
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
2014-12-06 17:56:07 +00:00
|
|
|
void zoomInSlowly();
|
|
|
|
void zoomOutSlowly();
|
2008-01-07 19:40:08 +00:00
|
|
|
void zoomFit();
|
|
|
|
void zoomReset();
|
|
|
|
void adjustSceneRect();
|
2013-08-08 19:58:15 +00:00
|
|
|
void resetSceneRect ();
|
2009-04-03 19:30:25 +00:00
|
|
|
void cut();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
|
|
|
void pasteInArea();
|
|
|
|
|
2013-04-16 12:00:41 +00:00
|
|
|
signals:
|
|
|
|
/// Signal emitted after the mode changed
|
|
|
|
void modeChanged();
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
private slots:
|
|
|
|
void getPasteArea(const QRectF &);
|
|
|
|
ElementContent pasteAreaDefined(const QRectF &);
|
|
|
|
ElementContent paste(const QPointF &);
|
|
|
|
ElementContent paste(const QDomDocument &, const QPointF &);
|
|
|
|
ElementContent pasteWithOffset(const QDomDocument &);
|
2007-08-25 03:43:05 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-08-25 03:43:05 +00:00
|
|
|
private:
|
2017-08-03 16:53:43 +00:00
|
|
|
ElementScene *m_scene;
|
2009-04-03 19:30:25 +00:00
|
|
|
QString to_paste_in_area_;
|
|
|
|
int offset_paste_count_;
|
|
|
|
QPointF start_top_left_corner_;
|
2013-05-11 18:20:26 +00:00
|
|
|
QPointF reference_view_;
|
2014-12-06 17:56:07 +00:00
|
|
|
bool gestures() const;
|
2007-08-25 03:43:05 +00:00
|
|
|
};
|
|
|
|
#endif
|