Grainline should now be visible in Layout mode
--HG-- branch : feature
This commit is contained in:
parent
46eb6dfaa3
commit
8ab094c40d
52
src/libs/vlayout/vgraphicsfillitem.cpp
Normal file
52
src/libs/vlayout/vgraphicsfillitem.cpp
Normal file
|
@ -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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
55
src/libs/vlayout/vgraphicsfillitem.h
Normal file
55
src/libs/vlayout/vgraphicsfillitem.h
Normal file
|
@ -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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef VGRAPHICSFILLITEM_H
|
||||||
|
#define VGRAPHICSFILLITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
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
|
|
@ -17,7 +17,8 @@ HEADERS += \
|
||||||
$$PWD/vbestsquare.h \
|
$$PWD/vbestsquare.h \
|
||||||
$$PWD/vposition.h \
|
$$PWD/vposition.h \
|
||||||
$$PWD/vtextmanager.h \
|
$$PWD/vtextmanager.h \
|
||||||
vposter.h
|
vposter.h \
|
||||||
|
vgraphicsfillitem.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vlayoutgenerator.cpp \
|
$$PWD/vlayoutgenerator.cpp \
|
||||||
|
@ -29,6 +30,7 @@ SOURCES += \
|
||||||
$$PWD/vbestsquare.cpp \
|
$$PWD/vbestsquare.cpp \
|
||||||
$$PWD/vposition.cpp \
|
$$PWD/vposition.cpp \
|
||||||
$$PWD/vtextmanager.cpp \
|
$$PWD/vtextmanager.cpp \
|
||||||
vposter.cpp
|
vposter.cpp \
|
||||||
|
vgraphicsfillitem.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include "vlayoutdef.h"
|
#include "vlayoutdef.h"
|
||||||
#include "vlayoutdetail_p.h"
|
#include "vlayoutdetail_p.h"
|
||||||
#include "vtextmanager.h"
|
#include "vtextmanager.h"
|
||||||
|
#include "vgraphicsfillitem.h"
|
||||||
|
|
||||||
class QGraphicsPathItem;
|
class QGraphicsPathItem;
|
||||||
class QLineF;
|
class QLineF;
|
||||||
|
@ -213,7 +214,32 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine
|
||||||
pt2.setX(pt1.x() + dLen * qCos(dAng));
|
pt2.setX(pt1.x() + dLen * qCos(dAng));
|
||||||
pt2.setY(pt1.y() - dLen * qSin(dAng));
|
pt2.setY(pt1.y() - dLen * qSin(dAng));
|
||||||
QVector<QPointF> v;
|
QVector<QPointF> 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;
|
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);
|
d->grainlinePoints = RoundPoints(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,11 +739,11 @@ QGraphicsItem *VLayoutDetail::GetItem() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsItem* VLayoutDetail::GetGrainlineItem() const
|
QGraphicsItem* VLayoutDetail::GetGrainlineItem() const
|
||||||
{
|
{
|
||||||
if (d->grainlinePoints.count() < 2)
|
if (d->grainlinePoints.count() < 6)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QGraphicsPathItem* item = new QGraphicsPathItem();
|
VGraphicsFillItem* item = new VGraphicsFillItem();
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
QVector<QPointF> v = Map(d->grainlinePoints);
|
QVector<QPointF> v = Map(d->grainlinePoints);
|
||||||
path.moveTo(v.at(0));
|
path.moveTo(v.at(0));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vgrainlineitem.h
|
** @file vgrainlineitem.cpp
|
||||||
** @author Bojan Kverh
|
** @author Bojan Kverh
|
||||||
** @date September 10, 2016
|
** @date September 10, 2016
|
||||||
**
|
**
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#include "vgrainlineitem.h"
|
#include "vgrainlineitem.h"
|
||||||
|
|
||||||
#define ARROW_ANGLE 0.35
|
#define ARROW_ANGLE M_PI/9
|
||||||
#define ARROW_LENGTH 15
|
#define ARROW_LENGTH 15
|
||||||
#define RECT_WIDTH 30
|
#define RECT_WIDTH 30
|
||||||
#define RESIZE_RECT_SIZE 10
|
#define RESIZE_RECT_SIZE 10
|
||||||
|
|
Loading…
Reference in New Issue
Block a user