From ad23a75d7a7e7c4a67612a2ce5e6e89ae440bcd0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 23 Mar 2017 19:36:50 +0200 Subject: [PATCH 01/18] Check if all points in a path are unique. Because in some valid cases the same geometric point can be included in a path several times we must force user to create unique point for each case. This happens because we determine each point by point id. --HG-- branch : feature --- .../vtools/dialogs/tools/dialogpiecepath.cpp | 6 ++++++ src/libs/vtools/dialogs/tools/dialogtool.cpp | 21 +++++++++++++++++++ src/libs/vtools/dialogs/tools/dialogtool.h | 1 + .../tools/piece/dialogseamallowance.cpp | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index 4ba8ed87f..3aade7598 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -889,6 +889,12 @@ bool DialogPiecePath::PathIsValid() const ui->helpLabel->setText(url); return false; } + else if (not EachPointLabelIsUnique(ui->listWidget)) + { + url += tr("Each point in the path must be unique!"); + ui->helpLabel->setText(url); + return false; + } } if (not m_showMode && ui->comboBoxPiece->count() <= 0) diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 25d4b5348..6783fb793 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -522,6 +522,27 @@ bool DialogTool::DoublePoints(QListWidget *listWidget) return false; } +//--------------------------------------------------------------------------------------------------------------------- +bool DialogTool::EachPointLabelIsUnique(QListWidget *listWidget) +{ + SCASSERT(listWidget != nullptr); + QSet pointLabels; + int countPoints = 0; + for (int i=0; i < listWidget->count(); ++i) + { + const QListWidgetItem *rowItem = listWidget->item(i); + SCASSERT(rowItem != nullptr); + const VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + if (rowNode.GetTypeTool() == Tool::NodePoint) + { + ++countPoints; + pointLabels.insert(rowNode.GetId()); + } + } + + return countPoints == pointLabels.size(); +} + //--------------------------------------------------------------------------------------------------------------------- QString DialogTool::DialogWarningIcon() { diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index a60ca0fff..4dd5f124b 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -270,6 +270,7 @@ protected: static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate); static bool FirstPointEqualLast(QListWidget *listWidget); static bool DoublePoints(QListWidget *listWidget); + static bool EachPointLabelIsUnique(QListWidget *listWidget); static QString DialogWarningIcon(); static QFont NodeFont(bool nodeExcluded); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index b1060eb01..1a14450f3 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2029,6 +2029,12 @@ bool DialogSeamAllowance::MainPathIsValid() const uiTabPaths->helpLabel->setText(url); valid = false; } + else if (not EachPointLabelIsUnique(uiTabPaths->listWidgetMainPath)) + { + url += tr("Each point in the path must be unique!"); + uiTabPaths->helpLabel->setText(url); + valid = false; + } } if (valid) From 81b88db5ccc137360243d56561d6ade335ebb77b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 24 Mar 2017 13:08:16 +0200 Subject: [PATCH 02/18] Dialog Seam allowance tool now supports passmarks. --HG-- branch : feature --- src/app/valentina/main.cpp | 2 - src/libs/vmisc/def.h | 13 ++ src/libs/vmisc/share/resources/icon.qrc | 2 + .../share/resources/icon/32x32/passmark.png | Bin 0 -> 1412 bytes .../resources/icon/32x32/passmark@2x.png | Bin 0 -> 2612 bytes .../share/resources/icon/svg/passmark.svg | 73 ++++++ src/libs/vpatterndb/vpiecenode.cpp | 40 +++- src/libs/vpatterndb/vpiecenode.h | 12 +- src/libs/vpatterndb/vpiecenode_p.h | 21 +- src/libs/vtools/dialogs/dialogs.pri | 3 +- .../vtools/dialogs/tools/dialogpiecepath.cpp | 2 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 21 +- src/libs/vtools/dialogs/tools/dialogtool.h | 2 +- .../tools/piece/dialogseamallowance.cpp | 213 +++++++++++++++++- .../dialogs/tools/piece/dialogseamallowance.h | 8 + .../dialogs/tools/piece/tabs/tabpassmarks.ui | 141 ++++++++++++ 16 files changed, 523 insertions(+), 30 deletions(-) create mode 100644 src/libs/vmisc/share/resources/icon/32x32/passmark.png create mode 100644 src/libs/vmisc/share/resources/icon/32x32/passmark@2x.png create mode 100644 src/libs/vmisc/share/resources/icon/svg/passmark.svg create mode 100644 src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 9dad7ebc1..51c1ce34c 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -54,8 +54,6 @@ int main(int argc, char *argv[]) qt_qhash_seed.store(0); // Lock producing random attribute order in XML - qRegisterMetaTypeStreamOperators("VPieceNode"); - #ifndef Q_OS_MAC // supports natively InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 4d8d2215a..e1523976b 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -89,6 +89,19 @@ enum class PieceNodeAngle : unsigned char BySecondEdgeRightAngle }; +enum class PassmarkLineType : unsigned char +{ + OneLine = 0, + TwoLines, + ThreeLines +}; + +enum class PassmarkAngleType : unsigned char +{ + Straightforward = 0, + Bisector +}; + enum class PiecePathIncludeType : unsigned char { AsMainPath = 0, diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index 0eb3b135e..45ab2b772 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -74,5 +74,7 @@ icon/32x32/paths@2x.png icon/32x32/pins.png icon/32x32/pins@2x.png + icon/32x32/passmark.png + icon/32x32/passmark@2x.png diff --git a/src/libs/vmisc/share/resources/icon/32x32/passmark.png b/src/libs/vmisc/share/resources/icon/32x32/passmark.png new file mode 100644 index 0000000000000000000000000000000000000000..c46b5ee65080f17c639ef59da90ec28a44e2a47f GIT binary patch literal 1412 zcmV-~1$+95P)1 zHywbids5*nAc(F?IO%753LwQM)a*+Sb6sfxh66cN<~UaLtD6P@P?c)0G&I)&M1d?S zGaM_r<9fXQ_Yu_WZM!{az9ms{EMyq93TJ>472Rw#r)zI0fYqFS)XjNEEhqCz(0Wr< z_*Qt&|Lq|E5L zAgz^3&rp^1Kp5m?I3!h#lOn%$2jKUBs!ZOWsVH1@tmsc@t_CmlY6gtwwaVK-|rF^+A_m} zmE7*y11AP{31BDVyHQ@uk4JW7wW+%C&q1Axtw^JI@;KlMlnJukYEIu5WSTOgZz=jF zfWTdsv*G#)`%d)>1n|vc%N3U9=SI8XP+)?cjBZ1D0>}aV)sS7)Ev1395x;wy0#9l{vJ5OJU~bfZ`a`gz2=dMr5vE4B20LiP}B2(F=vr znuas|-O|fVc-0*nL{mFFBQ`ca{7<^~P5S7g2vn3bn$==0Bo zsXM1sUJk0n&T)gz!8M+UYWAgvWnI}TFbv3v@T8rHZRiAXV;^iZfuL(GynkG zjIBiVHGd?Pxo~c`X&)bO(*OV*EB=PU$~;6ww6y3d^gL7zGu8TzX}6CkHuYagQWJAO SD%a}(0000;{j*M;TpcR}EB-!1| z7heGi5(?F+En;OHt*v7V+S-q?TAVUUsijs%E6!jcnhYQx`P|*Z!c?J^PHl(M7Ukn^ zlK=(z47uH>eSe>+@M&6n+5%BD_7lZ6GHA)wLFTo(8hR{UbBZ8+Ph2uz=(A`5Ao`B1$DT;r zoB~MO!hMpp4nUi8oPg&)4U13fH&+&En-sTgjeyY(ii!9kO%DAoo%8pHv?m)yGw%X% z6M&J4;|$mU-D@a;H`5)17c!D%!-g5QnRfulbx>UlT4*SN?U{%p5$WB|deABdS|#Fn z06HC17Qk;QT69Jx;z&eB_f^%1E?}n30Q`yL3|s_whM|P^WGa@7Jn>#=a;Of32fDxS zYan0*fwrry(aD*LC8Z}`-gNrLcy{MjfY$4BV6*7&6(jaA7{B(QPWmLsEv3P~rxKS4 zgcn{Ci4{mTb`x+1fG)D}RV^IcA*!S5=93KmxpSO>XqHbZX)Y=HkEo^ygccrdIaX}@ z{LKKqkT84+j9I!G)I}#(_2{ze%=utPrqa^mVrm}cl2|PidSKJIu zV6qyj_8xOqeM17_tZpcQbqqZ1W_XmuQbVZ`{i2W{5szsvS^?k>E((~`+2!AP_q!eW zqHzv5ZK^+1wAe2|_<;v?+$JiG$blmwdXx8aR{nXj4!|5I$3QFb<=MJA{&K4EI+5}| zt}B664E)A}8Y?k3RlM5~645&_g}Mp~PA>$Z!O0O2X3E<-bLZilRO9u~90Zt2(POWG zXqg9l$QPI7mhvLk(X>BQ?~jf+cb;|wC~-{()DZ_3>ng=l4Y?PtCtlXvR+RLwiMXI6 z_-!z}ikMq1ztu2(&&M~31hjoh=%T+Xry7ITSJxv`nQuH;O4G)+z|QZ|2Vzi9P#BU2L9}!H#h%+`R1Z6>=OyF zd3xxmO}+{Mri&zgPS&H}718U31OS>6e40Qnc<{Hx{dS{Bg3{ITXKV>G0JuLB#=?$5 zaeqA`7asOWQWXQIog9JID2C~^tMrSj$xV}s9w*>6w=gF8t?V6@4d!Q(72Q)B>;PMp z0KAHr`&C0cIkl7){Z+DQ7JzfE5Sd?AjaZF{-nFbw#ADh6%RzYC9ZMcsI9Tt$!fV?x&E><19gS%ftuPH zvXY%ZZ9Q=-OOgS=oht|{bvd{?S*>1#jcBFKv<-msK_q=db`=8qrj5IlmzzBgzTWbhII&I&G%30q}7cIQAEo)yrp zyFU8~n7s=K#zU$eeO4q;EnIYvAK7-3JfLPkCXi=wWk}&B2P_*`2 zK-L}rPB$c_YarDy=Q8tK0QwX&3|x_HEJ($_Q?%$~AkXdiI2a|m8vMvf3|Q>zYT>_Z zqDr{GQL>rVE1LN=ksviWu#Ie90-#TVBp{n5)GAs`5z*_8G4vvXy*|IOAT*UkI)Y9j z=|ZCC4y+k~b3gAQ!hB5*?i2}D(PH<5@TxNg20j5$ZYaU`Mf7?!e+k0l9@O7_aZ70_ zAA72IK&XOJw6=1P{SG{~5e8R@-h{}y`3Ql356mPRZNDY(gC3e6 zfG?@KI{pkG=)mY|Q8N)Qh2u2^kVl~H;Yjoj5j{f*tRvvZZYFjA&X9{%5ZL1emTzau zxmtk=ALunXR0qZb0N6p@Xxr3pCiT=)fNqBbG%T1M0W1Q3*Tf=ql*Gf z>&)RzllOC0N=}BZ27k|>r@Vp%QB$}j`gtKeC9sNs^&V78{@t!w6FLhEPE`Zg?c^lj z(1FQ_56W|s_1J0xJoa-w?2G$Kg#5Pt{X183N(L_fE}=voly_ywft3vM*vDyt<+mCX z?Z~L4#d`cZ2DW&xU$*@I=2ZPV2Hpenio|ol;P1zoB}F$kfw0&`f%oQgN|lXOfeXpX zE&A}o?2eP8>%j0jY3&31Ds{EcS^D;inL7{X?3y*9PgBB>GzRos25bc|)5$TYv9RD& zb?wB7SCZB1*S`ZdgFCASd$}+qjR6OyP*?s)z6XG7A182Sd&f<$iCDr3Cq$1ThRRd% z@0=L2j)<#%IN&Ne2((l+#E!GwC&bH@-g=muf8N|A>fa?|NLxXgD@LEq&Y~Fr4mmjn zRw$bJjEJ7Djz42bsDhV&2i%j2f7gp4?}2H&JJ4>EUBSRn7fJk-XjkJv{+(>ZUQ8v< zv^4)j%i|F;|-x26hMT`AJG{&^Hd&zq2P6Ap0IPbSD5Pe;= zaY)gQ-wyI?0K4h~25Jl?SevX?THC!0CHVgJTv0H;A?q>M_SYYDb?gV=xC)myK=mUo zp5G>-m5~O&9@ph<3{hjBthY@i*o^>2GO&?2uuSyoIAfiSiWa?>iC!o7TXxnaTNOQf zE1Ee6#0$ZJ<*D44XSAiWpT@opvh5NrT!La;u zjI77j5b!-WlfrQ}MGVh>1u>Ism>UTAmIrwd+^O_>W9dRhU-hdX;==a8gWeaEbQ>tQ zUeS&?oBD?o!?SR7_s$fIIla`&8v~$#a<>fj1lAvhZQ%e=J8|L_;!BGGKIlPL-*CZP z;xRrX7}kXY-6t?G%3T+fgq4~c+?cL;hkfBdp9{((065iq^Z#3vMPgr4jM&4OnCpKE Wm;E6#k0+)80000 + + +image/svg+xml \ No newline at end of file diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index b83daa1df..36df0b31b 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -215,25 +215,43 @@ void VPieceNode::SetAngleType(PieceNodeAngle type) } } -// Friend functions //--------------------------------------------------------------------------------------------------------------------- -QDataStream& operator<<(QDataStream& out, const VPieceNode& p) +bool VPieceNode::IsPassmark() const { - out << p.d->m_id << static_cast(p.d->m_typeTool) << p.d->m_reverse; - return out; + return d->m_isPassmark; } //--------------------------------------------------------------------------------------------------------------------- -QDataStream& operator>>(QDataStream& in, VPieceNode& p) +void VPieceNode::SetPassmark(bool passmark) { - in >> p.d->m_id; + if (GetTypeTool() == Tool::NodePoint) + { + d->m_isPassmark = passmark; + } +} - int type = 0; - in >> type; - p.d->m_typeTool = static_cast(type); +//--------------------------------------------------------------------------------------------------------------------- +PassmarkLineType VPieceNode::GetPassmarkLineType() const +{ + return d->m_passmarkLineType; +} - in >> p.d->m_reverse; - return in; +//--------------------------------------------------------------------------------------------------------------------- +void VPieceNode::SetPassmarkLineType(PassmarkLineType lineType) +{ + d->m_passmarkLineType = lineType; +} + +//--------------------------------------------------------------------------------------------------------------------- +PassmarkAngleType VPieceNode::GetPassmarkAngleType() const +{ + return d->m_passmarkAngleType; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceNode::SetPassmarkAngleType(PassmarkAngleType angleType) +{ + d->m_passmarkAngleType = angleType; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index d16616493..66684686f 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -47,9 +47,6 @@ public: VPieceNode &operator=(const VPieceNode &node); ~VPieceNode(); - friend QDataStream& operator<<(QDataStream& out, const VPieceNode& p); - friend QDataStream& operator>>(QDataStream& in, VPieceNode& p); - quint32 GetId() const; void SetId(quint32 id); @@ -76,6 +73,15 @@ public: PieceNodeAngle GetAngleType() const; void SetAngleType(PieceNodeAngle type); + + bool IsPassmark() const; + void SetPassmark(bool passmark); + + PassmarkLineType GetPassmarkLineType() const; + void SetPassmarkLineType(PassmarkLineType lineType); + + PassmarkAngleType GetPassmarkAngleType() const; + void SetPassmarkAngleType(PassmarkAngleType angleType); private: QSharedDataPointer d; }; diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 0c6fb68ed..bd53c1ef3 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -44,11 +44,14 @@ public: m_typeTool(Tool::NodePoint), m_reverse(false), m_excluded(false), + m_isPassmark(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), m_formulaWidthAfter(currentSeamAllowance), - m_angleType(PieceNodeAngle::ByLength) + m_angleType(PieceNodeAngle::ByLength), + m_passmarkLineType(PassmarkLineType::OneLine), + m_passmarkAngleType(PassmarkAngleType::Straightforward) {} VPieceNodeData(quint32 id, Tool typeTool, bool reverse) @@ -56,11 +59,14 @@ public: m_typeTool(typeTool), m_reverse(reverse), m_excluded(false), + m_isPassmark(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), m_formulaWidthAfter(currentSeamAllowance), - m_angleType(PieceNodeAngle::ByLength) + m_angleType(PieceNodeAngle::ByLength), + m_passmarkLineType(PassmarkLineType::OneLine), + m_passmarkAngleType(PassmarkAngleType::Straightforward) { if (m_typeTool == Tool::NodePoint) { @@ -74,11 +80,14 @@ public: m_typeTool(node.m_typeTool), m_reverse(node.m_reverse), m_excluded(node.m_excluded), + m_isPassmark(node.m_isPassmark), m_saBefore(node.m_saBefore), m_saAfter(node.m_saAfter), m_formulaWidthBefore(node.m_formulaWidthBefore), m_formulaWidthAfter(node.m_formulaWidthAfter), - m_angleType(node.m_angleType) + m_angleType(node.m_angleType), + m_passmarkLineType(node.m_passmarkLineType), + m_passmarkAngleType(node.m_passmarkAngleType) {} ~VPieceNodeData(); @@ -96,6 +105,9 @@ public: * affect on main path. Also include to exist path items automatically setted excluded. */ bool m_excluded; + /** @brief m_isPassmark has sense only for points. If true to seam allowance should be added a passmark. */ + bool m_isPassmark; + qreal m_saBefore; qreal m_saAfter; @@ -104,6 +116,9 @@ public: PieceNodeAngle m_angleType; + PassmarkLineType m_passmarkLineType; + PassmarkAngleType m_passmarkAngleType; + private: VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE; }; diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 94dbeb526..39720163e 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -138,4 +138,5 @@ FORMS += \ $$PWD/tools/piece/tabs/tablabels.ui \ $$PWD/tools/piece/tabs/tabgrainline.ui \ $$PWD/tools/piece/tabs/tabpins.ui \ - $$PWD/tools/dialoginsertnode.ui + $$PWD/tools/dialoginsertnode.ui \ + $$PWD/tools/piece/tabs/tabpassmarks.ui diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index 3aade7598..6f218628b 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -244,7 +244,7 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos) { rowNode.SetReverse(not rowNode.GetReverse()); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); - rowItem->setText(GetNodeName(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); ValidObjects(PathIsValid()); } diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 6783fb793..2019e1254 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -566,7 +566,7 @@ QFont DialogTool::NodeFont(bool nodeExcluded) } //--------------------------------------------------------------------------------------------------------------------- -QString DialogTool::GetNodeName(const VPieceNode &node) const +QString DialogTool::GetNodeName(const VPieceNode &node, bool showPassmark) const { const QSharedPointer obj = data->GetGObject(node.GetId()); QString name = obj->name(); @@ -581,6 +581,23 @@ QString DialogTool::GetNodeName(const VPieceNode &node) const name = QLatin1String("- ") + name; } } + else if (showPassmark && node.IsPassmark()) + { + switch(node.GetPassmarkLineType()) + { + case PassmarkLineType::OneLine: + name += QLatin1String("^"); + break; + case PassmarkLineType::TwoLines: + name += QLatin1String("^^"); + break; + case PassmarkLineType::ThreeLines: + name += QLatin1String("^^^"); + break; + default: + break; + } + } return name; } @@ -598,7 +615,7 @@ void DialogTool::NewNodeItem(QListWidget *listWidget, const VPieceNode &node) case (Tool::NodeElArc): case (Tool::NodeSpline): case (Tool::NodeSplinePath): - name = GetNodeName(node); + name = GetNodeName(node, true); break; default: qDebug()<<"Got wrong tools. Ignore."; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 4dd5f124b..38abeda24 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -274,7 +274,7 @@ protected: static QString DialogWarningIcon(); static QFont NodeFont(bool nodeExcluded); - QString GetNodeName(const VPieceNode &node) const; + QString GetNodeName(const VPieceNode &node, bool showPassmark = false) const; void NewNodeItem(QListWidget *listWidget, const VPieceNode &node); void InitNodeAngles(QComboBox *box); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 1a14450f3..2a5b80c5b 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -32,6 +32,7 @@ #include "ui_tablabels.h" #include "ui_tabgrainline.h" #include "ui_tabpins.h" +#include "ui_tabpassmarks.h" #include "../vwidgets/fancytabbar/fancytabbar.h" #include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecepath.h" @@ -46,7 +47,7 @@ #include #include -enum TabOrder {Paths=0, Labels=1, Grainline=2, Pins=3, Count=4}; +enum TabOrder {Paths=0, Labels=1, Grainline=2, Pins=3, Passmarks=4, Count=5}; namespace { @@ -80,10 +81,12 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & uiTabLabels(new Ui::TabLabels), uiTabGrainline(new Ui::TabGrainline), uiTabPins(new Ui::TabPins), + uiTabPassmarks(new Ui::TabPassmarks), m_tabPaths(new QWidget), m_tabLabels(new QWidget), m_tabGrainline(new QWidget), m_tabPins(new QWidget), + m_tabPassmarks(new QWidget), m_ftb(new FancyTabBar(FancyTabBar::Left, this)), dialogIsInitialized(false), applyAllowed(false),// By default disabled @@ -135,6 +138,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & InitLabelsTab(); InitGrainlineTab(); InitPinsTab(); + InitPassmarksTab(); flagName = true;//We have default name of piece. ChangeColor(uiTabLabels->labelEditName, okColor); @@ -153,10 +157,12 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & DialogSeamAllowance::~DialogSeamAllowance() { delete m_visPins; + delete m_tabPassmarks; delete m_tabPins; delete m_tabGrainline; delete m_tabLabels; delete m_tabPaths; + delete uiTabPassmarks; delete uiTabPins; delete uiTabGrainline; delete uiTabLabels; @@ -176,6 +182,7 @@ void DialogSeamAllowance::EnableApply(bool enable) m_ftb->SetTabEnabled(TabOrder::Labels, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed); m_ftb->SetTabEnabled(TabOrder::Pins, applyAllowed); + m_ftb->SetTabEnabled(TabOrder::Passmarks, applyAllowed); } //--------------------------------------------------------------------------------------------------------------------- @@ -579,6 +586,7 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) SCASSERT(rowItem != nullptr); VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + QAction *actionPassmark = nullptr; QAction *actionReverse = nullptr; if (rowNode.GetTypeTool() != Tool::NodePoint) { @@ -586,6 +594,12 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) actionReverse->setCheckable(true); actionReverse->setChecked(rowNode.GetReverse()); } + else + { + actionPassmark = menu->addAction(tr("Passmark")); + actionPassmark->setCheckable(true); + actionPassmark->setChecked(rowNode.IsPassmark()); + } QAction *actionExcluded = menu->addAction(tr("Excluded")); actionExcluded->setCheckable(true); @@ -597,24 +611,28 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) if (selectedAction == actionDelete) { delete uiTabPaths->listWidgetMainPath->item(row); - ValidObjects(MainPathIsValid()); } else if (rowNode.GetTypeTool() != Tool::NodePoint && selectedAction == actionReverse) { rowNode.SetReverse(not rowNode.GetReverse()); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); - rowItem->setText(GetNodeName(rowNode)); - ValidObjects(MainPathIsValid()); + rowItem->setText(GetNodeName(rowNode, true)); } else if (selectedAction == actionExcluded) { rowNode.SetExcluded(not rowNode.IsExcluded()); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); - rowItem->setText(GetNodeName(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); rowItem->setFont(NodeFont(rowNode.IsExcluded())); - ValidObjects(MainPathIsValid()); + } + else if (selectedAction == actionPassmark) + { + rowNode.SetPassmark(not rowNode.IsPassmark()); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); } + ValidObjects(MainPathIsValid()); ListChanged(); } @@ -736,6 +754,7 @@ void DialogSeamAllowance::ListChanged() visPath->RefreshGeometry(); } InitNodesList(); + InitPassmarksList(); CustomSAChanged(uiTabPaths->listWidgetCustomSA->currentRow()); } @@ -820,6 +839,68 @@ void DialogSeamAllowance::NodeChanged(int index) uiTabPaths->comboBoxAngle->blockSignals(false); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::PassmarkChanged(int index) +{ + uiTabPassmarks->radioButtonOneLine->setDisabled(true); + uiTabPassmarks->radioButtonTwoLines->setDisabled(true); + uiTabPassmarks->radioButtonThreeLines->setDisabled(true); + + uiTabPassmarks->radioButtonStraightforward->setDisabled(true); + uiTabPassmarks->radioButtonBisector->setDisabled(true); + + uiTabPassmarks->groupBoxLineType->blockSignals(true); + uiTabPassmarks->groupBoxAngleType->blockSignals(true); + + if (index != -1) + { + const VPiece piece = CreatePiece(); + const int nodeIndex = piece.GetPath().indexOfNode(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt()); + if (nodeIndex != -1) + { + const VPieceNode &node = piece.GetPath().at(nodeIndex); + + // Line type + uiTabPassmarks->radioButtonOneLine->setEnabled(true); + uiTabPassmarks->radioButtonTwoLines->setEnabled(true); + uiTabPassmarks->radioButtonThreeLines->setEnabled(true); + + switch(node.GetPassmarkLineType()) + { + case PassmarkLineType::OneLine: + uiTabPassmarks->radioButtonOneLine->setChecked(true); + break; + case PassmarkLineType::TwoLines: + uiTabPassmarks->radioButtonTwoLines->setChecked(true); + break; + case PassmarkLineType::ThreeLines: + uiTabPassmarks->radioButtonThreeLines->setChecked(true); + break; + default: + break; + } + + // Angle type + uiTabPassmarks->radioButtonStraightforward->setEnabled(true); + uiTabPassmarks->radioButtonBisector->setEnabled(true); + + switch(node.GetPassmarkAngleType()) + { + case PassmarkAngleType::Straightforward: + uiTabPassmarks->radioButtonStraightforward->setChecked(true); + break; + case PassmarkAngleType::Bisector: + uiTabPassmarks->radioButtonBisector->setChecked(true); + break; + default: + break; + } + } + } + uiTabPassmarks->groupBoxLineType->blockSignals(false); + uiTabPassmarks->groupBoxAngleType->blockSignals(false); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::CSAStartPointChanged(int index) { @@ -1010,6 +1091,7 @@ void DialogSeamAllowance::FancyTabChanged(int index) m_tabLabels->hide(); m_tabGrainline->hide(); m_tabPins->hide(); + m_tabPassmarks->hide(); QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") @@ -1027,6 +1109,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case TabOrder::Pins: m_tabPins->show(); break; + case TabOrder::Passmarks: + m_tabPassmarks->show(); + break; } QT_WARNING_POP @@ -1061,6 +1146,70 @@ void DialogSeamAllowance::TabChanged(int index) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::PassmarkLineTypeChanged(int id) +{ + const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex(); + if (i != -1) + { + QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt()); + if (rowItem) + { + VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + PassmarkLineType lineType = PassmarkLineType::OneLine; + if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonOneLine)) + { + lineType = PassmarkLineType::OneLine; + } + else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonTwoLines)) + { + lineType = PassmarkLineType::TwoLines; + } + else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonThreeLines)) + { + lineType = PassmarkLineType::ThreeLines; + } + + rowNode.SetPassmarkLineType(lineType); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); + + ListChanged(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::PassmarkAngleTypeChanged(int id) +{ + const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex(); + if (i != -1) + { + QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt()); + if (rowItem) + { + VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + PassmarkAngleType angleType = PassmarkAngleType::Straightforward; + if (id == uiTabPassmarks->buttonGroupAngleType->id(uiTabPassmarks->radioButtonStraightforward)) + { + angleType = PassmarkAngleType::Straightforward; + } + else if (id == uiTabPassmarks->buttonGroupAngleType->id(uiTabPassmarks->radioButtonBisector)) + { + angleType = PassmarkAngleType::Bisector; + } + + rowNode.SetPassmarkAngleType(angleType); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); + + ListChanged(); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::UpdateGrainlineValues() { @@ -2109,6 +2258,40 @@ void DialogSeamAllowance::InitNodesList() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitPassmarksList() +{ + const quint32 id = CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt(); + + uiTabPassmarks->comboBoxPassmarks->blockSignals(true); + uiTabPassmarks->comboBoxPassmarks->clear(); + + const QVector nodes = GetPieceInternals(uiTabPaths->listWidgetMainPath); + + for (int i = 0; i < nodes.size(); ++i) + { + const VPieceNode node = nodes.at(i); + if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) + { + const QString name = GetNodeName(node); + + uiTabPassmarks->comboBoxPassmarks->addItem(name, node.GetId()); + } + } + uiTabPassmarks->comboBoxPassmarks->blockSignals(false); + + const int index = uiTabPassmarks->comboBoxPassmarks->findData(id); + if (index != -1) + { + uiTabPassmarks->comboBoxPassmarks->setCurrentIndex(index); + PassmarkChanged(index);// Need in case combox index was not changed + } + else + { + uiTabPassmarks->comboBoxPassmarks->count() > 0 ? PassmarkChanged(0) : PassmarkChanged(-1); + } +} + //--------------------------------------------------------------------------------------------------------------------- QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id) { @@ -2194,6 +2377,7 @@ void DialogSeamAllowance::InitFancyTabBar() m_ftb->InsertTab(TabOrder::Labels, QIcon("://icon/32x32/labels.png"), tr("Labels")); m_ftb->InsertTab(TabOrder::Grainline, QIcon("://icon/32x32/grainline.png"), tr("Grainline")); m_ftb->InsertTab(TabOrder::Pins, QIcon("://icon/32x32/pins.png"), tr("Pins")); + m_ftb->InsertTab(TabOrder::Passmarks, QIcon("://icon/32x32/passmark.png"), tr("Passmarks")); ui->horizontalLayout->addWidget(m_ftb, 0, Qt::AlignLeft); @@ -2215,6 +2399,10 @@ void DialogSeamAllowance::InitFancyTabBar() uiTabPins->setupUi(m_tabPins); ui->horizontalLayout->addWidget(m_tabPins, 1); + m_tabPassmarks->hide(); + uiTabPassmarks->setupUi(m_tabPassmarks); + ui->horizontalLayout->addWidget(m_tabPassmarks, 1); + connect(m_ftb, &FancyTabBar::CurrentChanged, this, &DialogSeamAllowance::FancyTabChanged); connect(uiTabLabels->tabWidget, &QTabWidget::currentChanged, this, &DialogSeamAllowance::TabChanged); } @@ -2521,6 +2709,19 @@ void DialogSeamAllowance::InitPinsTab() &DialogSeamAllowance::ShowPinsContextMenu); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitPassmarksTab() +{ + InitPassmarksList(); + connect(uiTabPassmarks->comboBoxPassmarks, static_cast(&QComboBox::currentIndexChanged), + this, &DialogSeamAllowance::PassmarkChanged); + + connect(uiTabPassmarks->buttonGroupLineType, static_cast(&QButtonGroup::buttonClicked), + this, &DialogSeamAllowance::PassmarkLineTypeChanged); + connect(uiTabPassmarks->buttonGroupAngleType, static_cast(&QButtonGroup::buttonClicked), + this, &DialogSeamAllowance::PassmarkAngleTypeChanged); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::InitAllPinComboboxes() { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index f0967b597..98a8ee41e 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -42,6 +42,7 @@ namespace Ui class TabLabels; class TabGrainline; class TabPins; + class TabPassmarks; } class VisPiecePins; @@ -90,6 +91,7 @@ private slots: void ListChanged(); void EnableSeamAllowance(bool enable); void NodeChanged(int index); + void PassmarkChanged(int index); void CSAStartPointChanged(int index); void CSAEndPointChanged(int index); void CSAIncludeTypeChanged(int index); @@ -100,6 +102,8 @@ private slots: void PathDialogClosed(int result); void FancyTabChanged(int index); void TabChanged(int index); + void PassmarkLineTypeChanged(int id); + void PassmarkAngleTypeChanged(int id); void UpdateGrainlineValues(); void UpdateDetailLabelValues(); @@ -158,11 +162,13 @@ private: Ui::TabLabels *uiTabLabels; Ui::TabGrainline *uiTabGrainline; Ui::TabPins *uiTabPins; + Ui::TabPassmarks *uiTabPassmarks; QWidget *m_tabPaths; QWidget *m_tabLabels; QWidget *m_tabGrainline; QWidget *m_tabPins; + QWidget *m_tabPassmarks; FancyTabBar* m_ftb; @@ -236,6 +242,7 @@ private: void InitMainPathTab(); void InitSeamAllowanceTab(); void InitNodesList(); + void InitPassmarksList(); void InitCSAPoint(QComboBox *box); void InitPinPoint(QComboBox *box); void InitSAIncludeType(); @@ -244,6 +251,7 @@ private: void InitLabelsTab(); void InitGrainlineTab(); void InitPinsTab(); + void InitPassmarksTab(); void InitAllPinComboboxes(); void SetFormulaSAWidth(const QString &formula); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui new file mode 100644 index 000000000..ee1f01f9b --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui @@ -0,0 +1,141 @@ + + + TabPassmarks + + + + 0 + 0 + 208 + 285 + + + + Form + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Passmark: + + + + + + + + + + + + true + + + Lines + + + + + + false + + + One line + + + buttonGroupLineType + + + + + + + false + + + Two lines + + + buttonGroupLineType + + + + + + + false + + + Three lines + + + buttonGroupLineType + + + + + + + + + + Angle + + + + + + false + + + Straightforward + + + buttonGroupAngleType + + + + + + + false + + + Bisector + + + buttonGroupAngleType + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + From 799858503fd28bb95dde4651e1122033beddcc82 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 24 Mar 2017 13:17:14 +0200 Subject: [PATCH 03/18] Internal path should have all attributes that has the main path. --HG-- branch : feature --- src/libs/ifc/schema/pattern/v0.4.5.xsd | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ifc/schema/pattern/v0.4.5.xsd b/src/libs/ifc/schema/pattern/v0.4.5.xsd index 2813487dc..90319cf9f 100644 --- a/src/libs/ifc/schema/pattern/v0.4.5.xsd +++ b/src/libs/ifc/schema/pattern/v0.4.5.xsd @@ -348,6 +348,7 @@ + From 6ac1a1247cc246f03e4439516ebc937940b7c0e5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 24 Mar 2017 14:48:07 +0200 Subject: [PATCH 04/18] Read/write passmark information. --HG-- branch : feature --- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.4.6.xsd | 899 ++++++++++++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 56 +- src/libs/ifc/xml/vabstractpattern.h | 3 + src/libs/ifc/xml/vpatternconverter.cpp | 22 +- src/libs/ifc/xml/vpatternconverter.h | 5 +- src/libs/vmisc/def.cpp | 77 ++ src/libs/vmisc/def.h | 17 +- src/libs/vtools/tools/vabstracttool.cpp | 26 +- src/libs/vtools/tools/vtooluniondetails.cpp | 10 +- 10 files changed, 1081 insertions(+), 35 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.4.6.xsd diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 617a40a45..d7e74799b 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -29,6 +29,7 @@ schema/pattern/v0.4.3.xsd schema/pattern/v0.4.4.xsd schema/pattern/v0.4.5.xsd + schema/pattern/v0.4.6.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.4.6.xsd b/src/libs/ifc/schema/pattern/v0.4.6.xsd new file mode 100644 index 000000000..6a43d3873 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.4.6.xsd @@ -0,0 +1,899 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 509634035..c6ecc35e9 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -95,27 +95,30 @@ const QString VAbstractPattern::TagPath = QStringLiteral("path"); const QString VAbstractPattern::TagNodes = QStringLiteral("nodes"); const QString VAbstractPattern::TagNode = QStringLiteral("node"); -const QString VAbstractPattern::AttrName = QStringLiteral("name"); -const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); -const QString VAbstractPattern::AttrObject = QStringLiteral("object"); -const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); -const QString VAbstractPattern::AttrType = QStringLiteral("type"); -const QString VAbstractPattern::AttrLetter = QStringLiteral("letter"); -const QString VAbstractPattern::AttrMaterial = QStringLiteral("material"); -const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); -const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); -const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); -const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); -const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse"); -const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded"); -const QString VAbstractPattern::AttrSABefore = QStringLiteral("before"); -const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after"); -const QString VAbstractPattern::AttrStart = QStringLiteral("start"); -const QString VAbstractPattern::AttrPath = QStringLiteral("path"); -const QString VAbstractPattern::AttrEnd = QStringLiteral("end"); -const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs"); -const QString VAbstractPattern::AttrWidth = QStringLiteral("width"); -const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation"); +const QString VAbstractPattern::AttrName = QStringLiteral("name"); +const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); +const QString VAbstractPattern::AttrObject = QStringLiteral("object"); +const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); +const QString VAbstractPattern::AttrType = QStringLiteral("type"); +const QString VAbstractPattern::AttrLetter = QStringLiteral("letter"); +const QString VAbstractPattern::AttrMaterial = QStringLiteral("material"); +const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); +const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); +const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); +const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); +const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse"); +const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded"); +const QString VAbstractPattern::AttrNodePassmark = QStringLiteral("passmark"); +const QString VAbstractPattern::AttrNodePassmarkLine = QStringLiteral("passmarkLine"); +const QString VAbstractPattern::AttrNodePassmarkAngle = QStringLiteral("passmarkAngle"); +const QString VAbstractPattern::AttrSABefore = QStringLiteral("before"); +const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after"); +const QString VAbstractPattern::AttrStart = QStringLiteral("start"); +const QString VAbstractPattern::AttrPath = QStringLiteral("path"); +const QString VAbstractPattern::AttrEnd = QStringLiteral("end"); +const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs"); +const QString VAbstractPattern::AttrWidth = QStringLiteral("width"); +const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); @@ -673,6 +676,14 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) currentSeamAllowance); const PieceNodeAngle angle = static_cast(VDomDocument::GetParametrUInt(domElement, AttrAngle, "0")); + const bool passmark = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodePassmark, falseStr); + const PassmarkLineType passmarkLine = StringToPassmarkLineType(VDomDocument::GetParametrString(domElement, + VAbstractPattern::AttrNodePassmarkLine, + strOne)); + const PassmarkAngleType passmarkAngle = StringToPassmarkAngleType(VDomDocument::GetParametrString(domElement, + VAbstractPattern::AttrNodePassmarkAngle, + strStraightforward)); + const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint); Tool tool; @@ -708,6 +719,9 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) node.SetFormulaSAAfter(saAfter); node.SetAngleType(angle); node.SetExcluded(excluded); + node.SetPassmark(passmark); + node.SetPassmarkLineType(passmarkLine); + node.SetPassmarkAngleType(passmarkAngle); return node; } diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 0eb281daf..30f0bdd21 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -218,6 +218,9 @@ public: static const QString AttrArrows; static const QString AttrNodeReverse; static const QString AttrNodeExcluded; + static const QString AttrNodePassmark; + static const QString AttrNodePassmarkLine; + static const QString AttrNodePassmarkAngle; static const QString AttrSABefore; static const QString AttrSAAfter; static const QString AttrStart; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 44b74b287..162d46935 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.5"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.5.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.6"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.6.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -209,6 +209,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000404): return QStringLiteral("://schema/pattern/v0.4.4.xsd"); case (0x000405): + return QStringLiteral("://schema/pattern/v0.4.5.xsd"); + case (0x000406): return CurrentSchema; default: InvalidVersion(ver); @@ -335,6 +337,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000405), m_convertedFileName); V_FALLTHROUGH case (0x000405): + ToV0_4_6(); + ValidateXML(XSDSchema(0x000406), m_convertedFileName); + V_FALLTHROUGH + case (0x000406): break; default: InvalidVersion(m_ver); @@ -353,7 +359,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, 4, 5), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 6), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -692,6 +698,16 @@ void VPatternConverter::ToV0_4_5() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_4_6() +{ + // TODO. Delete if minimal supported version is 0.4.6 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 6), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.4.6")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 1eb0a7b0b..fe53ef5ee 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 6); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 6); #endif protected: @@ -106,6 +106,7 @@ private: void ToV0_4_3(); void ToV0_4_4(); void ToV0_4_5(); + void ToV0_4_6(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 37207d9b9..a567583b7 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -2022,3 +2022,80 @@ void InitHighDpiScaling(int argc, char *argv[]) #endif } } + +const QString strOne = QStringLiteral("one"); +const QString strTwo = QStringLiteral("two"); +const QString strThree = QStringLiteral("three"); + +//--------------------------------------------------------------------------------------------------------------------- +QString PassmarkLineTypeToString(PassmarkLineType type) +{ + switch(type) + { + case PassmarkLineType::OneLine: + return strOne; + case PassmarkLineType::TwoLines: + return strTwo; + case PassmarkLineType::ThreeLines: + return strThree; + default: + break; + } + + return strOne; +} + +//--------------------------------------------------------------------------------------------------------------------- +PassmarkLineType StringToPassmarkLineType(const QString &value) +{ + const QStringList values = QStringList() << strOne << strTwo << strThree; + + switch(values.indexOf(value)) + { + case 0: + return PassmarkLineType::OneLine; + case 1: + return PassmarkLineType::TwoLines; + case 2: + return PassmarkLineType::ThreeLines; + default: + break; + } + return PassmarkLineType::OneLine; +} + +const QString strStraightforward = QStringLiteral("straightforward"); +const QString strBisector = QStringLiteral("bisector"); + +//--------------------------------------------------------------------------------------------------------------------- +QString PassmarkAngleTypeToString(PassmarkAngleType type) +{ + switch(type) + { + case PassmarkAngleType::Straightforward: + return strStraightforward; + case PassmarkAngleType::Bisector: + return strBisector; + default: + break; + } + + return strStraightforward; +} + +//--------------------------------------------------------------------------------------------------------------------- +PassmarkAngleType StringToPassmarkAngleType(const QString &value) +{ + const QStringList values = QStringList() << strStraightforward << strBisector; + + switch(values.indexOf(value)) + { + case 0: + return PassmarkAngleType::Straightforward; + case 1: + return PassmarkAngleType::Bisector; + default: + break; + } + return PassmarkAngleType::Straightforward; +} diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index e1523976b..4dfdbad8f 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -91,17 +91,23 @@ enum class PieceNodeAngle : unsigned char enum class PassmarkLineType : unsigned char { - OneLine = 0, + OneLine = 0, // Default TwoLines, ThreeLines }; +QString PassmarkLineTypeToString(PassmarkLineType type); +PassmarkLineType StringToPassmarkLineType(const QString &value); + enum class PassmarkAngleType : unsigned char { - Straightforward = 0, + Straightforward = 0, // Default Bisector }; +QString PassmarkAngleTypeToString(PassmarkAngleType type); +PassmarkAngleType StringToPassmarkAngleType(const QString &value); + enum class PiecePathIncludeType : unsigned char { AsMainPath = 0, @@ -690,6 +696,13 @@ extern const QString degreeSymbol; extern const QString trueStr; extern const QString falseStr; +extern const QString strOne; +extern const QString strTwo; +extern const QString strThree; + +extern const QString strStraightforward; +extern const QString strBisector; + void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1); void SetOverrideCursor(Qt::CursorShape shape); void RestoreOverrideCursor(const QString & pixmapPath); diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index e4397de57..95af6c0bd 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -627,7 +627,7 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa const bool excluded = node.IsExcluded(); if (excluded) { - doc->SetAttribute(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded()); + doc->SetAttribute(nod, VAbstractPattern::AttrNodeExcluded, excluded); } else { // For backward compatebility. @@ -663,6 +663,30 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa doc->SetAttribute(nod, AttrAngle, angleType); } + if (type == Tool::NodePoint) + { + doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmark, node.IsPassmark()); + doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmarkLine, + PassmarkLineTypeToString(node.GetPassmarkLineType())); + doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmarkAngle, + PassmarkAngleTypeToString(node.GetPassmarkAngleType())); + + if (not node.IsPassmark() + && node.GetPassmarkLineType() == PassmarkLineType::OneLine + && node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward) + { // For backward compatebility. + nod.removeAttribute(VAbstractPattern::AttrNodePassmark); + nod.removeAttribute(VAbstractPattern::AttrNodePassmarkLine); + nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle); + } + } + else + { // Wrong configuration. + nod.removeAttribute(VAbstractPattern::AttrNodePassmark); + nod.removeAttribute(VAbstractPattern::AttrNodePassmarkLine); + nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle); + } + return nod; } diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index ef040ae14..d9829a213 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -594,11 +594,11 @@ quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitDat /** * @brief AddToNewDetail create united detail adding one node per time. */ -void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, const VPieceNode &node, +void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node, quint32 idTool, QVector &children, const QString &drawName, qreal dx = 0, qreal dy = 0, quint32 pRotate = NULL_ID, qreal angle = 0); -void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, const VPieceNode &node, +void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node, quint32 idTool, QVector &children, const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle) { @@ -625,10 +625,8 @@ void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &new break; } - VPieceNode newNode(id, node.GetTypeTool(), node.GetReverse()); - newNode.SetExcluded(node.IsExcluded()); - - newPath.Append(newNode); + node.SetId(id); + newPath.Append(node); } //--------------------------------------------------------------------------------------------------------------------- From e9c9d263f66479b7825c879fab66934b758a364f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 25 Mar 2017 10:18:03 +0200 Subject: [PATCH 05/18] Skip excluded nodes when prepare segment of curve. --HG-- branch : feature --- src/libs/vpatterndb/vpiecepath.cpp | 70 ++++++++++++++++++++++++++++-- src/libs/vpatterndb/vpiecepath.h | 3 ++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 998061e1b..3e23330e4 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -387,9 +387,12 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector 1) { int index = 0; - i == 0 ? index = nodes.size()-1 : index = i-1; + i == 0 ? index = FindInLoopNotExcludedUp(nodes.size()-1, nodes) : index = FindInLoopNotExcludedUp(i-1, nodes); - begin = CurveStartPoint(begin, data, nodes.at(index), points); + if (index != -1 && index != i) + { + begin = CurveStartPoint(begin, data, nodes.at(index), points); + } } return begin; } @@ -416,9 +419,12 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector 2) { int index = 0; - i == nodes.size() - 1 ? index = 0 : index = i+1; + i == nodes.size()-1 ? index=FindInLoopNotExcludedDown(0, nodes) : index=FindInLoopNotExcludedDown(i+1, nodes); - end = CurveEndPoint(end, data, nodes.at(index), points); + if (index != -1 && index != i) + { + end = CurveEndPoint(end, data, nodes.at(index), points); + } } return end; } @@ -762,6 +768,62 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const return point; } +//--------------------------------------------------------------------------------------------------------------------- +int VPiecePath::FindInLoopNotExcludedUp(int candidate, const QVector &nodes) +{ + if (candidate < 0 || candidate >= nodes.size()) + { + return -1; + } + + int checked = 0; + int i = candidate; + do + { + if (not nodes.at(i).IsExcluded()) + { + break; + } + + ++checked; + --i; + if (i < 0) + { + i = nodes.size() - 1; + } + } while (checked < nodes.size()); + + return i; +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPiecePath::FindInLoopNotExcludedDown(int candidate, const QVector &nodes) +{ + if (candidate < 0 || candidate >= nodes.size()) + { + return -1; + } + + int checked = 0; + int i = candidate; + do + { + if (not nodes.at(i).IsExcluded()) + { + break; + } + + ++checked; + ++i; + if (i >= nodes.size()) + { + i = 0; + } + } while (checked < nodes.size()); + + return i; +} + //--------------------------------------------------------------------------------------------------------------------- VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data) { diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 492053c0c..8bda5957b 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -94,6 +94,9 @@ public: QPointF NodePreviousPoint(const VContainer *data, int i) const; QPointF NodeNextPoint(const VContainer *data, int i) const; + static int FindInLoopNotExcludedUp(int candidate, const QVector &nodes); + static int FindInLoopNotExcludedDown(int candidate, const QVector &nodes); + static VSAPoint StartSegment(const VContainer *data, const QVector &nodes, int i, bool reverse); static VSAPoint EndSegment(const VContainer *data, const QVector &nodes, int i, bool reverse); From 39c11130f9bcaa239590ac2cf954837db7f3ed5b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 28 Mar 2017 12:08:33 +0300 Subject: [PATCH 06/18] Fix bug with internal move of nodes inside the main path. --HG-- branch : feature --- src/app/valentina/main.cpp | 3 ++ src/libs/vpatterndb/vpiecenode.cpp | 15 +++++++++ src/libs/vpatterndb/vpiecenode.h | 3 ++ src/libs/vpatterndb/vpiecenode_p.h | 53 +++++++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 51c1ce34c..f4e7fccfd 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -54,6 +54,9 @@ int main(int argc, char *argv[]) qt_qhash_seed.store(0); // Lock producing random attribute order in XML + // Need to internally move a node inside a piece main path + qRegisterMetaTypeStreamOperators("VPieceNode"); + #ifndef Q_OS_MAC // supports natively InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 36df0b31b..e2692521d 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -97,6 +97,21 @@ VPieceNode &VPieceNode::operator=(const VPieceNode &node) VPieceNode::~VPieceNode() {} +// Friend functions +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator<<(QDataStream &out, const VPieceNode &p) +{ + out << p.d; + return out; +} + +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator>>(QDataStream &in, VPieceNode &p) +{ + in >> *p.d; + return in; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VPieceNode::GetId() const { diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index 66684686f..c4215586f 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -47,6 +47,9 @@ public: VPieceNode &operator=(const VPieceNode &node); ~VPieceNode(); + friend QDataStream& operator<<(QDataStream& out, const VPieceNode& p); + friend QDataStream& operator>>(QDataStream& in, VPieceNode& p); + quint32 GetId() const; void SetId(quint32 id); diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index bd53c1ef3..8e91c7a10 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -92,6 +92,9 @@ public: ~VPieceNodeData(); + friend QDataStream& operator<<(QDataStream& out, const VPieceNodeData& p); + friend QDataStream& operator>>(QDataStream& in, VPieceNodeData& p); + /** @brief id object id. */ quint32 m_id; @@ -116,7 +119,7 @@ public: PieceNodeAngle m_angleType; - PassmarkLineType m_passmarkLineType; + PassmarkLineType m_passmarkLineType; PassmarkAngleType m_passmarkAngleType; private: @@ -126,6 +129,54 @@ private: VPieceNodeData::~VPieceNodeData() {} +// Friend functions +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p) +{ + out << p.m_id + << static_cast(p.m_typeTool) + << p.m_reverse + << p.m_excluded + << p.m_isPassmark + << p.m_saBefore + << p.m_saAfter + << p.m_formulaWidthBefore + << p.m_formulaWidthAfter + << static_cast(p.m_angleType) + << static_cast(p.m_passmarkLineType) + << static_cast(p.m_passmarkAngleType); + return out; +} + +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator>>(QDataStream &in, VPieceNodeData &p) +{ + int typeTool = 0; + int angleType = 0; + int passmarkLineType = 0; + int passmarkAngleType = 0; + + in >> p.m_id + >> typeTool + >> p.m_reverse + >> p.m_excluded + >> p.m_isPassmark + >> p.m_saBefore + >> p.m_saAfter + >> p.m_formulaWidthBefore + >> p.m_formulaWidthAfter + >> angleType + >> passmarkLineType + >> passmarkAngleType; + + p.m_typeTool = static_cast(typeTool); + p.m_angleType = static_cast(angleType); + p.m_passmarkLineType = static_cast(passmarkLineType); + p.m_passmarkAngleType = static_cast(passmarkAngleType); + + return in; +} + QT_WARNING_POP #endif // VPIECENODE_P_H From b9bebcaeb468014390eddd98b4c20f61139e847b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 28 Mar 2017 13:09:00 +0300 Subject: [PATCH 07/18] Show passmarks in the main path. --HG-- branch : feature --- src/libs/vlayout/vabstractpiece.h | 6 +- src/libs/vpatterndb/vpiece.cpp | 485 ++++++++++++++++++- src/libs/vpatterndb/vpiece.h | 17 + src/libs/vtools/tools/vtoolseamallowance.cpp | 18 +- 4 files changed, 515 insertions(+), 11 deletions(-) diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 4fa1e78b5..4cea4f1ac 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -158,6 +158,9 @@ public: static QVector Equidistant(const QVector &points, qreal width); static qreal SumTrapezoids(const QVector &points); static QVector CheckLoops(const QVector &points); + static QVector EkvPoint(const VSAPoint &p1Line1, const VSAPoint &p2Line1, + const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width); + static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width); template static QVector CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast = true); @@ -176,8 +179,6 @@ private: static QVector SubPath(const QVector &path, int startIndex, int endIndex); static Q_DECL_CONSTEXPR qreal PointPosition(const QPointF &p, const QLineF &line); static qreal MaxLocalSA(const VSAPoint &p, qreal width); - static QVector EkvPoint(const VSAPoint &p1Line1, const VSAPoint &p2Line1, - const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width); static QVector AngleByLength(const QPointF &p2, const QPointF &sp1, const QPointF &sp2, const QPointF &sp3, qreal width); static QVector AngleByIntersection(const QPointF &p1, const QPointF &p2, const QPointF &p3, @@ -195,7 +196,6 @@ private: static QVector AngleBySecondRightAngle(const QPointF &p2, const QPointF &p3, const QPointF &sp1, const QPointF &sp2, const QPointF &sp3, qreal width); - static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width); static QLineF ParallelLine(const QPointF &p1, const QPointF &p2, qreal width); static QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width); static QLineF BisectorLine(const QPointF &p1, const QPointF &p2, const QPointF &p3); diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 1de1c57ca..904c32fb9 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -66,6 +66,155 @@ QVector PieceMissingNodes(const QVector &d1Nodes, const QVecto return r; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector FilterRecords(QVector records) +{ + if (records.size() < 2) + { + return records; + } + + bool foundFilter = false;// Need in case "filter" will stay empty. + CustomSARecord filter; + int startIndex = records.size()-1; + + for (int i = 0; i < records.size(); ++i) + { + if (records.at(i).startPoint < static_cast(startIndex)) + { + startIndex = i; + filter = records.at(i); + foundFilter = true; + } + } + + if (not foundFilter) + { + return records; // return as is + } + + records.remove(startIndex); + + QVector secondRound; + for (int i = 0; i < records.size(); ++i) + { + if (records.at(i).startPoint > filter.endPoint) + { + secondRound.append(records.at(i)); + } + } + + QVector filtered; + filtered.append(filter); + + filtered += FilterRecords(secondRound); + + return filtered; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal PassmarkLength(const VSAPoint &passmarkSAPoint, qreal width) +{ + qreal w1 = passmarkSAPoint.GetSAAfter(); + if (w1 < 0) + { + w1 = width; + } + + qreal w2 = passmarkSAPoint.GetSABefore(); + if (w2 < 0) + { + w2 = width; + } + + return qMax(w1, w2); +} + +const qreal passmarkGap = (1.5/*mm*/ / 25.4) * PrintDPI; + +//--------------------------------------------------------------------------------------------------------------------- +QVector CreateTwoPassmarkLines(const QLineF &line) +{ + QPointF l1p1; + { + QLineF line1 = line; + line1.setAngle(line1.angle() + 90); + line1.setLength(passmarkGap/2.); + l1p1 = line1.p2(); + } + + QPointF l2p1; + { + QLineF line2 = line; + line2.setAngle(line2.angle() - 90); + line2.setLength(passmarkGap/2.); + l2p1 = line2.p2(); + } + + QPointF l1p2; + { + QLineF line1 = QLineF(line.p2(), line.p1()); + line1.setAngle(line1.angle() - 90); + line1.setLength(passmarkGap/2.); + l1p2 = line1.p2(); + } + + QPointF l2p2; + { + QLineF line2 = QLineF(line.p2(), line.p1()); + line2.setAngle(line2.angle() + 90); + line2.setLength(passmarkGap/2.); + l2p2 = line2.p2(); + } + + QVector lines; + lines.append(QLineF(l1p1, l1p2)); + lines.append(QLineF(l2p1, l2p2)); + return lines; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector CreateThreePassmarkLines(const QLineF &line) +{ + QPointF l1p1; + { + QLineF line1 = line; + line1.setAngle(line1.angle() + 90); + line1.setLength(passmarkGap); + l1p1 = line1.p2(); + } + + QPointF l2p1; + { + QLineF line2 = line; + line2.setAngle(line2.angle() - 90); + line2.setLength(passmarkGap); + l2p1 = line2.p2(); + } + + QPointF l1p2; + { + QLineF line1 = QLineF(line.p2(), line.p1()); + line1.setAngle(line1.angle() - 90); + line1.setLength(passmarkGap); + l1p2 = line1.p2(); + } + + QPointF l2p2; + { + QLineF line2 = QLineF(line.p2(), line.p1()); + line2.setAngle(line2.angle() + 90); + line2.setLength(passmarkGap); + l2p2 = line2.p2(); + } + + QVector lines; + lines.append(QLineF(l1p1, l1p2)); + lines.append(line); + lines.append(QLineF(l2p1, l2p2)); + return lines; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -137,7 +286,7 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const return QVector(); } - const QVector records = GetValidRecords(); + const QVector records = FilterRecords(GetValidRecords()); int recordIndex = -1; bool insertingCSA = false; const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); @@ -215,6 +364,52 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const return Equidistant(pointsEkv, width); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::PassmarksLines(const VContainer *data) const +{ + if (not IsSeamAllowance() || not IsPassmarksPossible()) + { + return QVector(); + } + + QVector passmarks; + + for (int i = 0; i< d->m_path.CountNodes(); ++i) + { + const VPieceNode &node = d->m_path.at(i); + if (node.IsExcluded() || not node.IsPassmark()) + { + continue;// skip node + } + + int passmarkIndex = i; + + int previousIndex = 0; + if (passmarkIndex == 0) + { + previousIndex = VPiecePath::FindInLoopNotExcludedUp(d->m_path.CountNodes()-1, d->m_path.GetNodes()); + } + else + { + previousIndex = VPiecePath::FindInLoopNotExcludedUp(passmarkIndex-1, d->m_path.GetNodes()); + } + + int nextIndex = 0; + if (passmarkIndex == d->m_path.CountNodes()-1) + { + nextIndex = VPiecePath::FindInLoopNotExcludedDown(0, d->m_path.GetNodes()); + } + else + { + nextIndex = VPiecePath::FindInLoopNotExcludedDown(passmarkIndex+1, d->m_path.GetNodes()); + } + + passmarks += CreatePassmark(previousIndex, passmarkIndex, nextIndex, data); + } + + return passmarks; +} + //--------------------------------------------------------------------------------------------------------------------- QPainterPath VPiece::MainPathPath(const VContainer *data) const { @@ -259,6 +454,30 @@ QPainterPath VPiece::SeamAllowancePath(const VContainer *data) const return ekv; } +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VPiece::PassmarksPath(const VContainer *data) const +{ + const QVector passmarks = PassmarksLines(data); + QPainterPath path; + + // seam allowence + if (IsSeamAllowance()) + { + if (not passmarks.isEmpty()) + { + for (qint32 i = 0; i < passmarks.count(); ++i) + { + path.moveTo(passmarks.at(i).p1()); + path.lineTo(passmarks.at(i).p2()); + } + + path.setFillRule(Qt::WindingFill); + } + } + + return path; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VPiece::GetMx() const { @@ -505,7 +724,8 @@ QVector VPiece::GetValidRecords() const && indexStartPoint != -1 && not d->m_path.at(indexStartPoint).IsExcluded() && indexEndPoint != -1 - && not d->m_path.at(indexEndPoint).IsExcluded()) + && not d->m_path.at(indexEndPoint).IsExcluded() + && record.startPoint < record.endPoint) { records.append(record); } @@ -513,6 +733,267 @@ QVector VPiece::GetValidRecords() const return records; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::GetNodeSAPoints(int index, const VContainer *data) const +{ + SCASSERT(data != nullptr) + + if (index < 0 || index >= d->m_path.CountNodes()) + { + return QVector(); + } + + const VPieceNode &node = d->m_path.at(index); + QVector points; + + if (node.GetTypeTool() == Tool::NodePoint) + { + points.append(VPiecePath::PreparePointEkv(node, data)); + } + else + { + const QSharedPointer curve = data->GeometricObject(node.GetId()); + const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); + + points += VPiecePath::CurveSeamAllowanceSegment(data, d->m_path.GetNodes(), curve, index, node.GetReverse(), + width); + } + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::GetPassmarkSAPoint(int index, const VContainer *data, VSAPoint &point) const +{ + SCASSERT(data != nullptr) + + const QVector points = GetNodeSAPoints(index, data); + + if (points.isEmpty() || points.size() > 1) + { + return false; + } + + point = points.first(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::GetPassmarkPreviousSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, + VSAPoint &point) const +{ + SCASSERT(data != nullptr) + + const QVector points = GetNodeSAPoints(index, data); + + if (points.isEmpty()) + { + return false; // Something wrong + } + + bool found = false; + int nodeIndex = points.size()-1; + do + { + const VSAPoint previous = points.at(nodeIndex); + if (passmarkSAPoint.toPoint() != previous.toPoint()) + { + point = previous; + found = true; + } + --nodeIndex; + } while (nodeIndex >= 0 && not found); + + if (not found) + { + return false; // Something wrong + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::GetPassmarkNextSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, + VSAPoint &point) const +{ + const QVector points = GetNodeSAPoints(index, data); + + if (points.isEmpty()) + { + return false; // Something wrong + } + + bool found = false; + int nodeIndex = 0; + do + { + const VSAPoint next = points.at(nodeIndex); + if (passmarkSAPoint.toPoint() != next.toPoint()) + { + point = next; + found = true; + } + ++nodeIndex; + + } while (nodeIndex < points.size() && not found); + + if (not found) + { + return false; // Something wrong + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPoint &passmarkSAPoint, + const VSAPoint &nextSAPoint, const VContainer *data, QPointF &point) const +{ + SCASSERT(data != nullptr) + + const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); + const QVector ekvPoints = EkvPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, passmarkSAPoint, width); + + if (ekvPoints.isEmpty()) + { // Just in case + return false; // Something wrong + } + + if (ekvPoints.size() == 1 || ekvPoints.size() > 2) + { + point = ekvPoints.first(); + } + else if (ekvPoints.size() == 2) + { + QLineF line = QLineF(ekvPoints.at(0), ekvPoints.at(1)); + line.setLength(line.length()/2.); + point = line.p2(); + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::IsPassmarksPossible() const +{ + int countPointNodes = 0; + int countOthers = 0; + + for (int i = 0; i< d->m_path.CountNodes(); ++i) + { + const VPieceNode &node = d->m_path.at(i); + if (node.IsExcluded()) + { + continue;// skip node + } + + node.GetTypeTool() == Tool::NodePoint ? ++countPointNodes : ++countOthers; + } + + return countPointNodes >= 3 || (countPointNodes >= 1 && countOthers >= 1); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPiece::IsPassmarkVisible(int passmarkIndex) const +{ + if (passmarkIndex < 0 || passmarkIndex >= d->m_path.CountNodes()) + { + return false; + } + + const VPieceNode &node = d->m_path.at(passmarkIndex); + if (node.GetTypeTool() != Tool::NodePoint || not node.IsPassmark() || node.IsExcluded()) + { + return false; + } + + const QVector records = FilterRecords(GetValidRecords()); + if (records.isEmpty()) + { + return true; + } + + for (int i = 0; i < records.size(); ++i) + { + const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); + const int indexEndPoint = d->m_path.indexOfNode(records.at(i).endPoint); + if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint) + { + return false; + } + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::CreatePassmark(int previousIndex, int passmarkIndex, int nextIndex, + const VContainer *data) const +{ + SCASSERT(data != nullptr); + + if (not IsPassmarkVisible(passmarkIndex)) + { + return QVector(); + } + + VSAPoint passmarkSAPoint; + if (not GetPassmarkSAPoint(passmarkIndex, data, passmarkSAPoint)) + { + return QVector(); // Something wrong + } + + VSAPoint previousSAPoint; + if (not GetPassmarkPreviousSAPoint(previousIndex, passmarkSAPoint, data, previousSAPoint)) + { + return QVector(); // Something wrong + } + + VSAPoint nextSAPoint; + if (not GetPassmarkNextSAPoint(nextIndex, passmarkSAPoint, data, nextSAPoint)) + { + return QVector(); // Something wrong + } + + QPointF seamPassmarkSAPoint; + if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint)) + { + return QVector(); // Something wrong + } + + const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); + const QLineF bigLine1 = ParallelLine(previousSAPoint, passmarkSAPoint, width ); + const QLineF bigLine2 = ParallelLine(passmarkSAPoint, nextSAPoint, width ); + + QVector passmarksLines; + + const qreal passmarkLength = PassmarkLength(passmarkSAPoint, width) * 0.25; + const VPieceNode &node = d->m_path.at(passmarkIndex); + if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward) + { + QLineF line = QLineF(seamPassmarkSAPoint, passmarkSAPoint); + line.setLength(passmarkLength); + if (node.GetPassmarkLineType() == PassmarkLineType::TwoLines) + { + passmarksLines += CreateTwoPassmarkLines(line); + } + else if (node.GetPassmarkLineType() == PassmarkLineType::ThreeLines) + { + passmarksLines += CreateThreePassmarkLines(line); + } + else + { + passmarksLines.append(line); + } + } + else + { + QLineF edge1 = QLineF(seamPassmarkSAPoint, bigLine1.p1()); + QLineF edge2 = QLineF(seamPassmarkSAPoint, bigLine2.p2()); + + edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.); + edge1.setLength(passmarkLength); + passmarksLines.append(edge1); + } + + return passmarksLines; +} + //--------------------------------------------------------------------------------------------------------------------- int VPiece::IsCSAStart(const QVector &records, quint32 id) { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 234a2bbf1..1235f16f4 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -61,9 +61,11 @@ public: QVector MainPathPoints(const VContainer *data) const; QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; QVector SeamAllowancePoints(const VContainer *data) const; + QVector PassmarksLines(const VContainer *data) const; QPainterPath MainPathPath(const VContainer *data) const; QPainterPath SeamAllowancePath(const VContainer *data) const; + QPainterPath PassmarksPath(const VContainer *data) const; qreal GetMx() const; void SetMx(qreal value); @@ -113,6 +115,21 @@ private: QVector GetValidRecords() const; + QVector GetNodeSAPoints(int index, const VContainer *data) const; + + bool GetPassmarkSAPoint(int index, const VContainer *data, VSAPoint &point) const; + bool GetPassmarkPreviousSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, + VSAPoint &point) const; + bool GetPassmarkNextSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, + VSAPoint &point) const; + bool GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPoint &passmarkSAPoint, + const VSAPoint &nextSAPoint, const VContainer *data, QPointF &point) const; + + bool IsPassmarksPossible() const; + bool IsPassmarkVisible(int passmarkIndex) const; + + QVector CreatePassmark(int previousIndex, int passmarkIndex, int nextIndex, const VContainer *data) const; + static int IsCSAStart(const QVector &records, quint32 id); }; diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 3bcbd3976..adc856fa2 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1172,7 +1172,7 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, this->setFlag(QGraphicsItem::ItemIsSelectable, true); RefreshGeometry(); - m_seamAllowance->setBrush(QBrush(Qt::FDiagPattern)); + m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern)); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus @@ -1232,15 +1232,21 @@ void VToolSeamAllowance::RefreshGeometry() this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); const VPiece detail = VAbstractTool::data.GetPiece(id); - QPainterPath mainPath = detail.MainPathPath(this->getData()); - this->setPath(mainPath); + QPainterPath path = detail.MainPathPath(this->getData()); + + { + QPainterPath mainPath = path; + mainPath.addPath(detail.PassmarksPath(this->getData())); + this->setPath(mainPath); + } + this->setPos(detail.GetMx(), detail.GetMy()); if (detail.IsSeamAllowance()) { - mainPath.addPath(detail.SeamAllowancePath(this->getData())); - mainPath.setFillRule(Qt::OddEvenFill); - m_seamAllowance->setPath(mainPath); + path.addPath(detail.SeamAllowancePath(this->getData())); + path.setFillRule(Qt::OddEvenFill); + m_seamAllowance->setPath(path); } else { From 33da692248cd8d76334645b18e74f34bbef9802b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 29 Mar 2017 13:09:49 +0300 Subject: [PATCH 08/18] Added special check for tools those use free click. When a user click on point the app show line between selected point and a mouse cursor. This usefull when need to select an angle or length. But because selection of a point also emit release event this particular event should be ignored. In case of release inside of point circle all worked good, but not if select point by label. --HG-- branch : feature --- .../dialogs/tools/dialogcurveintersectaxis.cpp | 15 +++++++++++++-- .../dialogs/tools/dialogcurveintersectaxis.h | 2 ++ src/libs/vtools/dialogs/tools/dialogendline.cpp | 17 +++++++++++++++-- src/libs/vtools/dialogs/tools/dialogendline.h | 2 ++ .../dialogs/tools/dialoglineintersectaxis.cpp | 15 +++++++++++++-- .../dialogs/tools/dialoglineintersectaxis.h | 2 ++ .../vtools/dialogs/tools/dialogrotation.cpp | 11 ++++++++++- src/libs/vtools/dialogs/tools/dialogrotation.h | 2 ++ 8 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index da06c4a6e..c52d44a38 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -56,8 +56,11 @@ //--------------------------------------------------------------------------------------------------------------------- DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), formulaAngle(QString()), - formulaBaseHeightAngle(0) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogCurveIntersectAxis), + formulaAngle(), + formulaBaseHeightAngle(0), + m_firstRelease(false) { ui->setupUi(this); @@ -191,6 +194,14 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) { if (click) { + // The check need to ignore first release of mouse button. + // User can select point by clicking on a label. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr) diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h index 531be5591..86be59791 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h @@ -88,6 +88,8 @@ private: QString formulaAngle; int formulaBaseHeightAngle; + + bool m_firstRelease; }; #endif // DIALOGCURVEINTERSECTAXIS_H diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index d67822fca..e59ac6041 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -62,8 +62,13 @@ * @param parent parent widget */ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), - formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogEndLine), + formulaLength(), + formulaAngle(), + formulaBaseHeight(0), + formulaBaseHeightAngle(0), + m_firstRelease(false) { ui->setupUi(this); @@ -298,6 +303,14 @@ void DialogEndLine::ShowDialog(bool click) { if (click) { + // The check need to ignore first release of mouse button. + // User can select point by clicking on a label. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + /*We will ignore click if pointer is in point circle*/ VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr) diff --git a/src/libs/vtools/dialogs/tools/dialogendline.h b/src/libs/vtools/dialogs/tools/dialogendline.h index 66c61417a..79afc7e98 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.h +++ b/src/libs/vtools/dialogs/tools/dialogendline.h @@ -110,6 +110,8 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; int formulaBaseHeightAngle; + + bool m_firstRelease; }; #endif // DIALOGENDLINE_H diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 2adf57691..7e4ac7123 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -60,8 +60,11 @@ //--------------------------------------------------------------------------------------------------------------------- DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), formulaAngle(QString()), - formulaBaseHeightAngle(0) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogLineIntersectAxis), + formulaAngle(), + formulaBaseHeightAngle(0), + m_firstRelease(false) { ui->setupUi(this); @@ -220,6 +223,14 @@ void DialogLineIntersectAxis::ShowDialog(bool click) { if (click) { + // The check need to ignore first release of mouse button. + // User can select point by clicking on a label. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr) diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h index d43f60d5e..49f690b46 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h @@ -92,6 +92,8 @@ private: QString formulaAngle; int formulaBaseHeightAngle; + + bool m_firstRelease; }; #endif // DIALOGLINEINTERSECTAXIS_H diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 9259be628..06f418a8b 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -72,7 +72,8 @@ DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QW formulaBaseHeightAngle(0), objects(), stage1(true), - m_suffix() + m_suffix(), + m_firstRelease(false) { ui->setupUi(this); @@ -200,6 +201,14 @@ void DialogRotation::ShowDialog(bool click) } else if (not stage1 && prepare && click) { + // The check need to ignore first release of mouse button. + // User can select point by clicking on a label. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + /*We will ignore click if pointer is in point circle*/ VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr) diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.h b/src/libs/vtools/dialogs/tools/dialogrotation.h index ada4857a9..ac6a14066 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.h +++ b/src/libs/vtools/dialogs/tools/dialogrotation.h @@ -109,6 +109,8 @@ private: QString m_suffix; + bool m_firstRelease; + void EvalAngle(); }; From 330e831815e42479b995d3ed15c4674ceb097965 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 29 Mar 2017 13:50:16 +0300 Subject: [PATCH 09/18] Fix multiple calling of method EndVisualization(). --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 80b15fc92..f255b341a 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -354,6 +354,7 @@ void MainWindow::InitScenes() sceneDetails->setTransform(ui->view->transform()); connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); + connect(ui->view, &VMainGraphicsView::MouseRelease, RECEIVER(this)[this](){EndVisualization(true);}); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); ui->view->setSizePolicy(policy); @@ -588,7 +589,6 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject); connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); - connect(ui->view, &VMainGraphicsView::MouseRelease, [this](){EndVisualization(true);}); ui->view->itemClicked(nullptr); } else From 11a7bf89b487715de139df48b5737d985aff938a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 29 Mar 2017 14:18:33 +0300 Subject: [PATCH 10/18] Piece path now works with passmarks. --HG-- branch : feature --- src/libs/vpatterndb/vpiece.cpp | 95 ++++---- src/libs/vpatterndb/vpiece.h | 1 + .../vtools/dialogs/tools/dialogpiecepath.cpp | 208 +++++++++++++++++- .../vtools/dialogs/tools/dialogpiecepath.h | 5 + .../vtools/dialogs/tools/dialogpiecepath.ui | 127 +++++++++++ src/libs/vtools/dialogs/tools/dialogtool.h | 17 ++ .../tools/piece/dialogseamallowance.cpp | 32 +-- .../dialogs/tools/piece/dialogseamallowance.h | 3 - 8 files changed, 413 insertions(+), 75 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 904c32fb9..6355f8a7b 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -67,52 +67,6 @@ QVector PieceMissingNodes(const QVector &d1Nodes, const QVecto return r; } -//--------------------------------------------------------------------------------------------------------------------- -QVector FilterRecords(QVector records) -{ - if (records.size() < 2) - { - return records; - } - - bool foundFilter = false;// Need in case "filter" will stay empty. - CustomSARecord filter; - int startIndex = records.size()-1; - - for (int i = 0; i < records.size(); ++i) - { - if (records.at(i).startPoint < static_cast(startIndex)) - { - startIndex = i; - filter = records.at(i); - foundFilter = true; - } - } - - if (not foundFilter) - { - return records; // return as is - } - - records.remove(startIndex); - - QVector secondRound; - for (int i = 0; i < records.size(); ++i) - { - if (records.at(i).startPoint > filter.endPoint) - { - secondRound.append(records.at(i)); - } - } - - QVector filtered; - filtered.append(filter); - - filtered += FilterRecords(secondRound); - - return filtered; -} - //--------------------------------------------------------------------------------------------------------------------- qreal PassmarkLength(const VSAPoint &passmarkSAPoint, qreal width) { @@ -733,6 +687,55 @@ QVector VPiece::GetValidRecords() const return records; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::FilterRecords(QVector records) const +{ + if (records.size() < 2) + { + return records; + } + + bool foundFilter = false;// Need in case "filter" will stay empty. + CustomSARecord filter; + int startIndex = d->m_path.CountNodes()-1; + + for (int i = 0; i < records.size(); ++i) + { + const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); + if (indexStartPoint < startIndex) + { + startIndex = i; + filter = records.at(i); + foundFilter = true; + } + } + + if (not foundFilter) + { + return records; // return as is + } + + records.remove(startIndex); + + QVector secondRound; + for (int i = 0; i < records.size(); ++i) + { + const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); + const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint); + if (indexStartPoint > indexEndPoint) + { + secondRound.append(records.at(i)); + } + } + + QVector filtered; + filtered.append(filter); + + filtered += FilterRecords(secondRound); + + return filtered; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::GetNodeSAPoints(int index, const VContainer *data) const { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 1235f16f4..7f5c40ec6 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -114,6 +114,7 @@ private: QSharedDataPointer d; QVector GetValidRecords() const; + QVector FilterRecords(QVector records) const; QVector GetNodeSAPoints(int index, const VContainer *data) const; diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp index 6f218628b..49faa85ec 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.cpp @@ -55,6 +55,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget InitPathTab(); InitSeamAllowanceTab(); + InitPassmarksTab(); flagName = true;//We have default name of piece. flagError = PathIsValid(); @@ -62,7 +63,8 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget vis = new VisToolPiecePath(data); - ui->tabWidget->removeTab(1); + ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabSeamAllowance)); + ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPassmarks)); } //--------------------------------------------------------------------------------------------------------------------- @@ -224,6 +226,7 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos) SCASSERT(rowItem != nullptr); VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + QAction *actionPassmark = nullptr; QAction *actionReverse = nullptr; if (rowNode.GetTypeTool() != Tool::NodePoint) { @@ -231,6 +234,12 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos) actionReverse->setCheckable(true); actionReverse->setChecked(rowNode.GetReverse()); } + else + { + actionPassmark = menu->addAction(tr("Passmark")); + actionPassmark->setCheckable(true); + actionPassmark->setChecked(rowNode.IsPassmark()); + } QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); @@ -238,16 +247,21 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos) if (selectedAction == actionDelete) { delete ui->listWidget->item(row); - ValidObjects(PathIsValid()); } else if (rowNode.GetTypeTool() != Tool::NodePoint && selectedAction == actionReverse) { rowNode.SetReverse(not rowNode.GetReverse()); rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); rowItem->setText(GetNodeName(rowNode, true)); - ValidObjects(PathIsValid()); + } + else if (selectedAction == actionPassmark) + { + rowNode.SetPassmark(not rowNode.IsPassmark()); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); } + ValidObjects(PathIsValid()); ListChanged(); } @@ -357,6 +371,68 @@ void DialogPiecePath::NodeChanged(int index) ui->comboBoxAngle->blockSignals(false); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::PassmarkChanged(int index) +{ + ui->radioButtonOneLine->setDisabled(true); + ui->radioButtonTwoLines->setDisabled(true); + ui->radioButtonThreeLines->setDisabled(true); + + ui->radioButtonStraightforward->setDisabled(true); + ui->radioButtonBisector->setDisabled(true); + + ui->groupBoxLineType->blockSignals(true); + ui->groupBoxAngleType->blockSignals(true); + + if (index != -1) + { + const VPiecePath path = CreatePath(); + const int nodeIndex = path.indexOfNode(CURRENT_DATA(ui->comboBoxPassmarks).toUInt()); + if (nodeIndex != -1) + { + const VPieceNode &node = path.at(nodeIndex); + + // Line type + ui->radioButtonOneLine->setEnabled(true); + ui->radioButtonTwoLines->setEnabled(true); + ui->radioButtonThreeLines->setEnabled(true); + + switch(node.GetPassmarkLineType()) + { + case PassmarkLineType::OneLine: + ui->radioButtonOneLine->setChecked(true); + break; + case PassmarkLineType::TwoLines: + ui->radioButtonTwoLines->setChecked(true); + break; + case PassmarkLineType::ThreeLines: + ui->radioButtonThreeLines->setChecked(true); + break; + default: + break; + } + + // Angle type + ui->radioButtonStraightforward->setEnabled(true); + ui->radioButtonBisector->setEnabled(true); + + switch(node.GetPassmarkAngleType()) + { + case PassmarkAngleType::Straightforward: + ui->radioButtonStraightforward->setChecked(true); + break; + case PassmarkAngleType::Bisector: + ui->radioButtonBisector->setChecked(true); + break; + default: + break; + } + } + } + ui->groupBoxLineType->blockSignals(false); + ui->groupBoxAngleType->blockSignals(false); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::ReturnDefBefore() { @@ -369,6 +445,70 @@ void DialogPiecePath::ReturnDefAfter() ui->plainTextEditFormulaWidthAfter->setPlainText(currentSeamAllowance); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::PassmarkLineTypeChanged(int id) +{ + const int i = ui->comboBoxPassmarks->currentIndex(); + if (i != -1) + { + QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxPassmarks).toUInt()); + if (rowItem) + { + VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + PassmarkLineType lineType = PassmarkLineType::OneLine; + if (id == ui->buttonGroupLineType->id(ui->radioButtonOneLine)) + { + lineType = PassmarkLineType::OneLine; + } + else if (id == ui->buttonGroupLineType->id(ui->radioButtonTwoLines)) + { + lineType = PassmarkLineType::TwoLines; + } + else if (id == ui->buttonGroupLineType->id(ui->radioButtonThreeLines)) + { + lineType = PassmarkLineType::ThreeLines; + } + + rowNode.SetPassmarkLineType(lineType); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); + + ListChanged(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::PassmarkAngleTypeChanged(int id) +{ + const int i = ui->comboBoxPassmarks->currentIndex(); + if (i != -1) + { + QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxPassmarks).toUInt()); + if (rowItem) + { + VPieceNode rowNode = qvariant_cast(rowItem->data(Qt::UserRole)); + + PassmarkAngleType angleType = PassmarkAngleType::Straightforward; + if (id == ui->buttonGroupAngleType->id(ui->radioButtonStraightforward)) + { + angleType = PassmarkAngleType::Straightforward; + } + else if (id == ui->buttonGroupAngleType->id(ui->radioButtonBisector)) + { + angleType = PassmarkAngleType::Bisector; + } + + rowNode.SetPassmarkAngleType(angleType); + rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode)); + rowItem->setText(GetNodeName(rowNode, true)); + + ListChanged(); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::EvalWidth() { @@ -581,6 +721,19 @@ void DialogPiecePath::InitSeamAllowanceTab() &DialogPiecePath::DeployWidthAfterFormulaTextEdit); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::InitPassmarksTab() +{ + InitPassmarksList(); + connect(ui->comboBoxPassmarks, static_cast(&QComboBox::currentIndexChanged), + this, &DialogPiecePath::PassmarkChanged); + + connect(ui->buttonGroupLineType, static_cast(&QButtonGroup::buttonClicked), + this, &DialogPiecePath::PassmarkLineTypeChanged); + connect(ui->buttonGroupAngleType, static_cast(&QButtonGroup::buttonClicked), + this, &DialogPiecePath::PassmarkAngleTypeChanged); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::InitPathTypes() { @@ -624,6 +777,40 @@ void DialogPiecePath::InitNodesList() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::InitPassmarksList() +{ + const quint32 id = CURRENT_DATA(ui->comboBoxPassmarks).toUInt(); + + ui->comboBoxPassmarks->blockSignals(true); + ui->comboBoxPassmarks->clear(); + + const QVector nodes = GetListInternals(ui->listWidget); + + for (int i = 0; i < nodes.size(); ++i) + { + const VPieceNode node = nodes.at(i); + if (node.GetTypeTool() == Tool::NodePoint && node.IsPassmark()) + { + const QString name = GetNodeName(node); + + ui->comboBoxPassmarks->addItem(name, node.GetId()); + } + } + ui->comboBoxPassmarks->blockSignals(false); + + const int index = ui->comboBoxPassmarks->findData(id); + if (index != -1) + { + ui->comboBoxPassmarks->setCurrentIndex(index); + PassmarkChanged(index);// Need in case combox index was not changed + } + else + { + ui->comboBoxPassmarks->count() > 0 ? PassmarkChanged(0) : PassmarkChanged(-1); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::NodeAngleChanged(int index) { @@ -783,6 +970,11 @@ void DialogPiecePath::UpdateNodeSAAfter(const QString &formula) //--------------------------------------------------------------------------------------------------------------------- void DialogPiecePath::SetFormulaSAWidth(const QString &formula) { + if (formula.isEmpty()) + { + return; + } + const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) @@ -795,6 +987,16 @@ void DialogPiecePath::SetFormulaSAWidth(const QString &formula) SCASSERT(path != nullptr) path->SetPath(CreatePath()); + if (ui->tabWidget->indexOf(ui->tabSeamAllowance) == -1) + { + ui->tabWidget->addTab(ui->tabSeamAllowance, tr("Seam allowance")); + } + + if (ui->tabWidget->indexOf(ui->tabPassmarks) == -1) + { + ui->tabWidget->addTab(ui->tabPassmarks, tr("Passmarks")); + } + MoveCursorToEnd(ui->plainTextEditFormulaWidth); } diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/dialogpiecepath.h index 19e79e4cd..2bb252704 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.h @@ -70,8 +70,11 @@ private slots: void ListChanged(); void NameChanged(); void NodeChanged(int index); + void PassmarkChanged(int index); void ReturnDefBefore(); void ReturnDefAfter(); + void PassmarkLineTypeChanged(int id); + void PassmarkAngleTypeChanged(int id); void EvalWidth(); void EvalWidthBefore(); @@ -105,9 +108,11 @@ private: void InitPathTab(); void InitSeamAllowanceTab(); + void InitPassmarksTab(); void InitPathTypes(); void InitListPieces(); void InitNodesList(); + void InitPassmarksList(); void NodeAngleChanged(int index); VPiecePath CreatePath() const; diff --git a/src/libs/vtools/dialogs/tools/dialogpiecepath.ui b/src/libs/vtools/dialogs/tools/dialogpiecepath.ui index 10d360ffd..7089b91d6 100644 --- a/src/libs/vtools/dialogs/tools/dialogpiecepath.ui +++ b/src/libs/vtools/dialogs/tools/dialogpiecepath.ui @@ -792,6 +792,129 @@ + + + Passmarks + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Passmark: + + + + + + + + + + + + true + + + Lines + + + + + + false + + + One line + + + buttonGroupLineType + + + + + + + false + + + Two lines + + + buttonGroupLineType + + + + + + + false + + + Three lines + + + buttonGroupLineType + + + + + + + + + + Angle + + + + + + false + + + Straightforward + + + buttonGroupAngleType + + + + + + + false + + + Bisector + + + buttonGroupAngleType + + + + + + + + + + Qt::Vertical + + + + 20 + 85 + + + + + + @@ -843,4 +966,8 @@ + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index 38abeda24..58c5820bd 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -256,6 +256,9 @@ protected: template void AddVisualization(); + template + QVector GetListInternals(const QListWidget *list) const; + void ChangeColor(QWidget *widget, const QColor &color); virtual void ShowVisualization() {} /** @@ -294,6 +297,20 @@ private: }; +//--------------------------------------------------------------------------------------------------------------------- +template +QVector DialogTool::GetListInternals(const QListWidget *list) const +{ + SCASSERT(list != nullptr) + QVector internals; + for (qint32 i = 0; i < list->count(); ++i) + { + QListWidgetItem *item = list->item(i); + internals.append(qvariant_cast(item->data(Qt::UserRole))); + } + return internals; +} + //--------------------------------------------------------------------------------------------------------------------- inline VAbstractTool *DialogTool::GetAssociatedTool() { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 2a5b80c5b..a77530fa5 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2029,10 +2029,10 @@ void DialogSeamAllowance::PatternPinPointChanged() VPiece DialogSeamAllowance::CreatePiece() const { VPiece piece; - piece.GetPath().SetNodes(GetPieceInternals(uiTabPaths->listWidgetMainPath)); - piece.SetCustomSARecords(GetPieceInternals(uiTabPaths->listWidgetCustomSA)); - piece.SetInternalPaths(GetPieceInternals(uiTabPaths->listWidgetInternalPaths)); - piece.SetPins(GetPieceInternals(uiTabPins->listWidgetPins)); + piece.GetPath().SetNodes(GetListInternals(uiTabPaths->listWidgetMainPath)); + piece.SetCustomSARecords(GetListInternals(uiTabPaths->listWidgetCustomSA)); + piece.SetInternalPaths(GetListInternals(uiTabPaths->listWidgetInternalPaths)); + piece.SetPins(GetListInternals(uiTabPins->listWidgetPins)); piece.SetForbidFlipping(uiTabPaths->checkBoxForbidFlipping->isChecked()); piece.SetSeamAllowance(uiTabPaths->checkBoxSeams->isChecked()); piece.SetName(uiTabLabels->lineEditName->text()); @@ -2232,7 +2232,7 @@ void DialogSeamAllowance::InitNodesList() uiTabPaths->comboBoxNodes->blockSignals(true); uiTabPaths->comboBoxNodes->clear(); - const QVector nodes = GetPieceInternals(uiTabPaths->listWidgetMainPath); + const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); for (int i = 0; i < nodes.size(); ++i) { @@ -2266,7 +2266,7 @@ void DialogSeamAllowance::InitPassmarksList() uiTabPassmarks->comboBoxPassmarks->blockSignals(true); uiTabPassmarks->comboBoxPassmarks->clear(); - const QVector nodes = GetPieceInternals(uiTabPaths->listWidgetMainPath); + const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); for (int i = 0; i < nodes.size(); ++i) { @@ -2495,7 +2495,7 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box) box->clear(); box->addItem(tr("Empty"), NULL_ID); - const QVector nodes = GetPieceInternals(uiTabPaths->listWidgetMainPath); + const QVector nodes = GetListInternals(uiTabPaths->listWidgetMainPath); for (int i = 0; i < nodes.size(); ++i) { @@ -2522,7 +2522,7 @@ void DialogSeamAllowance::InitPinPoint(QComboBox *box) box->clear(); box->addItem(QLatin1String("<") + tr("no pin") + QLatin1String(">"), NULL_ID); - const QVector pins = GetPieceInternals(uiTabPins->listWidgetPins); + const QVector pins = GetListInternals(uiTabPins->listWidgetPins); for (int i = 0; i < pins.size(); ++i) { @@ -2803,20 +2803,6 @@ void DialogSeamAllowance::ClearFields() uiTabLabels->comboBoxPlacement->setCurrentIndex(0); } -//--------------------------------------------------------------------------------------------------------------------- -template -QVector DialogSeamAllowance::GetPieceInternals(const QListWidget *list) const -{ - SCASSERT(list != nullptr) - QVector internals; - for (qint32 i = 0; i < list->count(); ++i) - { - QListWidgetItem *item = list->item(i); - internals.append(qvariant_cast(item->data(Qt::UserRole))); - } - return internals; -} - //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula) { @@ -2984,7 +2970,7 @@ void DialogSeamAllowance::ShowPins() m_visPins = new VisPiecePins(data); } - m_visPins->SetPins(GetPieceInternals(uiTabPins->listWidgetPins)); + m_visPins->SetPins(GetListInternals(uiTabPins->listWidgetPins)); if (not qApp->getCurrentScene()->items().contains(m_visPins)) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 98a8ee41e..76472f446 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -256,9 +256,6 @@ private: void SetFormulaSAWidth(const QString &formula); - template - QVector GetPieceInternals(const QListWidget *list) const; - void SetGrainlineAngle(QString angleFormula); void SetGrainlineLength(QString lengthFormula); From e19c9392a15d3b2bd7ffd20daf2c8fb0ae6bdbb8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 29 Mar 2017 14:20:55 +0300 Subject: [PATCH 11/18] Custom seam allowance now visible again. --HG-- branch : feature --- src/libs/vpatterndb/vpiece.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 6355f8a7b..0a04cf466 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -679,7 +679,7 @@ QVector VPiece::GetValidRecords() const && not d->m_path.at(indexStartPoint).IsExcluded() && indexEndPoint != -1 && not d->m_path.at(indexEndPoint).IsExcluded() - && record.startPoint < record.endPoint) + && indexStartPoint < indexEndPoint) { records.append(record); } From 4907ce584fa8bae162aeb234309e6555efadcdb2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 11:06:47 +0300 Subject: [PATCH 12/18] Fixed issue #646. Wrong seam allowance if node is on line. --HG-- branch : feature --- src/app/share/collection/bugs/Issue_#646.val | 86 ++ src/libs/vlayout/vabstractpiece.cpp | 26 + src/libs/vlayout/vabstractpiece.h | 19 +- src/test/ValentinaTest/tst_vabstractpiece.cpp | 797 ++++++++++++++++-- src/test/ValentinaTest/tst_vabstractpiece.h | 3 + src/test/ValentinaTest/tst_vpiece.cpp | 12 +- 6 files changed, 863 insertions(+), 80 deletions(-) create mode 100644 src/app/share/collection/bugs/Issue_#646.val diff --git a/src/app/share/collection/bugs/Issue_#646.val b/src/app/share/collection/bugs/Issue_#646.val new file mode 100644 index 000000000..51c06c361 --- /dev/null +++ b/src/app/share/collection/bugs/Issue_#646.val @@ -0,0 +1,86 @@ + + + + 0.4.6 + cm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ +
+
diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 0f8bc5108..3189e35bb 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -935,3 +935,29 @@ QVector VAbstractPiece::SubPath(const QVector &path, int start return subPath; } + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint) +{ + return (VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint) + && prevPoint == nextPoint);// not zigzag +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, const VSAPoint &nextPoint) +{ + // See bug #646 + bool ekvPointOnLine = false; + + if (VFuzzyComparePossibleNulls(prevPoint.GetSAAfter(), iPoint.GetSABefore()) + && VFuzzyComparePossibleNulls(iPoint.GetSAAfter(), nextPoint.GetSABefore())) + { + if (VFuzzyComparePossibleNulls(prevPoint.GetSAAfter(), nextPoint.GetSABefore())) + { + ekvPointOnLine = true; + } + } + return (VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint) + && prevPoint == nextPoint// not zigzag + && ekvPointOnLine); +} diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 4cea4f1ac..b51974b35 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -200,6 +200,9 @@ private: static QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width); static QLineF BisectorLine(const QPointF &p1, const QPointF &p2, const QPointF &p3); static qreal AngleBetweenBisectors(const QLineF &b1, const QLineF &b2); + static bool IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint); + static bool IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, + const VSAPoint &nextPoint); }; Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE); @@ -245,16 +248,16 @@ QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bo next = 0; } - const QPointF &iPoint = buf1.at(i); - const QPointF &prevPoint = buf1.at(prev); - const QPointF &nextPoint = buf1.at(next); + const T &iPoint = buf1.at(i); + const T &prevPoint = buf1.at(prev); + const T &nextPoint = buf1.at(next); - if ((not VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint) && prevPoint != nextPoint)// not zigzag - // If RemoveDublicates does not remove these points it is a valid case. - // Case where last point equal first point - || ((i == 0 || i == buf1.size() - 1) && (iPoint == prevPoint || iPoint == nextPoint))) + if (not IsEkvPointOnLine(iPoint, prevPoint, nextPoint) + // If RemoveDublicates does not remove these points it is a valid case. + // Case where last point equal first point + || ((i == 0 || i == buf1.size() - 1) && (iPoint == prevPoint || iPoint == nextPoint))) { - buf2.append(buf1.at(i)); + buf2.append(iPoint); prev = -1; } } diff --git a/src/test/ValentinaTest/tst_vabstractpiece.cpp b/src/test/ValentinaTest/tst_vabstractpiece.cpp index 5af96445b..c7ee88eb8 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.cpp +++ b/src/test/ValentinaTest/tst_vabstractpiece.cpp @@ -89,6 +89,10 @@ void TST_VAbstractPiece::EquidistantRemoveLoop_data() QTest::newRow("Issue 548. Case3") << InputPointsIssue548Case3() << 75.59055118110237 // seam allowance width (2.0 cm) << OutputPointsIssue548Case3(); + + QTest::newRow("Issue 646.") << InputPointsIssue646() + << 37.795275590551185 // seam allowance width (1.0 cm + << OutputPointsIssue646(); } //--------------------------------------------------------------------------------------------------------------------- @@ -543,7 +547,7 @@ QVector TST_VAbstractPiece::OutputPointsCase1() const { QVector points; - points += QPointF(30.00000000000004, 970.3929479721926); + points += QPointF(30.0, 970.3935748031496); points += QPointF(30.0, 2.204434307474013); points += QPointF(47.110950439162494, 2.154008996440882); points += QPointF(75.17428353484098, 1.4485680510386028); @@ -570,8 +574,9 @@ QVector TST_VAbstractPiece::OutputPointsCase1() const points += QPointF(556.8930273120665, -30.847456102511416); points += QPointF(539.6101141051189, 79.89131577778163); points += QPointF(585.9167315845334, -20.702420721823447); - points += QPointF(1117.424153174025, 212.64949937811681); - points += QPointF(1095.8827941924872, 257.6002084082805); + points += QPointF(1117.4712505569892, 212.6701769158142); + points += QPointF(1107.8013393916237, 232.47256047676322); + points += QPointF(1096.0328222042483, 257.2724337531229); points += QPointF(1085.2347243947604, 280.86364678273935); points += QPointF(1075.284743777034, 303.4467181585846); points += QPointF(1066.1500107021461, 325.033221582634); @@ -587,12 +592,19 @@ QVector TST_VAbstractPiece::OutputPointsCase1() const points += QPointF(1001.7684597861733, 562.2905401031172); points += QPointF(1001.5753826870504, 572.6532694631434); points += QPointF(1001.7511114738644, 580.6472328726268); - points += QPointF(1002.5244573746393, 592.6631414076071); + points += QPointF(1002.5434394846042, 592.958077085046); + points += QPointF(1003.1165308093626, 598.6055609315013); + points += QPointF(1003.1581157531632, 598.979729387987); points += QPointF(1003.5253444923072, 601.4269775229475); + points += QPointF(1004.0349710465857, 604.0480668398186); points += QPointF(1004.8346806929111, 607.4219012430418); + points += QPointF(1005.9446128953437, 611.4069696127774); points += QPointF(1007.3734895026099, 615.879537116226); + points += QPointF(1009.1216689960736, 620.7301358517914); points += QPointF(1011.1831553003773, 625.860901250618); + points += QPointF(1013.5469326629959, 631.1835932583286); points += QPointF(1016.1978697144372, 636.6181674061058); + points += QPointF(1019.1173567112357, 642.0917891993197); points += QPointF(1022.283791807397, 647.5382096308747); points += QPointF(1025.6730034935645, 652.8974380139866); points += QPointF(1029.258679857382, 658.1156604426072); @@ -613,9 +625,10 @@ QVector TST_VAbstractPiece::OutputPointsCase1() const points += QPointF(1092.8646688655851, 703.7605199081748); points += QPointF(1098.2162239125396, 704.699271425244); points += QPointF(1104.0444208482252, 705.3744462055462); - points += QPointF(1304.758494368609, 711.4626979457951); - points += QPointF(1293.9429531218987, 1089.1048479381132); - points += QPointF(30.00000000000004, 970.3929479721926); + points += QPointF(1111.3488014116317, 705.7937559506274); + points += QPointF(1290.2705536650083, 707.499620616225); + points += QPointF(1302.4161318705774, 881.6558256043734); + points += QPointF(30.0, 970.3935748031496); return points; } @@ -1765,15 +1778,23 @@ QVector TST_VAbstractPiece::OutputPointsCase3() const points += QPointF(288.165803158891, 198.9246157503596); points += QPointF(289.7040578703973, 191.38436170566055); points += QPointF(291.98164916416846, 183.91963819443603); - points += QPointF(293.700387439861, 179.7469098237058); - points += QPointF(296.5884693392089, 171.49219190163677); + points += QPointF(294.9455451728963, 176.72393356713948); + points += QPointF(295.79237435003455, 175.03780734840188); + points += QPointF(296.245263052401, 173.2550222963373); points += QPointF(297.59693481965496, 166.31235205234043); points += QPointF(298.2857333094973, 160.53208953533525); points += QPointF(298.43819035278193, 155.84335424804448); points += QPointF(298.1940021729857, 152.25436961670644); points += QPointF(297.7243212024687, 149.73346552056378); + points += QPointF(297.2141642634996, 148.17665975044923); + points += QPointF(296.81807124385705, 147.38451061538373); + points += QPointF(296.5985303999919, 147.07754941478083); + points += QPointF(296.486859378041, 146.96500596407506); points += QPointF(296.30769954702157, 146.83360641173047); + points += QPointF(295.85745446032604, 146.59522243594577); + points += QPointF(294.9800374980412, 146.2693748418327); points += QPointF(293.59863859999393, 145.93124637657365); + points += QPointF(291.70740855306775, 145.66527555041208); points += QPointF(289.51401190033005, 145.54903057599236); points += QPointF(285.1770288005626, 145.6959639947203); points += QPointF(278.3617236899766, 146.6950293230864); @@ -1782,8 +1803,9 @@ QVector TST_VAbstractPiece::OutputPointsCase3() const points += QPointF(257.2170705229372, 153.76755541765795); points += QPointF(251.60582957396716, 156.6541701343772); points += QPointF(247.78435692308207, 159.04593361720316); - points += QPointF(241.3885876220272, 164.12014968959915); - points += QPointF(236.47226924439926, 167.68896212834986); + points += QPointF(246.25434386618122, 160.2598011722792); + points += QPointF(243.67170607597288, 162.99575598015517); + points += QPointF(232.3489004893592, 169.9758475438662); points += QPointF(220.7012128062336, 176.43583903855628); points += QPointF(209.5894888372958, 181.6299305429989); points += QPointF(198.8701621522812, 185.51474135189684); @@ -2406,16 +2428,14 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const // The test check an open equdistant of correct detail. QVector points;// Input points. - qreal width = 37.795275590551185; // seam allowance width - VSAPoint point = VSAPoint(787.5835464566929, 1701.3138897637796); - point.SetSAAfter(width); + point.SetSAAfter(-1); point.SetSABefore(0); points.append(point); point = VSAPoint(863.1740976377953, 1701.3138897637796); - point.SetSAAfter(width); - point.SetSAAfter(width); + point.SetSAAfter(-1); + point.SetSAAfter(-1); points.append(point); points.append(VSAPoint(938.7646488188976, 1701.3138897637796)); @@ -2456,11 +2476,12 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const point = VSAPoint(797.0323653543306, 2608.4005039370077); point.SetSAAfter(0); - point.SetSABefore(width); + point.SetSABefore(-1); points.append(point); QVector ekvOrig; - ekvOrig.append(QPointF(735.0001191244485, 1663.5186141732283)); + ekvOrig.append(QPointF(787.1898456692913, 1663.5186141732283)); + ekvOrig.append(QPointF(863.1740976377953, 1663.5186141732283)); ekvOrig.append(QPointF(990.8407796109454, 1663.5186141732283)); ekvOrig.append(QPointF(964.6314897747087, 1743.9055956070622)); ekvOrig.append(QPointF(946.222111945205, 1803.203545947388)); @@ -2476,35 +2497,32 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const ekvOrig.append(QPointF(851.6617474319463, 2094.450692409028)); ekvOrig.append(QPointF(841.5996933370075, 2040.6378051462616)); ekvOrig.append(QPointF(829.8479530577714, 1985.5930036729653)); - ekvOrig.append(QPointF(816.2523082919595, 1928.9761616385213)); - ekvOrig.append(QPointF(800.6574868367429, 1870.4501190599349)); - ekvOrig.append(QPointF(782.9077406929495, 1809.6811643713463)); - ekvOrig.append(QPointF(762.8278965797896, 1746.2775544138444)); - ekvOrig.append(QPointF(735.0001191244485, 1663.5186141732283)); + ekvOrig.append(QPointF(828.2738301865061, 1979.0378260789357)); + ekvOrig.append(QPointF(834.4319111572987, 2570.213599275029)); + ekvOrig.append(QPointF(796.554931640625, 2597.28125)); + ekvOrig.append(QPointF(787.1898456692913, 1663.5186141732283)); - QTest::newRow("GAVAUDAN Laure.") << points << width << ekvOrig; - - width = 11.338582677165354; + QTest::newRow("GAVAUDAN Laure.") << points << 37.795275590551185 << ekvOrig; points.clear(); point = VSAPoint(97.33089106412862, -223.03306117556497); - point.SetSAAfter(width); + point.SetSAAfter(-1); point.SetSABefore(0); points.append(point); point = VSAPoint(990.7494050554426, 2.819093995045); - point.SetSAAfter(width); - point.SetSABefore(width); + point.SetSAAfter(-1); + point.SetSABefore(-1); points.append(point); point = VSAPoint(908.3966357321774, 379.5839357215547); - point.SetSAAfter(width); - point.SetSABefore(width); + point.SetSAAfter(-1); + point.SetSABefore(-1); points.append(point); point = VSAPoint(-135.41154226686143, 697.6417881399819); point.SetSAAfter(0); - point.SetSABefore(width); + point.SetSABefore(-1); points.append(point); ekvOrig.clear(); @@ -2515,9 +2533,8 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const ekvOrig.append(QPointF(100.10981413873267, -234.02583351343978)); // See the file "collection/bugs/Issue_#604.val" (since 0.5.0) - QTest::newRow("Issue #604.") << points << width << ekvOrig; + QTest::newRow("Issue #604.") << points << 11.338582677165354 << ekvOrig; - width = 56.692913385826778; points.clear(); point = VSAPoint(11565.008125001967, -71.44488549419934); @@ -2582,8 +2599,9 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const points.append(point); ekvOrig.clear(); - ekvOrig.append(QPointF(11561.415280975947, -14.63551463077929)); + ekvOrig.append(QPointF(11561.414612602906, -14.624946442565701)); ekvOrig.append(QPointF(11781.95342513335, -3501.7429788659483)); + ekvOrig.append(QPointF(11772.755890703675, -3486.161176715607)); ekvOrig.append(QPointF(11867.496139886347, -3648.194635075343)); ekvOrig.append(QPointF(11962.541506347354, -3812.5802499029824)); ekvOrig.append(QPointF(12058.651107851038, -3980.6023049242845)); @@ -2594,10 +2612,12 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const ekvOrig.append(QPointF(12581.270838581826, -4919.426688379175)); ekvOrig.append(QPointF(12699.418991549643, -5135.746802194771)); ekvOrig.append(QPointF(12887.73123714858, -5482.200849627318)); - ekvOrig.append(QPointF(13166.166408012898, -5997.136108335216)); - ekvOrig.append(QPointF(13707.969757502442, -7002.431719565925)); - ekvOrig.append(QPointF(13491.504168170613, -14.778652871227324)); - ekvOrig.append(QPointF(13302.271351803516, -19.843181325566178)); + ekvOrig.append(QPointF(13166.168107919768, -5997.139252126215)); + ekvOrig.append(QPointF(13480.123425536643, -6579.495645468361)); + ekvOrig.append(QPointF(13707.971545534987, -7002.489438444617)); + ekvOrig.append(QPointF(13491.50417959835, -14.779021766203327)); + ekvOrig.append(QPointF(13456.704320007799, -15.781428847446987)); + ekvOrig.append(QPointF(13302.284438389732, -19.842883268086513)); ekvOrig.append(QPointF(13153.729251428536, -23.226346601010544)); ekvOrig.append(QPointF(13009.961769808971, -25.932558019731804)); ekvOrig.append(QPointF(12869.919891108724, -27.961844111086332)); @@ -2608,11 +2628,12 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() const ekvOrig.append(QPointF(12188.347825426712, -27.961844111086332)); ekvOrig.append(QPointF(12048.305946726465, -25.9325580197318)); ekvOrig.append(QPointF(11904.538465106896, -23.226346601010544)); - ekvOrig.append(QPointF(11755.996364731915, -19.843181325566132)); - ekvOrig.append(QPointF(11561.415280975947, -14.63551463077929)); + ekvOrig.append(QPointF(11755.9832781457, -19.842883268086513)); + ekvOrig.append(QPointF(11601.563396526772, -15.78142884742432)); + ekvOrig.append(QPointF(11561.414612602906, -14.624946442565701)); // See the file "collection/bugs/Issue_#627.val" - QTest::newRow("Issue #627.") << points << width << ekvOrig; + QTest::newRow("Issue #627.") << points << 56.692913385826778 << ekvOrig; } //--------------------------------------------------------------------------------------------------------------------- @@ -2706,6 +2727,7 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(483.54330708661416, 3819.527433070866); expect << QPointF(483.54330708661416, 1929.763653543307); expect << QPointF(407.9527559055629, 984.8817637795973); + expect << QPointF(407.9527559055118, 1929.763653543307); expect << QPointF(407.9527559055118, 3819.527433070866); expect << QPointF(30.0, 3819.527433070866); @@ -2797,6 +2819,8 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(2432.8400274534156, 774.2066093113424); expect << QPointF(2431.567845112944, 650.353473841431); expect << QPointF(2430.8388882820395, 551.3113535235192); + expect << QPointF(2521.6176598985803, 672.644700521423); + expect << QPointF(2521.6176454460388, 672.6446812044021); expect << QPointF(2524.825194988043, 676.8586168908913); expect << QPointF(2531.556290527688, 684.9826746886265); expect << QPointF(2538.6519462028364, 692.7334672321138); @@ -2813,8 +2837,10 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(2636.1142555502283, 750.5955187728248); expect << QPointF(2646.3162132089255, 753.1140847224424); expect << QPointF(2656.6713277293766, 755.1338781606632); + expect << QPointF(2661.9066021773087, 755.9323325983765); expect << QPointF(2669.4674223109823, 756.929551265488); expect << QPointF(2684.673455582832, 758.0191371470853); + expect << QPointF(2692.299212598425, 758.1101102362205); expect << QPointF(2699.3540234509323, 757.9931392559722); expect << QPointF(2713.2964524768695, 756.6087867033591); expect << QPointF(2726.9543839401804, 753.8786800188636); @@ -2823,7 +2849,9 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(2765.2893446462085, 737.9998193813908); expect << QPointF(2776.8774375508674, 730.2726803766734); expect << QPointF(2787.7151087388274, 721.3927793437279); + expect << QPointF(2792.78632430596, 716.4869857232671); expect << QPointF(2795.193441837398, 714.0407970608542); + expect << QPointF(2797.5205646867075, 711.5183868986292); expect << QPointF(2797.55905511811, 711.5533198040212); expect << QPointF(2797.5653033070657, 778.3129219994751); expect << QPointF(2798.042165185835, 888.6599947271147); @@ -2836,6 +2864,7 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(2817.932217136939, 1243.4015401395004); expect << QPointF(2824.216896993419, 1305.208606836678); expect << QPointF(2835.7112555523727, 1412.0840031200023); + expect << QPointF(2855.928400378448, 1592.3456114466708); expect << QPointF(2868.5464960059594, 1703.7728336081707); // See the file "collection/bugs/Issue_#642.val" @@ -3219,8 +3248,8 @@ QVector TST_VAbstractPiece::OutputPointsIssue298Case2() const { QVector points; - points += QPointF(-2.7952999999999975, 4.8384699505981095); - points += QPointF(67.34448942068963, -0.23248582689164274); + points += QPointF(-2.7952999999999975, 4.838469950598078); + points += QPointF(67.34448942068963, -0.2324858268916558); points += QPointF(73.11721243320879, 39.48203774070609); points += QPointF(75.42415682885321, 49.62029267468959); points += QPointF(78.79409614728041, 60.281321268788744); @@ -3240,8 +3269,9 @@ QVector TST_VAbstractPiece::OutputPointsIssue298Case2() const points += QPointF(199.7939139119543, 214.75881893038778); points += QPointF(209.1143810932559, 221.476716907111); points += QPointF(216.03386663545683, 225.9476461661168); - points += QPointF(215.3306509043856, 223.3387762725701); - points += QPointF(205.75073516810195, 194.75155680967347); + points += QPointF(215.3109698947021, 223.26576141899216); + points += QPointF(212.94471478165408, 216.10983179087987); + points += QPointF(205.75950336032207, 194.7799429182702); points += QPointF(197.88802785264718, 169.29686123304236); points += QPointF(193.97579117825833, 155.08026950731082); points += QPointF(191.1640933645057, 142.90507610480435); @@ -3256,13 +3286,14 @@ QVector TST_VAbstractPiece::OutputPointsIssue298Case2() const points += QPointF(270.9888544453203, 108.1087159300009); points += QPointF(280.35077918473866, 121.00209505562212); points += QPointF(294.42535276480356, 142.5434013797918); - points += QPointF(318.5597512322288, 182.00074197391842); - points += QPointF(394.73028222951507, 311.42213969492946); + points += QPointF(318.5638508136392, 182.00744438169633); + points += QPointF(355.64786176301806, 245.0768771131813); + points += QPointF(394.7264228866019, 311.415821866629); points += QPointF(422.9514429826756, 357.62079373755); points += QPointF(440.37197676737753, 384.8111617646563); points += QPointF(488.2841719585649, 455.71983154868764); points += QPointF(-2.795300000000013, 455.7506738094777); - points += QPointF(-2.7952999999999975, 4.8384699505981095); + points += QPointF(-2.7952999999999975, 4.838469950598078); return points; } @@ -3304,10 +3335,10 @@ QVector TST_VAbstractPiece::InputPointsIssue548Case2() const { QVector points; points << VSAPoint(99.86433649395013, 10.166060970128015); - points << VSAPoint(236.97989607468364, 65.89325192030674); - points << VSAPoint(198.93409106041895, 172.04876297154925); - points << VSAPoint(260.32251114299453, 75.38027418944861); - points << VSAPoint(324.54110236213444, 101.48031496062993); + points << VSAPoint(176.0178302829931, 57.36978169486653); + points << VSAPoint(115.46606095399079, 156.67924434657942); + points << VSAPoint(197.43414263641347, 70.64467660756823); + points << VSAPoint(247.18110236220474, 101.48031496062993); points << VSAPoint(29.858267716535437, 300.85039370078744); return points; @@ -3317,11 +3348,12 @@ QVector TST_VAbstractPiece::InputPointsIssue548Case2() const QVector TST_VAbstractPiece::OutputPointsIssue548Case2() const { QVector points; - points << QPointF(73.40376616581447, -41.38574336196901); - points << QPointF(404.3486874792147, 93.11854543221973); - points << QPointF(29.59864884322894, 346.6587450186291); - points << QPointF(-12.946885351826726, 317.1657644661815); - points << QPointF(73.40376616581447, -41.38574336196901); + points << QPointF(75.35612582031402, -49.49247429729551); + points << QPointF(207.99390662262346, 32.7230151178754); + points << QPointF(309.47290565612207, 95.62474281894228); + points << QPointF(34.78597607721976, 347.62014343263024); + points << QPointF(-13.438975506560153, 319.209057294505); + points << QPointF(75.35612582031402, -49.49247429729551); return points; } @@ -3332,10 +3364,10 @@ QVector TST_VAbstractPiece::InputPointsIssue548Case3() const QVector points; points += VSAPoint(99.86433649395013, 10.166060970128015); - points += VSAPoint(236.97989607468364, 65.89325192030674); - points += VSAPoint(198.93409106041895, 172.04876297154925); - points += VSAPoint(260.32251114299453, 75.38027418944861); - points += VSAPoint(324.54110236213444, 101.48031496062993); + points += VSAPoint(176.0178302829931, 57.36978169486653); + points += VSAPoint(115.46606095399079, 156.67924434657942); + points += VSAPoint(197.43414263641347, 70.64467660756823); + points += VSAPoint(247.18110236220474, 101.48031496062993); points += VSAPoint(29.858267716535437, 300.85039370078744); return points; @@ -3346,11 +3378,12 @@ QVector TST_VAbstractPiece::OutputPointsIssue548Case3() const { QVector points; - points += QPointF(46.94319583767885, -92.9375476940661); - points += QPointF(484.15627259629446, 84.75677590380938); - points += QPointF(29.339029969922702, 392.46709633647066); - points += QPointF(-55.75203842018885, 333.48113523157537); - points += QPointF(46.94319583767885, -92.9375476940661); + points += QPointF(50.84791514667799, -109.15100956471929); + points += QPointF(220.96071459087483, -3.7066408675763003); + points += QPointF(371.76470895003956, 89.76917067725468); + points += QPointF(39.71368443790398, 394.38989316447305); + points += QPointF(-56.73621872965576, 337.56772088822254); + points += QPointF(50.84791514667799, -109.15100956471929); return points; } @@ -3388,3 +3421,633 @@ QVector TST_VAbstractPiece::InputPointsCase5a() const return points; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector TST_VAbstractPiece::InputPointsIssue646() const +{ + QVector points; + + points += VSAPoint(1352.8346456692914, 1173.8581417322835); + + VSAPoint point = VSAPoint(1352.8346456692914, 1362.8345196850394); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1352.8346456692914, 1362.8345196850394); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1351.7927746622177, 1365.3174895470343); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1349.2904293989368, 1370.0604466887874); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1346.2962576995217, 1374.5430452326066); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1342.8219234115563, 1378.7733079571037); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1338.8790903826243, 1382.7592576408904); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1334.4794224603097, 1386.5089170625781); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1329.6345834921963, 1390.0303090007792); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1324.356237325868, 1393.3314562341047); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1315.7019501937195, 1397.9127915604581); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1302.6841808427803, 1403.289891141198); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1288.142331955491, 1407.930421917447); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1272.169714312523, 1411.8985661180982); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1254.8596386945478, 1415.2585059720464); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1236.3054158822356, 1418.074423708184); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1216.6003566562576, 1420.4105015554055); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1195.8377717972853, 1422.3309217426045); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1163.0181823648445, 1424.6044927975377); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1116.2675882169847, 1426.7215739585208); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(1041.771617936041, 1429.0735145188771); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(963.6986998754783, 1432.082545646023); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(924.3395298428601, 1434.378255703845); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(898.1648782802928, 1436.3169978244687); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(872.1457412334543, 1438.6744512606858); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(846.3754294830155, 1441.5147982413903); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(820.9472538096477, 1444.9022209954755); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(795.9545249940218, 1448.9009017518354); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(771.4905538168089, 1453.5750227393632); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(747.6486510586797, 1458.9887661869527); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(724.5221275003055, 1465.2063143234973); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(702.2042939223572, 1472.2918493778907); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(691.4173228346457, 1476.2203464566928); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(682.8822388593928, 1479.3575289855721); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(665.6479146239083, 1485.1110371155814); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(648.2139215316024, 1490.2399559097548); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(630.5772803437565, 1494.74477312083); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(612.7350118216522, 1498.6259765015448); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(594.6841367265706, 1501.884053804636); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(576.4216758197934, 1504.5194927828425); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(557.9446498626021, 1506.5327811889006); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(539.2500796162778, 1507.9244067755485); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(520.334985842102, 1508.6948572955234); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(501.1963893013563, 1508.844620501563); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(481.8313107553219, 1508.3741841464052); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(462.23677096528036, 1507.2840359827874); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(442.40979069251296, 1505.5746637634468); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(422.3473906983012, 1503.2465552411209); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(402.0465917439264, 1500.300198168548); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(381.50441459067014, 1496.7360802984645); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(360.7178799998137, 1492.554689383609); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(339.6840087326385, 1487.7565131767187); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(318.399821550426, 1482.3420394305313); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(296.8623392144576, 1476.3117558977842); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(275.06858248601475, 1469.6661503312146); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(253.01557212637874, 1462.4057104835604); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(230.70032889683108, 1454.530924107559); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(208.11987355865324, 1446.0422789559484); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(185.27122687312647, 1436.9402627814657); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(162.15140960153235, 1427.2253633368487); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(138.7574425051522, 1416.8980683748348); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(115.08634634526746, 1405.9588656481617); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(91.13514188315949, 1394.4082429095668); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(66.90084988010975, 1382.2466879117876); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(42.38049109739966, 1369.4746884075616); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(30.0, 1362.8345196850394); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + point = VSAPoint(30.0, 1362.8345196850394); + point.SetSAAfter(0); + point.SetSABefore(0); + points.append(point); + + points += VSAPoint(30.0, 1173.8581417322835); + points += VSAPoint(30.0, 39.999874015748034); + points += VSAPoint(30.0, 39.999874015748034); + points += VSAPoint(31.836416744798022, 50.53779899603764); + points += VSAPoint(35.952598805592906, 71.21252386912929); + points += VSAPoint(40.586864315463195, 91.4101105071633); + points += VSAPoint(45.72373012289418, 111.13523876561466); + points += VSAPoint(51.347713076371164, 130.39258849995826); + points += VSAPoint(57.44333002437946, 149.186839565669); + points += VSAPoint(63.995097815404385, 167.52267181822185); + points += VSAPoint(70.98753329793121, 185.40476511309168); + points += VSAPoint(78.4051533204453, 202.83779930575355); + points += VSAPoint(86.23247473143188, 219.82645425168224); + points += VSAPoint(94.4540143793763, 236.37540980635274); + points += VSAPoint(103.05428911276391, 252.48934582523998); + points += VSAPoint(112.01781578007993, 268.17294216381885); + points += VSAPoint(121.32911122980973, 283.43087867756435); + points += VSAPoint(130.97269231043856, 298.2678352219515); + points += VSAPoint(140.93307587045177, 312.688491652455); + points += VSAPoint(151.19477875833468, 326.69752782454987); + points += VSAPoint(161.74231782257255, 340.2996235937111); + points += VSAPoint(172.5602099116507, 353.4994588154136); + points += VSAPoint(183.63297187405442, 366.30171334513216); + points += VSAPoint(194.94512055826902, 378.7110670383419); + points += VSAPoint(206.4811728127799, 390.7321997505177); + points += VSAPoint(218.22564548607224, 402.3697913371344); + points += VSAPoint(230.1630554266314, 413.62852165366695); + points += VSAPoint(242.27791948294265, 424.51307055559033); + points += VSAPoint(254.55475450349132, 435.02811789837943); + points += VSAPoint(273.2244253126398, 450.16283591309366); + points += VSAPoint(298.5641233209854, 469.0320795095655); + points += VSAPoint(324.2730084590162, 486.5075542680491); + points += VSAPoint(350.2272155146146, 502.6266990323438); + points += VSAPoint(376.30287927566314, 517.426952646249); + points += VSAPoint(402.37613453004406, 530.9457539535642); + points += VSAPoint(428.3231160656401, 543.220541798089); + points += VSAPoint(454.0199586703335, 554.2887550236223); + points += VSAPoint(479.34279713200675, 564.1878324739641); + points += VSAPoint(504.1677662385423, 572.9552129929135); + points += VSAPoint(528.3710007778225, 580.62833542427); + points += VSAPoint(551.8286355377302, 587.2446386118332); + points += VSAPoint(574.4168053061474, 592.8415613994023); + points += VSAPoint(596.0116448709566, 597.4565426307768); + points += VSAPoint(616.4892890200404, 601.127021149756); + points += VSAPoint(635.725872541281, 603.8904358001398); + points += VSAPoint(653.5975302225612, 605.7842254257271); + points += VSAPoint(669.9803968517632, 606.8458288703175); + points += VSAPoint(684.7506072167696, 607.1126849777106); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(691.417322834647, 606.9290078739997); + points += VSAPoint(698.4117938885747, 606.70357708988); + points += VSAPoint(712.3872092557954, 606.6270580415836); + points += VSAPoint(726.3421370199347, 606.9929810221732); + points += VSAPoint(740.2718488317498, 607.7938249260419); + points += VSAPoint(754.1716163419968, 609.0220686475833); + points += VSAPoint(768.0367112014326, 610.6701910811905); + points += VSAPoint(781.8624050608131, 612.7306711212568); + points += VSAPoint(795.6439695708956, 615.1959876621759); + points += VSAPoint(809.3766763824362, 618.0586195983409); + points += VSAPoint(823.0557971461919, 621.3110458241451); + points += VSAPoint(843.4718370533695, 626.8577230967079); + points += VSAPoint(870.4518221032482, 635.6110880188724); + points += VSAPoint(897.1323526756041, 645.7882501986742); + points += VSAPoint(923.4756019764898, 657.3290407912602); + points += VSAPoint(949.4437432119576, 670.1732909517772); + points += VSAPoint(974.99894958806, 684.2608318353717); + points += VSAPoint(1000.1033943108496, 699.5314945971908); + points += VSAPoint(1024.7192505863786, 715.9251103923807); + points += VSAPoint(1048.8086916206998, 733.381510376089); + points += VSAPoint(1072.333890619865, 751.8405257034619); + points += VSAPoint(1095.257020789927, 771.2419875296464); + points += VSAPoint(1117.5402553369386, 791.5257270097889); + points += VSAPoint(1139.1457674669518, 812.6315752990365); + points += VSAPoint(1160.0357303860196, 834.499363552536); + points += VSAPoint(1180.1723173001938, 857.0689229254342); + points += VSAPoint(1199.517701415527, 880.2800845728775); + points += VSAPoint(1218.0340559380716, 904.072679650013); + points += VSAPoint(1235.6835540738803, 928.3865393119875); + points += VSAPoint(1252.4283690290056, 953.1614947139476); + points += VSAPoint(1268.2306740094996, 978.33737701104); + points += VSAPoint(1283.0526422214152, 1003.8540173584115); + points += VSAPoint(1296.8564468708046, 1029.651246911209); + points += VSAPoint(1309.60426116372, 1055.6688968245794); + points += VSAPoint(1321.258258306214, 1081.846798253669); + points += VSAPoint(1331.780611504339, 1108.1247823536248); + points += VSAPoint(1341.1334939641479, 1134.4426802795938); + points += VSAPoint(1349.2790788916927, 1160.7403231867224); + points += VSAPoint(1352.8346456692914, 1173.8581417322835); + + return points; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector TST_VAbstractPiece::OutputPointsIssue646() const +{ + QVector points; + + points += QPointF(1391.2089508950362, 1170.962993556315); + points += QPointF(1352.8346456692914, 1362.8345196850394); + points += QPointF(1351.7927746622177, 1365.3174895470343); + points += QPointF(1349.2904293989368, 1370.0604466887874); + points += QPointF(1346.2962576995217, 1374.5430452326066); + points += QPointF(1342.8219234115563, 1378.7733079571037); + points += QPointF(1338.8790903826243, 1382.7592576408904); + points += QPointF(1334.4794224603097, 1386.5089170625781); + points += QPointF(1329.6345834921963, 1390.0303090007792); + points += QPointF(1324.356237325868, 1393.3314562341047); + points += QPointF(1315.7019501937195, 1397.9127915604581); + points += QPointF(1302.6841808427803, 1403.289891141198); + points += QPointF(1288.142331955491, 1407.930421917447); + points += QPointF(1272.169714312523, 1411.8985661180982); + points += QPointF(1254.8596386945478, 1415.2585059720464); + points += QPointF(1236.3054158822356, 1418.074423708184); + points += QPointF(1216.6003566562576, 1420.4105015554055); + points += QPointF(1195.8377717972853, 1422.3309217426045); + points += QPointF(1163.0181823648445, 1424.6044927975377); + points += QPointF(1116.2675882169847, 1426.7215739585208); + points += QPointF(1041.771617936041, 1429.0735145188771); + points += QPointF(963.6986998754783, 1432.082545646023); + points += QPointF(924.3395298428601, 1434.378255703845); + points += QPointF(898.1648782802928, 1436.3169978244687); + points += QPointF(872.1457412334543, 1438.6744512606858); + points += QPointF(846.3754294830155, 1441.5147982413903); + points += QPointF(820.9472538096477, 1444.9022209954755); + points += QPointF(795.9545249940218, 1448.9009017518354); + points += QPointF(771.4905538168089, 1453.5750227393632); + points += QPointF(747.6486510586797, 1458.9887661869527); + points += QPointF(724.5221275003055, 1465.2063143234973); + points += QPointF(702.2042939223572, 1472.2918493778907); + points += QPointF(691.4173228346457, 1476.2203464566928); + points += QPointF(682.8822388593928, 1479.3575289855721); + points += QPointF(665.6479146239083, 1485.1110371155814); + points += QPointF(648.2139215316024, 1490.2399559097548); + points += QPointF(630.5772803437565, 1494.74477312083); + points += QPointF(612.7350118216522, 1498.6259765015448); + points += QPointF(594.6841367265706, 1501.884053804636); + points += QPointF(576.4216758197934, 1504.5194927828425); + points += QPointF(557.9446498626021, 1506.5327811889006); + points += QPointF(539.2500796162778, 1507.9244067755485); + points += QPointF(520.334985842102, 1508.6948572955234); + points += QPointF(501.1963893013563, 1508.844620501563); + points += QPointF(481.8313107553219, 1508.3741841464052); + points += QPointF(462.23677096528036, 1507.2840359827874); + points += QPointF(442.40979069251296, 1505.5746637634468); + points += QPointF(422.3473906983012, 1503.2465552411209); + points += QPointF(402.0465917439264, 1500.300198168548); + points += QPointF(381.50441459067014, 1496.7360802984645); + points += QPointF(360.7178799998137, 1492.554689383609); + points += QPointF(339.6840087326385, 1487.7565131767187); + points += QPointF(318.399821550426, 1482.3420394305313); + points += QPointF(296.8623392144576, 1476.3117558977842); + points += QPointF(275.06858248601475, 1469.6661503312146); + points += QPointF(253.01557212637874, 1462.4057104835604); + points += QPointF(230.70032889683108, 1454.530924107559); + points += QPointF(208.11987355865324, 1446.0422789559484); + points += QPointF(185.27122687312647, 1436.9402627814657); + points += QPointF(162.15140960153235, 1427.2253633368487); + points += QPointF(138.7574425051522, 1416.8980683748348); + points += QPointF(115.08634634526746, 1405.9588656481617); + points += QPointF(91.13514188315949, 1394.4082429095668); + points += QPointF(66.90084988010975, 1382.2466879117876); + points += QPointF(42.38049109739966, 1369.4746884075616); + points += QPointF(30.0, 1362.8345196850394); + points += QPointF(-7.795275590551185, 1173.8581417322835); + points += QPointF(-7.795275590551185, 5.332135175169643); + points += QPointF(61.282362682462484, -0.6418380334156654); + points += QPointF(68.99270783774104, 43.602497599341376); + points += QPointF(72.9132813035755, 63.2947212555562); + points += QPointF(77.3013929112068, 82.41949176853801); + points += QPointF(82.1591612486953, 101.07290945528996); + points += QPointF(87.47127192119272, 119.26236235620561); + points += QPointF(93.22265002333297, 136.995242382529); + points += QPointF(99.39845834352354, 154.27891130896086); + points += QPointF(105.98409057569768, 171.12066698560935); + points += QPointF(112.96515967796651, 187.5277107532596); + points += QPointF(120.3274817141749, 203.50711700306462); + points += QPointF(128.05705569238026, 219.06580572797276); + points += QPointF(136.140040064258, 234.21051878050557); + points += QPointF(144.56272665980467, 248.94780038335693); + points += QPointF(153.31151289915712, 263.28398225332904); + points += QPointF(162.37287314390684, 277.2251735037908); + points += QPointF(171.7333300269448, 290.7772553015979); + points += QPointF(181.37942653744733, 303.94588008167347); + points += QPointF(191.29769954207885, 316.73647497324424); + points += QPointF(201.4746553074722, 329.15424897723653); + points += QPointF(211.8967474561181, 341.2042033492513); + points += QPointF(222.55035765443486, 352.89114459720207); + points += QPointF(233.42177919919385, 364.21969948550475); + points += QPointF(244.49720354953487, 375.1943314526637); + points += QPointF(255.7627097438719, 385.81935788241924); + points += QPointF(267.20425655639707, 396.09896772498274); + points += QPointF(278.75265348524636, 405.99011151219827); + points += QPointF(296.42128624929416, 420.3133300264941); + points += QPointF(320.48452011994203, 438.2320527150828); + points += QPointF(344.87558321732604, 454.8117451133493); + points += QPointF(369.53320753519137, 470.12563295711334); + points += QPointF(394.3361710694346, 484.20351622969935); + points += QPointF(419.16155857757707, 497.07530679920615); + points += QPointF(443.88487919291146, 508.77121504768843); + points += QPointF(468.38014199617356, 519.321880586359); + points += QPointF(492.51986728337727, 528.7584613476223); + points += QPointF(516.1750084818626, 537.1126962804665); + points += QPointF(539.2147513582057, 544.4169583447066); + points += QPointF(561.5061404146093, 550.7043180882887); + points += QPointF(582.9134517220549, 556.0086464028718); + points += QPointF(603.297176144298, 560.3648031296603); + points += QPointF(622.512375480477, 563.8089969972691); + points += QPointF(640.4059816430324, 566.3794874049449); + points += QPointF(656.8122283884328, 568.1179931683923); + points += QPointF(671.5446156432315, 569.0726461855179); + points += QPointF(684.5714272485307, 569.308003986851); + points += QPointF(690.2881064563063, 569.1505016813809); + points += QPointF(697.6994465521921, 568.9116352687084); + points += QPointF(712.7791990595856, 568.829069686213); + points += QPointF(727.9225489586405, 569.2261552050226); + points += QPointF(743.0205601588, 570.0941667183644); + points += QPointF(758.0665280331999, 571.4236936735902); + points += QPointF(773.0540417864709, 573.2052363093372); + points += QPointF(787.9769792031311, 575.4292414839725); + points += QPointF(802.8294963913348, 578.0861355014533); + points += QPointF(817.6060134704758, 581.1663534276446); + points += QPointF(832.3840681765656, 584.6800684918327); + points += QPointF(854.2646050023646, 590.6246236981764); + points += QPointF(883.0268449918112, 599.956221997473); + points += QPointF(911.458987786853, 610.8015283739599); + points += QPointF(939.4455853403952, 623.0622581751827); + points += QPointF(966.9537607342976, 636.6682333974711); + points += QPointF(993.9516330911679, 651.551057077312); + points += QPointF(1020.4078966730023, 667.6440112755474); + points += QPointF(1046.2914925169705, 684.8819135818707); + points += QPointF(1071.5713620583545, 703.2009569179793); + points += QPointF(1096.216269205861, 722.5385497176682); + points += QPointF(1120.1946768785947, 742.8331673228507); + points += QPointF(1143.4746649906992, 764.024220756791); + points += QPointF(1166.0238785179056, 786.0519457597054); + points += QPointF(1187.8094960863832, 808.8573128063047); + points += QPointF(1208.7982112227505, 832.3819574965946); + points += QPointF(1228.9562198237943, 856.5681299364858); + points += QPointF(1248.2492085181873, 881.3586613164372); + points += QPointF(1266.6423393728558, 906.6969456633109); + points += QPointF(1284.1002268781353, 932.5269345592678); + points += QPointF(1300.5869033558602, 958.7931423679255); + points += QPointF(1316.065768928307, 985.4406590911037); + points += QPointF(1330.4995219936793, 1012.4151672497809); + points += QPointF(1343.850065889632, 1039.6629580676176); + points += QPointF(1356.0783871611402, 1067.1309405095865); + points += QPointF(1367.1444008135065, 1094.7666342875323); + points += QPointF(1377.006758382479, 1122.5181345255592); + points += QPointF(1385.5816561538945, 1150.2017940249868); + points += QPointF(1391.2089508950362, 1170.962993556315); + return points; +} diff --git a/src/test/ValentinaTest/tst_vabstractpiece.h b/src/test/ValentinaTest/tst_vabstractpiece.h index d46f53f6b..52b5b0548 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.h +++ b/src/test/ValentinaTest/tst_vabstractpiece.h @@ -90,6 +90,9 @@ private: QVector InputPointsCase3a() const; QVector InputPointsCase4a() const; QVector InputPointsCase5a() const; + + QVector InputPointsIssue646() const; + QVector OutputPointsIssue646() const; }; #endif // TST_VABSTRACTPIECE_H diff --git a/src/test/ValentinaTest/tst_vpiece.cpp b/src/test/ValentinaTest/tst_vpiece.cpp index 811d19cc9..7668d80f0 100644 --- a/src/test/ValentinaTest/tst_vpiece.cpp +++ b/src/test/ValentinaTest/tst_vpiece.cpp @@ -106,7 +106,7 @@ void TST_VPiece::ClearLoop() const QVector pointsEkv = detail.SeamAllowancePoints(data); QVector origPoints; - origPoints.append(QPointF(42.46405659601934, 415.2845470563871)); + origPoints.append(QPointF(42.46405659601932, 415.2845470563871)); origPoints.append(QPointF(669.4711112822802, 560.1912138528764)); origPoints.append(QPointF(669.3860586912449, 594.8702688224456)); origPoints.append(QPointF(669.8537241707239, 619.8499975627876)); @@ -120,8 +120,10 @@ void TST_VPiece::ClearLoop() origPoints.append(QPointF(689.2446146317781, 744.0149891243127)); origPoints.append(QPointF(692.7177992446996, 752.7004886151328)); origPoints.append(QPointF(696.2448548679188, 760.4478278509594)); - origPoints.append(QPointF(701.7756191283249, 771.1817664136103)); - origPoints.append(QPointF(715.0901851898707, 793.875700151992)); + origPoints.append(QPointF(701.8005387196029, 771.2301295961994)); + origPoints.append(QPointF(709.4908502689113, 784.4621360005407)); + origPoints.append(QPointF(713.2090350731621, 790.7616409320319)); + origPoints.append(QPointF(715.0121915355467, 793.763727920337)); origPoints.append(QPointF(718.7808834775552, 799.1742815201673)); origPoints.append(QPointF(722.5723522600899, 803.7317522627161)); origPoints.append(QPointF(726.4900810611796, 807.6675956080389)); @@ -135,10 +137,10 @@ void TST_VPiece::ClearLoop() origPoints.append(QPointF(766.9761113390083, 824.236813134474)); origPoints.append(QPointF(773.6735265709667, 824.7970381873482)); origPoints.append(QPointF(780.6615727577812, 825.0343457026618)); - origPoints.append(QPointF(792.1099959092389, 824.8480813766124)); + origPoints.append(QPointF(792.109995909239, 824.8480813766124)); origPoints.append(QPointF(826.0032661558732, 877.1274330708662)); origPoints.append(QPointF(828.6858753986579, 1697.305833468011)); - origPoints.append(QPointF(42.46405659601934, 415.2845470563871)); + origPoints.append(QPointF(42.46405659601932, 415.2845470563871)); // Begin comparison Comparison(pointsEkv, origPoints); From d1e28f4d46a6fdf8215255cac86909f5db33aca7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 11:07:42 +0300 Subject: [PATCH 13/18] Refactoring. Replace PassmarkLength by VAbstractPiece::MaxLocalSA. --HG-- branch : feature --- src/libs/vlayout/vabstractpiece.h | 2 +- src/libs/vpatterndb/vpiece.cpp | 20 +------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index b51974b35..acd030497 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -168,6 +168,7 @@ public: protected: template static QVector RemoveDublicates(const QVector &points, bool removeFirstAndLast = true); + static qreal MaxLocalSA(const VSAPoint &p, qreal width); private: QSharedDataPointer d; @@ -178,7 +179,6 @@ private: static bool Crossing(const QVector &sub1, const QVector &sub2); static QVector SubPath(const QVector &path, int startIndex, int endIndex); static Q_DECL_CONSTEXPR qreal PointPosition(const QPointF &p, const QLineF &line); - static qreal MaxLocalSA(const VSAPoint &p, qreal width); static QVector AngleByLength(const QPointF &p2, const QPointF &sp1, const QPointF &sp2, const QPointF &sp3, qreal width); static QVector AngleByIntersection(const QPointF &p1, const QPointF &p2, const QPointF &p3, diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 0a04cf466..d6a875471 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -67,24 +67,6 @@ QVector PieceMissingNodes(const QVector &d1Nodes, const QVecto return r; } -//--------------------------------------------------------------------------------------------------------------------- -qreal PassmarkLength(const VSAPoint &passmarkSAPoint, qreal width) -{ - qreal w1 = passmarkSAPoint.GetSAAfter(); - if (w1 < 0) - { - w1 = width; - } - - qreal w2 = passmarkSAPoint.GetSABefore(); - if (w2 < 0) - { - w2 = width; - } - - return qMax(w1, w2); -} - const qreal passmarkGap = (1.5/*mm*/ / 25.4) * PrintDPI; //--------------------------------------------------------------------------------------------------------------------- @@ -965,7 +947,7 @@ QVector VPiece::CreatePassmark(int previousIndex, int passmarkIndex, int QVector passmarksLines; - const qreal passmarkLength = PassmarkLength(passmarkSAPoint, width) * 0.25; + const qreal passmarkLength = VAbstractPiece::MaxLocalSA(passmarkSAPoint, width) * 0.25; const VPieceNode &node = d->m_path.at(passmarkIndex); if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward) { From e2db513172cd6d5d76c87d3424acca2018cd56d4 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 11:08:11 +0300 Subject: [PATCH 14/18] Refactoring. Remove unused variables. --HG-- branch : feature --- src/libs/vpatterndb/vpiecenode_p.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 8e91c7a10..993d5c742 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -45,8 +45,6 @@ public: m_reverse(false), m_excluded(false), m_isPassmark(false), - m_saBefore(-1), - m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), m_formulaWidthAfter(currentSeamAllowance), m_angleType(PieceNodeAngle::ByLength), @@ -60,8 +58,6 @@ public: m_reverse(reverse), m_excluded(false), m_isPassmark(false), - m_saBefore(-1), - m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), m_formulaWidthAfter(currentSeamAllowance), m_angleType(PieceNodeAngle::ByLength), @@ -81,8 +77,6 @@ public: m_reverse(node.m_reverse), m_excluded(node.m_excluded), m_isPassmark(node.m_isPassmark), - m_saBefore(node.m_saBefore), - m_saAfter(node.m_saAfter), m_formulaWidthBefore(node.m_formulaWidthBefore), m_formulaWidthAfter(node.m_formulaWidthAfter), m_angleType(node.m_angleType), @@ -111,9 +105,6 @@ public: /** @brief m_isPassmark has sense only for points. If true to seam allowance should be added a passmark. */ bool m_isPassmark; - qreal m_saBefore; - qreal m_saAfter; - QString m_formulaWidthBefore; QString m_formulaWidthAfter; @@ -138,8 +129,6 @@ QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p) << p.m_reverse << p.m_excluded << p.m_isPassmark - << p.m_saBefore - << p.m_saAfter << p.m_formulaWidthBefore << p.m_formulaWidthAfter << static_cast(p.m_angleType) @@ -161,8 +150,6 @@ QDataStream &operator>>(QDataStream &in, VPieceNodeData &p) >> p.m_reverse >> p.m_excluded >> p.m_isPassmark - >> p.m_saBefore - >> p.m_saAfter >> p.m_formulaWidthBefore >> p.m_formulaWidthAfter >> angleType From d3ab7f5b16e704a2042b63dbe8e374994e92f325 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 11:09:12 +0300 Subject: [PATCH 15/18] Return -1 if was used global seam allowance width instead of calculating its value. --HG-- branch : feature --- src/libs/vpatterndb/vpiecenode.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index e2692521d..3a669297d 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -154,12 +154,22 @@ void VPieceNode::SetReverse(bool reverse) //--------------------------------------------------------------------------------------------------------------------- qreal VPieceNode::GetSABefore(const VContainer *data) const { + if (d->m_formulaWidthBefore == currentSeamAllowance) + { + return -1; + } + return EvalFormula(data, d->m_formulaWidthBefore); } //--------------------------------------------------------------------------------------------------------------------- qreal VPieceNode::GetSABefore(const VContainer *data, Unit unit) const { + if (d->m_formulaWidthBefore == currentSeamAllowance) + { + return -1; + } + qreal value = EvalFormula(data, d->m_formulaWidthBefore); if (value >= 0) { @@ -186,12 +196,22 @@ void VPieceNode::SetFormulaSABefore(const QString &formula) //--------------------------------------------------------------------------------------------------------------------- qreal VPieceNode::GetSAAfter(const VContainer *data) const { + if (d->m_formulaWidthAfter == currentSeamAllowance) + { + return -1; + } + return EvalFormula(data, d->m_formulaWidthAfter); } //--------------------------------------------------------------------------------------------------------------------- qreal VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const { + if (d->m_formulaWidthAfter == currentSeamAllowance) + { + return -1; + } + qreal value = EvalFormula(data, d->m_formulaWidthAfter); if (value >= 0) { From f05cd909a281966095c732a5e2b8735e2718d1ab Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 12:26:06 +0300 Subject: [PATCH 16/18] Unite nodes to be able to show passmarks from custom seam allowance included as main path. --HG-- branch : feature --- src/libs/vpatterndb/vpiece.cpp | 145 +++++++++++++++++++---------- src/libs/vpatterndb/vpiece.h | 21 +++-- src/libs/vpatterndb/vpiecepath.cpp | 26 ++++-- src/libs/vpatterndb/vpiecepath.h | 2 + 4 files changed, 125 insertions(+), 69 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index d6a875471..b049a5543 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -226,11 +226,12 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const int recordIndex = -1; bool insertingCSA = false; const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); + const QVector unitedPath = GetUnitedPath(data); QVector pointsEkv; - for (int i = 0; i< d->m_path.CountNodes(); ++i) + for (int i = 0; i< unitedPath.size(); ++i) { - const VPieceNode &node = d->m_path.at(i); + const VPieceNode &node = unitedPath.at(i); if (node.IsExcluded()) { continue;// skip excluded node @@ -245,21 +246,18 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const pointsEkv.append(VPiecePath::PreparePointEkv(node, data)); recordIndex = IsCSAStart(records, node.GetId()); - if (recordIndex != -1) + if (recordIndex != -1 && records.at(recordIndex).includeType == PiecePathIncludeType::AsCustomSA) { insertingCSA = true; const VPiecePath path = data->GetPiecePath(records.at(recordIndex).path); QVector r = path.SeamAllowancePoints(data, width, records.at(recordIndex).reverse); - if (records.at(recordIndex).includeType == PiecePathIncludeType::AsCustomSA) + for (int j = 0; j < r.size(); ++j) { - for (int j = 0; j < r.size(); ++j) - { - r[j].SetAngleType(PieceNodeAngle::ByLength); - r[j].SetSABefore(0); - r[j].SetSAAfter(0); - } + r[j].SetAngleType(PieceNodeAngle::ByLength); + r[j].SetSABefore(0); + r[j].SetSAAfter(0); } pointsEkv += r; @@ -286,8 +284,8 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const { const QSharedPointer curve = data->GeometricObject(node.GetId()); - pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, d->m_path.GetNodes(), curve, i, - node.GetReverse(), width); + pointsEkv += VPiecePath::CurveSeamAllowanceSegment(data, unitedPath, curve, i, node.GetReverse(), + width); } } break; @@ -303,16 +301,17 @@ QVector VPiece::SeamAllowancePoints(const VContainer *data) const //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::PassmarksLines(const VContainer *data) const { - if (not IsSeamAllowance() || not IsPassmarksPossible()) + const QVector unitedPath = GetUnitedPath(data); + if (not IsSeamAllowance() || not IsPassmarksPossible(unitedPath)) { return QVector(); } QVector passmarks; - for (int i = 0; i< d->m_path.CountNodes(); ++i) + for (int i = 0; i< unitedPath.size(); ++i) { - const VPieceNode &node = d->m_path.at(i); + const VPieceNode &node = unitedPath.at(i); if (node.IsExcluded() || not node.IsPassmark()) { continue;// skip node @@ -323,24 +322,24 @@ QVector VPiece::PassmarksLines(const VContainer *data) const int previousIndex = 0; if (passmarkIndex == 0) { - previousIndex = VPiecePath::FindInLoopNotExcludedUp(d->m_path.CountNodes()-1, d->m_path.GetNodes()); + previousIndex = VPiecePath::FindInLoopNotExcludedUp(unitedPath.size()-1, unitedPath); } else { - previousIndex = VPiecePath::FindInLoopNotExcludedUp(passmarkIndex-1, d->m_path.GetNodes()); + previousIndex = VPiecePath::FindInLoopNotExcludedUp(passmarkIndex-1, unitedPath); } int nextIndex = 0; - if (passmarkIndex == d->m_path.CountNodes()-1) + if (passmarkIndex == unitedPath.size()-1) { - nextIndex = VPiecePath::FindInLoopNotExcludedDown(0, d->m_path.GetNodes()); + nextIndex = VPiecePath::FindInLoopNotExcludedDown(0, unitedPath); } else { - nextIndex = VPiecePath::FindInLoopNotExcludedDown(passmarkIndex+1, d->m_path.GetNodes()); + nextIndex = VPiecePath::FindInLoopNotExcludedDown(passmarkIndex+1, unitedPath); } - passmarks += CreatePassmark(previousIndex, passmarkIndex, nextIndex, data); + passmarks += CreatePassmark(unitedPath, previousIndex, passmarkIndex, nextIndex, data); } return passmarks; @@ -644,6 +643,47 @@ const VGrainlineData &VPiece::GetGrainlineGeometry() const return d->m_glGrainline; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::GetUnitedPath(const VContainer *data) const +{ + SCASSERT(data != nullptr) + + QVector united = d->m_path.GetNodes(); + const QVector records = FilterRecords(GetValidRecords()); + + for (int i = 0; i < records.size(); ++i) + { + if (records.at(i).includeType == PiecePathIncludeType::AsMainPath) + { + const int indexStartPoint = VPiecePath::indexOfNode(united, records.at(i).startPoint); + const int indexEndPoint = VPiecePath::indexOfNode(united, records.at(i).endPoint); + + if (indexStartPoint == -1 || indexEndPoint == -1) + { + continue; + } + + const QVector midBefore = united.mid(0, indexStartPoint+1); + const QVector midAfter = united.mid(indexEndPoint); + + QVector customNodes = data->GetPiecePath(records.at(i).path).GetNodes(); + if (records.at(i).reverse) + { + customNodes = VGObject::GetReversePoints(customNodes); + + // Additionally reverse all curves + for (int j = 0; j < customNodes.size(); ++j) + { // don't make a check because node point will ignore the change + customNodes[j].SetReverse(not customNodes.at(j).GetReverse()); + } + } + + united = midBefore + customNodes + midAfter; + } + } + return united; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::GetValidRecords() const { @@ -719,16 +759,16 @@ QVector VPiece::FilterRecords(QVector records) c } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::GetNodeSAPoints(int index, const VContainer *data) const +QVector VPiece::GetNodeSAPoints(const QVector &path, int index, const VContainer *data) const { SCASSERT(data != nullptr) - if (index < 0 || index >= d->m_path.CountNodes()) + if (index < 0 || index >= path.size()) { return QVector(); } - const VPieceNode &node = d->m_path.at(index); + const VPieceNode &node = path.at(index); QVector points; if (node.GetTypeTool() == Tool::NodePoint) @@ -740,18 +780,18 @@ QVector VPiece::GetNodeSAPoints(int index, const VContainer *data) con const QSharedPointer curve = data->GeometricObject(node.GetId()); const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); - points += VPiecePath::CurveSeamAllowanceSegment(data, d->m_path.GetNodes(), curve, index, node.GetReverse(), - width); + points += VPiecePath::CurveSeamAllowanceSegment(data, path, curve, index, node.GetReverse(), width); } return points; } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkSAPoint(int index, const VContainer *data, VSAPoint &point) const +bool VPiece::GetPassmarkSAPoint(const QVector &path, int index, const VContainer *data, + VSAPoint &point) const { SCASSERT(data != nullptr) - const QVector points = GetNodeSAPoints(index, data); + const QVector points = GetNodeSAPoints(path, index, data); if (points.isEmpty() || points.size() > 1) { @@ -763,12 +803,12 @@ bool VPiece::GetPassmarkSAPoint(int index, const VContainer *data, VSAPoint &poi } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkPreviousSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, - VSAPoint &point) const +bool VPiece::GetPassmarkPreviousSAPoint(const QVector &path, int index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point) const { SCASSERT(data != nullptr) - const QVector points = GetNodeSAPoints(index, data); + const QVector points = GetNodeSAPoints(path, index, data); if (points.isEmpty()) { @@ -796,10 +836,10 @@ bool VPiece::GetPassmarkPreviousSAPoint(int index, const VSAPoint &passmarkSAPoi } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::GetPassmarkNextSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, - VSAPoint &point) const +bool VPiece::GetPassmarkNextSAPoint(const QVector &path, int index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point) const { - const QVector points = GetNodeSAPoints(index, data); + const QVector points = GetNodeSAPoints(path, index, data); if (points.isEmpty()) { @@ -855,14 +895,14 @@ bool VPiece::GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPo } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::IsPassmarksPossible() const +bool VPiece::IsPassmarksPossible(const QVector &path) const { int countPointNodes = 0; int countOthers = 0; - for (int i = 0; i< d->m_path.CountNodes(); ++i) + for (int i = 0; i< path.size(); ++i) { - const VPieceNode &node = d->m_path.at(i); + const VPieceNode &node = path.at(i); if (node.IsExcluded()) { continue;// skip node @@ -875,14 +915,14 @@ bool VPiece::IsPassmarksPossible() const } //--------------------------------------------------------------------------------------------------------------------- -bool VPiece::IsPassmarkVisible(int passmarkIndex) const +bool VPiece::IsPassmarkVisible(const QVector &path, int passmarkIndex) const { - if (passmarkIndex < 0 || passmarkIndex >= d->m_path.CountNodes()) + if (passmarkIndex < 0 || passmarkIndex >= path.size()) { return false; } - const VPieceNode &node = d->m_path.at(passmarkIndex); + const VPieceNode &node = path.at(passmarkIndex); if (node.GetTypeTool() != Tool::NodePoint || not node.IsPassmark() || node.IsExcluded()) { return false; @@ -896,41 +936,44 @@ bool VPiece::IsPassmarkVisible(int passmarkIndex) const for (int i = 0; i < records.size(); ++i) { - const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint); - const int indexEndPoint = d->m_path.indexOfNode(records.at(i).endPoint); - if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint) + if (records.at(i).includeType == PiecePathIncludeType::AsCustomSA) { - return false; + const int indexStartPoint = VPiecePath::indexOfNode(path, records.at(i).startPoint); + const int indexEndPoint = VPiecePath::indexOfNode(path, records.at(i).endPoint); + if (passmarkIndex > indexStartPoint && passmarkIndex < indexEndPoint) + { + return false; + } } } return true; } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::CreatePassmark(int previousIndex, int passmarkIndex, int nextIndex, - const VContainer *data) const +QVector VPiece::CreatePassmark(const QVector &path, int previousIndex, int passmarkIndex, + int nextIndex, const VContainer *data) const { SCASSERT(data != nullptr); - if (not IsPassmarkVisible(passmarkIndex)) + if (not IsPassmarkVisible(path, passmarkIndex)) { return QVector(); } VSAPoint passmarkSAPoint; - if (not GetPassmarkSAPoint(passmarkIndex, data, passmarkSAPoint)) + if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint)) { return QVector(); // Something wrong } VSAPoint previousSAPoint; - if (not GetPassmarkPreviousSAPoint(previousIndex, passmarkSAPoint, data, previousSAPoint)) + if (not GetPassmarkPreviousSAPoint(path, previousIndex, passmarkSAPoint, data, previousSAPoint)) { return QVector(); // Something wrong } VSAPoint nextSAPoint; - if (not GetPassmarkNextSAPoint(nextIndex, passmarkSAPoint, data, nextSAPoint)) + if (not GetPassmarkNextSAPoint(path, nextIndex, passmarkSAPoint, data, nextSAPoint)) { return QVector(); // Something wrong } @@ -948,7 +991,7 @@ QVector VPiece::CreatePassmark(int previousIndex, int passmarkIndex, int QVector passmarksLines; const qreal passmarkLength = VAbstractPiece::MaxLocalSA(passmarkSAPoint, width) * 0.25; - const VPieceNode &node = d->m_path.at(passmarkIndex); + const VPieceNode &node = path.at(passmarkIndex); if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward) { QLineF line = QLineF(seamPassmarkSAPoint, passmarkSAPoint); diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 7f5c40ec6..a2ec5971f 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -113,23 +113,26 @@ public: private: QSharedDataPointer d; + QVector GetUnitedPath(const VContainer *data) const; + QVector GetValidRecords() const; QVector FilterRecords(QVector records) const; - QVector GetNodeSAPoints(int index, const VContainer *data) const; + QVector GetNodeSAPoints(const QVector &path, int index, const VContainer *data) const; - bool GetPassmarkSAPoint(int index, const VContainer *data, VSAPoint &point) const; - bool GetPassmarkPreviousSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, - VSAPoint &point) const; - bool GetPassmarkNextSAPoint(int index, const VSAPoint &passmarkSAPoint, const VContainer *data, - VSAPoint &point) const; + bool GetPassmarkSAPoint(const QVector &path, int index, const VContainer *data, VSAPoint &point) const; + bool GetPassmarkPreviousSAPoint(const QVector &path, int index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point) const; + bool GetPassmarkNextSAPoint(const QVector &path, int index, const VSAPoint &passmarkSAPoint, + const VContainer *data, VSAPoint &point) const; bool GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPoint &passmarkSAPoint, const VSAPoint &nextSAPoint, const VContainer *data, QPointF &point) const; - bool IsPassmarksPossible() const; - bool IsPassmarkVisible(int passmarkIndex) const; + bool IsPassmarksPossible(const QVector &path) const; + bool IsPassmarkVisible(const QVector &path, int passmarkIndex) const; - QVector CreatePassmark(int previousIndex, int passmarkIndex, int nextIndex, const VContainer *data) const; + QVector CreatePassmark(const QVector &path, int previousIndex, int passmarkIndex, int nextIndex, + const VContainer *data) const; static int IsCSAStart(const QVector &records, quint32 id); }; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 3e23330e4..3e569a8b7 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -466,15 +466,7 @@ QVector VPiecePath::MissingNodes(const VPiecePath &path) const //--------------------------------------------------------------------------------------------------------------------- int VPiecePath::indexOfNode(quint32 id) const { - for (int i = 0; i < d->m_nodes.size(); ++i) - { - if (d->m_nodes.at(i).GetId() == id) - { - return i; - } - } - qDebug()<<"Can't find node."; - return -1; + return indexOfNode(d->m_nodes, id); } //--------------------------------------------------------------------------------------------------------------------- @@ -768,6 +760,20 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const return point; } +//--------------------------------------------------------------------------------------------------------------------- +int VPiecePath::indexOfNode(const QVector &nodes, quint32 id) +{ + for (int i = 0; i < nodes.size(); ++i) + { + if (nodes.at(i).GetId() == id) + { + return i; + } + } + qDebug()<<"Can't find node."; + return -1; +} + //--------------------------------------------------------------------------------------------------------------------- int VPiecePath::FindInLoopNotExcludedUp(int candidate, const QVector &nodes) { @@ -827,6 +833,8 @@ int VPiecePath::FindInLoopNotExcludedDown(int candidate, const QVector point = data->GeometricObject(node.GetId()); VSAPoint p(point->toQPointF()); diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index 8bda5957b..bd41edb64 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -94,6 +94,8 @@ public: QPointF NodePreviousPoint(const VContainer *data, int i) const; QPointF NodeNextPoint(const VContainer *data, int i) const; + static int indexOfNode(const QVector &nodes, quint32 id); + static int FindInLoopNotExcludedUp(int candidate, const QVector &nodes); static int FindInLoopNotExcludedDown(int candidate, const QVector &nodes); From b62aaaf9928f0ccb18a374033a53d48398071b07 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 13:27:57 +0300 Subject: [PATCH 17/18] Layout now works with passmarks. --HG-- branch : feature --- src/libs/vlayout/vlayoutpiece.cpp | 42 +++++++++++++++++++++++++------ src/libs/vlayout/vlayoutpiece.h | 6 ++++- src/libs/vlayout/vlayoutpiece_p.h | 5 ++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 1ddb6fc8e..8e786e279 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -299,14 +299,13 @@ QVector CorrectPosition(const QRectF &parentBoundingRect, QVector RoundPoints(const QVector &points) +QVector RoundPoints(QVector points) { - QVector p; for (int i=0; i < points.size(); ++i) { - p.append(QPointF(qRound(points.at(i).x()), qRound(points.at(i).y()))); + points[i] = QPointF(qRound(points.at(i).x()), qRound(points.at(i).y())); } - return p; + return points; } //--------------------------------------------------------------------------------------------------------------------- @@ -385,6 +384,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern det.SetCountourPoints(piece.MainPathPoints(pattern)); det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance()); det.SetInternalPaths(ConvertInternalPaths(piece, pattern)); + det.SetPassmarks(piece.PassmarksLines(pattern)); det.SetName(piece.GetName()); @@ -803,6 +803,21 @@ void VLayoutPiece::SetLayoutAllowancePoints() } } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPiece::GetPassmarks() const +{ + return Map(d->passmarks); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPiece::SetPassmarks(const QVector &passmarks) +{ + if (IsSeamAllowance()) + { + d->passmarks = passmarks; + } +} + //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutPiece::GetInternalPaths() const { @@ -816,9 +831,10 @@ void VLayoutPiece::SetInternalPaths(const QVector &internalPat } //--------------------------------------------------------------------------------------------------------------------- -QVector VLayoutPiece::Map(const QVector &points) const +template +QVector VLayoutPiece::Map(const QVector &points) const { - QVector p; + QVector p; for (int i = 0; i < points.size(); ++i) { p.append(d->matrix.map(points.at(i))); @@ -826,7 +842,7 @@ QVector VLayoutPiece::Map(const QVector &points) const if (d->mirror) { - QList list = p.toList(); + QList list = p.toList(); for (int k=0, s=list.size(), max=(s/2); k passmarks = GetPassmarks(); + QPainterPath passmaksPath; + for (qint32 i = 0; i < passmarks.count(); ++i) + { + passmaksPath.moveTo(passmarks.at(i).p1()); + passmaksPath.lineTo(passmarks.at(i).p2()); + } + + path.addPath(passmaksPath); path.setFillRule(Qt::WindingFill); } diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index aac2b78f8..cab060636 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -73,6 +73,9 @@ public: QVector GetLayoutAllowancePoints() const; void SetLayoutAllowancePoints(); + QVector GetPassmarks() const; + void SetPassmarks(const QVector &passmarks); + QVector GetInternalPaths() const; void SetInternalPaths(const QVector &internalPaths); @@ -128,7 +131,8 @@ private: void CreateInternalPathItem(int i, QGraphicsItem *parent) const; void CreateGrainlineItem(QGraphicsItem *parent) const; - QVector Map(const QVector &points) const; + template + QVector Map(const QVector &points) const; QLineF Edge(const QVector &path, int i) const; int EdgeByPoint(const QVector &path, const QPointF &p1) const; diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index 40e91832e..f00a1dc67 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -52,6 +52,7 @@ public: : contour(), seamAllowance(), layoutAllowance(), + passmarks(), m_internalPaths(), matrix(), layoutWidth(0), @@ -68,6 +69,7 @@ public: contour(detail.contour), seamAllowance(detail.seamAllowance), layoutAllowance(detail.layoutAllowance), + passmarks(detail.passmarks), m_internalPaths(detail.m_internalPaths), matrix(detail.matrix), layoutWidth(detail.layoutWidth), @@ -90,6 +92,9 @@ public: /** @brief layoutAllowance list of layout allowance points. */ QVector layoutAllowance; + /** @brief passmarks list of passmakrs. */ + QVector passmarks; + /** @brief m_internalPaths list of internal paths. */ QVector m_internalPaths; From 517974d68f237649cdc6c7d06be71e342ae7515c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 30 Mar 2017 13:31:03 +0300 Subject: [PATCH 18/18] Updated changelog. --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7cb5477de..3334b3531 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -56,6 +56,7 @@ - [#509] Improve feature: Support internal Paths in Detail tool. - [#619] Non writable directory prevents opening. - [#620] Detail path not correct. Previous curve also should cut segment. +- [#157] New feature: Passmarks tool. # Version 0.4.6 - [#594] Broken export on Mac.