32 m_undo_command(nullptr)
52 void PartEllipse::paint(QPainter *painter,
const QStyleOptionGraphicsItem *options, QWidget *widget)
57 QPen t = painter -> pen();
58 t.setCosmetic(options && options -> levelOfDetail < 1.0);
64 painter -> drawEllipse(
rect());
81 QDomElement xml_element;
82 if (qFuzzyCompare(
rect().width(),
rect().height()))
84 xml_element = xml_document.createElement(
"circle");
85 xml_element.setAttribute(
"diameter", QString(
"%1").arg(
rect().width()));
89 xml_element = xml_document.createElement(
"ellipse");
90 xml_element.setAttribute(
"width", QString(
"%1").arg(
rect().width()));
91 xml_element.setAttribute(
"height", QString(
"%1").arg(
rect().height()));
95 xml_element.setAttribute(
"x", QString(
"%1").arg(top_left.x()));
96 xml_element.setAttribute(
"y", QString(
"%1").arg(top_left.y()));
113 if (qde.tagName() ==
"ellipse")
115 width = qde.attribute(
"width",
"0").toDouble();
116 height = qde.attribute(
"height",
"0").toDouble();
119 width = height = qde.attribute(
"diameter",
"0").toDouble();
121 m_rect = QRectF(mapFromScene(qde.attribute(
"x",
"0").toDouble(),
122 qde.attribute(
"y",
"0").toDouble()),
123 QSizeF(width, height));
135 QPainterPathStroker pps;
147 QPainterPathStroker pps;
150 return (pps.createStroke(
shape));
160 if (event->button() == Qt::LeftButton &&
event->buttonDownPos(Qt::LeftButton) ==
event->pos())
174 if (change == ItemSelectedHasChanged && scene())
176 if (value.toBool() ==
true)
182 if (scene()->selectedItems().size() == 1)
191 else if (change == ItemPositionHasChanged)
195 else if (change == ItemSceneChange)
203 return QGraphicsItem::itemChange(change, value);
224 if(event->type() == QEvent::GraphicsSceneMousePress)
229 else if(event->type() == QEvent::GraphicsSceneMouseMove)
234 else if (event->type() == QEvent::GraphicsSceneMouseRelease)
252 qghi->setColor(Qt::darkGreen);
258 qghi->setColor(Qt::blue);
274 points_vector = mapToScene(points_vector);
275 for (
int i = 0 ; i < points_vector.size() ; ++i)
305 QPointF new_pos =
event->scenePos();
306 if (event->modifiers() != Qt::ControlModifier)
308 new_pos = mapFromScene(new_pos);
340 if (this->isSelected() && scene()->selectedItems().size() == 1)
358 QColor
color = Qt::blue;
360 color = Qt::darkGreen;
362 handler->setColor(
color);
363 scene()->addItem(handler);
364 handler->installSceneEventFilter(
this);
365 handler->setZValue(this->zValue()+1);
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
QPainterPath shape() const override
PartEllipse::shape.
PartEllipse(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
PartEllipse::PartEllipse Constructor.
const QDomElement toXml(QDomDocument &) const override
PartEllipse::toXml Export this ellipse in xml.
~PartEllipse() override
PartEllipse::~PartEllipse Destructor.
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMousePressEvent.
void fromXml(const QDomElement &) override
PartEllipse::fromXml Import the properties of this ellipse from a xml element.
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMouseMoveEvent.
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartEllipse::sceneEventFilter.
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartEllipse::paint Draw this ellpise.
void enableAnimation(bool animate=true)
QPropertyUndoCommand::enableAnimation True to enable animation.
static void drawCross(const QPointF ¢er, QPainter *painter)
CustomElementGraphicPart::drawCross Draw a cross at pos center.
QVector< QetGraphicsHandlerItem * > m_handler_vector
The AbstractPartEllipse class This is the base class for all ellipse based item like ellipse...
static QRectF mirrorRectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::mirrorRectForPosAtIndex Return a rectangle after modification of the point...
void sceneSelectionChanged()
PartEllipse::sceneSelectionChanged When the scene selection change, if there are several primitive se...
void removeHandler()
PartEllipse::removeHandler Remove the handlers of this item.
void stylesToXml(QDomElement &) const
CustomElementGraphicPart::stylesToXml Write the curent style to xml element. The style are stored lik...
static QRectF rectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::rectForPosAtIndex Return a rectangle after modification of the point '' at...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
void adjusteHandlerPos()
PartEllipse::adjusteHandlerPos.
QPropertyUndoCommand * m_undo_command
void setRect(const QRectF &rect) override
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartEllipse::mouseReleaseEvent Handle mouse release event.
virtual QPointF sceneTopLeft() const
AbstractPartEllipse::sceneTopLeft.
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartEllipse::handlerMouseReleaseEvent.
void stylesFromXml(const QDomElement &)
CustomElementGraphicPart::stylesFromXml Read the style used by this, from a xml element.
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartEllipse::itemChange.
static QVector< QPointF > pointsForRect(const QRectF &rect)
QetGraphicsHandlerUtility::pointsForRect Return the keys points of the rectangle, stored in a vector...
void addHandler()
PartEllipse::addHandler Add handlers for this item.
QPainterPath shadowShape() const override
virtual ElementScene * elementScene() const
static QVector< QetGraphicsHandlerItem * > handlerForPoint(const QVector< QPointF > &points, int size=10)
QetGraphicsHandlerItem::handlerForPoint.
qreal penWeight() const
CustomElementGraphicPart::penWeight.
void applyStylesToQPainter(QPainter &) const
CustomElementGraphicPart::applyStylesToQPainter Apply the current style to the QPainter.
QPointF snapToGrid(QPointF point)
void setNewValue(const QVariant &new_value)
QPropertyUndoCommand::setNewValue Set the new value of the property (set with redo) to ...
void drawShadowShape(QPainter *painter)
CustomElementGraphicPart::drawShadowShape Draw a transparent blue shadow arround the shape of this it...