55 void PartArc::paint(QPainter *painter,
const QStyleOptionGraphicsItem *options, QWidget *widget)
62 painter -> setBrush(Qt::NoBrush);
63 QPen t = painter -> pen();
64 t.setCosmetic(options && options -> levelOfDetail < 1.0);
70 QPen pen(Qt::DotLine);
72 pen.setCosmetic(
true);
75 painter -> drawEllipse(
rect());
99 QDomElement xml_element = xml_document.createElement(
"arc");
101 xml_element.setAttribute(
"x", QString(
"%1").arg(top_left.x()));
102 xml_element.setAttribute(
"y", QString(
"%1").arg(top_left.y()));
103 xml_element.setAttribute(
"width", QString(
"%1").arg(
rect().width()));
104 xml_element.setAttribute(
"height", QString(
"%1").arg(
rect().height()));
106 xml_element.setAttribute(
"start", QString(
"%1").arg(
m_start_angle / 16));
107 xml_element.setAttribute(
"angle", QString(
"%1").arg(
m_span_angle / 16));
119 m_rect = QRectF(mapFromScene(qde.attribute(
"x",
"0").toDouble(),
120 qde.attribute(
"y",
"0").toDouble()),
121 QSizeF(qde.attribute(
"width",
"0").toDouble(),
122 qde.attribute(
"height",
"0").toDouble()) );
125 m_span_angle = qde.attribute(
"angle",
"-1440").toDouble() * 16;
138 QPainterPathStroker pps;
151 QPainterPathStroker pps;
154 return (pps.createStroke(
shape));
164 if (event->button() == Qt::LeftButton &&
event->buttonDownPos(Qt::LeftButton) ==
event->pos())
178 if (change == ItemSelectedHasChanged && scene())
180 if (value.toBool() ==
true)
186 if (scene()->selectedItems().size() == 1)
195 else if (change == ItemPositionHasChanged)
199 else if (change == ItemSceneChange)
207 return QGraphicsItem::itemChange(change, value);
228 if(event->type() == QEvent::GraphicsSceneMousePress)
233 else if(event->type() == QEvent::GraphicsSceneMouseMove)
238 else if (event->type() == QEvent::GraphicsSceneMouseRelease)
259 qghi->setColor(Qt::darkGreen);
270 qghi->setColor(Qt::magenta);
281 qghi->setColor(Qt::blue);
293 QVector <QPointF> points_vector;
303 points_vector = mapToScene(points_vector);
304 for (
int i = 0 ; i < points_vector.size() ; ++i)
357 QPointF new_pos =
event->scenePos();
358 if (event->modifiers() != Qt::ControlModifier)
360 new_pos = mapFromScene(new_pos);
368 QLineF line(
m_rect.center(), mapFromScene(event->scenePos()));
369 prepareGeometryChange();
429 if (this->isSelected() && scene()->selectedItems().size() == 1)
452 QColor
color = Qt::blue;
454 color = Qt::darkGreen;
458 handler->setColor(
color);
459 scene()->addItem(handler);
460 handler->installSceneEventFilter(
this);
461 handler->setZValue(this->zValue()+1);
void fromXml(const QDomElement &) override
PartArc::fromXml Import the properties of this arc from a xml element.
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
void setRect(const QRectF &rect) override
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
static QVector< QPointF > pointsForArc(const QRectF &rect, qreal start_angle, qreal span_angle)
QetGraphicsHandlerUtility::pointsForArc Return the points for the given arc. The first value in the v...
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartArc::mouseReleaseEvent Handle mouse release event.
void setStartAngle(const int &start_angle) override
AbstractPartEllipse::setStartAngle Sets the start angle for an ellipse segment to angle...
QPainterPath shape() const override
PartArc::shape.
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.
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartArc::itemChange.
~PartArc() override
PartArc::~PartArc Destructor.
The AbstractPartEllipse class This is the base class for all ellipse based item like ellipse...
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartArc::paint Draw this arc.
void removeHandler()
PartArc::removeHandler Remove the handlers of this item.
static QRectF mirrorRectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::mirrorRectForPosAtIndex Return a rectangle after modification of the point...
void setSpanAngle(const int &span_angle) override
AbstractPartEllipse::setSpanAngle Returns the span angle of an ellipse segment in 16ths of a degree...
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartArc::sceneEventFilter.
void stylesToXml(QDomElement &) const
CustomElementGraphicPart::stylesToXml Write the curent style to xml element. The style are stored lik...
QPainterPath shadowShape() const override
static QRectF rectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::rectForPosAtIndex Return a rectangle after modification of the point '' at...
void switchResizeMode()
PartArc::switchResizeMode.
void adjusteHandlerPos()
PartArc::adjusteHandlerPos.
PartArc(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
PartArc::PartArc Constructor.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
const QDomElement toXml(QDomDocument &) const override
PartArc::toXml Export this arc in xml.
QPropertyUndoCommand * m_undo_command2
void addHandler()
PartArc::addHandler Add handlers for this item.
virtual QPointF sceneTopLeft() const
AbstractPartEllipse::sceneTopLeft.
void stylesFromXml(const QDomElement &)
CustomElementGraphicPart::stylesFromXml Read the style used by this, from a xml element.
void sceneSelectionChanged()
PartArc::sceneSelectionChanged When the scene selection change, if there are several primitive select...
static QVector< QPointF > pointsForRect(const QRectF &rect)
QetGraphicsHandlerUtility::pointsForRect Return the keys points of the rectangle, stored in a vector...
QVector< QetGraphicsHandlerItem * > m_handler_vector
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMouseMoveEvent.
QPropertyUndoCommand * m_undo_command
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMouseReleaseEvent.
virtual ElementScene * elementScene() const
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMousePressEvent.
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...