Resolved issue #651. Improve feature: Layout orientation according to grainline.
--HG-- branch : develop
This commit is contained in:
parent
58dae6e9d9
commit
6016308d58
|
@ -3,6 +3,7 @@
|
|||
- [#894] Quick way to disable a passmark.
|
||||
- [#895] Improve path validation. Do not allow repeat the same curve twice.
|
||||
- Improve UI. Make placeholder menu scrollable.
|
||||
- [#651] Improve feature: Layout orientation according to grainline.
|
||||
|
||||
# Version 0.6.2 (unreleased)
|
||||
- [#903] Bug in tool Cut Spline path.
|
||||
|
|
4
dist/OBS_debian/debian.valentina.1
vendored
4
dist/OBS_debian/debian.valentina.1
vendored
|
@ -1,6 +1,6 @@
|
|||
.\" Manpage for valentina.
|
||||
.\" Contact dismine@gmail.com to correct errors.
|
||||
.TH valentina 1 "18 July, 2018" "valentina man page"
|
||||
.TH valentina 1 "27 December, 2018" "valentina man page"
|
||||
.SH NAME
|
||||
Valentina \- Pattern making program.
|
||||
.SH SYNOPSIS
|
||||
|
@ -179,6 +179,8 @@ The path to output destination folder. By default the directory at which the app
|
|||
.RB "Page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
|
||||
.IP "-r, --rotate <Angle>"
|
||||
.RB "Rotation in degrees (one of predefined, " "export mode" "). Default value is " "180" ". 0 is no-rotate. Valid values: 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 180. Each value show how many times details will be rotated. For example 180 mean two times (360/180=2) by 180 degree."
|
||||
.IP "--followGrainline"
|
||||
.RB "Order detail to follow grainline direction (" "export mode" ").
|
||||
.IP "-c, --crop"
|
||||
.RB "Auto crop unused length (" "export mode" ")."
|
||||
.IP "-u, --unite"
|
||||
|
|
4
dist/debian/valentina.1
vendored
4
dist/debian/valentina.1
vendored
|
@ -1,6 +1,6 @@
|
|||
.\" Manpage for valentina.
|
||||
.\" Contact dismine@gmail.com to correct errors.
|
||||
.TH valentina 1 "18 July, 2018" "valentina man page"
|
||||
.TH valentina 1 "27 December, 2018" "valentina man page"
|
||||
.SH NAME
|
||||
Valentina \- Pattern making program.
|
||||
.SH SYNOPSIS
|
||||
|
@ -179,6 +179,8 @@ The path to output destination folder. By default the directory at which the app
|
|||
.RB "Page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
|
||||
.IP "-r, --rotate <Angle>"
|
||||
.RB "Rotation in degrees (one of predefined, " "export mode" "). Default value is " "180" ". 0 is no-rotate. Valid values: 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 180. Each value show how many times details will be rotated. For example 180 mean two times (360/180=2) by 180 degree."
|
||||
.IP "--followGrainline"
|
||||
.RB "Order detail to follow grainline direction (" "export mode" ").
|
||||
.IP "-c, --crop"
|
||||
.RB "Auto crop unused length (" "export mode" ")."
|
||||
.IP "-u, --unite"
|
||||
|
|
|
@ -227,6 +227,11 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
|
|||
"60, 72, 90, 180"),
|
||||
translate("VCommandLine", "Angle")));
|
||||
|
||||
optionsIndex.insert(LONG_OPTION_FOLLOW_GRAINLINE, index++);
|
||||
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_FOLLOW_GRAINLINE,
|
||||
translate("VCommandLine",
|
||||
"Order detail to follow grainline direction (export mode).")));
|
||||
|
||||
optionsIndex.insert(LONG_OPTION_CROP, index++);
|
||||
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_CROP << LONG_OPTION_CROP,
|
||||
translate("VCommandLine", "Auto crop unused length (export mode).")));
|
||||
|
@ -568,6 +573,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
|
|||
}
|
||||
}
|
||||
diag.SetFields(margins);
|
||||
diag.SetFollowGrainline(parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_FOLLOW_GRAINLINE))));
|
||||
|
||||
diag.DialogAccepted(); // filling VLayoutGenerator
|
||||
|
||||
|
|
|
@ -232,6 +232,18 @@ void DialogLayoutSettings::SetRotate(bool state)
|
|||
ui->groupBoxRotate->setChecked(state);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogLayoutSettings::GetFollowGrainline() const
|
||||
{
|
||||
return ui->checkBoxFollowGrainline->isChecked();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutSettings::SetFollowGrainline(bool state)
|
||||
{
|
||||
ui->checkBoxFollowGrainline->setChecked(state);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int DialogLayoutSettings::GetIncrease() const
|
||||
{
|
||||
|
@ -564,6 +576,7 @@ void DialogLayoutSettings::DialogAccepted()
|
|||
generator->SetPaperWidth(GetPaperWidth());
|
||||
generator->SetShift(static_cast<quint32>(qFloor(GetShift())));
|
||||
generator->SetRotate(GetRotate());
|
||||
generator->SetFollowGrainline(GetFollowGrainline());
|
||||
generator->SetRotationIncrease(GetIncrease());
|
||||
generator->SetAutoCrop(GetAutoCrop());
|
||||
generator->SetSaveLength(IsSaveLength());
|
||||
|
@ -655,6 +668,7 @@ void DialogLayoutSettings::RestoreDefaults()
|
|||
SetShift(VSettings::GetDefLayoutShift());
|
||||
SetGroup(VSettings::GetDefLayoutGroup());
|
||||
SetRotate(VSettings::GetDefLayoutRotate());
|
||||
SetFollowGrainline(VSettings::GetDefLayoutFollowGrainline());
|
||||
SetIncrease(VSettings::GetDefLayoutRotationIncrease());
|
||||
SetFields(GetDefPrinterFields());
|
||||
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields());
|
||||
|
@ -1004,6 +1018,7 @@ void DialogLayoutSettings::ReadSettings()
|
|||
const qreal height = UnitConvertor(settings->GetLayoutPaperHeight(), Unit::Px, LayoutUnit());
|
||||
SheetSize(QSizeF(width, height));
|
||||
SetGroup(settings->GetLayoutGroup());
|
||||
SetFollowGrainline(settings->GetLayoutFollowGrainline());
|
||||
SetRotate(settings->GetLayoutRotate());
|
||||
SetIncrease(settings->GetLayoutRotationIncrease());
|
||||
SetAutoCrop(settings->GetLayoutAutoCrop());
|
||||
|
@ -1031,6 +1046,7 @@ void DialogLayoutSettings::WriteSettings() const
|
|||
settings->SetLayoutPaperWidth(GetPaperWidth());
|
||||
settings->SetLayoutShift(GetShift());
|
||||
settings->SetLayoutRotate(GetRotate());
|
||||
settings->SetLayoutFollowGrainline(GetFollowGrainline());
|
||||
settings->SetLayoutRotationIncrease(GetIncrease());
|
||||
settings->SetLayoutAutoCrop(GetAutoCrop());
|
||||
settings->SetLayoutSaveLength(IsSaveLength());
|
||||
|
|
|
@ -76,6 +76,9 @@ public:
|
|||
bool GetRotate() const;
|
||||
void SetRotate(bool state);
|
||||
|
||||
bool GetFollowGrainline() const;
|
||||
void SetFollowGrainline(bool state);
|
||||
|
||||
int GetIncrease() const;
|
||||
bool SetIncrease(int increase);
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>533</height>
|
||||
<width>601</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -326,6 +326,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -416,6 +429,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxFollowGrainline">
|
||||
<property name="text">
|
||||
<string>Follow grainline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -55,6 +55,7 @@ VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
|||
state(LayoutErrors::NoError),
|
||||
shift(0),
|
||||
rotate(true),
|
||||
followGrainline(false),
|
||||
rotationIncrease(180),
|
||||
autoCrop(false),
|
||||
saveLength(false),
|
||||
|
@ -140,6 +141,7 @@ void VLayoutGenerator::Generate()
|
|||
paper.SetLayoutWidth(bank->GetLayoutWidth());
|
||||
paper.SetPaperIndex(static_cast<quint32>(papers.count()));
|
||||
paper.SetRotate(rotate);
|
||||
paper.SetFollowGrainline(followGrainline);
|
||||
paper.SetRotationIncrease(rotationIncrease);
|
||||
paper.SetSaveLength(saveLength);
|
||||
do
|
||||
|
@ -347,6 +349,7 @@ void VLayoutGenerator::GatherPages()
|
|||
paper.SetLayoutWidth(bank->GetLayoutWidth());
|
||||
paper.SetPaperIndex(static_cast<quint32>(i));
|
||||
paper.SetRotate(rotate);
|
||||
paper.SetFollowGrainline(followGrainline);
|
||||
paper.SetRotationIncrease(rotationIncrease);
|
||||
paper.SetSaveLength(saveLength);
|
||||
paper.SetDetails(nDetails.at(i));
|
||||
|
@ -412,6 +415,7 @@ void VLayoutGenerator::UnitePages()
|
|||
paper.SetLayoutWidth(bank->GetLayoutWidth());
|
||||
paper.SetPaperIndex(static_cast<quint32>(i));
|
||||
paper.SetRotate(rotate);
|
||||
paper.SetFollowGrainline(followGrainline);
|
||||
paper.SetRotationIncrease(rotationIncrease);
|
||||
paper.SetSaveLength(saveLength);
|
||||
paper.SetDetails(nDetails.at(i));
|
||||
|
@ -533,6 +537,18 @@ void VLayoutGenerator::SetRotate(bool value)
|
|||
rotate = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutGenerator::GetFollowGrainline() const
|
||||
{
|
||||
return followGrainline;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutGenerator::SetFollowGrainline(bool value)
|
||||
{
|
||||
followGrainline = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutGenerator::GetPaperWidth() const
|
||||
{
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
bool GetRotate() const;
|
||||
void SetRotate(bool value);
|
||||
|
||||
bool GetFollowGrainline() const;
|
||||
void SetFollowGrainline(bool value);
|
||||
|
||||
int GetRotationIncrease() const;
|
||||
void SetRotationIncrease(int value);
|
||||
|
||||
|
@ -132,6 +135,7 @@ private:
|
|||
LayoutErrors state;
|
||||
quint32 shift;
|
||||
bool rotate;
|
||||
bool followGrainline;
|
||||
int rotationIncrease;
|
||||
bool autoCrop;
|
||||
bool saveLength;
|
||||
|
|
|
@ -143,6 +143,18 @@ void VLayoutPaper::SetRotate(bool value)
|
|||
d->localRotate = d->globalRotate;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPaper::GetFollowGrainline() const
|
||||
{
|
||||
return d->followGrainline;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutPaper::SetFollowGrainline(bool value)
|
||||
{
|
||||
d->followGrainline = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VLayoutPaper::GetRotationIncrease() const
|
||||
{
|
||||
|
@ -242,8 +254,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutPiece &detail, std::atomic_bool &stop
|
|||
for (int i=1; i<= detailEdgesCount; ++i)
|
||||
{
|
||||
VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop, d->localRotate,
|
||||
d->localRotationIncrease,
|
||||
d->saveLength);
|
||||
d->localRotationIncrease, d->saveLength, d->followGrainline);
|
||||
//Info for debug
|
||||
#ifdef LAYOUT_DEBUG
|
||||
thread->setPaperIndex(d->paperIndex);
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
bool GetRotate() const;
|
||||
void SetRotate(bool value);
|
||||
|
||||
bool GetFollowGrainline() const;
|
||||
void SetFollowGrainline(bool value);
|
||||
|
||||
int GetRotationIncrease() const;
|
||||
void SetRotationIncrease(int value);
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ public:
|
|||
localRotate(true),
|
||||
globalRotationIncrease(180),
|
||||
localRotationIncrease(180),
|
||||
saveLength(false)
|
||||
saveLength(false),
|
||||
followGrainline(false)
|
||||
{}
|
||||
|
||||
VLayoutPaperData(int height,
|
||||
|
@ -67,7 +68,8 @@ public:
|
|||
localRotate(true),
|
||||
globalRotationIncrease(180),
|
||||
localRotationIncrease(180),
|
||||
saveLength(false)
|
||||
saveLength(false),
|
||||
followGrainline(false)
|
||||
{}
|
||||
|
||||
VLayoutPaperData(const VLayoutPaperData &paper)
|
||||
|
@ -81,7 +83,8 @@ public:
|
|||
localRotate(paper.localRotate),
|
||||
globalRotationIncrease(paper.globalRotationIncrease),
|
||||
localRotationIncrease(paper.localRotationIncrease),
|
||||
saveLength(paper.saveLength)
|
||||
saveLength(paper.saveLength),
|
||||
followGrainline(paper.followGrainline)
|
||||
{}
|
||||
|
||||
~VLayoutPaperData() {}
|
||||
|
@ -100,6 +103,7 @@ public:
|
|||
int globalRotationIncrease;
|
||||
int localRotationIncrease;
|
||||
bool saveLength;
|
||||
bool followGrainline;
|
||||
|
||||
private:
|
||||
VLayoutPaperData& operator=(const VLayoutPaperData&) Q_DECL_EQ_DELETE;
|
||||
|
|
|
@ -673,6 +673,10 @@ void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pa
|
|||
return;
|
||||
}
|
||||
|
||||
d->grainlineEnabled = true;
|
||||
d->grainlineArrowType = geom.GetArrowType();
|
||||
d->grainlineAngle = qRadiansToDegrees(dAng);
|
||||
|
||||
QPointF pt2(pt1.x() + dLen * qCos(dAng), pt1.y() - dLen * qSin(dAng));
|
||||
|
||||
const qreal dArrowLen = ToPixel(0.5, *pattern->GetPatternUnit());
|
||||
|
@ -709,6 +713,24 @@ QVector<QPointF> VLayoutPiece::GetGrainline() const
|
|||
return Map(d->grainlinePoints);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPiece::IsGrainlineEnabled() const
|
||||
{
|
||||
return d->grainlineEnabled;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutPiece::GrainlineAngle() const
|
||||
{
|
||||
return d->grainlineAngle;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ArrowType VLayoutPiece::GrainlineArrowType() const
|
||||
{
|
||||
return d->grainlineArrowType;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QTransform VLayoutPiece::GetMatrix() const
|
||||
{
|
||||
|
@ -1195,7 +1217,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
|||
{
|
||||
SCASSERT(parent != nullptr)
|
||||
|
||||
if (d->grainlinePoints.count() < 2)
|
||||
if (not d->grainlineEnabled || d->grainlinePoints.count() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -104,6 +104,9 @@ public:
|
|||
|
||||
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
|
||||
QVector<QPointF> GetGrainline() const;
|
||||
bool IsGrainlineEnabled() const;
|
||||
qreal GrainlineAngle() const;
|
||||
ArrowType GrainlineArrowType() const;
|
||||
|
||||
QTransform GetMatrix() const;
|
||||
void SetMatrix(const QTransform &matrix);
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
detailLabel(),
|
||||
patternInfo(),
|
||||
grainlinePoints(),
|
||||
grainlineArrowType(ArrowType::atFront),
|
||||
grainlineAngle(0),
|
||||
grainlineEnabled(false),
|
||||
m_tmDetail(),
|
||||
m_tmPattern(),
|
||||
m_placeLabels()
|
||||
|
@ -79,6 +82,9 @@ public:
|
|||
detailLabel(detail.detailLabel),
|
||||
patternInfo(detail.patternInfo),
|
||||
grainlinePoints(detail.grainlinePoints),
|
||||
grainlineArrowType(detail.grainlineArrowType),
|
||||
grainlineAngle(detail.grainlineAngle),
|
||||
grainlineEnabled(detail.grainlineEnabled),
|
||||
m_tmDetail(detail.m_tmDetail),
|
||||
m_tmPattern(detail.m_tmPattern),
|
||||
m_placeLabels(detail.m_placeLabels)
|
||||
|
@ -118,6 +124,10 @@ public:
|
|||
/** @brief grainlineInfo line */
|
||||
QVector<QPointF> grainlinePoints;
|
||||
|
||||
ArrowType grainlineArrowType;
|
||||
qreal grainlineAngle;
|
||||
bool grainlineEnabled;
|
||||
|
||||
/** @brief m_tmDetail text manager for laying out detail info */
|
||||
VTextManager m_tmDetail;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPosition::VPosition(const VContour &gContour, int j, const VLayoutPiece &detail, int i, std::atomic_bool *stop,
|
||||
bool rotate, int rotationIncrease, bool saveLength)
|
||||
bool rotate, int rotationIncrease, bool saveLength, bool followGainline)
|
||||
: QRunnable(),
|
||||
bestResult(VBestSquare(gContour.GetSize(), saveLength)),
|
||||
gContour(gContour),
|
||||
|
@ -65,7 +65,8 @@ VPosition::VPosition(const VContour &gContour, int j, const VLayoutPiece &detail
|
|||
stop(stop),
|
||||
rotate(rotate),
|
||||
rotationIncrease(rotationIncrease),
|
||||
angle_between(0)
|
||||
angle_between(0),
|
||||
followGrainline(followGainline)
|
||||
{
|
||||
if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false)
|
||||
{
|
||||
|
@ -81,6 +82,8 @@ void VPosition::run()
|
|||
return;
|
||||
}
|
||||
|
||||
if (not followGrainline || not detail.IsGrainlineEnabled())
|
||||
{
|
||||
// We should use copy of the detail.
|
||||
VLayoutPiece workDetail = detail;
|
||||
|
||||
|
@ -108,6 +111,11 @@ void VPosition::run()
|
|||
Rotate(rotationIncrease);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FollowGrainline();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -351,14 +359,14 @@ bool VPosition::CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int angle) const
|
||||
bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, qreal angle) const
|
||||
{
|
||||
const QLineF globalEdge = gContour.GlobalEdge(j);
|
||||
bool flagSquare = false;
|
||||
|
||||
if (detail.IsForceFlipping())
|
||||
{
|
||||
detail.Mirror(globalEdge);
|
||||
detail.Mirror(not followGrainline ? globalEdge : QLineF(10, 10, 10, 100));
|
||||
}
|
||||
|
||||
RotateEdges(detail, globalEdge, dEdge, angle);
|
||||
|
@ -391,6 +399,26 @@ bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int a
|
|||
return flagSquare;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPosition::RotateOnAngle(qreal angle)
|
||||
{
|
||||
// We should use copy of the detail.
|
||||
VLayoutPiece workDetail = detail;
|
||||
|
||||
if (CheckRotationEdges(workDetail, j, i, angle))
|
||||
{
|
||||
#ifdef LAYOUT_DEBUG
|
||||
# ifdef SHOW_CANDIDATE_BEST
|
||||
++frame;
|
||||
DrawDebug(gContour, workDetail, frame, paperIndex, detailsCount, details);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
SaveCandidate(bestResult, workDetail, j, i, BestFrom::Rotation);
|
||||
}
|
||||
++frame;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
|
||||
{
|
||||
|
@ -449,7 +477,7 @@ void VPosition::CombineEdges(VLayoutPiece &detail, const QLineF &globalEdge, con
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPosition::RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, int angle) const
|
||||
void VPosition::RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, qreal angle) const
|
||||
{
|
||||
QLineF detailEdge;
|
||||
if (gContour.GetContour().isEmpty())
|
||||
|
@ -487,21 +515,31 @@ void VPosition::Rotate(int increase)
|
|||
return;
|
||||
}
|
||||
|
||||
// We should use copy of the detail.
|
||||
VLayoutPiece workDetail = detail;
|
||||
|
||||
if (CheckRotationEdges(workDetail, j, i, angle))
|
||||
{
|
||||
#ifdef LAYOUT_DEBUG
|
||||
# ifdef SHOW_CANDIDATE_BEST
|
||||
++frame;
|
||||
DrawDebug(gContour, workDetail, frame, paperIndex, detailsCount, details);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
SaveCandidate(bestResult, workDetail, j, i, BestFrom::Rotation);
|
||||
RotateOnAngle(angle);
|
||||
}
|
||||
++frame;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPosition::FollowGrainline()
|
||||
{
|
||||
if (stop->load())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QLineF detailGrainline(10, 10, 100, 10);
|
||||
detailGrainline.setAngle(detail.GrainlineAngle());
|
||||
|
||||
const qreal angle = detailGrainline.angleTo(FabricGrainline());
|
||||
|
||||
if (detail.GrainlineArrowType() == ArrowType::atFront)
|
||||
{
|
||||
RotateOnAngle(angle);
|
||||
}
|
||||
|
||||
if (detail.GrainlineArrowType() == ArrowType::atRear)
|
||||
{
|
||||
RotateOnAngle(angle+180);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class VPosition : public QRunnable
|
|||
{
|
||||
public:
|
||||
VPosition(const VContour &gContour, int j, const VLayoutPiece &detail, int i, std::atomic_bool *stop, bool rotate,
|
||||
int rotationIncrease, bool saveLength);
|
||||
int rotationIncrease, bool saveLength, bool followGainline);
|
||||
virtual ~VPosition() override{}
|
||||
|
||||
quint32 getPaperIndex() const;
|
||||
|
@ -83,6 +83,7 @@ private:
|
|||
* @brief angle_between keep angle between global edge and detail edge. Need for optimization rotation.
|
||||
*/
|
||||
qreal angle_between;
|
||||
bool followGrainline;
|
||||
|
||||
enum class CrossingType : char
|
||||
{
|
||||
|
@ -103,19 +104,34 @@ private:
|
|||
void SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detail, int globalI, int detJ, BestFrom type);
|
||||
|
||||
bool CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge);
|
||||
bool CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int angle) const;
|
||||
bool CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, qreal angle) const;
|
||||
|
||||
void RotateOnAngle(qreal angle);
|
||||
|
||||
CrossingType Crossing(const VLayoutPiece &detail) const;
|
||||
bool SheetContains(const QRectF &rect) const;
|
||||
|
||||
void CombineEdges(VLayoutPiece &detail, const QLineF &globalEdge, const int &dEdge);
|
||||
void RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, int angle) const;
|
||||
void RotateEdges(VLayoutPiece &detail, const QLineF &globalEdge, int dEdge, qreal angle) const;
|
||||
|
||||
static QPainterPath ShowDirection(const QLineF &edge);
|
||||
static QPainterPath DrawContour(const QVector<QPointF> &points);
|
||||
static QPainterPath DrawDetails(const QVector<VLayoutPiece> &details);
|
||||
|
||||
void Rotate(int increase);
|
||||
void FollowGrainline();
|
||||
|
||||
QLineF FabricGrainline() const;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VPosition::FabricGrainline return fabric gainline accoding to paper orientation
|
||||
* @return fabric gainline line
|
||||
*/
|
||||
inline QLineF VPosition::FabricGrainline() const
|
||||
{
|
||||
return gContour.GetHeight() >= gContour.GetWidth() ? QLineF(10, 10, 10, 100) : QLineF(10, 10, 100, 10);
|
||||
}
|
||||
|
||||
#endif // VPOSITION_H
|
||||
|
|
|
@ -127,6 +127,8 @@ const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin
|
|||
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin");
|
||||
const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape");
|
||||
|
||||
const QString LONG_OPTION_FOLLOW_GRAINLINE = QStringLiteral("followGrainline");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts.
|
||||
|
@ -175,7 +177,8 @@ QStringList AllKeys()
|
|||
<< LONG_OPTION_TILED_PDF_RIGHT_MARGIN
|
||||
<< LONG_OPTION_TILED_PDF_TOP_MARGIN
|
||||
<< LONG_OPTION_TILED_PDF_BOTTOM_MARGIN
|
||||
<< LONG_OPTION_TILED_PDF_LANDSCAPE;
|
||||
<< LONG_OPTION_TILED_PDF_LANDSCAPE
|
||||
<< LONG_OPTION_FOLLOW_GRAINLINE;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ extern const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN;
|
|||
extern const QString LONG_OPTION_TILED_PDF_TOP_MARGIN;
|
||||
extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN;
|
||||
extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
|
||||
extern const QString LONG_OPTION_FOLLOW_GRAINLINE;
|
||||
|
||||
QStringList AllKeys();
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1Strin
|
|||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShift, (QLatin1String("layout/shift")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotate, (QLatin1String("layout/Rotate")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotationIncrease, (QLatin1String("layout/rotationIncrease")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCrop, (QLatin1String("layout/autoCrop")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength")))
|
||||
|
@ -370,6 +371,24 @@ void VSettings::SetLayoutRotate(bool value)
|
|||
setValue(*settingLayoutRotate, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetLayoutFollowGrainline() const
|
||||
{
|
||||
return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetDefLayoutFollowGrainline()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetLayoutFollowGrainline(bool value)
|
||||
{
|
||||
setValue(*settingLayoutFollowGrainline, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VSettings::GetLayoutRotationIncrease() const
|
||||
{
|
||||
|
|
|
@ -97,6 +97,10 @@ public:
|
|||
static bool GetDefLayoutRotate();
|
||||
void SetLayoutRotate(bool value);
|
||||
|
||||
bool GetLayoutFollowGrainline() const;
|
||||
static bool GetDefLayoutFollowGrainline();
|
||||
void SetLayoutFollowGrainline(bool value);
|
||||
|
||||
int GetLayoutRotationIncrease() const;
|
||||
static int GetDefLayoutRotationIncrease();
|
||||
void SetLayoutRotationIncrease(int value);
|
||||
|
|
Loading…
Reference in New Issue
Block a user