Seamly2D
Code documentation
vabstractpattern.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vabstractpattern.cpp
3  ** @author Douglas S Caskey
4  ** @date Mar 1, 2023
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2023 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25 /************************************************************************
26  **
27  ** @file vabstractpattern.cpp
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 15 6, 2015
30  **
31  ** @brief
32  ** @copyright
33  ** This source code is part of the Valentina project, a pattern making
34  ** program, whose allow create and modeling patterns of clothing.
35  ** Copyright (C) 2015 Valentina project
36  ** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
37  **
38  ** Valentina is free software: you can redistribute it and/or modify
39  ** it under the terms of the GNU General Public License as published by
40  ** the Free Software Foundation, either version 3 of the License, or
41  ** (at your option) any later version.
42  **
43  ** Valentina is distributed in the hope that it will be useful,
44  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
45  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  ** GNU General Public License for more details.
47  **
48  ** You should have received a copy of the GNU General Public License
49  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
50  **
51  *************************************************************************/
52 
53 #include "vabstractpattern.h"
54 
55 #include <QDomNode>
56 #include <QDomNodeList>
57 #include <QLatin1String>
58 #include <QList>
59 #include <QMessageBox>
60 #include <QMessageLogger>
61 #include <QSet>
62 #include <QStaticStringData>
63 #include <QStringData>
64 #include <QStringDataPtr>
65 #include <QtDebug>
66 
67 #include "vdomdocument.h"
68 #include "vpatternconverter.h"
69 #include "vtoolrecord.h"
70 #include "../exception/vexceptionemptyparameter.h"
71 #include "../exception/vexceptionobjecterror.h"
72 #include "../exception/vexceptionconversionerror.h"
73 #include "../ifc/exception/vexceptionbadid.h"
74 #include "../ifc/ifcdef.h"
75 #include "../vmisc/vabstractapplication.h"
76 #include "../vmisc/vcommonsettings.h"
77 #include "../vpatterndb/vcontainer.h"
78 #include "../vpatterndb/vpiecenode.h"
79 #include "../qmuparser/qmutokenparser.h"
80 #include "../vtools/tools/vdatatool.h"
81 
82 class QDomElement;
83 
84 const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
85 const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
86 const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
87 const QString VAbstractPattern::TagPieces = QStringLiteral("pieces");
88 const QString VAbstractPattern::TagPiece = QStringLiteral("piece");
89 const QString VAbstractPattern::TagDescription = QStringLiteral("description");
90 const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
91 const QString VAbstractPattern::TagImage = QStringLiteral("image");
92 const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
93 const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
94 const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
95 const QString VAbstractPattern::TagDraftBlock = QStringLiteral("draftBlock");
96 const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
97 const QString VAbstractPattern::TagGroup = QStringLiteral("group");
98 const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
99 const QString VAbstractPattern::TagPoint = QStringLiteral("point");
100 const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
101 const QString VAbstractPattern::TagArc = QStringLiteral("arc");
102 const QString VAbstractPattern::TagElArc = QStringLiteral("elArc");
103 const QString VAbstractPattern::TagTools = QStringLiteral("tools");
104 const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
105 const QString VAbstractPattern::TagGradation = QStringLiteral("gradation");
106 const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
107 const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
108 const QString VAbstractPattern::TagData = QStringLiteral("data");
109 const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
110 const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
111 const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
112 const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
113 const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
114 const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
115 const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
116 const QString VAbstractPattern::TagPath = QStringLiteral("path");
117 const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
118 const QString VAbstractPattern::TagNode = QStringLiteral("node");
119 const QString VAbstractPattern::TagLine = QStringLiteral("line");
120 
121 const QString VAbstractPattern::AttrName = QStringLiteral("name");
122 const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
123 const QString VAbstractPattern::AttrGroupLocked = QStringLiteral("locked");
124 const QString VAbstractPattern::AttrGroupColor = QStringLiteral("groupColor");
125 const QString VAbstractPattern::AttrObject = QStringLiteral("object");
126 const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
127 const QString VAbstractPattern::AttrType = QStringLiteral("type");
128 const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
129 const QString VAbstractPattern::AttrAnnotation = QStringLiteral("annotation");
130 const QString VAbstractPattern::AttrOrientation = QStringLiteral("orientation");
131 const QString VAbstractPattern::AttrRotationWay = QStringLiteral("rotationWay");
132 const QString VAbstractPattern::AttrTilt = QStringLiteral("tilt");
133 const QString VAbstractPattern::AttrFoldPosition = QStringLiteral("foldPosition");
134 const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
135 const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
136 const QString VAbstractPattern::AttrDateFormat = QStringLiteral("dateFormat");
137 const QString VAbstractPattern::AttrTimeFormat = QStringLiteral("timeFormat");
138 const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
139 const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
140 const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded");
141 const QString VAbstractPattern::AttrNodeIsNotch = QStringLiteral("notch");
142 const QString VAbstractPattern::AttrNodeNotchType = QStringLiteral("notchType");
143 const QString VAbstractPattern::AttrNodeNotchSubType = QStringLiteral("notchSubtype");
144 const QString VAbstractPattern::AttrNodeShowNotch = QStringLiteral("showNotch");
145 const QString VAbstractPattern::AttrNodeShowSecondNotch = QStringLiteral("showSecondNotch");
146 const QString VAbstractPattern::AttrNodeNotchLength = QStringLiteral("notchLength");
147 const QString VAbstractPattern::AttrNodeNotchWidth = QStringLiteral("notchWidth");
148 const QString VAbstractPattern::AttrNodeNotchAngle = QStringLiteral("notchAngle");
149 const QString VAbstractPattern::AttrNodeNotchCount = QStringLiteral("notchCount");
150 const QString VAbstractPattern::AttrSABefore = QStringLiteral("before");
151 const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after");
152 const QString VAbstractPattern::AttrStart = QStringLiteral("start");
153 const QString VAbstractPattern::AttrPath = QStringLiteral("path");
154 const QString VAbstractPattern::AttrEnd = QStringLiteral("end");
155 const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs");
156 const QString VAbstractPattern::AttrWidth = QStringLiteral("width");
157 const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
158 
159 const QString VAbstractPattern::AttrAll = QStringLiteral("all");
160 
161 const QString VAbstractPattern::AttrH50 = QStringLiteral("h50");
162 const QString VAbstractPattern::AttrH56 = QStringLiteral("h56");
163 const QString VAbstractPattern::AttrH62 = QStringLiteral("h62");
164 const QString VAbstractPattern::AttrH68 = QStringLiteral("h68");
165 const QString VAbstractPattern::AttrH74 = QStringLiteral("h74");
166 const QString VAbstractPattern::AttrH80 = QStringLiteral("h80");
167 const QString VAbstractPattern::AttrH86 = QStringLiteral("h86");
168 const QString VAbstractPattern::AttrH92 = QStringLiteral("h92");
169 const QString VAbstractPattern::AttrH98 = QStringLiteral("h98");
170 const QString VAbstractPattern::AttrH104 = QStringLiteral("h104");
171 const QString VAbstractPattern::AttrH110 = QStringLiteral("h110");
172 const QString VAbstractPattern::AttrH116 = QStringLiteral("h116");
173 const QString VAbstractPattern::AttrH122 = QStringLiteral("h122");
174 const QString VAbstractPattern::AttrH128 = QStringLiteral("h128");
175 const QString VAbstractPattern::AttrH134 = QStringLiteral("h134");
176 const QString VAbstractPattern::AttrH140 = QStringLiteral("h140");
177 const QString VAbstractPattern::AttrH146 = QStringLiteral("h146");
178 const QString VAbstractPattern::AttrH152 = QStringLiteral("h152");
179 const QString VAbstractPattern::AttrH158 = QStringLiteral("h158");
180 const QString VAbstractPattern::AttrH164 = QStringLiteral("h164");
181 const QString VAbstractPattern::AttrH170 = QStringLiteral("h170");
182 const QString VAbstractPattern::AttrH176 = QStringLiteral("h176");
183 const QString VAbstractPattern::AttrH182 = QStringLiteral("h182");
184 const QString VAbstractPattern::AttrH188 = QStringLiteral("h188");
185 const QString VAbstractPattern::AttrH194 = QStringLiteral("h194");
186 const QString VAbstractPattern::AttrH200 = QStringLiteral("h200");
187 
188 const QString VAbstractPattern::AttrS22 = QStringLiteral("s22");
189 const QString VAbstractPattern::AttrS24 = QStringLiteral("s24");
190 const QString VAbstractPattern::AttrS26 = QStringLiteral("s26");
191 const QString VAbstractPattern::AttrS28 = QStringLiteral("s28");
192 const QString VAbstractPattern::AttrS30 = QStringLiteral("s30");
193 const QString VAbstractPattern::AttrS32 = QStringLiteral("s32");
194 const QString VAbstractPattern::AttrS34 = QStringLiteral("s34");
195 const QString VAbstractPattern::AttrS36 = QStringLiteral("s36");
196 const QString VAbstractPattern::AttrS38 = QStringLiteral("s38");
197 const QString VAbstractPattern::AttrS40 = QStringLiteral("s40");
198 const QString VAbstractPattern::AttrS42 = QStringLiteral("s42");
199 const QString VAbstractPattern::AttrS44 = QStringLiteral("s44");
200 const QString VAbstractPattern::AttrS46 = QStringLiteral("s46");
201 const QString VAbstractPattern::AttrS48 = QStringLiteral("s48");
202 const QString VAbstractPattern::AttrS50 = QStringLiteral("s50");
203 const QString VAbstractPattern::AttrS52 = QStringLiteral("s52");
204 const QString VAbstractPattern::AttrS54 = QStringLiteral("s54");
205 const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
206 const QString VAbstractPattern::AttrS58 = QStringLiteral("s58");
207 const QString VAbstractPattern::AttrS60 = QStringLiteral("s60");
208 const QString VAbstractPattern::AttrS62 = QStringLiteral("s62");
209 const QString VAbstractPattern::AttrS64 = QStringLiteral("s64");
210 const QString VAbstractPattern::AttrS66 = QStringLiteral("s66");
211 const QString VAbstractPattern::AttrS68 = QStringLiteral("s68");
212 const QString VAbstractPattern::AttrS70 = QStringLiteral("s70");
213 const QString VAbstractPattern::AttrS72 = QStringLiteral("s72");
214 
215 const QString VAbstractPattern::AttrCustom = QStringLiteral("custom");
216 const QString VAbstractPattern::AttrDefHeight = QStringLiteral("defHeight");
217 const QString VAbstractPattern::AttrDefSize = QStringLiteral("defSize");
218 const QString VAbstractPattern::AttrExtension = QStringLiteral("extension");
219 
220 const QString VAbstractPattern::IncrementName = QStringLiteral("name");
221 const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula");
222 const QString VAbstractPattern::IncrementDescription = QStringLiteral("description");
223 
224 const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
225 const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
226 const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint");
227 const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
228 const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
229 
233 
234 namespace
235 {
236 void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
237 {
238  VFormulaField formula;
239  try
240  {
241  formula.expression = VDomDocument::GetParametrString(element, attribute);
242  }
243  catch (VExceptionEmptyParameter &e)
244  {
245  Q_UNUSED(e)
246  return;
247  }
248 
249  formula.element = element;
250  formula.attribute = attribute;
251 
252  expressions.append(formula);
253 }
254 }
255 
256 //---------------------------------------------------------------------------------------------------------------------
258  : QObject(parent)
259  , VDomDocument()
260  , activeDraftBlock(QString())
261  , m_DefaultLineColor(qApp->Settings()->getDefaultLineColor())
262  , m_DefaultLineWeight(qApp->Settings()->getDefaultLineWeight())
263  , m_DefaultLineType(qApp->Settings()->getDefaultLineType())
264  , lastSavedExportFormat(QString())
265  , cursor(0)
266  , toolsOnRemove(QVector<VDataTool*>())
267  , history(QVector<VToolRecord>())
268  , patternPieces(QStringList())
269  , modified(false)
270 {}
271 
272 //---------------------------------------------------------------------------------------------------------------------
274 {
275  QSet<QString> measurements;
276  QSet<QString> others;
277 
278  const QStringList increments = ListIncrements();
279  for (int i=0; i < increments.size(); ++i)
280  {
281  others.insert(increments.at(i));
282  }
283 
284  const QVector<VFormulaField> expressions = ListExpressions();
285  for (int i=0; i < expressions.size(); ++i)
286  {
287  // Eval formula
288  QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, false));
289  const QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
290  delete cal.take();
291 
292  const QList<QString> tValues = tokens.values();
293  for (int j = 0; j < tValues.size(); ++j)
294  {
295  if (tValues.at(j) == QChar('-'))
296  {
297  continue;
298  }
299 
300  if (measurements.contains(tValues.at(j)))
301  {
302  continue;
303  }
304 
305  if (others.contains(tValues.at(j)))
306  {
307  continue;
308  }
309 
310  if (IsVariable(tValues.at(j)) || IsPostfixOperator(tValues.at(j)) || IsFunction(tValues.at(j)))
311  {
312  others.insert(tValues.at(j));
313  }
314  else
315  {
316  measurements.insert(tValues.at(j));
317  }
318  }
319  }
320 
321  return QStringList(measurements.values());
322 }
323 
324 //---------------------------------------------------------------------------------------------------------------------
325 /**
326  * @brief changeActiveDraftBlock set new active draft block name.
327  * @param name new name.
328  * @param parse parser file mode.
329  */
330 void VAbstractPattern::changeActiveDraftBlock(const QString &name, const Document &parse)
331 {
332  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name draft block is empty");
333  if (draftBlockNameExists(name))
334  {
335  this->activeDraftBlock = name;
336  if (parse == Document::FullParse)
337  {
338  emit activeDraftBlockChanged(name);
339  }
340  }
341 }
342 
343 //---------------------------------------------------------------------------------------------------------------------
344 /**
345  * @brief getActiveDraftBlockName return current draft block name.
346  * @return draft block name.
347  */
349 {
350  return activeDraftBlock;
351 }
352 
353 //---------------------------------------------------------------------------------------------------------------------
354 /**
355  * @brief getActiveDraftElement return draftBlock element for current draft block.
356  * @param element draftBlock element.
357  * @return true if found.
358  */
359 bool VAbstractPattern::getActiveDraftElement(QDomElement &element) const
360 {
361  if (activeDraftBlock.isEmpty() == false)
362  {
363  const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraftBlock);
364  if (elements.size() == 0)
365  {
366  return false;
367  }
368  for ( qint32 i = 0; i < elements.count(); i++ )
369  {
370  element = elements.at( i ).toElement();
371  if (element.isNull() == false)
372  {
373  const QString fieldName = element.attribute( AttrName );
374  if ( fieldName == activeDraftBlock )
375  {
376  return true;
377  }
378  }
379  }
380  element = QDomElement();
381  }
382  return false;
383 }
384 
385 //---------------------------------------------------------------------------------------------------------------------
386 /**
387  * @brief draftBlockNameExists check if draft block with this name exists.
388  * @param name draft block name.
389  * @return true if exist.
390  */
391 bool VAbstractPattern::draftBlockNameExists(const QString &name) const
392 {
393  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "draft block name is empty");
394  const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraftBlock);
395  if (elements.size() == 0)
396  {
397  return false;
398  }
399  for ( qint32 i = 0; i < elements.count(); i++ )
400  {
401  const QDomElement elem = elements.at( i ).toElement();
402  if (elem.isNull() == false)
403  {
404  if ( GetParametrString(elem, AttrName) == name )
405  {
406  return true;
407  }
408  }
409  }
410  return false;
411 }
412 
413 //---------------------------------------------------------------------------------------------------------------------
414 /**
415  * @brief getActiveNodeElement find element in current draft block by name.
416  * @param name name tag.
417  * @param element element.
418  * @return true if found.
419  */
420 bool VAbstractPattern::getActiveNodeElement(const QString &name, QDomElement &element) const
421 {
422  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "draft block name is empty");
423  QDomElement draftBlockElement;
424  if (getActiveDraftElement(draftBlockElement))
425  {
426  const QDomNodeList listElement = draftBlockElement.elementsByTagName(name);
427  if (listElement.size() != 1)
428  {
429  return false;
430  }
431  element = listElement.at( 0 ).toElement();
432  if (element.isNull() == false)
433  {
434  return true;
435  }
436  else
437  {
438  return false;
439  }
440  }
441  return false;
442 }
443 
444 //---------------------------------------------------------------------------------------------------------------------
445 void VAbstractPattern::parseGroups(const QDomElement &domElement)
446 {
447  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
448 
449  QMap<quint32, quint32> itemTool;
450  QMap<quint32, bool> itemVisibility;
451 
452  QDomNode domNode = domElement.firstChild();
453  while (domNode.isNull() == false)
454  {
455  if (domNode.isElement())
456  {
457  const QDomElement domElement = domNode.toElement();
458  if (domElement.isNull() == false)
459  {
460  if (domElement.tagName() == TagGroup)
461  {
463 
464  const QPair<bool, QMap<quint32, quint32> > groupData = parseItemElement(domElement);
465  const QMap<quint32, quint32> group = groupData.second;
466  auto i = group.constBegin();
467  while (i != group.constEnd())
468  {
469  if (not itemTool.contains(i.key()))
470  {
471  itemTool.insert(i.key(), i.value());
472  }
473 
474  const bool previous = itemVisibility.value(i.key(), false);
475  itemVisibility.insert(i.key(), previous || groupData.first);
476  ++i;
477  }
478  }
479  }
480  }
481  domNode = domNode.nextSibling();
482  }
483 
484  auto i = itemTool.constBegin();
485  while (i != itemTool.constEnd())
486  {
487  if (tools.contains(i.value()))
488  {
489  VDataTool* tool = tools.value(i.value());
490  tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true));
491  }
492  ++i;
493  }
494 }
495 
496 //---------------------------------------------------------------------------------------------------------------------
498 {
499  const QDomElement rootElement = this->documentElement();
500  if (rootElement.isNull())
501  {
502  return 0;
503  }
504 
505  return rootElement.elementsByTagName(TagDraftBlock).count();
506 }
507 
508 //---------------------------------------------------------------------------------------------------------------------
509 QDomElement VAbstractPattern::getDraftBlockElement(const QString &name)
510 {
511  if (name.isEmpty() == false)
512  {
513  const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraftBlock);
514  if (elements.size() == 0)
515  {
516  return QDomElement();
517  }
518  for ( qint32 i = 0; i < elements.count(); i++ )
519  {
520  QDomElement element = elements.at( i ).toElement();
521  if (element.isNull() == false)
522  {
523  if ( element.attribute( AttrName ) == name )
524  {
525  return element;
526  }
527  }
528  }
529  }
530  return QDomElement();
531 }
532 
533 //---------------------------------------------------------------------------------------------------------------------
534 /**
535  * @brief renameDraftBlock change draft block name.
536  * @param oldName old draft block name.
537  * @param newName new draft block name.
538  * @return true if success.
539  */
540 bool VAbstractPattern::renameDraftBlock(const QString &oldName, const QString &newName)
541 {
542  Q_ASSERT_X(not newName.isEmpty(), Q_FUNC_INFO, "new name draft block is empty");
543  Q_ASSERT_X(not oldName.isEmpty(), Q_FUNC_INFO, "old name draft block is empty");
544 
545  if (draftBlockNameExists(oldName) == false)
546  {
547  qDebug()<<"Do not exist draft block with name"<<oldName;
548  return false;
549  }
550 
551  if (draftBlockNameExists(newName))
552  {
553  qDebug()<<"Already exist draft block with name"<<newName;
554  return false;
555  }
556 
557  QDomElement ppElement = getDraftBlockElement(oldName);
558  if (ppElement.isElement())
559  {
560  if (activeDraftBlock == oldName)
561  {
562  activeDraftBlock = newName;
563  }
564  ppElement.setAttribute(AttrName, newName);
565  emit patternChanged(false);//For situation when we change name directly, without undocommands.
566  emit draftBlockNameChanged(oldName, newName);
567  return true;
568  }
569  else
570  {
571  qDebug()<<"Can't find draft block node with name"<<oldName<<Q_FUNC_INFO;
572  return false;
573  }
574 }
575 
576 //---------------------------------------------------------------------------------------------------------------------
577 /**
578  * @brief appendDraftBlock add new draft block.
579  *
580  * Method check if not exist draft block with the same name and change name active draft block name, send signal
581  * about change draft block. Doen't add draft block to file structure. This task make SPoint tool.
582  * @param name draft block name.
583  * @return true if success.
584  */
585 bool VAbstractPattern::appendDraftBlock(const QString &name)
586 {
587  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name draft block is empty");
588  if (name.isEmpty())
589  {
590  return false;
591  }
592  if (draftBlockNameExists(name) == false)
593  {
594  setActiveDraftBlock(name);
595  return true;
596  }
597  return false;
598 }
599 
600 //---------------------------------------------------------------------------------------------------------------------
602 {
603  return cursor;
604 }
605 
606 //---------------------------------------------------------------------------------------------------------------------
607 void VAbstractPattern::setCursor(const quint32 &value)
608 {
609  if (cursor != value)
610  {
611  cursor = value;
612  emit ChangedCursor(cursor);
613  }
614 }
615 
616 
617 //---------------------------------------------------------------------------------------------------------------------
619 {
623 }
624 
625 //---------------------------------------------------------------------------------------------------------------------
627 {
628  return m_DefaultLineColor;
629 }
630 
631 //---------------------------------------------------------------------------------------------------------------------
633 {
634  return m_DefaultLineWeight;
635 }
636 
637 //---------------------------------------------------------------------------------------------------------------------
639 {
640  return m_DefaultLineType;
641 }
642 
643 //---------------------------------------------------------------------------------------------------------------------
644 /**
645  * @brief getTool return tool from tool list.
646  * @param id tool id.
647  * @return tool.
648  */
650 {
651  ToolExists(id);
652  return tools.value(id);
653 }
654 
655 //---------------------------------------------------------------------------------------------------------------------
656 /**
657  * @brief AddTool add tool to list tools.
658  * @param id tool id.
659  * @param tool tool.
660  */
661 void VAbstractPattern::AddTool(quint32 id, VDataTool *tool)
662 {
663  Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
664  SCASSERT(tool != nullptr)
665  tools.insert(id, tool);
666 }
667 
668 //---------------------------------------------------------------------------------------------------------------------
670 {
671  tools.remove(id);
672 }
673 
674 //---------------------------------------------------------------------------------------------------------------------
675 VPiecePath VAbstractPattern::ParsePieceNodes(const QDomElement &domElement)
676 {
677  VPiecePath path;
678  const QDomNodeList nodeList = domElement.childNodes();
679  for (qint32 i = 0; i < nodeList.size(); ++i)
680  {
681  const QDomElement element = nodeList.at(i).toElement();
682  if (not element.isNull())
683  {
684  path.Append(ParseSANode(element));
685  }
686  }
687  return path;
688 }
689 
690 //---------------------------------------------------------------------------------------------------------------------
692 {
693  QVector<CustomSARecord> records;
694  const QDomNodeList nodeList = domElement.childNodes();
695  for (qint32 i = 0; i < nodeList.size(); ++i)
696  {
697  const QDomElement element = nodeList.at(i).toElement();
698  if (not element.isNull())
699  {
700  CustomSARecord record;
705  record.includeType = static_cast<PiecePathIncludeType>(GetParametrUInt(element,
707  "1"));
708  records.append(record);
709  }
710  }
711  return records;
712 }
713 
714 //---------------------------------------------------------------------------------------------------------------------
716 {
717  QVector<quint32> records;
718  const QDomNodeList nodeList = domElement.childNodes();
719  for (qint32 i = 0; i < nodeList.size(); ++i)
720  {
721  const QDomElement element = nodeList.at(i).toElement();
722  if (not element.isNull())
723  {
724  const quint32 path = GetParametrUInt(element, VAbstractPattern::AttrPath, NULL_ID_STR);
725  if (path > NULL_ID)
726  {
727  records.append(path);
728  }
729  }
730  }
731  return records;
732 }
733 
734 //---------------------------------------------------------------------------------------------------------------------
736 {
737  QVector<quint32> records;
738  const QDomNodeList nodeList = domElement.childNodes();
739  for (qint32 i = 0; i < nodeList.size(); ++i)
740  {
741  const QDomElement element = nodeList.at(i).toElement();
742  if (not element.isNull())
743  {
744  const quint32 path = element.text().toUInt();
745  if (path > NULL_ID)
746  {
747  records.append(path);
748  }
749  }
750  }
751  return records;
752 }
753 
754 //---------------------------------------------------------------------------------------------------------------------
755 VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
756 {
757  const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
758  const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0");
760  const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore,
762  const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter,
764  const PieceNodeAngle angle = static_cast<PieceNodeAngle>(VDomDocument::GetParametrUInt(domElement, AttrAngle, "0"));
765 
767  const NotchType notchType = stringToNotchType(VDomDocument::GetParametrString(domElement,
769  const NotchSubType notchSubType = stringToNotchSubType(VDomDocument::GetParametrString(domElement,
771 
772  const bool showNotch = VDomDocument::getParameterBool(domElement, VAbstractPattern::AttrNodeShowNotch,
773  trueStr);
775  trueStr);
776  const qreal notchLength = VDomDocument::GetParametrDouble(domElement, VAbstractPattern::AttrNodeNotchLength,
777  QString::number(qApp->Settings()->getDefaultNotchLength()));
778  const qreal notchWidth = VDomDocument::GetParametrDouble(domElement, VAbstractPattern::AttrNodeNotchWidth,
779  QString::number(qApp->Settings()->getDefaultNotchWidth()));
780  const qreal notchAngle = VDomDocument::GetParametrDouble(domElement, VAbstractPattern::AttrNodeNotchAngle, ".00");
781  const quint32 notchCount = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeNotchCount, "1");
782 
783 
785  Tool tool;
786 
787  const QStringList types = QStringList() << VAbstractPattern::NodePoint
792 
793  switch (types.indexOf(t))
794  {
795  case 0: // VAbstractPattern::NodePoint
796  tool = Tool::NodePoint;
797  break;
798  case 1: // VAbstractPattern::NodeArc
799  tool = Tool::NodeArc;
800  break;
801  case 2: // VAbstractPattern::NodeSpline
802  tool = Tool::NodeSpline;
803  break;
804  case 3: // VAbstractPattern::NodeSplinePath
805  tool = Tool::NodeSplinePath;
806  break;
807  case 4: // NodeElArc
808  tool = Tool::NodeElArc;
809  break;
810  default:
811  VException e(QObject::tr("Wrong tag name '%1'.").arg(t));
812  throw e;
813  }
814  VPieceNode node(id, tool, reverse);
815  node.setBeforeSAFormula(saBefore);
816  node.setAfterSAFormula(saAfter);
817  node.SetAngleType(angle);
818  node.SetExcluded(excluded);
819  node.setNotch(notch);
820  node.setNotchType(notchType);
821  node.setNotchSubType(notchSubType);
822  node.setShowNotch(showNotch);
823  node.setShowSeamlineNotch(showSecond);
824  node.setNotchLength(notchLength);
825  node.setNotchWidth(notchWidth);
826  node.setNotchAngle(notchAngle);
827  node.setNotchCount(notchCount);
828  return node;
829 }
830 
831 //---------------------------------------------------------------------------------------------------------------------
833 {
834  SCASSERT(tool != nullptr)
835  toolsOnRemove.append(tool);
836 }
837 
838 //---------------------------------------------------------------------------------------------------------------------
839 /**
840  * @brief getHistory return list with list of history records.
841  * @return list of history records.
842  */
844 {
845  return &history;
846 }
847 
848 //---------------------------------------------------------------------------------------------------------------------
850 {
851  QVector<VToolRecord> draftBlockHistory;
852  for (qint32 i = 0; i< history.size(); ++i)
853  {
854  const VToolRecord tool = history.at(i);
856  {
857  continue;
858  }
859  draftBlockHistory.append(tool);
860  }
861  return draftBlockHistory;
862 }
863 
864 //---------------------------------------------------------------------------------------------------------------------
866 {
867  QMap<quint32, Tool> draftBlockHistory;
868  for (qint32 i = 0; i< history.size(); ++i)
869  {
870  const VToolRecord tool = history.at(i);
872  {
873  continue;
874  }
875  draftBlockHistory.insert(tool.getId(), tool.getTypeTool());
876  }
877  return draftBlockHistory;
878 }
879 
880 //---------------------------------------------------------------------------------------------------------------------
881 QString VAbstractPattern::MPath() const
882 {
884 }
885 
886 //---------------------------------------------------------------------------------------------------------------------
887 void VAbstractPattern::SetMPath(const QString &path)
888 {
889  if (setTagText(TagMeasurements, path))
890  {
891  emit patternChanged(false);
892  patternLabelWasChanged = true;
893  }
894  else
895  {
896  qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO;
897  }
898 }
899 
900 //---------------------------------------------------------------------------------------------------------------------
901 quint32 VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const
902 {
903  quint32 siblingId = NULL_ID;
904 
906  for (qint32 i = 0; i < history.size(); ++i)
907  {
908  const VToolRecord tool = history.at(i);
909  if (nodeId == tool.getId())
910  {
911  if (i == 0)
912  {
913  siblingId = NULL_ID;
914  }
915  else
916  {
917  for (qint32 j = i; j > 0; --j)
918  {
919  const VToolRecord tool = history.at(j-1);
920  switch ( tool.getTypeTool() )
921  {
922  case Tool::Piece:
923  case Tool::Union:
924  case Tool::NodeArc:
925  case Tool::NodeElArc:
926  case Tool::NodePoint:
927  case Tool::NodeSpline:
929  continue;
930  default:
931  siblingId = tool.getId();
932  j = 0;// break loop
933  break;
934  }
935  }
936  }
937  }
938  }
939  return siblingId;
940 }
941 
942 //---------------------------------------------------------------------------------------------------------------------
944 {
945  return patternPieces;
946 }
947 
948 //---------------------------------------------------------------------------------------------------------------------
950 {
952 
953  map.insert(GHeights::ALL, true);
954  map.insert(GHeights::H50, true);
955  map.insert(GHeights::H56, true);
956  map.insert(GHeights::H62, true);
957  map.insert(GHeights::H68, true);
958  map.insert(GHeights::H74, true);
959  map.insert(GHeights::H80, true);
960  map.insert(GHeights::H86, true);
961  map.insert(GHeights::H92, true);
962  map.insert(GHeights::H98, true);
963  map.insert(GHeights::H104, true);
964  map.insert(GHeights::H110, true);
965  map.insert(GHeights::H116, true);
966  map.insert(GHeights::H122, true);
967  map.insert(GHeights::H128, true);
968  map.insert(GHeights::H134, true);
969  map.insert(GHeights::H140, true);
970  map.insert(GHeights::H146, true);
971  map.insert(GHeights::H152, true);
972  map.insert(GHeights::H158, true);
973  map.insert(GHeights::H164, true);
974  map.insert(GHeights::H170, true);
975  map.insert(GHeights::H176, true);
976  map.insert(GHeights::H182, true);
977  map.insert(GHeights::H188, true);
978  map.insert(GHeights::H194, true);
979  map.insert(GHeights::H200, true);
980 
981  QDomNodeList tags = elementsByTagName(TagGradation);
982  if (tags.size() == 0)
983  {
984  return map;
985  }
986 
987  QStringList gTags = QStringList() << TagHeights << TagSizes;
988  QDomNode domNode = tags.at(0).firstChild();
989  while (domNode.isNull() == false)
990  {
991  if (domNode.isElement())
992  {
993  const QDomElement domElement = domNode.toElement();
994  if (domElement.isNull() == false)
995  {
996  const QString defValue = trueStr;
997  switch (gTags.indexOf(domElement.tagName()))
998  {
999  case 0: // TagHeights
1000  if (getParameterBool(domElement, AttrAll, defValue))
1001  {
1002  return map;
1003  }
1004  else
1005  {
1006  map.insert(GHeights::ALL, false);
1007  }
1008 
1009  map.insert(GHeights::H50, getParameterBool(domElement, AttrH50, defValue));
1010  map.insert(GHeights::H56, getParameterBool(domElement, AttrH56, defValue));
1011  map.insert(GHeights::H62, getParameterBool(domElement, AttrH62, defValue));
1012  map.insert(GHeights::H68, getParameterBool(domElement, AttrH68, defValue));
1013  map.insert(GHeights::H74, getParameterBool(domElement, AttrH74, defValue));
1014  map.insert(GHeights::H80, getParameterBool(domElement, AttrH80, defValue));
1015  map.insert(GHeights::H86, getParameterBool(domElement, AttrH86, defValue));
1016  map.insert(GHeights::H92, getParameterBool(domElement, AttrH92, defValue));
1017  map.insert(GHeights::H98, getParameterBool(domElement, AttrH98, defValue));
1018  map.insert(GHeights::H104, getParameterBool(domElement, AttrH104, defValue));
1019  map.insert(GHeights::H110, getParameterBool(domElement, AttrH110, defValue));
1020  map.insert(GHeights::H116, getParameterBool(domElement, AttrH116, defValue));
1021  map.insert(GHeights::H122, getParameterBool(domElement, AttrH122, defValue));
1022  map.insert(GHeights::H128, getParameterBool(domElement, AttrH128, defValue));
1023  map.insert(GHeights::H134, getParameterBool(domElement, AttrH134, defValue));
1024  map.insert(GHeights::H140, getParameterBool(domElement, AttrH140, defValue));
1025  map.insert(GHeights::H146, getParameterBool(domElement, AttrH146, defValue));
1026  map.insert(GHeights::H152, getParameterBool(domElement, AttrH152, defValue));
1027  map.insert(GHeights::H158, getParameterBool(domElement, AttrH158, defValue));
1028  map.insert(GHeights::H164, getParameterBool(domElement, AttrH164, defValue));
1029  map.insert(GHeights::H170, getParameterBool(domElement, AttrH170, defValue));
1030  map.insert(GHeights::H176, getParameterBool(domElement, AttrH176, defValue));
1031  map.insert(GHeights::H182, getParameterBool(domElement, AttrH182, defValue));
1032  map.insert(GHeights::H188, getParameterBool(domElement, AttrH188, defValue));
1033  map.insert(GHeights::H194, getParameterBool(domElement, AttrH194, defValue));
1034  map.insert(GHeights::H200, getParameterBool(domElement, AttrH200, defValue));
1035  return map;
1036  case 1: // TagSizes
1037  default:
1038  break;
1039  }
1040  }
1041  }
1042  domNode = domNode.nextSibling();
1043  }
1044  return map;
1045 }
1046 
1047 //---------------------------------------------------------------------------------------------------------------------
1049 {
1051  QDomNodeList tags = elementsByTagName(TagGradation);
1052  if (tags.isEmpty())
1053  {
1054  qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
1055  return;
1056  }
1057 
1058  QStringList gTags = QStringList() << TagHeights << TagSizes;
1059  QDomNode domNode = tags.at(0).firstChild();
1060  while (domNode.isNull() == false)
1061  {
1062  if (domNode.isElement())
1063  {
1064  QDomElement domElement = domNode.toElement();
1065  if (domElement.isNull() == false)
1066  {
1067  switch (gTags.indexOf(domElement.tagName()))
1068  {
1069  case 0: // TagHeights
1070  SetAttribute(domElement, AttrAll, options.value(GHeights::ALL));
1071  if (options.value(GHeights::ALL))
1072  {
1073  domElement.removeAttribute(AttrH50);
1074  domElement.removeAttribute(AttrH56);
1075  domElement.removeAttribute(AttrH62);
1076  domElement.removeAttribute(AttrH68);
1077  domElement.removeAttribute(AttrH74);
1078  domElement.removeAttribute(AttrH80);
1079  domElement.removeAttribute(AttrH86);
1080  domElement.removeAttribute(AttrH92);
1081  domElement.removeAttribute(AttrH98);
1082  domElement.removeAttribute(AttrH104);
1083  domElement.removeAttribute(AttrH110);
1084  domElement.removeAttribute(AttrH116);
1085  domElement.removeAttribute(AttrH122);
1086  domElement.removeAttribute(AttrH128);
1087  domElement.removeAttribute(AttrH134);
1088  domElement.removeAttribute(AttrH140);
1089  domElement.removeAttribute(AttrH146);
1090  domElement.removeAttribute(AttrH152);
1091  domElement.removeAttribute(AttrH158);
1092  domElement.removeAttribute(AttrH164);
1093  domElement.removeAttribute(AttrH170);
1094  domElement.removeAttribute(AttrH176);
1095  domElement.removeAttribute(AttrH182);
1096  domElement.removeAttribute(AttrH188);
1097  domElement.removeAttribute(AttrH194);
1098  domElement.removeAttribute(AttrH200);
1099  }
1100  else
1101  {
1102  SetAttribute(domElement, AttrH50, options.value(GHeights::H50));
1103  SetAttribute(domElement, AttrH56, options.value(GHeights::H56));
1104  SetAttribute(domElement, AttrH62, options.value(GHeights::H62));
1105  SetAttribute(domElement, AttrH68, options.value(GHeights::H68));
1106  SetAttribute(domElement, AttrH74, options.value(GHeights::H74));
1107  SetAttribute(domElement, AttrH80, options.value(GHeights::H80));
1108  SetAttribute(domElement, AttrH86, options.value(GHeights::H86));
1109  SetAttribute(domElement, AttrH92, options.value(GHeights::H92));
1110  SetAttribute(domElement, AttrH98, options.value(GHeights::H98));
1111  SetAttribute(domElement, AttrH104, options.value(GHeights::H104));
1112  SetAttribute(domElement, AttrH110, options.value(GHeights::H110));
1113  SetAttribute(domElement, AttrH116, options.value(GHeights::H116));
1114  SetAttribute(domElement, AttrH122, options.value(GHeights::H122));
1115  SetAttribute(domElement, AttrH128, options.value(GHeights::H128));
1116  SetAttribute(domElement, AttrH134, options.value(GHeights::H134));
1117  SetAttribute(domElement, AttrH140, options.value(GHeights::H140));
1118  SetAttribute(domElement, AttrH146, options.value(GHeights::H146));
1119  SetAttribute(domElement, AttrH152, options.value(GHeights::H152));
1120  SetAttribute(domElement, AttrH158, options.value(GHeights::H158));
1121  SetAttribute(domElement, AttrH164, options.value(GHeights::H164));
1122  SetAttribute(domElement, AttrH170, options.value(GHeights::H170));
1123  SetAttribute(domElement, AttrH176, options.value(GHeights::H176));
1124  SetAttribute(domElement, AttrH182, options.value(GHeights::H182));
1125  SetAttribute(domElement, AttrH188, options.value(GHeights::H188));
1126  SetAttribute(domElement, AttrH194, options.value(GHeights::H194));
1127  SetAttribute(domElement, AttrH200, options.value(GHeights::H200));
1128  }
1129 
1130  modified = true;
1131  emit patternChanged(false);
1132  return;
1133  case 1: // TagSizes
1134  default:
1135  break;
1136  }
1137  }
1138  }
1139  domNode = domNode.nextSibling();
1140  }
1141 }
1142 
1143 //---------------------------------------------------------------------------------------------------------------------
1145 {
1147  map.insert(GSizes::ALL, true);
1148  map.insert(GSizes::S22, true);
1149  map.insert(GSizes::S24, true);
1150  map.insert(GSizes::S26, true);
1151  map.insert(GSizes::S28, true);
1152  map.insert(GSizes::S30, true);
1153  map.insert(GSizes::S32, true);
1154  map.insert(GSizes::S34, true);
1155  map.insert(GSizes::S36, true);
1156  map.insert(GSizes::S38, true);
1157  map.insert(GSizes::S40, true);
1158  map.insert(GSizes::S42, true);
1159  map.insert(GSizes::S44, true);
1160  map.insert(GSizes::S46, true);
1161  map.insert(GSizes::S48, true);
1162  map.insert(GSizes::S50, true);
1163  map.insert(GSizes::S52, true);
1164  map.insert(GSizes::S54, true);
1165  map.insert(GSizes::S56, true);
1166  map.insert(GSizes::S58, true);
1167  map.insert(GSizes::S60, true);
1168  map.insert(GSizes::S62, true);
1169  map.insert(GSizes::S64, true);
1170  map.insert(GSizes::S66, true);
1171  map.insert(GSizes::S68, true);
1172  map.insert(GSizes::S70, true);
1173  map.insert(GSizes::S72, true);
1174 
1175  QDomNodeList tags = elementsByTagName(TagGradation);
1176  if (tags.size() == 0)
1177  {
1178  return map;
1179  }
1180 
1181  QStringList gTags = QStringList() << TagHeights << TagSizes;
1182  QDomNode domNode = tags.at(0).firstChild();
1183  while (domNode.isNull() == false)
1184  {
1185  if (domNode.isElement())
1186  {
1187  const QDomElement domElement = domNode.toElement();
1188  if (domElement.isNull() == false)
1189  {
1190  const QString defValue = trueStr;
1191  switch (gTags.indexOf(domElement.tagName()))
1192  {
1193  case 1: // TagSizes
1194  if (getParameterBool(domElement, AttrAll, defValue))
1195  {
1196  return map;
1197  }
1198  else
1199  {
1200  map.insert(GSizes::ALL, false);
1201  }
1202 
1203  map.insert(GSizes::S22, getParameterBool(domElement, AttrS22, defValue));
1204  map.insert(GSizes::S24, getParameterBool(domElement, AttrS24, defValue));
1205  map.insert(GSizes::S26, getParameterBool(domElement, AttrS26, defValue));
1206  map.insert(GSizes::S28, getParameterBool(domElement, AttrS28, defValue));
1207  map.insert(GSizes::S30, getParameterBool(domElement, AttrS30, defValue));
1208  map.insert(GSizes::S32, getParameterBool(domElement, AttrS32, defValue));
1209  map.insert(GSizes::S34, getParameterBool(domElement, AttrS34, defValue));
1210  map.insert(GSizes::S36, getParameterBool(domElement, AttrS36, defValue));
1211  map.insert(GSizes::S38, getParameterBool(domElement, AttrS38, defValue));
1212  map.insert(GSizes::S40, getParameterBool(domElement, AttrS40, defValue));
1213  map.insert(GSizes::S42, getParameterBool(domElement, AttrS42, defValue));
1214  map.insert(GSizes::S44, getParameterBool(domElement, AttrS44, defValue));
1215  map.insert(GSizes::S46, getParameterBool(domElement, AttrS46, defValue));
1216  map.insert(GSizes::S48, getParameterBool(domElement, AttrS48, defValue));
1217  map.insert(GSizes::S50, getParameterBool(domElement, AttrS50, defValue));
1218  map.insert(GSizes::S52, getParameterBool(domElement, AttrS52, defValue));
1219  map.insert(GSizes::S54, getParameterBool(domElement, AttrS54, defValue));
1220  map.insert(GSizes::S56, getParameterBool(domElement, AttrS56, defValue));
1221  map.insert(GSizes::S58, getParameterBool(domElement, AttrS58, defValue));
1222  map.insert(GSizes::S60, getParameterBool(domElement, AttrS60, defValue));
1223  map.insert(GSizes::S62, getParameterBool(domElement, AttrS62, defValue));
1224  map.insert(GSizes::S64, getParameterBool(domElement, AttrS64, defValue));
1225  map.insert(GSizes::S66, getParameterBool(domElement, AttrS66, defValue));
1226  map.insert(GSizes::S68, getParameterBool(domElement, AttrS68, defValue));
1227  map.insert(GSizes::S70, getParameterBool(domElement, AttrS70, defValue));
1228  map.insert(GSizes::S72, getParameterBool(domElement, AttrS72, defValue));
1229  return map;
1230  case 0: // TagHeights
1231  default:
1232  break;
1233  }
1234  }
1235  }
1236  domNode = domNode.nextSibling();
1237  }
1238  return map;
1239 }
1240 
1241 //---------------------------------------------------------------------------------------------------------------------
1243 {
1245  QDomNodeList tags = elementsByTagName(TagGradation);
1246  if (tags.isEmpty())
1247  {
1248  qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
1249  return;
1250  }
1251 
1252  QStringList gTags = QStringList() << TagHeights << TagSizes;
1253  QDomNode domNode = tags.at(0).firstChild();
1254  while (domNode.isNull() == false)
1255  {
1256  if (domNode.isElement())
1257  {
1258  QDomElement domElement = domNode.toElement();
1259  if (domElement.isNull() == false)
1260  {
1261  switch (gTags.indexOf(domElement.tagName()))
1262  {
1263  case 1: // TagSizes
1264  SetAttribute(domElement, AttrAll, options.value(GSizes::ALL));
1265  if (options.value(GSizes::ALL))
1266  {
1267  domElement.removeAttribute(AttrS22);
1268  domElement.removeAttribute(AttrS24);
1269  domElement.removeAttribute(AttrS26);
1270  domElement.removeAttribute(AttrS28);
1271  domElement.removeAttribute(AttrS30);
1272  domElement.removeAttribute(AttrS32);
1273  domElement.removeAttribute(AttrS34);
1274  domElement.removeAttribute(AttrS36);
1275  domElement.removeAttribute(AttrS38);
1276  domElement.removeAttribute(AttrS40);
1277  domElement.removeAttribute(AttrS42);
1278  domElement.removeAttribute(AttrS44);
1279  domElement.removeAttribute(AttrS46);
1280  domElement.removeAttribute(AttrS48);
1281  domElement.removeAttribute(AttrS50);
1282  domElement.removeAttribute(AttrS52);
1283  domElement.removeAttribute(AttrS54);
1284  domElement.removeAttribute(AttrS56);
1285  domElement.removeAttribute(AttrS58);
1286  domElement.removeAttribute(AttrS60);
1287  domElement.removeAttribute(AttrS62);
1288  domElement.removeAttribute(AttrS64);
1289  domElement.removeAttribute(AttrS66);
1290  domElement.removeAttribute(AttrS68);
1291  domElement.removeAttribute(AttrS70);
1292  domElement.removeAttribute(AttrS72);
1293  }
1294  else
1295  {
1296  SetAttribute(domElement, AttrS22, options.value(GSizes::S22));
1297  SetAttribute(domElement, AttrS24, options.value(GSizes::S24));
1298  SetAttribute(domElement, AttrS26, options.value(GSizes::S26));
1299  SetAttribute(domElement, AttrS28, options.value(GSizes::S28));
1300  SetAttribute(domElement, AttrS30, options.value(GSizes::S30));
1301  SetAttribute(domElement, AttrS32, options.value(GSizes::S32));
1302  SetAttribute(domElement, AttrS34, options.value(GSizes::S34));
1303  SetAttribute(domElement, AttrS36, options.value(GSizes::S36));
1304  SetAttribute(domElement, AttrS38, options.value(GSizes::S38));
1305  SetAttribute(domElement, AttrS40, options.value(GSizes::S40));
1306  SetAttribute(domElement, AttrS42, options.value(GSizes::S42));
1307  SetAttribute(domElement, AttrS44, options.value(GSizes::S44));
1308  SetAttribute(domElement, AttrS46, options.value(GSizes::S46));
1309  SetAttribute(domElement, AttrS48, options.value(GSizes::S48));
1310  SetAttribute(domElement, AttrS50, options.value(GSizes::S50));
1311  SetAttribute(domElement, AttrS52, options.value(GSizes::S52));
1312  SetAttribute(domElement, AttrS54, options.value(GSizes::S54));
1313  SetAttribute(domElement, AttrS56, options.value(GSizes::S56));
1314  SetAttribute(domElement, AttrS58, options.value(GSizes::S58));
1315  SetAttribute(domElement, AttrS60, options.value(GSizes::S60));
1316  SetAttribute(domElement, AttrS62, options.value(GSizes::S62));
1317  SetAttribute(domElement, AttrS64, options.value(GSizes::S64));
1318  SetAttribute(domElement, AttrS66, options.value(GSizes::S66));
1319  SetAttribute(domElement, AttrS68, options.value(GSizes::S68));
1320  SetAttribute(domElement, AttrS70, options.value(GSizes::S70));
1321  SetAttribute(domElement, AttrS72, options.value(GSizes::S72));
1322  }
1323 
1324  modified = true;
1325  emit patternChanged(false);
1326  return;
1327  case 0: // TagHeights
1328  default:
1329  break;
1330  }
1331  }
1332  }
1333  domNode = domNode.nextSibling();
1334  }
1335 }
1336 
1337 //---------------------------------------------------------------------------------------------------------------------
1339 {
1340  return UniqueTagText(TagDescription);
1341 }
1342 
1343 //---------------------------------------------------------------------------------------------------------------------
1344 void VAbstractPattern::SetDescription(const QString &text)
1345 {
1347  setTagText(TagDescription, text);
1348  modified = true;
1349  emit patternChanged(false);
1350 }
1351 
1352 //---------------------------------------------------------------------------------------------------------------------
1354 {
1355  return UniqueTagText(TagNotes);
1356 }
1357 
1358 //---------------------------------------------------------------------------------------------------------------------
1359 void VAbstractPattern::SetNotes(const QString &text)
1360 {
1362  setTagText(TagNotes, text);
1363  modified = true;
1364  emit patternChanged(false);
1365 }
1366 
1367 //---------------------------------------------------------------------------------------------------------------------
1369 {
1370  return UniqueTagText(TagPatternName);
1371 }
1372 
1373 //---------------------------------------------------------------------------------------------------------------------
1374 void VAbstractPattern::SetPatternName(const QString &qsName)
1375 {
1377  setTagText(TagPatternName, qsName);
1378  patternLabelWasChanged = true;
1379  modified = true;
1380  emit patternChanged(false);
1381 }
1382 
1383 //---------------------------------------------------------------------------------------------------------------------
1385 {
1386  return UniqueTagText(TagCompanyName);
1387 }
1388 
1389 //---------------------------------------------------------------------------------------------------------------------
1390 void VAbstractPattern::SetCompanyName(const QString &qsName)
1391 {
1393  setTagText(TagCompanyName, qsName);
1394  patternLabelWasChanged = true;
1395  modified = true;
1396  emit patternChanged(false);
1397 }
1398 
1399 //---------------------------------------------------------------------------------------------------------------------
1401 {
1402  return UniqueTagText(TagPatternNum);
1403 }
1404 
1405 //---------------------------------------------------------------------------------------------------------------------
1406 void VAbstractPattern::SetPatternNumber(const QString &qsNum)
1407 {
1409  setTagText(TagPatternNum, qsNum);
1410  patternLabelWasChanged = true;
1411  modified = true;
1412  emit patternChanged(false);
1413 }
1414 
1415 //---------------------------------------------------------------------------------------------------------------------
1417 {
1419 }
1420 
1421 //---------------------------------------------------------------------------------------------------------------------
1422 void VAbstractPattern::SetCustomerName(const QString &qsName)
1423 {
1425  setTagText(TagCustomerName, qsName);
1426  patternLabelWasChanged = true;
1427  modified = true;
1428  emit patternChanged(false);
1429 }
1430 
1431 //---------------------------------------------------------------------------------------------------------------------
1433 {
1434  QString globalLabelDateFormat = qApp->Settings()->GetLabelDateFormat();
1435 
1436  const QDomNodeList list = elementsByTagName(TagPatternLabel);
1437  if (list.isEmpty())
1438  {
1439  return globalLabelDateFormat;
1440  }
1441 
1442  QDomElement tag = list.at(0).toElement();
1443  return GetParametrString(tag, AttrDateFormat, globalLabelDateFormat);
1444 }
1445 
1446 //---------------------------------------------------------------------------------------------------------------------
1447 void VAbstractPattern::SetLabelDateFormat(const QString &format)
1448 {
1449  QDomElement tag = CheckTagExists(TagPatternLabel);
1450  SetAttribute(tag, AttrDateFormat, format);
1451  patternLabelWasChanged = true;
1452  modified = true;
1453  emit patternChanged(false);
1454 }
1455 
1456 //---------------------------------------------------------------------------------------------------------------------
1458 {
1459  QString globalLabelTimeFormat = qApp->Settings()->GetLabelTimeFormat();
1460 
1461  const QDomNodeList list = elementsByTagName(TagPatternLabel);
1462  if (list.isEmpty())
1463  {
1464  return globalLabelTimeFormat;
1465  }
1466 
1467  QDomElement tag = list.at(0).toElement();
1468  return GetParametrString(tag, AttrTimeFormat, globalLabelTimeFormat);
1469 }
1470 
1471 //---------------------------------------------------------------------------------------------------------------------
1472 void VAbstractPattern::SetLabelTimeFormat(const QString &format)
1473 {
1474  QDomElement tag = CheckTagExists(TagPatternLabel);
1475  SetAttribute(tag, AttrTimeFormat, format);
1476  patternLabelWasChanged = true;
1477  modified = true;
1478  emit patternChanged(false);
1479 }
1480 
1481 //---------------------------------------------------------------------------------------------------------------------
1483 {
1484  QDomElement tag = CheckTagExists(TagPatternLabel);
1485  RemoveAllChildren(tag);
1486  SetLabelTemplate(tag, lines);
1487  patternLabelLines = lines;
1488  patternLabelWasChanged = true;
1489  modified = true;
1490  emit patternChanged(false);
1491 }
1492 
1493 //---------------------------------------------------------------------------------------------------------------------
1495 {
1496  if (patternLabelLines.isEmpty())
1497  {
1498  const QDomNodeList list = elementsByTagName(TagPatternLabel);
1499  if (list.isEmpty())
1500  {
1501  return QVector<VLabelTemplateLine>();
1502  }
1503 
1504  patternLabelLines = GetLabelTemplate(list.at(0).toElement());
1505  }
1506 
1507  return patternLabelLines;
1508 }
1509 
1510 //---------------------------------------------------------------------------------------------------------------------
1512 {
1513  patternLabelWasChanged = changed;
1514 }
1515 
1516 //---------------------------------------------------------------------------------------------------------------------
1518 {
1519  return patternLabelWasChanged;
1520 }
1521 
1522 //---------------------------------------------------------------------------------------------------------------------
1524 {
1525  return UniqueTagText(TagImage);
1526 }
1527 
1528 //---------------------------------------------------------------------------------------------------------------------
1530 {
1531  const QString defExt = QStringLiteral("PNG");
1532  const QDomNodeList nodeList = this->elementsByTagName(TagImage);
1533  if (nodeList.isEmpty())
1534  {
1535  return defExt;
1536  }
1537  else
1538  {
1539  const QDomNode domNode = nodeList.at(0);
1540  if (domNode.isNull() == false && domNode.isElement())
1541  {
1542  const QDomElement domElement = domNode.toElement();
1543  if (domElement.isNull() == false)
1544  {
1545  const QString ext = domElement.attribute(AttrExtension, defExt);
1546  return ext;
1547  }
1548  }
1549  }
1550  return defExt;
1551 }
1552 
1553 //---------------------------------------------------------------------------------------------------------------------
1554 void VAbstractPattern::SetImage(const QString &text, const QString &extension)
1555 {
1556  QDomElement imageElement = CheckTagExists(TagImage);
1557  setTagText(imageElement, text);
1558  CheckTagExists(TagImage).setAttribute(AttrExtension, extension);
1559  modified = true;
1560  emit patternChanged(false);
1561 }
1562 
1563 //---------------------------------------------------------------------------------------------------------------------
1565 {
1566  QDomElement pattern = documentElement();
1567  pattern.removeChild(CheckTagExists(TagImage));
1568  modified = true;
1569  emit patternChanged(false);
1570 }
1571 
1572 //---------------------------------------------------------------------------------------------------------------------
1574 {
1576 }
1577 
1578 //---------------------------------------------------------------------------------------------------------------------
1580 {
1582  emit patternChanged(false);
1583 }
1584 
1585 //---------------------------------------------------------------------------------------------------------------------
1586 /**
1587  * @brief getOpItems get vector of operation tool obects.
1588  * @param toolId operation tool id.
1589  * @param itemType type of item - either source or destination.
1590  * @return vector of item element object ids.
1591  */
1592 QVector<quint32> VAbstractPattern::getOpItems(const quint32 &toolId, const QString &itemType)
1593 {
1594  QVector<quint32> items;
1595  quint32 objId;
1596  const QDomElement domElement = elementById(toolId);
1597  const QDomNodeList nodeList = domElement.childNodes();
1598  for (qint32 i = 0; i < nodeList.size(); ++i)
1599  {
1600  const QDomElement dataElement = nodeList.at(i).toElement();
1601  if (!dataElement.isNull() && dataElement.tagName() == itemType)
1602  {
1603  const QDomNodeList srcList = dataElement.childNodes();
1604  for (qint32 j = 0; j < srcList.size(); ++j)
1605  {
1606  const QDomElement element = srcList.at(j).toElement();
1607  if (!element.isNull())
1608  {
1610  items.append(objId);
1611  }
1612  }
1613  }
1614  }
1615 
1616  return items;
1617 }
1618 
1619 //---------------------------------------------------------------------------------------------------------------------
1621 {
1622  QVector<quint32> items;
1623  quint32 objId;
1624  const QDomElement domElement = elementById(toolId);
1625 
1627  items.append(objId);
1628 
1630  items.append(objId);
1631 
1632  return items;
1633 }
1634 
1635 //---------------------------------------------------------------------------------------------------------------------
1636 /**
1637  * @brief haveLiteChange we have unsaved change.
1638  */
1640 {
1641  emit patternChanged(false);
1642 }
1643 
1644 //---------------------------------------------------------------------------------------------------------------------
1646 {
1647  emit UndoCommand();
1648 }
1649 
1650 //---------------------------------------------------------------------------------------------------------------------
1652 {
1653  emit ClearMainWindow();
1654 }
1655 
1656 //---------------------------------------------------------------------------------------------------------------------
1658 {
1659  emit UpdateInLayoutList(id);
1660 }
1661 
1662 //---------------------------------------------------------------------------------------------------------------------
1664 {
1665  emit showPiece(id);
1666 }
1667 
1668 //---------------------------------------------------------------------------------------------------------------------
1669 void VAbstractPattern::ToolExists(const quint32 &id)
1670 {
1671  if (tools.contains(id) == false)
1672  {
1673  throw VExceptionBadId(tr("Can't find tool in table."), id);
1674  }
1675 }
1676 
1677 //---------------------------------------------------------------------------------------------------------------------
1678 VPiecePath VAbstractPattern::ParsePathNodes(const QDomElement &domElement)
1679 {
1680  VPiecePath path;
1681  const QDomNodeList nodeList = domElement.childNodes();
1682  for (qint32 i = 0; i < nodeList.size(); ++i)
1683  {
1684  const QDomElement element = nodeList.at(i).toElement();
1685  if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode)
1686  {
1687  path.Append(ParseSANode(element));
1688  }
1689  }
1690  return path;
1691 }
1692 
1693 //---------------------------------------------------------------------------------------------------------------------
1694 /**
1695  * @brief setActiveDraftBlock set current draft block.
1696  * @param name draft block name.
1697  */
1698 void VAbstractPattern::setActiveDraftBlock(const QString &name)
1699 {
1700  Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name draft block is empty");
1701  this->activeDraftBlock = name;
1702  emit activeDraftBlockChanged(name);
1703 }
1704 
1705 //---------------------------------------------------------------------------------------------------------------------
1706 QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
1707 {
1708  const QDomNodeList list = elementsByTagName(tag);
1709  QDomElement element;
1710  if (list.isEmpty())
1711  {
1712  const QStringList tags = QStringList() << TagUnit << TagImage << TagDescription << TagNotes
1715  switch (tags.indexOf(tag))
1716  {
1717  case 1: //TagImage
1718  element = createElement(TagImage);
1719  break;
1720  case 2: //TagDescription
1721  element = createElement(TagDescription);
1722  break;
1723  case 3: //TagNotes
1724  element = createElement(TagNotes);
1725  break;
1726  case 4: //TagGradation
1727  {
1728  element = createElement(TagGradation);
1729 
1730  QDomElement heights = createElement(TagHeights);
1731  heights.setAttribute(AttrAll, QLatin1String("true"));
1732  element.appendChild(heights);
1733 
1734  QDomElement sizes = createElement(TagSizes);
1735  sizes.setAttribute(AttrAll, QLatin1String("true"));
1736  element.appendChild(sizes);
1737  break;
1738  }
1739  case 5: // TagPatternName
1740  element = createElement(TagPatternName);
1741  break;
1742  case 6: // TagPatternNum
1743  element = createElement(TagPatternNum);
1744  break;
1745  case 7: // TagCompanyName
1746  element = createElement(TagCompanyName);
1747  break;
1748  case 8: // TagCustomerName
1749  element = createElement(TagCustomerName);
1750  break;
1751  case 9: // TagPatternLabel
1752  element = createElement(TagPatternLabel);
1753  break;
1754  case 0: //TagUnit (Mandatory tag)
1755  default:
1756  return QDomElement();
1757  }
1758  InsertTag(tags, element);
1759  return element;
1760  }
1761  return list.at(0).toElement();
1762 }
1763 
1764 //---------------------------------------------------------------------------------------------------------------------
1765 void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &element)
1766 {
1767  QDomElement pattern = documentElement();
1768  for (int i = tags.indexOf(element.tagName())-1; i >= 0; --i)
1769  {
1770  const QDomNodeList list = elementsByTagName(tags.at(i));
1771  if (not list.isEmpty())
1772  {
1773  pattern.insertAfter(element, list.at(0));
1774  break;
1775  }
1776  }
1777  SetVersion();
1778 }
1779 
1780 //---------------------------------------------------------------------------------------------------------------------
1782 {
1783  const QDomNodeList blockList = elementsByTagName(TagDraftBlock);
1784 
1785  int index = 0;
1786  if (not blockList.isEmpty())
1787  {
1788  for (int i = 0; i < blockList.size(); ++i)
1789  {
1790  QDomElement node = blockList.at(i).toElement();
1791  if (node.attribute(AttrName) == activeDraftBlock)
1792  {
1793  index = i;
1794  break;
1795  }
1796  }
1797  }
1798 
1799  return index;
1800 }
1801 
1802 //---------------------------------------------------------------------------------------------------------------------
1804 {
1805  QStringList increments;
1806  const QDomNodeList list = elementsByTagName(TagIncrement);
1807  for (int i=0; i < list.size(); ++i)
1808  {
1809  const QDomElement dom = list.at(i).toElement();
1810 
1811  try
1812  {
1813  increments.append(GetParametrString(dom, IncrementName));
1814  }
1815  catch (VExceptionEmptyParameter &e)
1816  {
1817  Q_UNUSED(e)
1818  }
1819  }
1820 
1821  return increments;
1822 }
1823 
1824 //---------------------------------------------------------------------------------------------------------------------
1826 {
1828 
1829  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1830  // Note. Tool Union Details also contains formulas, but we don't use them for union and keep only to simplifying
1831  // working with nodes. Same code for saving reading.
1832  list << ListPointExpressions();
1833  list << ListArcExpressions();
1834  list << ListElArcExpressions();
1835  list << ListSplineExpressions();
1836  list << ListIncrementExpressions();
1837  list << ListOperationExpressions();
1838  list << ListPathExpressions();
1839  list << ListPieceExpressions();
1840 
1841  return list;
1842 }
1843 
1844 //---------------------------------------------------------------------------------------------------------------------
1846 {
1847  // Check if new tool doesn't bring new attribute with a formula.
1848  // If no just increment a number.
1849  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1850  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1851 
1852  QVector<VFormulaField> expressions;
1853  const QDomNodeList list = elementsByTagName(TagPoint);
1854  for (int i=0; i < list.size(); ++i)
1855  {
1856  const QDomElement dom = list.at(i).toElement();
1857 
1858  // Each tag can contains several attributes.
1859  ReadExpressionAttribute(expressions, dom, AttrLength);
1860  ReadExpressionAttribute(expressions, dom, AttrAngle);
1861  ReadExpressionAttribute(expressions, dom, AttrC1Radius);
1862  ReadExpressionAttribute(expressions, dom, AttrC2Radius);
1863  ReadExpressionAttribute(expressions, dom, AttrCRadius);
1864  ReadExpressionAttribute(expressions, dom, AttrRadius);
1865  }
1866 
1867  return expressions;
1868 }
1869 
1870 //---------------------------------------------------------------------------------------------------------------------
1872 {
1873  // Check if new tool doesn't bring new attribute with a formula.
1874  // If no just increment number.
1875  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1876  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1877 
1878  QVector<VFormulaField> expressions;
1879  const QDomNodeList list = elementsByTagName(TagArc);
1880  for (int i=0; i < list.size(); ++i)
1881  {
1882  const QDomElement dom = list.at(i).toElement();
1883 
1884  // Each tag can contains several attributes.
1885  ReadExpressionAttribute(expressions, dom, AttrAngle1);
1886  ReadExpressionAttribute(expressions, dom, AttrAngle2);
1887  ReadExpressionAttribute(expressions, dom, AttrRadius);
1888  ReadExpressionAttribute(expressions, dom, AttrLength);
1889  }
1890 
1891  return expressions;
1892 }
1893 
1894 //---------------------------------------------------------------------------------------------------------------------
1896 {
1897  // Check if new tool doesn't bring new attribute with a formula.
1898  // If no just increment number.
1899  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1900  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1901 
1902  QVector<VFormulaField> expressions;
1903  const QDomNodeList list = elementsByTagName(TagElArc);
1904  for (int i=0; i < list.size(); ++i)
1905  {
1906  const QDomElement dom = list.at(i).toElement();
1907 
1908  // Each tag can contains several attributes.
1909  ReadExpressionAttribute(expressions, dom, AttrRadius1);
1910  ReadExpressionAttribute(expressions, dom, AttrRadius2);
1911  ReadExpressionAttribute(expressions, dom, AttrAngle1);
1912  ReadExpressionAttribute(expressions, dom, AttrAngle2);
1913  ReadExpressionAttribute(expressions, dom, AttrRotationAngle);
1914  }
1915 
1916  return expressions;
1917 }
1918 
1919 //---------------------------------------------------------------------------------------------------------------------
1921 {
1922  QVector<VFormulaField> expressions;
1923  expressions << ListPathPointExpressions();
1924  return expressions;
1925 }
1926 
1927 //---------------------------------------------------------------------------------------------------------------------
1929 {
1930  // Check if new tool doesn't bring new attribute with a formula.
1931  // If no just increment number.
1932  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1933  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1934 
1935  QVector<VFormulaField> expressions;
1936  const QDomNodeList list = elementsByTagName(AttrPathPoint);
1937  for (int i=0; i < list.size(); ++i)
1938  {
1939  const QDomElement dom = list.at(i).toElement();
1940 
1941  // Each tag can contains several attributes.
1942  ReadExpressionAttribute(expressions, dom, AttrKAsm1);
1943  ReadExpressionAttribute(expressions, dom, AttrKAsm2);
1944  ReadExpressionAttribute(expressions, dom, AttrAngle);
1945  }
1946 
1947  return expressions;
1948 }
1949 
1950 //---------------------------------------------------------------------------------------------------------------------
1952 {
1953  QVector<VFormulaField> expressions;
1954  const QDomNodeList list = elementsByTagName(TagIncrement);
1955  for (int i=0; i < list.size(); ++i)
1956  {
1957  const QDomElement dom = list.at(i).toElement();
1958 
1959  ReadExpressionAttribute(expressions, dom, IncrementFormula);
1960  }
1961 
1962  return expressions;
1963 }
1964 
1965 //---------------------------------------------------------------------------------------------------------------------
1967 {
1968  // Check if new tool doesn't bring new attribute with a formula.
1969  // If no just increment number.
1970  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1971  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1972 
1973  QVector<VFormulaField> expressions;
1974  const QDomNodeList list = elementsByTagName(TagOperation);
1975  for (int i=0; i < list.size(); ++i)
1976  {
1977  const QDomElement dom = list.at(i).toElement();
1978 
1979  // Each tag can contains several attributes.
1980  ReadExpressionAttribute(expressions, dom, AttrAngle);
1981  ReadExpressionAttribute(expressions, dom, AttrLength);
1982  }
1983 
1984  return expressions;
1985 }
1986 
1987 //---------------------------------------------------------------------------------------------------------------------
1989 {
1990  // Check if new tool doesn't bring new attribute with a formula.
1991  // If no just increment number.
1992  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
1993  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
1994 
1995  QVector<VFormulaField> expressions;
1996 
1997  const QDomNodeList nodeList = nodes.childNodes();
1998  for (qint32 i = 0; i < nodeList.size(); ++i)
1999  {
2000  const QDomElement element = nodeList.at(i).toElement();
2001  if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode)
2002  {
2005  }
2006  }
2007  return expressions;
2008 }
2009 
2010 //---------------------------------------------------------------------------------------------------------------------
2012 {
2013  // Check if new tool doesn't bring new attribute with a formula.
2014  // If no just increment number.
2015  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
2016  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
2017 
2018  QVector<VFormulaField> expressions;
2019  const QDomNodeList list = elementsByTagName(TagPath);
2020  for (int i=0; i < list.size(); ++i)
2021  {
2022  const QDomElement dom = list.at(i).toElement();
2023  if (dom.isNull())
2024  {
2025  continue;
2026  }
2027 
2028  expressions << ListNodesExpressions(dom.firstChildElement(TagNodes));
2029  }
2030 
2031  return expressions;
2032 }
2033 
2034 //---------------------------------------------------------------------------------------------------------------------
2036 {
2037  QVector<VFormulaField> expressions;
2038  if (not element.isNull())
2039  {
2040  // Each tag can contains several attributes.
2041  ReadExpressionAttribute(expressions, element, AttrRotation);
2042  ReadExpressionAttribute(expressions, element, AttrLength);
2043  }
2044 
2045  return expressions;
2046 }
2047 
2048 //---------------------------------------------------------------------------------------------------------------------
2050 {
2051  // Check if new tool doesn't bring new attribute with a formula.
2052  // If no just increment number.
2053  // If new tool bring absolutely new type and has formula(s) create new method to cover it.
2054  Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
2055 
2056  QVector<VFormulaField> expressions;
2057  const QDomNodeList list = elementsByTagName(TagPiece);
2058  for (int i=0; i < list.size(); ++i)
2059  {
2060  const QDomElement dom = list.at(i).toElement();
2061  if (dom.isNull())
2062  {
2063  continue;
2064  }
2065 
2066  // Each tag can contains several attributes.
2067  ReadExpressionAttribute(expressions, dom, AttrWidth);
2068 
2069  expressions << ListNodesExpressions(dom.firstChildElement(TagNodes));
2070  expressions << ListGrainlineExpressions(dom.firstChildElement(TagGrainline));
2071  }
2072 
2073  return expressions;
2074 }
2075 
2076 //---------------------------------------------------------------------------------------------------------------------
2077 bool VAbstractPattern::IsVariable(const QString &token) const
2078 {
2079  for (int i = 0; i < builInVariables.size(); ++i)
2080  {
2081  if (token.indexOf( builInVariables.at(i) ) == 0)
2082  {
2084  {
2085  return token == builInVariables.at(i);
2086  }
2087  else
2088  {
2089  return true;
2090  }
2091  }
2092  }
2093 
2094  return false;
2095 }
2096 
2097 //---------------------------------------------------------------------------------------------------------------------
2098 bool VAbstractPattern::IsPostfixOperator(const QString &token) const
2099 {
2100  for (int i = 0; i < builInPostfixOperators.size(); ++i)
2101  {
2102  if (token.indexOf( builInPostfixOperators.at(i) ) == 0)
2103  {
2104  return true;
2105  }
2106  }
2107 
2108  return false;
2109 }
2110 
2111 //---------------------------------------------------------------------------------------------------------------------
2112 bool VAbstractPattern::IsFunction(const QString &token) const
2113 {
2114  for (int i = 0; i < builInFunctions.size(); ++i)
2115  {
2116  if (token.indexOf( builInFunctions.at(i) ) == 0)
2117  {
2118  return true;
2119  }
2120  }
2121 
2122  return false;
2123 }
2124 
2125 //---------------------------------------------------------------------------------------------------------------------
2126 QPair<bool, QMap<quint32, quint32> > VAbstractPattern::parseItemElement(const QDomElement &domElement)
2127 {
2128  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2129 
2130  try
2131  {
2132  const bool visible = getParameterBool(domElement, AttrVisible, trueStr);
2133 
2134  QMap<quint32, quint32> items;
2135 
2136  const QDomNodeList nodeList = domElement.childNodes();
2137  const qint32 num = nodeList.size();
2138  for (qint32 i = 0; i < num; ++i)
2139  {
2140  const QDomElement element = nodeList.at(i).toElement();
2141  if (not element.isNull() && element.tagName() == TagGroupItem)
2142  {
2143  const quint32 object = GetParametrUInt(element, AttrObject, NULL_ID_STR);
2144  const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR);
2145  items.insert(object, tool);
2146  }
2147  }
2148 
2149  QPair<bool, QMap<quint32, quint32> > group;
2150  group.first = visible;
2151  group.second = items;
2152 
2153  return group;
2154  }
2155  catch (const VExceptionBadId &e)
2156  {
2157  VExceptionObjectError excep(tr("Error creating or updating group"), domElement);
2158  excep.AddMoreInformation(e.ErrorMessage());
2159  throw excep;
2160  }
2161 }
2162 
2163 //---------------------------------------------------------------------------------------------------------------------
2164 /*
2165  * @brief IsModified state of the document for cases that do not cover QUndoStack.
2166  * @return true if the document was modified without using QUndoStack.
2167  */
2169 {
2170  return modified;
2171 }
2172 
2173 //---------------------------------------------------------------------------------------------------------------------
2175 {
2176  this->modified = modified;
2177 }
2178 
2179 //---------------------------------------------------------------------------------------------------------------------
2181 {
2182  QDomElement draftBlock;
2183  if (getActiveDraftElement(draftBlock))
2184  {
2185  QDomElement groups = draftBlock.firstChildElement(TagGroups);
2186 
2187  if (groups.isNull())
2188  {
2189  groups = createElement(TagGroups);
2190  draftBlock.appendChild(groups);
2191  }
2192 
2193  return groups;
2194  }
2195  return QDomElement();
2196 }
2197 
2198 //---------------------------------------------------------------------------------------------------------------------
2199 QDomElement VAbstractPattern::createGroup(quint32 groupId, const QString &name, const QString &color, const QString &type,
2200  const QString &weight, const QMap<quint32, quint32> &groupData)
2201 {
2202  if (groupId == NULL_ID)
2203  {
2204  return QDomElement();
2205  }
2206 
2207  //Create new empty group
2208  QDomElement group = createElement(TagGroup);
2209  SetAttribute(group, AttrId, groupId);
2210  SetAttribute(group, AttrName, name);
2211  SetAttribute(group, AttrVisible, true);
2212  SetAttribute(group, AttrGroupLocked, false);
2213  SetAttribute(group, AttrGroupColor, color);
2214  SetAttribute(group, AttrLineType, type);
2215  SetAttribute(group, AttrLineWeight, weight);
2216 
2217  //Add objects to group
2218  if (!groupData.isEmpty())
2219  {
2220  auto i = groupData.constBegin();
2221  while (i != groupData.constEnd())
2222  {
2223  QDomElement item = createElement(TagGroupItem);
2224  item.setAttribute(AttrObject, i.key());
2225  item.setAttribute(AttrTool, i.value());
2226  group.appendChild(item);
2227  ++i;
2228  }
2229  return group;
2230  }
2231  else
2232  {
2233  return group;
2234  }
2235 }
2236 
2237 QDomElement VAbstractPattern::addGroupItems(const QString &name, const QMap<quint32, quint32> &groupData)
2238 {
2239  quint32 groupId = getGroupIdByName(name);
2240  const bool locked = getGroupLock(groupId);
2241  if (locked)
2242  {
2243  return QDomElement();
2244  }
2245 
2246  QDomElement group = getGroupByName(name);
2247 
2248  if (! getParameterBool(group, AttrGroupLocked, trueStr))
2249  {
2250  if (!groupData.isEmpty())
2251  {
2252  auto i = groupData.constBegin();
2253  while (i != groupData.constEnd())
2254  {
2255  QDomElement item = createElement(TagGroupItem);
2256  item.setAttribute(AttrObject, i.key());
2257  item.setAttribute(AttrTool, i.value());
2258  group.appendChild(item);
2259  ++i;
2260  }
2261  modified = true;
2262  emit patternChanged(false);
2263 
2264  emit updateGroups();
2265  }
2266  }
2267  return group;
2268 }
2269 
2270 //---------------------------------------------------------------------------------------------------------------------
2272 {
2273  QString name = tr("New group");
2274  QDomElement groups = createGroups();
2275  if (not groups.isNull())
2276  {
2277  QDomElement group = elementById(id, TagGroup);
2278  if (group.isElement())
2279  {
2280  name = GetParametrString(group, AttrName, name);
2281  return name;
2282  }
2283  else
2284  {
2285  if (groups.childNodes().isEmpty())
2286  {
2287  QDomNode parent = groups.parentNode();
2288  parent.removeChild(groups);
2289  }
2290 
2291  qDebug("Can't get group by id = %u.", id);
2292  return name;
2293  }
2294  }
2295  else
2296  {
2297  qDebug("Can't get tag Groups.");
2298  return name;
2299  }
2300 }
2301 
2302 //---------------------------------------------------------------------------------------------------------------------
2303 void VAbstractPattern::setGroupName(quint32 id, const QString &name)
2304 {
2305  QDomElement groups = createGroups();
2306  if (not groups.isNull())
2307  {
2308  QDomElement group = elementById(id, TagGroup);
2309  if (group.isElement())
2310  {
2311  group.setAttribute(AttrName, name);
2312  modified = true;
2313  emit patternChanged(false);
2314  }
2315  else
2316  {
2317  if (groups.childNodes().isEmpty())
2318  {
2319  QDomNode parent = groups.parentNode();
2320  parent.removeChild(groups);
2321  }
2322 
2323  qDebug("Can't get group by id = %u.", id);
2324  }
2325  }
2326  else
2327  {
2328  qDebug("Can't get tag Groups.");
2329  }
2330 }
2331 
2332 //---------------------------------------------------------------------------------------------------------------------
2334 {
2335  GroupAttributes groupData;
2337 
2338  try
2339  {
2340  QDomElement groups = createGroups();
2341  if (not groups.isNull())
2342  {
2343  QDomNode domNode = groups.firstChild();
2344  while (domNode.isNull() == false)
2345  {
2346  if (domNode.isElement())
2347  {
2348  const QDomElement group = domNode.toElement();
2349  if (group.isNull() == false)
2350  {
2351  if (group.tagName() == TagGroup)
2352  {
2353  const quint32 id = GetParametrUInt(group, AttrId, "0");
2354  const QString name = GetParametrString(group, AttrName, tr("New group 2"));
2355  const bool visible = getParameterBool(group, AttrVisible, trueStr);
2356  const bool locked = getParameterBool(group, AttrGroupLocked, trueStr);
2357  const QString color = GetParametrString(group, AttrGroupColor, ColorBlack);
2358  const QString linetype = GetParametrString(group, AttrLineType, LineTypeSolidLine);
2359  const QString lineweight = GetParametrString(group, AttrLineWeight, "0.35");
2360 
2361  groupData.name = name;
2362  groupData.visible = visible;
2363  groupData.locked = locked;
2364  groupData.color = color;
2365  groupData.linetype = linetype;
2366  groupData.lineweight = lineweight;
2367  data.insert(id, groupData);
2368  }
2369  }
2370  }
2371  domNode = domNode.nextSibling();
2372  }
2373  emit patternHasGroups(true);
2374  }
2375  else
2376  {
2377  emit patternHasGroups(false);
2378  qDebug("Can't get tag Groups.");
2379  }
2380  }
2381  catch (const VExceptionConversionError &)
2382  {
2384  }
2385 
2386  return data;
2387 }
2388 
2389 
2390 /*---------------------------------------------------------------------------------------------------------------------
2391  * @brief Gets List of Groups for the current Draft Block
2392  *
2393  * @return AttrName - Group Name.
2394  * @throw VExceptionConversionError if group error.
2395  */
2396 
2398 {
2399  QStringList groupList;
2400  try
2401  {
2402  QDomElement groups = createGroups();
2403  if (not groups.isNull())
2404  {
2405  QDomNode domNode = groups.firstChild();
2406  if (domNode.isNull() == false)
2407  {
2408  while (domNode.isNull() == false)
2409  {
2410  if (domNode.isElement())
2411  {
2412  const QDomElement group = domNode.toElement();
2413  if (group.isNull() == false)
2414  {
2415  if (group.tagName() == TagGroup)
2416  {
2417 
2418  groupList << GetParametrString(group, AttrName);
2419  }
2420  }
2421  }
2422  domNode = domNode.nextSibling();
2423  }
2424  emit patternHasGroups(true);
2425  }
2426  else
2427  {
2428  emit patternHasGroups(false);
2429  qDebug("Can't get tag Groups.");
2430  }
2431  }
2432 
2433  }
2434  catch (const VExceptionConversionError &)
2435  {
2436  return groupList;
2437  }
2438 
2439  return groupList;
2440 }
2441 
2442 /*---------------------------------------------------------------------------------------------------------------------
2443  * @brief Gets Dom Element for a given group name.
2444  *
2445  * @return group - group Dom Element.
2446  */
2447 QDomElement VAbstractPattern::getGroupByName(const QString &name)
2448 {
2449 
2450  QDomElement groups = createGroups();
2451  if (not groups.isNull())
2452  {
2453  QDomNode domNode = groups.firstChild();
2454  if (domNode.isNull() == false)
2455  {
2456  while (domNode.isNull() == false)
2457  {
2458  if (domNode.isElement())
2459  {
2460  const QDomElement group = domNode.toElement();
2461  if (group.isNull() == false)
2462  {
2463  if (group.tagName() == TagGroup)
2464  {
2465  const QString groupName = GetParametrString(group, AttrName);
2466  if (groupName == name)
2467  {
2468  return group;
2469  }
2470  }
2471  }
2472  }
2473  domNode = domNode.nextSibling();
2474  }
2475  emit patternHasGroups(true);
2476  }
2477  else
2478  {
2479  emit patternHasGroups(false);
2480  qDebug("Can't get tag Groups.");
2481  }
2482  }
2483  return groups;
2484 }
2485 
2486 /*---------------------------------------------------------------------------------------------------------------------
2487  * @brief Gets groupId for a given group name.
2488  *
2489  * @return groupId - group Id.
2490  */
2491 quint32 VAbstractPattern::getGroupIdByName(const QString &name)
2492 {
2493 
2494  QDomElement groups = createGroups();
2495  if (not groups.isNull())
2496  {
2497  QDomNode domNode = groups.firstChild();
2498  if (domNode.isNull() == false)
2499  {
2500  while (domNode.isNull() == false)
2501  {
2502  if (domNode.isElement())
2503  {
2504  const QDomElement group = domNode.toElement();
2505  if (group.isNull() == false)
2506  {
2507  if (group.tagName() == TagGroup)
2508  {
2509  const QString groupName = GetParametrString(group, AttrName);
2510  if (groupName == name)
2511  {
2512  const quint32 groupId = GetParametrUInt(group, AttrId, "0");
2513  return groupId;
2514  }
2515  }
2516  }
2517  }
2518  domNode = domNode.nextSibling();
2519  }
2520  }
2521  else
2522  {
2523  qDebug("Can't get tag Groups.");
2524  }
2525  }
2526  return quint32();
2527 }
2528 
2529 //---------------------------------------------------------------------------------------------------------------------
2530 /**
2531  * @brief Returns the groups that contain or do not contain the item identified by the toolid and the objectid
2532  * @param toolId
2533  * @param objectId
2534  * @param containsItem |true if the groups contain the given item, false if they don't contain the item
2535  * @return
2536  */
2537 QMap<quint32, QString> VAbstractPattern::getGroupsContainingItem(quint32 toolId, quint32 objectId, bool containsItem)
2538 {
2540 
2541  if(objectId == 0)
2542  {
2543  objectId = toolId;
2544  }
2545 
2546  QDomElement groups = createGroups();
2547  if (not groups.isNull())
2548  {
2549  QDomNode domNode = groups.firstChild();
2550  while (domNode.isNull() == false) // iterate through the groups
2551  {
2552  if (domNode.isElement())
2553  {
2554  const QDomElement group = domNode.toElement();
2555  if (group.isNull() == false)
2556  {
2557  if (group.tagName() == TagGroup)
2558  {
2559  bool groupHasItem = hasGroupItem(group, toolId, objectId);
2560  if((containsItem && groupHasItem) || (not containsItem && not groupHasItem))
2561  {
2562  const quint32 groupId = GetParametrUInt(group, AttrId, "0");
2563  const QString name = GetParametrString(group, AttrName, tr("New group"));
2564  data.insert(groupId, name);
2565  }
2566  }
2567  }
2568  }
2569  domNode = domNode.nextSibling();
2570  }
2571  }
2572  else
2573  {
2574  qDebug("Can't get tag Groups.");
2575  }
2576 
2577  return data;
2578 }
2579 //---------------------------------------------------------------------------------------------------------------------
2580 /**
2581  * @brief Checks if the given group has the item with the given toolId and objectId
2582  * @param groupDomElement
2583  * @param toolId
2584  * @param objectId
2585  * @return
2586  */
2587 bool VAbstractPattern::hasGroupItem(const QDomElement &groupDomElement, quint32 toolId, quint32 objectId)
2588 {
2589  bool result = false;
2590 
2591  QDomNode itemNode = groupDomElement.firstChild();
2592  while (itemNode.isNull() == false) // iterate through the items of the group
2593  {
2594  if (itemNode.isElement())
2595  {
2596  const QDomElement item = itemNode.toElement();
2597  if (item.isNull() == false)
2598  {
2599  quint32 toolIdIterate= GetParametrUInt(item, AttrTool, "0");
2600  quint32 objectIdIterate= GetParametrUInt(item, AttrObject, "0");
2601 
2602  if(toolIdIterate == toolId && objectIdIterate == objectId)
2603  {
2604  result = true;
2605  break;
2606  }
2607  }
2608  }
2609  itemNode = itemNode.nextSibling();
2610  }
2611  return result;
2612 }
2613 
2614 /**
2615  * @brief Deletes an item from the group containing the toolId
2616  * @param toolId
2617  */
2619 {
2620  QMap<quint32,QString> groupsContainingItem = getGroupsContainingItem(toolId, 0, true);
2621  QStringList list = QStringList(groupsContainingItem.values());
2622  QString listGroupName = list.value(0);
2623  quint32 groupId = groupsContainingItem.key(listGroupName);
2624 
2625  const bool locked = getGroupLock(groupId);
2626  if (locked)
2627  {
2628  return;
2629  }
2630 
2631  QDomElement group = removeGroupItem(toolId, 0, groupId);
2632 }
2633 
2634 /**
2635  * @brief Adds an item to the given group with the given toolId and objectId
2636  * @param toolId
2637  */
2638 void VAbstractPattern::addToolToGroup(quint32 toolId, quint32 objectId, const QString &groupName)
2639 {
2640  quint32 groupId = getGroupIdByName(groupName);
2641  const bool locked = getGroupLock(groupId);
2642  if (locked)
2643  {
2644  return;
2645  }
2646 
2647  //Delete tool if contained in an existing group
2648  QMap<quint32,QString> groupsContainingItem = getGroupsContainingItem(toolId, objectId, true);
2649  QStringList list = QStringList(groupsContainingItem.values());
2650  QString listGroupName = list.value(0);
2651  groupId = groupsContainingItem.key(listGroupName);
2652 
2653  QDomElement group = removeGroupItem(toolId, objectId, groupId);
2654 
2655  //Add to new Group.
2656  QMap<quint32,QString> groupsNotContainingItem = getGroupsContainingItem(toolId, objectId, false);
2657  list = QStringList(groupsNotContainingItem.values());
2658 
2659  for(int i=0; i<list.count(); ++i)
2660  {
2661  const QString listGroupName = list.value(i);
2662  if (groupName == listGroupName)
2663  {
2664  const quint32 groupId = groupsNotContainingItem.key(list[i]);
2665  QDomElement group = addGroupItem(toolId, objectId, groupId);
2666  modified = true;
2667  emit patternChanged(false);
2668  emit updateGroups();
2669  QDomElement groups = createGroups();
2670  if (not groups.isNull())
2671  {
2672  parseGroups(groups);
2673  }
2674  break;
2675  }
2676  }
2677 
2678 }
2679 
2680 //---------------------------------------------------------------------------------------------------------------------
2681 /**
2682  * @brief Adds an item to the given group with the given toolId and objectId
2683  * @param toolId
2684  * @param objectId
2685  * @param groupId
2686  */
2687 QDomElement VAbstractPattern::addGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
2688 {
2689 
2690  const bool locked = getGroupLock(groupId);
2691  if (locked)
2692  {
2693  return QDomElement();
2694  }
2695 
2696  QDomElement group = elementById(groupId, TagGroup);
2697 
2698  if (!group.isNull())
2699  {
2700  if(objectId == 0)
2701  {
2702  objectId = toolId;
2703  }
2704 
2705  QDomElement item = createElement(TagGroupItem);
2706  item.setAttribute(AttrTool, toolId);
2707  item.setAttribute(AttrObject, objectId);
2708  group.appendChild(item);
2709 
2710  modified = true;
2711  emit patternChanged(false);
2712 
2713  emit updateGroups();
2714 
2715  QDomElement groups = createGroups();
2716  if (not groups.isNull())
2717  {
2718  parseGroups(groups);
2719  }
2720 
2721  return item;
2722  }
2723  else
2724  {
2725  qDebug() << "The group of id " << groupId << " doesn't exist";
2726  }
2727 
2728  return QDomElement();
2729 }
2730 
2731 //---------------------------------------------------------------------------------------------------------------------
2732 /**
2733  * @brief Removes the item of given toolId and objectId from the group of given groupId
2734  * @param toolId
2735  * @param objectId
2736  * @param groupId
2737  */
2738 QDomElement VAbstractPattern::removeGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
2739 {
2740  QDomElement group = elementById(groupId, TagGroup);
2741 
2742  const bool locked = getGroupLock(groupId);
2743  if (locked)
2744  {
2745  return QDomElement();
2746  }
2747 
2748  if (!group.isNull())
2749  {
2750  if(objectId == 0)
2751  {
2752  objectId = toolId;
2753  }
2754 
2755  QDomNode itemNode = group.firstChild();
2756  while (itemNode.isNull() == false) // iterate through the items of the group
2757  {
2758  if (itemNode.isElement())
2759  {
2760  const QDomElement item = itemNode.toElement();
2761  if (item.isNull() == false)
2762  {
2763  quint32 toolIdIterate= GetParametrUInt(item, AttrTool, "0");
2764  quint32 objectIdIterate= GetParametrUInt(item, AttrObject, "0");
2765 
2766  if(toolIdIterate == toolId && objectIdIterate == objectId)
2767  {
2768  group.removeChild(itemNode);
2769 
2770  // to signalised that the pattern was changed and need to be saved
2771  modified = true;
2772  emit patternChanged(false);
2773 
2774  // to update the group table of the gui
2775  emit updateGroups();
2776 
2777  // parse the groups to update the drawing, in case the item was removed from an invisible group
2778  QDomElement groups = createGroups();
2779  if (not groups.isNull())
2780  {
2781  parseGroups(groups);
2782  }
2783 
2784  return item;
2785  }
2786  }
2787  }
2788  itemNode = itemNode.nextSibling();
2789  }
2790  }
2791  else
2792  {
2793  qDebug() << "The group of id " << groupId << " doesn't exist";
2794  }
2795 
2796  return QDomElement();
2797 }
2798 
2799 //---------------------------------------------------------------------------------------------------------------------
2800 /**
2801  * @brief Returns true if the given group is empty
2802  * @param id
2803  * @return
2804  */
2806 {
2807  QDomElement group = elementById(id, TagGroup);
2808 
2809  if (group.isNull() == false)
2810  {
2811  return not group.hasChildNodes();
2812  }
2813  else
2814  {
2815  qDebug() << "The group of id " << id << " doesn't exist";
2816  return true;
2817  }
2818 }
2819 
2820 //---------------------------------------------------------------------------------------------------------------------
2822 {
2823  QDomElement group = elementById(id, TagGroup);
2824  if (group.isElement())
2825  {
2826  return getParameterBool(group, AttrVisible, trueStr);
2827  }
2828  else
2829  {
2830  qDebug("Can't get group by id = %u.", id);
2831  return true;
2832  }
2833 }
2834 
2835 //---------------------------------------------------------------------------------------------------------------------
2836 void VAbstractPattern::setGroupVisibility(quint32 id, bool visible)
2837 {
2838  QDomElement group = elementById(id, TagGroup);
2839  if (group.isElement())
2840  {
2841  SetAttribute(group, AttrVisible, visible);
2842  modified = true;
2843  emit patternChanged(false);
2844 
2845  QDomElement groups = createGroups();
2846  if (not groups.isNull())
2847  {
2848  parseGroups(groups);
2849  }
2850  }
2851  else
2852  {
2853  qDebug("Can't get group by id = %u.", id);
2854  }
2855 }
2856 
2857 
2858 /*---------------------------------------------------------------------------------------------------------------------
2859  * @brief Gets whether a Group is locked or not
2860  * @param id - Tool Id.
2861  * @return AttrGroupLocked - True if locked False if unlocked.
2862  * @return True if can't find group by id.
2863 */
2864 
2866 {
2867  QDomElement group = elementById(id, TagGroup);
2868  if (group.isElement())
2869  {
2870  return getParameterBool(group, AttrGroupLocked, trueStr);
2871  }
2872  else
2873  {
2874  qDebug("Can't get group by id = %u.", id);
2875  return true;
2876  }
2877 }
2878 
2879 //---------------------------------------------------------------------------------------------------------------------
2880 void VAbstractPattern::setGroupLock(quint32 id, bool locked)
2881 {
2882  QDomElement group = elementById(id, TagGroup);
2883  if (group.isElement())
2884  {
2885  SetAttribute(group, AttrGroupLocked, locked);
2886  modified = true;
2887  emit patternChanged(false);
2888  //qDebug("VAbstractPattern::setGroupLock - Group %u is locked.", id);
2889 
2890  QDomElement groups = createGroups();
2891  if (not groups.isNull())
2892  {
2893  parseGroups(groups);
2894  }
2895  }
2896  else
2897  {
2898  qDebug("Can't get group by id = %u.", id);
2899  }
2900 }
2901 
2902 /*---------------------------------------------------------------------------------------------------------------------
2903  * @brief Gets the Group color
2904  * @param id - Tool Id.
2905  * @return AttrGroupColor - Color of the group.
2906  * @return color - group color.
2907 */
2908 
2910 {
2911  QDomElement group = elementById(id, TagGroup);
2912  QString color;
2913  if (group.isElement())
2914  {
2915 
2916  color = GetParametrString(group, AttrGroupColor, ColorBlack);
2917  return color;
2918  }
2919  else
2920  {
2921  qDebug("Can't get group by id = %u.", id);
2922  return ColorBlack;
2923  }
2924 }
2925 
2926 //---------------------------------------------------------------------------------------------------------------------
2927 void VAbstractPattern::setGroupColor(quint32 id, QString color)
2928 {
2929  QDomElement group = elementById(id, TagGroup);
2930  if (group.isElement())
2931  {
2932  SetAttribute(group, AttrGroupColor, color);
2933  modified = true;
2934  emit patternChanged(false);
2935  }
2936  else
2937  {
2938  qDebug("Can't get group by id = %u.", id);
2939  }
2940 }
2941 
2942 /*---------------------------------------------------------------------------------------------------------------------
2943  * @brief Gets the Group Line Type
2944  * @param id - Tool Id.
2945  * @return AttrLineType - Line type of the group.
2946  * @return type - group line type.
2947 */
2948 
2950 {
2951  QDomElement group = elementById(id, TagGroup);
2952  QString type;
2953  if (group.isElement())
2954  {
2955 
2957  return type;
2958  }
2959  else
2960  {
2961  qDebug("Can't get group by id = %u.", id);
2962  return LineTypeSolidLine;
2963  }
2964 }
2965 
2966 //---------------------------------------------------------------------------------------------------------------------
2967 void VAbstractPattern::setGroupLineType(quint32 id, QString type)
2968 {
2969  QDomElement group = elementById(id, TagGroup);
2970  if (group.isElement())
2971  {
2972  SetAttribute(group, AttrLineType, type);
2973  modified = true;
2974  emit patternChanged(false);
2975  }
2976  else
2977  {
2978  qDebug("Can't get group by id = %u.", id);
2979  }
2980 }
2981 
2982 /*---------------------------------------------------------------------------------------------------------------------
2983  * @brief Gets the Group Line Weight
2984  * @param id - Tool Id.
2985  * @return AttrLineWeight - Linw weight of the group.
2986  * @return weight - group line weight.
2987 */
2988 
2990 {
2991  QDomElement group = elementById(id, TagGroup);
2992  QString weight;
2993  if (group.isElement())
2994  {
2995 
2996  weight = GetParametrString(group, AttrLineWeight, "0.35");
2997  return weight;
2998  }
2999  else
3000  {
3001  qDebug("Can't get group by id = %u.", id);
3002  return ColorBlack;
3003  }
3004 }
3005 
3006 //---------------------------------------------------------------------------------------------------------------------
3007 void VAbstractPattern::setGroupLineWeight(quint32 id, QString weight)
3008 {
3009  QDomElement group = elementById(id, TagGroup);
3010  if (group.isElement())
3011  {
3012  SetAttribute(group, AttrLineWeight, weight);
3013  modified = true;
3014  emit patternChanged(false);
3015  }
3016  else
3017  {
3018  qDebug("Can't get group by id = %u.", id);
3019  }
3020 }
3021 
3022 /*---------------------------------------------------------------------------------------------------------------------
3023  * @brief Gets whether a group name already exists
3024  * @param groupName - group name.
3025  * @return exists - True id name exists False if it does not.
3026 */
3027 bool VAbstractPattern::groupNameExists(const QString &groupName)
3028 {
3029  QStringList groupList = groupListByName();
3030  bool exists = groupList.contains(groupName, Qt::CaseInsensitive);
3031  return exists;
3032 }
3033 
3034 QString VAbstractPattern::useGroupColor(quint32 toolId, QString color)
3035 {
3036  QMap<quint32,QString> groupsContainingItem = getGroupsContainingItem(toolId, 0, true);
3037  QStringList list = QStringList(groupsContainingItem.values());
3038  QString groupName = list.value(0);
3039 
3040  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupColor - Group Name = %s",qUtf8Printable(groupName));
3041  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupColor - Tool ID = %d",toolId);
3042  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupColor - Tool Color = %s",qUtf8Printable(color));
3043  quint32 objectId = toolId;
3044  bool groupHasItem = hasGroupItem(getGroupByName(groupName), toolId, objectId);
3045  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupColor - Group has item = %d",groupHasItem);
3046  if ((color == ColorByGroup) && groupHasItem)
3047  {
3048  QString groupColor = getGroupColor(getGroupIdByName(groupName));
3049  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupColor - Group Color = %s",qUtf8Printable(groupColor));
3050  return groupColor;
3051  }
3052  else
3053  {
3054  return color;
3055  }
3056 }
3057 
3058 QString VAbstractPattern::useGroupLineType(quint32 toolId, QString type)
3059 {
3060  QMap<quint32,QString> groupsContainingItem = getGroupsContainingItem(toolId, 0, true);
3061  QStringList list = QStringList(groupsContainingItem.values());
3062  QString groupName = list.value(0);
3063 
3064  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupLineType - Group Name = %s",qUtf8Printable(groupName));
3065  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupLineType - Tool ID = %d",toolId);
3066  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupLineType - Tool Color = %s",qUtf8Printable(type));
3067  quint32 objectId = toolId;
3068  bool groupHasItem = hasGroupItem(getGroupByName(groupName), toolId, objectId);
3069  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupLineType - Group has item = %d",groupHasItem);
3070  if ((type == LineTypeByGroup) && groupHasItem)
3071  {
3072  QString groupLineType = getGroupLineType(getGroupIdByName(groupName));
3073  //qCDebug(vbstractPattern,"VAbstractPattern::useGroupLineType - Group Linetpe = %s",qUtf8Printable(groupLineType));
3074  return groupLineType;
3075  }
3076  else
3077  {
3078  return type;
3079  }
3080 }
3081 
3082 QString VAbstractPattern::useGroupLineWeight(quint32 toolId, QString weight)
3083 {
3084  QMap<quint32,QString> groupsContainingItem = getGroupsContainingItem(toolId, 0, true);
3085  QStringList list = QStringList(groupsContainingItem.values());
3086  QString groupName = list.value(0);
3087 
3088  quint32 objectId = toolId;
3089  bool groupHasItem = hasGroupItem(getGroupByName(groupName), toolId, objectId);
3090  if ((weight == LineWeightByGroup) && groupHasItem)
3091  {
3092  QString groupLineWeight = getGroupLineWeight(getGroupIdByName(groupName));
3093  return groupLineWeight;
3094  }
3095  else
3096  {
3097  return weight;
3098  }
3099 }
Definition: pen.h:37
QString color
Definition: pen_toolbar.h:51
qreal lineWeight
Definition: pen_toolbar.h:52
QString lineType
Definition: pen_toolbar.h:53
static const QString AttrTimeFormat
void setGroupLock(quint32 id, bool locked)
void SetPatternNumber(const QString &qsNum)
void updatePieceList(quint32 id)
static const QString AttrS28
static const QString TagNode
void SetGradationHeights(const QMap< GHeights, bool > &options)
static const QString AttrLetter
static const QString AttrObject
bool getGroupLock(quint32 id)
static const QString AttrEnd
static const QString AttrS66
bool IsFunction(const QString &token) const
void SetImage(const QString &text, const QString &extension)
static const QString TagData
void setGroupColor(quint32 id, QString color)
QMap< quint32, GroupAttributes > getGroups()
bool GetPatternWasChanged() const
QVector< VFormulaField > ListArcExpressions() const
static const QString TagSpline
void setGroupLineWeight(quint32 id, QString weight)
void deleteToolFromGroup(quint32 toolId)
Deletes an item from the group containing the toolId.
void AddToolOnRemove(VDataTool *tool)
VAbstractPattern(QObject *parent=nullptr)
static QVector< VLabelTemplateLine > patternLabelLines
patternLabelLines list to speed up reading a template by many pieces.
QString GetCompanyName() const
static const QString AttrS70
static const QString AttrS60
static const QString AttrS50
void draftBlockNameChanged(const QString &oldName, const QString &newName)
draftBlockNameChanged save new name draft block.
static const QString AttrS36
QVector< VLabelTemplateLine > getPatternLabelTemplate() const
static const QString AttrAnnotation
QDomElement createGroups()
static const QString AttrS56
static const QString AttrType
void UpdateInLayoutList(quint32 id)
static const QString AttrH50
static const QString AttrH182
static const QString AttrS54
static const QString AttrGroupColor
QDomElement removeGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Removes the item of given toolId and objectId from the group of given groupId.
static const QString AttrH158
bool IsPostfixOperator(const QString &token) const
QDomElement getGroupByName(const QString &name)
QStringList groupListByName()
static const QString AttrTilt
QPair< bool, QMap< quint32, quint32 > > parseItemElement(const QDomElement &domElement)
static const QString TagPieces
bool isGroupEmpty(quint32 id)
Returns true if the given group is empty.
void ChangedCursor(quint32 id)
ChangedCursor change cursor position.
static QVector< quint32 > ParsePieceAnchors(const QDomElement &domElement)
static const QString NodeArc
static const QString AttrRotation
QString GetLabelDateFormat() const
QVector< quint32 > getDartItems(const quint32 &toolId)
static const QString AttrNodeNotchType
static const QString TagDescription
static const QString AttrS34
void SetModified(bool modified)
bool renameDraftBlock(const QString &oldName, const QString &newName)
renameDraftBlock change draft block name.
static const QString AttrS52
static const QString AttrFoldPosition
static const QString AttrStart
int draftBlockCount() const
static const QString NodePoint
static const QString AttrCustom
static const QString AttrExtension
QString useGroupColor(quint32 toolId, QString color)
static const QString AttrS26
static const QString TagMeasurements
static const QString IncrementDescription
QString MPath() const
static const QString AttrS62
static const QString AttrAll
QString GetPatternName() const
QString GetPatternNumber() const
static const QString AttrH134
QStringList getPatternPieces() const
static const QString AttrH68
static const QString TagModeling
quint32 SiblingNodeId(const quint32 &nodeId) const
static const QString TagArc
void SetPatternWasChanged(bool changed)
static const QString TagPatternName
QString activeDraftBlock
activeBlockName name current pattern peace.
bool draftBlockNameExists(const QString &name) const
draftBlockNameExists check if draft block with this name exists.
QString GetImageExtension() const
quint32 getGroupIdByName(const QString &name)
void setActiveDraftBlock(const QString &name)
setActiveDraftBlock set current draft block.
static const QString AttrH128
static const QString AttrDefSize
static const QString TagPattern
QVector< quint32 > getOpItems(const quint32 &toolId, const QString &itemType)
getOpItems get vector of operation tool obects.
static const QString AttrOnFold
static const QString AttrH140
void SetPatternName(const QString &qsName)
void haveLiteChange()
haveLiteChange we have unsaved change.
void addToolToGroup(quint32 toolId, quint32 objectId, const QString &groupName)
Adds an item to the given group with the given toolId and objectId.
QDomElement getDraftBlockElement(const QString &name)
static const QString AttrS58
static void AddTool(quint32 id, VDataTool *tool)
AddTool add tool to list tools.
bool appendDraftBlock(const QString &name)
appendDraftBlock add new draft block.
QDomElement addGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Adds an item to the given group with the given toolId and objectId.
void setPatternLabelTemplate(const QVector< VLabelTemplateLine > &lines)
static const QString AttrWidth
static const QString TagNotes
static const QString AttrH92
void activeDraftBlockChanged(const QString &newName)
activeDraftBlockChanged change active draft block.
static const QString TagTools
QString getGroupName(quint32 id)
static const QString AttrH80
void patternChanged(bool saved)
patternChanged emit if we have unsaved change.
static const QString TagGroupItem
void ClearMainWindow()
static const QString AttrH86
void SetCustomerName(const QString &qsName)
static const QString AttrS40
QString GetVersion() const
static const QString TagGroup
static const QString AttrNodeNotchSubType
QDomElement addGroupItems(const QString &name, const QMap< quint32, quint32 > &groupData)
static const QString AttrH74
QString GetDescription() const
static const QString NodeSplinePath
static const QString AttrPath
static const QString TagCustomerName
static const QString AttrGroupLocked
static const QString AttrH194
static const QString TagPatternInfo
static const QString AttrS32
QDomElement createGroup(quint32 id, const QString &name, const QString &color, const QString &type, const QString &weight, const QMap< quint32, quint32 > &groupData)
static const QString TagHeights
static const QString AttrH56
QVector< VToolRecord > history
history history records.
static const QString TagElArc
static const QString AttrH110
QVector< VFormulaField > ListOperationExpressions() const
static const QString NodeSpline
static const QString AttrH146
bool getGroupVisibility(quint32 id)
static const QString AttrNodeShowSecondNotch
static const QString AttrQuantity
QVector< VFormulaField > ListGrainlineExpressions(const QDomElement &element) const
static const QString AttrS44
QVector< VFormulaField > ListPathPointExpressions() const
static const QString AttrRotationWay
void parseGroups(const QDomElement &domElement)
static QHash< quint32, VDataTool * > tools
tools list with pointer on tools.
QString getGroupLineWeight(quint32 id)
static const QString AttrH164
QMap< GHeights, bool > GetGradationHeights() const
static const QString AttrOrientation
static const QString AttrSAAfter
QVector< VFormulaField > ListElArcExpressions() const
static const QString TagPatternLabel
void selectedPiece(quint32 id)
static const QString AttrTool
static const QString AttrH188
static VPiecePath ParsePathNodes(const QDomElement &domElement)
QVector< VToolRecord > getBlockHistory() const
QString GetImage() const
static const QString AttrS46
static const QString TagLine
void setGroupName(quint32 id, const QString &name)
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
static const QString TagIncrement
static const QString AttrNodeNotchLength
static const QString TagGroups
bool getActiveDraftElement(QDomElement &element) const
getActiveDraftElement return draftBlock element for current draft block.
static const QString TagPatternNum
static void RemoveTool(quint32 id)
quint32 cursor
cursor cursor keep id tool after which we will add new tool in file.
void setDefaultPen(Pen pen)
static const QString AttrNodeNotchCount
static const QString AttrSABefore
static const QString AttrH98
static VPieceNode ParseSANode(const QDomElement &domElement)
static const QString AttrArrows
static const QString AttrS22
static const QString AttrS38
static const QString AttrH62
QStringList ListMeasurements() const
static const QString TagDraftBlock
static QVector< CustomSARecord > ParsePieceCSARecords(const QDomElement &domElement)
QString GetCustomerName() const
QStringList ListIncrements() const
void setGroupLineType(quint32 id, QString type)
QMap< GSizes, bool > GetGradationSizes() const
QString getGroupLineType(quint32 id)
static VPiecePath ParsePieceNodes(const QDomElement &domElement)
bool IsVariable(const QString &token) const
static const QString IncrementName
static const QString NodeElArc
void InsertTag(const QStringList &tags, const QDomElement &element)
static const QString AttrS30
QString useGroupLineWeight(quint32 toolId, QString weight)
QMap< quint32, Tool > getGroupObjHistory() const
static const QString TagOperation
static const QString AttrS64
static const QString AttrIncludeAs
void showPiece(quint32 id)
void setCursor(const quint32 &value)
static const QString AttrH104
QString getDefaultLineType() const
static const QString AttrH200
void SetNotes(const QString &text)
static const QString IncrementFormula
static const QString AttrH176
bool getActiveNodeElement(const QString &name, QDomElement &element) const
getActiveNodeElement find element in current draft block by name.
void SetCompanyName(const QString &qsName)
QString useGroupLineType(quint32 toolId, QString type)
void SetLabelDateFormat(const QString &format)
static const QString AttrH152
static const QString AttrNodeReverse
QString getActiveDraftBlockName() const
getActiveDraftBlockName return current draft block name.
static const QString AttrS48
QMap< quint32, QString > getGroupsContainingItem(quint32 toolId, quint32 objectId, bool containsItem)
Returns the groups that contain or do not contain the item identified by the toolid and the objectid.
QVector< VFormulaField > ListExpressions() const
quint32 getCursor() const
static const QString AttrNodeExcluded
bool groupNameExists(const QString &groupName)
static const QString TagPath
static const QString TagPiece
static const QString TagCompanyName
static const QString AttrH116
QVector< VDataTool * > toolsOnRemove
QVector< VFormulaField > ListIncrementExpressions() const
static const QString AttrH122
void SetGradationSizes(const QMap< GSizes, bool > &options)
QDomElement CheckTagExists(const QString &tag)
static const QString AttrS24
bool hasGroupItem(const QDomElement &domElement, quint32 toolId, quint32 objectId)
Checks if the given group has the item with the given toolId and objectId.
static void ToolExists(const quint32 &id)
static const QString TagImage
static const QString AttrS42
QVector< VFormulaField > ListPointExpressions() const
static const QString AttrDateFormat
static const QString TagCalculation
QVector< VFormulaField > ListNodesExpressions(const QDomElement &nodes) const
QString getGroupColor(quint32 id)
static const QString AttrH170
static const QString TagGrainline
void setGroupVisibility(quint32 id, bool visible)
QString GetLabelTimeFormat() const
static const QString AttrName
QVector< VFormulaField > ListPieceExpressions() const
static const QString AttrNodeNotchAngle
static const QString AttrNodeIsNotch
qreal getDefaultLineWeight() const
QString GetNotes() const
void SetLabelTimeFormat(const QString &format)
static const QString AttrVisible
static const QString TagPoint
static const QString TagGradation
bool modified
modified keep state of the document for cases that do not cover QUndoStack
QString getDefaultLineColor() const
void changeActiveDraftBlock(const QString &name, const Document &parse=Document::FullParse)
changeActiveDraftBlock set new active draft block name.
static const QString AttrS68
static const QString AttrS72
static const QString AttrNodeNotchWidth
static const QString AttrDefHeight
QVector< VToolRecord > * getHistory()
getHistory return list with list of history records.
static const QString TagNodes
static const QString AttrNodeShowNotch
QVector< VFormulaField > ListSplineExpressions() const
static bool patternLabelWasChanged
static const QString TagIncrements
int getActiveDraftBlockIndex() const
void SetMPath(const QString &path)
void SetDescription(const QString &text)
void patternHasGroups(bool value)
QStringList patternPieces
patternPieces list of patern pieces names for combobox
static const QString TagSizes
static QVector< quint32 > ParsePieceInternalPaths(const QDomElement &domElement)
QVector< VFormulaField > ListPathExpressions() const
static void UpdateId(quint32 newId)
UpdateId update id. If new id bigger when current save new like current.
Definition: vcontainer.cpp:269
The VDataTool class need for getting access to data container of tool.
Definition: vdatatool.h:71
virtual void GroupVisibility(quint32 object, bool visible)=0
The VDomDocument class represents a Seamly2D document (.val file).
Definition: vdomdocument.h:105
QDomElement elementById(quint32 id, const QString &tagName=QString())
static QString GetParametrString(const QDomElement &domElement, const QString &name, const QString &defValue=QString())
Returns the string value of the given attribute. RENAME: see above.
void SetLabelTemplate(QDomElement &element, const QVector< VLabelTemplateLine > &lines)
static quint32 GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
static bool getParameterBool(const QDomElement &domElement, const QString &name, const QString &defValue)
bool setTagText(const QString &tag, const QString &text)
QHash< quint32, QDomElement > map
Map used for finding element by id.
Definition: vdomdocument.h:170
static qreal GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the double value of the given attribute.
static const QString TagVersion
Definition: vdomdocument.h:115
static const QString TagUnit
Definition: vdomdocument.h:116
QString UniqueTagText(const QString &tagName, const QString &defVal=QString()) const
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
Definition: vdomdocument.h:185
static const QString AttrId
Definition: vdomdocument.h:108
static void RemoveAllChildren(QDomElement &domElement)
RemoveAllChildren remove all children from file.
QVector< VLabelTemplateLine > GetLabelTemplate(const QDomElement &element) const
The VExceptionBadId class for exception bad id.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
The VExceptionConversionError class for exception of conversion error.
The VExceptionEmptyParameter class for exception empty parameter.
The VExceptionObjectError class for exception object error.
The VException class parent for all exception. Could be use for abstract exception.
Definition: vexception.h:66
void AddMoreInformation(const QString &info)
AddMoreInformation add more information for error.
Definition: vexception.cpp:107
static const QString PatternMaxVerStr
void setBeforeSAFormula(const QString &formula)
Definition: vpiecenode.cpp:221
void setShowNotch(bool value)
Definition: vpiecenode.cpp:344
void setNotchCount(int notchCount)
Definition: vpiecenode.cpp:399
void SetExcluded(bool exclude)
Definition: vpiecenode.cpp:417
void setNotch(bool notch)
Definition: vpiecenode.cpp:293
void setNotchType(NotchType notchType)
Definition: vpiecenode.cpp:320
void setAfterSAFormula(const QString &formula)
Definition: vpiecenode.cpp:263
void setNotchLength(qreal notchLength)
Definition: vpiecenode.cpp:363
void setNotchWidth(qreal notchWidth)
Definition: vpiecenode.cpp:375
void setShowSeamlineNotch(bool value)
Definition: vpiecenode.cpp:356
void SetAngleType(PieceNodeAngle type)
Definition: vpiecenode.cpp:278
void setNotchAngle(qreal notchAngle)
Definition: vpiecenode.cpp:387
void setNotchSubType(NotchSubType notchSubType)
Definition: vpiecenode.cpp:332
void Append(const VPieceNode &node)
Definition: vpiecepath.cpp:197
const VPieceNode & at(int indx) const
Definition: vpiecepath.cpp:221
The VToolRecord class record about tool in history.
Definition: vtoolrecord.h:64
Tool getTypeTool() const
getTypeTool return tool type.
Definition: vtoolrecord.h:114
quint32 getId() const
getId return tool id.
Definition: vtoolrecord.h:94
QString getDraftBlockName() const
getDraftBlockName return pattern peace name.
Definition: vtoolrecord.h:134
const QStringList builInFunctions
Definition: def.cpp:120
const QString strStraightforward
Definition: def.cpp:627
const QStringList builInPostfixOperators
Definition: def.cpp:133
const QString strSlit
Definition: def.cpp:565
const QString trueStr
Definition: def.cpp:197
const QString falseStr
Definition: def.cpp:198
NotchType stringToNotchType(const QString &value)
Definition: def.cpp:600
NotchSubType stringToNotchSubType(const QString &value)
Definition: def.cpp:650
NotchType
Definition: def.h:123
#define SCASSERT(cond)
Definition: def.h:317
PieceNodeAngle
Definition: def.h:113
NotchSubType
Definition: def.h:137
Tool
Definition: def.h:161
@ NodeSplinePath
@ NodeSpline
@ NodeElArc
@ NodeArc
@ NodePoint
@ LAST_ONE_DO_NOT_USE
PiecePathIncludeType
Definition: def.h:152
const QString AttrPoint2
Definition: ifcdef.cpp:116
const QString AttrC1Radius
Definition: ifcdef.cpp:141
const QString LineTypeByGroup
Definition: ifcdef.cpp:370
const QString AttrKAsm2
Definition: ifcdef.cpp:120
const QString AttrLength
Definition: ifcdef.cpp:94
const QString AttrLineType
Definition: ifcdef.cpp:90
const QString AttrC2Radius
Definition: ifcdef.cpp:142
const QString LineTypeSolidLine
Definition: ifcdef.cpp:159
const QString AttrLineWeight
Definition: ifcdef.cpp:91
const QString AttrAngle
Definition: ifcdef.cpp:103
const QString AttrRadius2
Definition: ifcdef.cpp:102
const QString AttrPoint1
Definition: ifcdef.cpp:115
const QString currentSeamAllowance
Definition: ifcdef.cpp:442
const QString AttrRotationAngle
Definition: ifcdef.cpp:151
const QString ColorBlack
Definition: ifcdef.cpp:373
const QString AttrRadius1
Definition: ifcdef.cpp:101
const QString AttrRadius
Definition: ifcdef.cpp:100
const QString currentLength
Definition: ifcdef.cpp:441
const QStringList builInVariables
Definition: ifcdef.cpp:444
const QString AttrCRadius
Definition: ifcdef.cpp:145
const QString AttrAngle2
Definition: ifcdef.cpp:105
const QString AttrPathPoint
Definition: ifcdef.cpp:123
const QString AttrIdObject
Definition: ifcdef.cpp:148
const QString ColorByGroup
Definition: ifcdef.cpp:371
const QString AttrAngle1
Definition: ifcdef.cpp:104
const QString LineWeightByGroup
Definition: ifcdef.cpp:369
const QString AttrKAsm1
Definition: ifcdef.cpp:119
#define NULL_ID
Definition: ifcdef.h:76
#define NULL_ID_STR
Definition: ifcdef.h:77
void ReadExpressionAttribute(QVector< VFormulaField > &expressions, const QDomElement &element, const QString &attribute)
The CustomSA struct contains record about custom seam allowanse (SA).
Definition: def.h:510
quint32 endPoint
Definition: def.h:521
quint32 path
Definition: def.h:520
quint32 startPoint
Definition: def.h:519
bool reverse
Definition: def.h:522
PiecePathIncludeType includeType
Definition: def.h:523
QDomElement element
Document
#define qApp
Definition: vapplication.h:67