56 #include <QGraphicsScene>
57 #include <QGraphicsSceneMouseEvent>
58 #include <QGuiApplication>
62 #include <QSharedPointer>
66 #include "../ifc/exception/vexception.h"
67 #include "../ifc/exception/vexceptionbadid.h"
68 #include "../ifc/xml/vabstractpattern.h"
69 #include "../qmuparser/qmutokenparser.h"
70 #include "../vgeometry/vgobject.h"
71 #include "../vgeometry/vpointf.h"
72 #include "../vgeometry/vspline.h"
73 #include "../vpatterndb/vcontainer.h"
74 #include "../vwidgets/vcontrolpointspline.h"
75 #include "../../../visualization/line/visline.h"
76 #include "../../vabstracttool.h"
77 #include "../vdrawtool.h"
82 , QGraphicsPathItem(parent)
86 , m_piecesMode(
qApp->Settings()->getShowControlPoints())
89 setAcceptHoverEvents(
true);
99 for (qint32 i = 0; i < points.count()-1; ++i)
101 path.moveTo(points.at(i));
102 path.lineTo(points.at(i+1));
111 path.setFillRule(Qt::WindingFill);
134 QPen arrowPen(pen());
135 arrowPen.setStyle(Qt::SolidLine);
137 painter->setPen(arrowPen);
138 painter->setBrush(brush());
147 QGraphicsPathItem::paint(painter, option, widget);
170 this->setEnabled(enabled);
185 setAcceptHoverEvents(enabled);
191 setFlag(QGraphicsItem::ItemIsSelectable, enabled);
199 const QString toolTip = QString(
"<table>"
200 "<tr> <td><b> %4:</b> %5</td> </tr>"
201 "<tr> <td><b>%1:</b> %2 %3</td> </tr>"
204 .arg(
qApp->fromPixel(curve->GetLength()))
241 QGraphicsPathItem::hoverEnterEvent(event);
253 QGraphicsPathItem::hoverLeaveEvent(event);
265 if (change == QGraphicsItem::ItemSelectedChange)
270 return QGraphicsPathItem::itemChange(change, value);
280 switch (event->key())
296 QGraphicsPathItem::keyReleaseEvent ( event );
303 QGraphicsPathItem::mousePressEvent(event);
306 if (not (flags() & ItemIsSelectable) && scene())
308 scene()->clearSelection();
321 if (event->button() == Qt::LeftButton)
325 QGraphicsPathItem::mouseReleaseEvent(event);
359 const QPointF &pos)
const
364 QLineF line(
static_cast<QPointF
>(spline.
GetP1()), pos);
365 if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
370 qreal newAngle1 = line.angle();
371 QString newAngle1F = QString().setNum(newAngle1);
373 qreal newLength1 = line.length();
374 QString newLength1F = QString().setNum(
qApp->fromPixel(newLength1));
394 QLineF line(
static_cast<QPointF
>(spline.
GetP4()), pos);
395 if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
400 qreal newAngle2 = line.angle();
401 QString newAngle2F = QString().setNum(newAngle2);
403 qreal newLength2 = line.length();
404 QString newLength2F = QString().setNum(
qApp->fromPixel(newLength2));
419 newLength2, newLength2F);
429 this->setPath(curve->GetPath());
445 return curve->getLineColor();
452 curve->setLineColor(value);
461 return curve->GetPenStyle();
468 curve->SetPenStyle(value);
481 return curve->getLineWeight();
492 curve->setLineWeight(value);
500 return ObjectName<VAbstractCurve>(
m_id);
static const qreal lengthCurveDirectionArrow
static QPainterPath ShowDirection(const QVector< DirectionArrow > &arrows, qreal width)
static const QString TagSpline
QString useGroupColor(quint32 toolId, QString color)
QString useGroupLineWeight(quint32 toolId, QString weight)
QString useGroupLineType(quint32 toolId, QString type)
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
virtual QPainterPath shape() const Q_DECL_OVERRIDE
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mouseReleaseEvent handle mouse release events.
void setLineColor(const QString &value)
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE
void SetPenStyle(const QString &value)
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE
ShowTool highlight tool.
virtual void piecesMode(bool mode) Q_DECL_OVERRIDE
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE
void setEnabledPoint(bool enable)
setEnabledPoint disable control points.
virtual void RefreshGeometry()
RefreshGeometry refresh item on scene.
virtual void refreshCtrlPoints()
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
virtual QString getTagName() const Q_DECL_OVERRIDE
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverEnterEvent handle hover enter events.
QString getLineColor() const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
void setLineWeight(const QString &value)
setLineWeight set line weight of the spline
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE
FullUpdateFromFile update tool data form file.
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverLeaveEvent handle hover leave events.
virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE
keyReleaseEvent handle key release events.
virtual QString makeToolTip() const Q_DECL_OVERRIDE
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE
itemChange hadle item change.
QVector< VControlPointSpline * > controlPoints
controlPoints list pointers of control points.
virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE
QString GetPenStyle() const
VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent=nullptr)
void ShowHandles(bool show)
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE
QString getLineWeight() const
getLineWeight return line weight of the spline
VSpline CorrectedSpline(const VSpline &spline, const SplinePointPosition &position, const QPointF &pos) const
The VContainer class container of all variables.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
VSpline class that implements the spline.
virtual qreal GetC2Length() const Q_DECL_OVERRIDE
virtual VPointF GetP4() const Q_DECL_OVERRIDE
GetP4 return last spline point.
QString GetC1LengthFormula() const
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
GetAngle1 return first angle control line.
virtual VPointF GetP1() const Q_DECL_OVERRIDE
GetP1 return first spline point.
QString GetStartAngleFormula() const
QString GetEndAngleFormula() const
virtual qreal GetC1Length() const Q_DECL_OVERRIDE
QString GetC2LengthFormula() const
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
GetAngle2 return second angle control line.
static qreal CorrectAngle(const qreal &angle)
static bool IsSingle(const QString &formula)
IsSingle test formula and return true if it contain only one number.
double ToPixel(double val, const Unit &unit)
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
qreal sceneScale(QGraphicsScene *scene)
QPainterPath ItemShapeFromPath(const QPainterPath &path, const QPen &pen)
qreal scaleWidth(qreal width, qreal scale)
QColor correctColor(const QGraphicsItem *item, const QColor &color)
const QString AttrLineWeight
const QString AttrPenStyle
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.