2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2025-01-04 13:37:40 +01:00
|
|
|
Copyright 2006-2025 The QElectroTech Team
|
2020-10-17 20:25:30 +02: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-12-01 10:47:15 +00:00
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
#ifndef PART_ELLIPSE_H
|
|
|
|
#define PART_ELLIPSE_H
|
2015-02-09 08:57:40 +00:00
|
|
|
|
|
|
|
#include "abstractpartellipse.h"
|
2015-07-20 17:45:37 +00:00
|
|
|
|
2015-07-20 21:06:00 +00:00
|
|
|
class QPropertyUndoCommand;
|
2015-02-09 08:57:40 +00:00
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
2020-10-17 20:25:30 +02:00
|
|
|
@brief The PartEllipse class
|
|
|
|
This class represents an ellipse primitive which may be used to compose the
|
|
|
|
drawing of an electrical element within the element editor.
|
2020-08-16 11:19:36 +02:00
|
|
|
*/
|
2025-02-14 20:31:03 +01:00
|
|
|
class PartEllipse : public AbstractPartEllipse
|
2015-02-09 08:57:40 +00:00
|
|
|
{
|
2020-10-17 20:25:30 +02:00
|
|
|
Q_OBJECT
|
2015-02-09 08:57:40 +00:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
// constructors, destructor
|
|
|
|
public:
|
|
|
|
PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
|
|
|
|
~PartEllipse() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
PartEllipse(const PartEllipse &);
|
|
|
|
|
2025-02-14 20:31:03 +01:00
|
|
|
signals:
|
|
|
|
void rotationChanged();
|
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
// methods
|
|
|
|
public:
|
|
|
|
enum { Type = UserType + 1103 };
|
|
|
|
/**
|
|
|
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartEllipse.
|
|
|
|
@return the QGraphicsItem type
|
|
|
|
*/
|
|
|
|
int type() const override { return Type; }
|
|
|
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
2014-05-29 13:46:04 +00:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
//Name and XML
|
2021-03-11 19:52:50 +01:00
|
|
|
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
2020-10-17 20:25:30 +02:00
|
|
|
QString xmlName() const override { return(QString("ellipse")); }
|
2021-03-11 19:52:50 +01:00
|
|
|
const QDomElement toXml (QDomDocument &) const override;
|
|
|
|
void fromXml (const QDomElement &) override;
|
2020-10-17 20:25:30 +02:00
|
|
|
QPainterPath shape() const override;
|
|
|
|
QPainterPath shadowShape() const override;
|
2025-02-14 16:47:39 +01:00
|
|
|
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjustHandlerPos();}
|
2025-02-14 20:31:03 +01:00
|
|
|
void setRotation(qreal angle);
|
|
|
|
qreal rotation() const;
|
|
|
|
void flip();
|
|
|
|
void mirror();
|
2015-07-20 17:45:37 +00:00
|
|
|
|
2022-08-13 12:40:59 +02:00
|
|
|
void addHandler() override;
|
|
|
|
void removeHandler() override;
|
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
protected:
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
|
|
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
2015-07-20 17:45:37 +00:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
private:
|
|
|
|
void switchResizeMode();
|
2025-02-14 16:47:39 +01:00
|
|
|
void adjustHandlerPos();
|
2020-10-17 20:25:30 +02:00
|
|
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
2021-03-11 19:52:50 +01:00
|
|
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
2020-10-17 20:25:30 +02:00
|
|
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
2016-07-19 17:12:30 +00:00
|
|
|
|
2020-10-17 20:25:30 +02:00
|
|
|
private:
|
|
|
|
QPropertyUndoCommand *m_undo_command;
|
|
|
|
int m_resize_mode = 1,
|
|
|
|
m_vector_index = -1;
|
2025-02-14 20:31:03 +01:00
|
|
|
qreal m_rot = 0;
|
2007-06-30 17:41:07 +00:00
|
|
|
};
|
|
|
|
#endif
|