diff --git a/src/libs/vlayout/vgraphicsfillitem.cpp b/src/libs/vlayout/vgraphicsfillitem.cpp new file mode 100644 index 000000000..4edcb17cb --- /dev/null +++ b/src/libs/vlayout/vgraphicsfillitem.cpp @@ -0,0 +1,52 @@ +/************************************************************************ + ** + ** @file vgraphicsfillitem.cpp + ** @author Bojan Kverh + ** @date October 16, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#include "vgraphicsfillitem.h" + +//--------------------------------------------------------------------------------------------------------------------- +VGraphicsFillItem::VGraphicsFillItem() + :QGraphicsPathItem() +{} + +//--------------------------------------------------------------------------------------------------------------------- +VGraphicsFillItem::~VGraphicsFillItem() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsFillItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + painter->save(); + painter->setBrush(painter->pen().color()); + painter->drawPath(path()); + painter->restore(); +} + +//--------------------------------------------------------------------------------------------------------------------- + diff --git a/src/libs/vlayout/vgraphicsfillitem.h b/src/libs/vlayout/vgraphicsfillitem.h new file mode 100644 index 000000000..467d62e12 --- /dev/null +++ b/src/libs/vlayout/vgraphicsfillitem.h @@ -0,0 +1,55 @@ +/************************************************************************ + ** + ** @file vgraphicsfillitem.h + ** @author Bojan Kverh + ** @date October 16, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina 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 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina 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 Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VGRAPHICSFILLITEM_H +#define VGRAPHICSFILLITEM_H + +#include +#include + +class VGraphicsFillItem : public QGraphicsPathItem +{ +public: + /** + * @brief VGraphicsFillItem Constructor + */ + VGraphicsFillItem(); + /** + * @brief ~VGraphicsFillItem Destructor + */ + ~VGraphicsFillItem(); + /** + * @brief paint Paints the item, filling the inside surface + * @param painter pointer to the painter object + * @param option unused + * @param widget unused + */ + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); +}; + +#endif // VGRAPHICSFILLITEM_H diff --git a/src/libs/vlayout/vlayout.pri b/src/libs/vlayout/vlayout.pri index d1cc7645f..6d82d469f 100644 --- a/src/libs/vlayout/vlayout.pri +++ b/src/libs/vlayout/vlayout.pri @@ -17,7 +17,8 @@ HEADERS += \ $$PWD/vbestsquare.h \ $$PWD/vposition.h \ $$PWD/vtextmanager.h \ - vposter.h + vposter.h \ + vgraphicsfillitem.h SOURCES += \ $$PWD/vlayoutgenerator.cpp \ @@ -29,6 +30,7 @@ SOURCES += \ $$PWD/vbestsquare.cpp \ $$PWD/vposition.cpp \ $$PWD/vtextmanager.cpp \ - vposter.cpp + vposter.cpp \ + vgraphicsfillitem.cpp win32-msvc*:SOURCES += $$PWD/stable.cpp diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 16204c087..dc666987f 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -51,6 +51,7 @@ #include "vlayoutdef.h" #include "vlayoutdetail_p.h" #include "vtextmanager.h" +#include "vgraphicsfillitem.h" class QGraphicsPathItem; class QLineF; @@ -213,7 +214,32 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine pt2.setX(pt1.x() + dLen * qCos(dAng)); pt2.setY(pt1.y() - dLen * qSin(dAng)); QVector v; + QPointF pt; + qreal dArrowLen = ToPixel(0.5, *rPattern.GetPatternUnit()); + qreal dArrowAng = M_PI/9; + + v << pt1; + + pt.setX(pt1.x() + dArrowLen * qCos(dAng + dArrowAng)); + pt.setY(pt1.y() - dArrowLen * qSin(dAng + dArrowAng)); + v << pt; + pt.setX(pt1.x() + dArrowLen * qCos(dAng - dArrowAng)); + pt.setY(pt1.y() - dArrowLen * qSin(dAng - dArrowAng)); + v << pt; + v << pt1 << pt2; + + dAng += M_PI; + + pt.setX(pt2.x() + dArrowLen * qCos(dAng + dArrowAng)); + pt.setY(pt2.y() - dArrowLen * qSin(dAng + dArrowAng)); + v << pt; + pt.setX(pt2.x() + dArrowLen * qCos(dAng - dArrowAng)); + pt.setY(pt2.y() - dArrowLen * qSin(dAng - dArrowAng)); + v << pt; + + v << pt2; + d->grainlinePoints = RoundPoints(v); } @@ -713,11 +739,11 @@ QGraphicsItem *VLayoutDetail::GetItem() const //--------------------------------------------------------------------------------------------------------------------- QGraphicsItem* VLayoutDetail::GetGrainlineItem() const { - if (d->grainlinePoints.count() < 2) + if (d->grainlinePoints.count() < 6) { return 0; } - QGraphicsPathItem* item = new QGraphicsPathItem(); + VGraphicsFillItem* item = new VGraphicsFillItem(); QPainterPath path; QVector v = Map(d->grainlinePoints); path.moveTo(v.at(0)); diff --git a/src/libs/vtools/tools/vgrainlineitem.cpp b/src/libs/vtools/tools/vgrainlineitem.cpp index 37546c553..ff4ae9bed 100644 --- a/src/libs/vtools/tools/vgrainlineitem.cpp +++ b/src/libs/vtools/tools/vgrainlineitem.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vgrainlineitem.h + ** @file vgrainlineitem.cpp ** @author Bojan Kverh ** @date September 10, 2016 ** @@ -38,7 +38,7 @@ #include "vgrainlineitem.h" -#define ARROW_ANGLE 0.35 +#define ARROW_ANGLE M_PI/9 #define ARROW_LENGTH 15 #define RECT_WIDTH 30 #define RESIZE_RECT_SIZE 10