QElectroTech  0.8-dev
partellipse.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 PART_ELLIPSE_H
19 #define PART_ELLIPSE_H
20 
21 #include "abstractpartellipse.h"
22 
24 
31 {
32  Q_OBJECT
33 
34  // constructors, destructor
35  public:
36  PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
37  ~PartEllipse() override;
38 
39  private:
41 
42  // methods
43  public:
44  enum { Type = UserType + 1103 };
49  int type() const override { return Type; }
50  void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
51 
52  //Name and XML
53  QString name() const override { return(QObject::tr("ellipse", "element part name")); }
54  QString xmlName() const override { return(QString("ellipse")); }
55  const QDomElement toXml (QDomDocument &) const override;
56  void fromXml (const QDomElement &) override;
57  QPainterPath shape() const override;
58  QPainterPath shadowShape() const override;
59  void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
60 
61  protected:
62  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
63  QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
64  bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
65 
66  private:
67  void switchResizeMode();
68  void adjusteHandlerPos();
69  void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
70  void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
71  void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
72  void sceneSelectionChanged ();
73 
74  void addHandler();
75  void removeHandler();
76 
77  private:
79  int m_resize_mode = 1,
81 };
82 #endif
qetgraphicshandlerutility.h
PartEllipse::fromXml
void fromXml(const QDomElement &) override
PartEllipse::fromXml Import the properties of this ellipse from a xml element.
Definition: partellipse.cpp:108
QPropertyUndoCommand::enableAnimation
void enableAnimation(bool animate=true)
QPropertyUndoCommand::enableAnimation True to enable animation.
Definition: qpropertyundocommand.cpp:92
ElementScene::snapToGrid
QPointF snapToGrid(QPointF point)
ElementScene::snapToGrid Rounds the coordinates of the point passed as a parameter so that this point...
Definition: elementscene.cpp:1270
QetGraphicsHandlerItem::Type
@ Type
Definition: qetgraphicshandleritem.h:42
PartEllipse::handlerMouseMoveEvent
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMouseMoveEvent.
Definition: partellipse.cpp:301
ElementScene::undoStack
QUndoStack & undoStack()
ElementScene::undoStack.
Definition: elementscene.cpp:603
PartEllipse::m_undo_command
QPropertyUndoCommand * m_undo_command
Definition: partellipse.h:78
abstractpartellipse.h
CustomElementGraphicPart::drawCross
static void drawCross(const QPointF &center, QPainter *painter)
CustomElementGraphicPart::drawCross Draw a cross at pos center.
Definition: customelementgraphicpart.cpp:60
PartEllipse::setRect
void setRect(const QRectF &rect) override
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
Definition: partellipse.h:59
partellipse.h
PartEllipse::removeHandler
void removeHandler()
PartEllipse::removeHandler Remove the handlers of this item.
Definition: partellipse.cpp:374
PartEllipse::name
QString name() const override
Definition: partellipse.h:53
CustomElementGraphicPart::stylesToXml
void stylesToXml(QDomElement &) const
CustomElementGraphicPart::stylesToXml Write the curent style to xml element. The style are stored lik...
Definition: customelementgraphicpart.cpp:162
QPropertyUndoCommand::setNewValue
void setNewValue(const QVariant &new_value)
QPropertyUndoCommand::setNewValue Set the new value of the property (set with redo) to new_value.
Definition: qpropertyundocommand.cpp:83
CustomElementGraphicPart::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Definition: customelementgraphicpart.cpp:1318
AbstractPartEllipse::setRect
virtual void setRect(const QRectF &rect)
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
Definition: abstractpartellipse.cpp:119
PartEllipse::toXml
const QDomElement toXml(QDomDocument &) const override
PartEllipse::toXml Export this ellipse in xml.
Definition: partellipse.cpp:79
PartEllipse::paint
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartEllipse::paint Draw this ellpise.
Definition: partellipse.cpp:52
PartEllipse::sceneEventFilter
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartEllipse::sceneEventFilter.
Definition: partellipse.cpp:212
PartEllipse::handlerMouseReleaseEvent
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMouseReleaseEvent.
Definition: partellipse.cpp:323
PartEllipse::m_vector_index
int m_vector_index
Definition: partellipse.h:80
PartEllipse::~PartEllipse
~PartEllipse() override
PartEllipse::~PartEllipse Destructor.
Definition: partellipse.cpp:39
CustomElementGraphicPart::stylesFromXml
void stylesFromXml(const QDomElement &)
CustomElementGraphicPart::stylesFromXml Read the style used by this, from a xml element.
Definition: customelementgraphicpart.cpp:508
QetGraphicsHandlerUtility::mirrorRectForPosAtIndex
static QRectF mirrorRectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::mirrorRectForPosAtIndex Return a rectangle after modification of the point...
Definition: qetgraphicshandlerutility.cpp:139
PartEllipse::itemChange
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartEllipse::itemChange.
Definition: partellipse.cpp:172
PartEllipse::PartEllipse
PartEllipse(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
PartEllipse::PartEllipse Constructor.
Definition: partellipse.cpp:30
PartEllipse
The PartEllipse class This class represents an ellipse primitive which may be used to compose the dra...
Definition: partellipse.h:31
QetGraphicsHandlerUtility::pointsForRect
static QVector< QPointF > pointsForRect(const QRectF &rect)
QetGraphicsHandlerUtility::pointsForRect Return the keys points of the rectangle, stored in a vector....
Definition: qetgraphicshandlerutility.cpp:36
PartEllipse::Type
@ Type
Definition: partellipse.h:44
AbstractPartEllipse::sceneTopLeft
virtual QPointF sceneTopLeft() const
AbstractPartEllipse::sceneTopLeft.
Definition: abstractpartellipse.cpp:98
PartEllipse::handlerMousePressEvent
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMousePressEvent.
Definition: partellipse.cpp:285
elementscene.h
AbstractPartEllipse
The AbstractPartEllipse class This is the base class for all ellipse based item like ellipse,...
Definition: abstractpartellipse.h:40
qpropertyundocommand.h
PartEllipse::addHandler
void addHandler()
PartEllipse::addHandler Add handlers for this item.
Definition: partellipse.cpp:350
QetGraphicsHandlerUtility::rectForPosAtIndex
static QRectF rectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::rectForPosAtIndex Return a rectangle after modification of the point 'pos'...
Definition: qetgraphicshandlerutility.cpp:106
qetgraphicshandleritem.h
PartEllipse::switchResizeMode
void switchResizeMode()
Definition: partellipse.cpp:246
AbstractPartEllipse::m_handler_vector
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition: abstractpartellipse.h:84
QetGraphicsHandlerItem
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition: qetgraphicshandleritem.h:37
PartEllipse::m_resize_mode
int m_resize_mode
Definition: partellipse.h:79
CustomElementGraphicPart::m_hovered
bool m_hovered
Definition: customelementgraphicpart.h:323
AbstractPartEllipse::rect
QRectF rect
Definition: abstractpartellipse.h:44
SHADOWS_HEIGHT
#define SHADOWS_HEIGHT
Definition: customelementgraphicpart.h:37
PartEllipse::type
int type() const override
Definition: partellipse.h:49
CustomElementGraphicPart::color
Color color
Definition: customelementgraphicpart.h:44
PartEllipse::adjusteHandlerPos
void adjusteHandlerPos()
PartEllipse::adjusteHandlerPos.
Definition: partellipse.cpp:265
PartEllipse::shadowShape
QPainterPath shadowShape() const override
Definition: partellipse.cpp:142
CustomElementPart::elementScene
virtual ElementScene * elementScene() const
Definition: customelementpart.cpp:37
CustomElementGraphicPart::applyStylesToQPainter
void applyStylesToQPainter(QPainter &) const
CustomElementGraphicPart::applyStylesToQPainter Apply the current style to the QPainter.
Definition: customelementgraphicpart.cpp:885
CustomElementGraphicPart::penWeight
qreal penWeight() const
CustomElementGraphicPart::penWeight.
Definition: customelementgraphicpart.cpp:109
PartEllipse::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartEllipse::mouseReleaseEvent Handle mouse release event.
Definition: partellipse.cpp:158
AbstractPartEllipse::m_rect
QRectF m_rect
Definition: abstractpartellipse.h:81
QPropertyUndoCommand
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
Definition: qpropertyundocommand.h:34
PartEllipse::PartEllipse
PartEllipse(const PartEllipse &)
QetGraphicsHandlerItem::handlerForPoint
static QVector< QetGraphicsHandlerItem * > handlerForPoint(const QVector< QPointF > &points, int size=10)
QetGraphicsHandlerItem::handlerForPoint.
Definition: qetgraphicshandleritem.cpp:87
PartEllipse::shape
QPainterPath shape() const override
PartEllipse::shape.
Definition: partellipse.cpp:130
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
PartEllipse::xmlName
QString xmlName() const override
Definition: partellipse.h:54
QETElementEditor
Definition: qetelementeditor.h:33
CustomElementGraphicPart::drawShadowShape
void drawShadowShape(QPainter *painter)
CustomElementGraphicPart::drawShadowShape Draw a transparent blue shadow arround the shape of this it...
Definition: customelementgraphicpart.cpp:1240
PartEllipse::sceneSelectionChanged
void sceneSelectionChanged()
PartEllipse::sceneSelectionChanged When the scene selection change, if there are several primitive se...
Definition: partellipse.cpp:338