2013-11-14 10:11:22 +00:00
|
|
|
/*
|
2017-01-20 10:55:49 +00:00
|
|
|
Copyright 2006-2017 The QElectroTech Team
|
2013-11-14 10:11:22 +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/>.
|
|
|
|
*/
|
|
|
|
#ifndef QETGRAPHICSITEM_H
|
|
|
|
#define QETGRAPHICSITEM_H
|
|
|
|
|
2014-07-21 20:44:32 +00:00
|
|
|
#include <QGraphicsObject>
|
|
|
|
|
|
|
|
class Diagram;
|
2013-11-14 10:11:22 +00:00
|
|
|
|
2015-01-08 18:59:23 +00:00
|
|
|
class QetGraphicsItem : public QGraphicsObject
|
|
|
|
{
|
2013-11-14 10:11:22 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-01-08 18:59:23 +00:00
|
|
|
//constructor destructor
|
2017-08-05 02:06:59 +00:00
|
|
|
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
2015-01-08 18:59:23 +00:00
|
|
|
virtual ~QetGraphicsItem() = 0;
|
|
|
|
|
|
|
|
//public methode
|
2015-05-08 17:49:29 +00:00
|
|
|
Diagram *diagram () const;
|
2015-01-08 18:59:23 +00:00
|
|
|
virtual void setPos (const QPointF &p);
|
|
|
|
virtual void setPos (qreal x, qreal y);
|
|
|
|
virtual void rotateBy (const qreal &);
|
|
|
|
virtual void applyRotation (const qreal &);
|
2015-05-08 17:49:29 +00:00
|
|
|
|
|
|
|
virtual bool isMovable () const {return is_movable_;}
|
|
|
|
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
|
|
|
|
2015-01-08 18:59:23 +00:00
|
|
|
virtual void editProperty () {}
|
|
|
|
virtual QString name ()const {return QString("");}
|
|
|
|
|
|
|
|
//protected method
|
2013-11-14 10:11:22 +00:00
|
|
|
protected:
|
2015-01-08 18:59:23 +00:00
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
|
|
|
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e);
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
|
2013-11-14 10:11:22 +00:00
|
|
|
|
|
|
|
protected:
|
2015-01-08 18:59:23 +00:00
|
|
|
bool is_movable_;
|
|
|
|
bool first_move_;
|
|
|
|
bool snap_to_grid_;
|
|
|
|
QPointF mouse_to_origin_movement_;
|
2013-11-14 10:11:22 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QETGRAPHICSITEM_H
|