Resolved issue #783. Flipping control.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-12-17 15:06:46 +02:00
parent f14a529832
commit 88844ec33f
18 changed files with 1166 additions and 8 deletions

View File

@ -33,6 +33,7 @@
- [#726] Improve Move tool. Add optional rotate option.
- [#774] New feature. Matching Parentheses.
- [#779] Add more roll paper size templates.
- [#783] Flipping control.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -844,7 +844,9 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse
VToolSeamAllowance::AttrSeamAllowanceBuiltIn,
falseStr));
initData.detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping,
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
initData.detail.SetForceFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForceFlipping,
QString().setNum(qApp->ValentinaSettings()->GetForceWorkpieceFlipping())));
initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));

View File

@ -45,6 +45,7 @@
<file>schema/pattern/v0.7.1.xsd</file>
<file>schema/pattern/v0.7.2.xsd</file>
<file>schema/pattern/v0.7.3.xsd</file>
<file>schema/pattern/v0.7.4.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -58,8 +58,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.3.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.4");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.4.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -219,7 +219,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(0x000700, QStringLiteral("://schema/pattern/v0.7.0.xsd")),
std::make_pair(0x000701, QStringLiteral("://schema/pattern/v0.7.1.xsd")),
std::make_pair(0x000702, QStringLiteral("://schema/pattern/v0.7.2.xsd")),
std::make_pair(0x000703, CurrentSchema)
std::make_pair(0x000703, QStringLiteral("://schema/pattern/v0.7.3.xsd")),
std::make_pair(0x000704, CurrentSchema)
};
if (schemas.contains(ver))
@ -414,6 +415,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000703), m_convertedFileName);
V_FALLTHROUGH
case (0x000703):
ToV0_7_4();
ValidateXML(XSDSchema(0x000704), m_convertedFileName);
V_FALLTHROUGH
case (0x000704):
break;
default:
InvalidVersion(m_ver);
@ -431,7 +436,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 3),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 4),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -935,6 +940,16 @@ void VPatternConverter::ToV0_7_3()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_7_4()
{
// TODO. Delete if minimal supported version is 0.7.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 4),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.7.4"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 3);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 4);
protected:
virtual int MinVer() const Q_DECL_OVERRIDE;
@ -116,6 +116,7 @@ private:
void ToV0_7_1();
void ToV0_7_2();
void ToV0_7_3();
void ToV0_7_4();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -85,6 +85,28 @@ bool VAbstractPiece::IsForbidFlipping() const
void VAbstractPiece::SetForbidFlipping(bool value)
{
d->m_forbidFlipping = value;
if (value)
{
SetForceFlipping(not value);
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPiece::IsForceFlipping() const
{
return d->m_forceFlipping;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPiece::SetForceFlipping(bool value)
{
d->m_forceFlipping = value;
if (value)
{
SetForbidFlipping(not value);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -160,6 +160,9 @@ public:
bool IsForbidFlipping() const;
void SetForbidFlipping(bool value);
bool IsForceFlipping() const;
void SetForceFlipping(bool value);
bool IsSeamAllowance() const;
void SetSeamAllowance(bool value);

View File

@ -46,6 +46,7 @@ public:
VAbstractPieceData()
: m_name(tr("Detail")),
m_forbidFlipping(false),
m_forceFlipping(false),
m_seamAllowance(false),
m_seamAllowanceBuiltIn(false),
m_hideMainPath(false),
@ -58,6 +59,7 @@ public:
: QSharedData(piece),
m_name(piece.m_name),
m_forbidFlipping(piece.m_forbidFlipping),
m_forceFlipping(piece.m_forceFlipping),
m_seamAllowance(piece.m_seamAllowance),
m_seamAllowanceBuiltIn(piece.m_seamAllowanceBuiltIn),
m_hideMainPath(piece.m_hideMainPath),
@ -71,6 +73,7 @@ public:
QString m_name;
/** @brief forbidFlipping forbid piece be mirrored in a layout. */
bool m_forbidFlipping;
bool m_forceFlipping;
bool m_seamAllowance;
bool m_seamAllowanceBuiltIn;
bool m_hideMainPath;

View File

@ -196,7 +196,7 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &s
return false;//Not enough edges
}
if (detail.IsForbidFlipping() && not d->globalRotate)
if ((detail.IsForceFlipping() || detail.IsForbidFlipping()) && not d->globalRotate)
{ // Compensate forbidden flipping by rotating. 180 degree will be enough.
d->localRotate = true;
d->localRotationIncrease = 180;

View File

@ -429,6 +429,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
det.SetSAWidth(qApp->toPixel(piece.GetSAWidth()));
det.SetForbidFlipping(piece.IsForbidFlipping());
det.SetForceFlipping(piece.IsForceFlipping());
return det;
}

View File

@ -278,7 +278,7 @@ bool VPosition::CheckCombineEdges(VLayoutPiece &detail, int j, int &dEdge)
#endif
CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.DetailBoundingRect()))
if (not detail.IsForceFlipping() && SheetContains(detail.DetailBoundingRect()))
{
if (not gContour.GetContour().isEmpty())
{
@ -356,6 +356,11 @@ bool VPosition::CheckRotationEdges(VLayoutPiece &detail, int j, int dEdge, int a
const QLineF globalEdge = gContour.GlobalEdge(j);
bool flagSquare = false;
if (detail.IsForceFlipping())
{
detail.Mirror(globalEdge);
}
RotateEdges(detail, globalEdge, dEdge, angle);
#ifdef LAYOUT_DEBUG

View File

@ -65,6 +65,7 @@ const QString settingConfigurationFreeCurveMode = QStringLiteral("confi
const QString settingPatternUndo = QStringLiteral("pattern/undo");
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
const QString settingPatternForceFlipping = QStringLiteral("pattern/forceFlipping");
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
const QString settingPatternDefaultSeamAllowance = QStringLiteral("pattern/defaultSeamAllowance");
@ -700,6 +701,28 @@ bool VCommonSettings::GetForbidWorkpieceFlipping() const
void VCommonSettings::SetForbidWorkpieceFlipping(bool value)
{
setValue(settingPatternForbidFlipping, value);
if (value)
{
SetForceWorkpieceFlipping(not value);
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetForceWorkpieceFlipping() const
{
return value(settingPatternForceFlipping, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetForceWorkpieceFlipping(bool value)
{
setValue(settingPatternForceFlipping, value);
if (value)
{
SetForbidWorkpieceFlipping(not value);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -144,6 +144,9 @@ public:
bool GetForbidWorkpieceFlipping() const;
void SetForbidWorkpieceFlipping(bool value);
bool GetForceWorkpieceFlipping() const;
void SetForceWorkpieceFlipping(bool value);
bool IsHideMainPath() const;
void SetHideMainPath(bool value);

View File

@ -300,6 +300,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
CustomSAChanged(0);
uiTabPaths->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
uiTabPaths->checkBoxForceFlipping->setChecked(piece.IsForceFlipping());
uiTabPaths->checkBoxSeams->setChecked(piece.IsSeamAllowance());
uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn());
uiTabLabels->lineEditName->setText(piece.GetName());
@ -2283,6 +2284,7 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetPins(GetListInternals<quint32>(uiTabPins->listWidgetPins));
piece.SetPlaceLabels(GetListInternals<quint32>(uiTabPlaceLabels->listWidgetPlaceLabels));
piece.SetForbidFlipping(uiTabPaths->checkBoxForbidFlipping->isChecked());
piece.SetForceFlipping(uiTabPaths->checkBoxForceFlipping->isChecked());
piece.SetSeamAllowance(uiTabPaths->checkBoxSeams->isChecked());
piece.SetSeamAllowanceBuiltIn(uiTabPaths->checkBoxBuiltIn->isChecked());
piece.SetHideMainPath(uiTabPaths->checkBoxHideMainPath->isChecked());
@ -2613,7 +2615,24 @@ void DialogSeamAllowance::InitFancyTabBar()
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitMainPathTab()
{
connect(uiTabPaths->checkBoxForbidFlipping, &QCheckBox::stateChanged, this, [this](int state)
{
if (state == Qt::Checked)
{
uiTabPaths->checkBoxForceFlipping->setChecked(false);
}
});
connect(uiTabPaths->checkBoxForceFlipping, &QCheckBox::stateChanged, this, [this](int state)
{
if (state == Qt::Checked)
{
uiTabPaths->checkBoxForbidFlipping->setChecked(false);
}
});
uiTabPaths->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
uiTabPaths->checkBoxForceFlipping->setChecked(qApp->Settings()->GetForceWorkpieceFlipping());
uiTabPaths->checkBoxHideMainPath->setChecked(qApp->Settings()->IsHideMainPath());
uiTabPaths->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu);

View File

@ -83,6 +83,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxForceFlipping">
<property name="toolTip">
<string>Force piece to be always flipped in a layout.</string>
</property>
<property name="text">
<string>Force flipping</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxHideMainPath">
<property name="toolTip">

View File

@ -69,6 +69,7 @@ const QString VToolSeamAllowance::TagPins = QStringLiteral("pins");
const QString VToolSeamAllowance::TagPlaceLabels = QStringLiteral("placeLabels");
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
const QString VToolSeamAllowance::AttrForceFlipping = QStringLiteral("forceFlipping");
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
const QString VToolSeamAllowance::AttrHideMainPath = QStringLiteral("hideMainPath");
const QString VToolSeamAllowance::AttrSeamAllowanceBuiltIn = QStringLiteral("seamAllowanceBuiltIn");
@ -260,6 +261,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy()));
doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout());
doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping());
doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping());
doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance());
doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath());

View File

@ -77,6 +77,7 @@ public:
static const QString TagPlaceLabels;
static const QString AttrForbidFlipping;
static const QString AttrForceFlipping;
static const QString AttrSeamAllowance;
static const QString AttrHideMainPath;
static const QString AttrSeamAllowanceBuiltIn;