Seamly2D
Code documentation
vpattern.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vpattern.cpp
3  ** @author Douglas S Caskey
4  ** @date Dec 31, 2022
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2022 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 vpattern.cpp
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 24 2, 2014
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) 2013-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 "vpattern.h"
54 #include "../vwidgets/vabstractmainwindow.h"
55 #include "../vtools/tools/vdatatool.h"
56 #include "../vtools/tools/pattern_piece_tool.h"
57 #include "../vtools/tools/union_tool.h"
58 #include "../vtools/tools/drawTools/drawtools.h"
59 #include "../vtools/tools/nodeDetails/nodedetails.h"
60 #include "../ifc/exception/vexceptionobjecterror.h"
61 #include "../ifc/exception/vexceptionwrongid.h"
62 #include "../ifc/exception/vexceptionconversionerror.h"
63 #include "../ifc/exception/vexceptionemptyparameter.h"
64 #include "../ifc/exception/vexceptionundo.h"
65 #include "../ifc/xml/vpatternconverter.h"
66 #include "../vmisc/customevents.h"
67 #include "../vmisc/vsettings.h"
68 #include "../vmisc/vmath.h"
69 #include "../vmisc/projectversion.h"
70 #include "../vmisc/vabstractapplication.h"
71 #include "../qmuparser/qmuparsererror.h"
72 #include "../qmuparser/qmutokenparser.h"
73 #include "../vgeometry/varc.h"
74 #include "../vgeometry/vellipticalarc.h"
75 #include "../vgeometry/vsplinepath.h"
76 #include "../vgeometry/vcubicbezier.h"
77 #include "../vgeometry/vcubicbezierpath.h"
78 #include "../core/vapplication.h"
79 #include "../vpatterndb/vpiecenode.h"
80 #include "../vpatterndb/calculator.h"
81 #include "../vpatterndb/floatItemData/vpiecelabeldata.h"
82 #include "../vpatterndb/floatItemData/vpatternlabeldata.h"
83 #include "../vpatterndb/floatItemData/vgrainlinedata.h"
84 #include "../vpatterndb/vpiecepath.h"
85 #include "../vpatterndb/vnodedetail.h"
86 
87 #include <QMessageBox>
88 #include <QUndoStack>
89 #include <QtNumeric>
90 #include <QDebug>
91 #include <QFileInfo>
92 
93 const QString VPattern::AttrReadOnly = QStringLiteral("readOnly");
94 
95 namespace
96 {
97 //---------------------------------------------------------------------------------------------------------------------
98 QString FileComment()
99 {
100  return QString("Pattern created with Seamly2D v%1 (https://seamly.net).").arg(APP_VERSION_STR);
101 }
102 }
103 
104 //---------------------------------------------------------------------------------------------------------------------
106  VMainGraphicsScene *pieceScene, QObject *parent)
107  : VAbstractPattern(parent),
108  data(data),
109  mode(mode),
110  draftScene(draftScene),
111  pieceScene(pieceScene)
112 {
113  SCASSERT(draftScene != nullptr)
114  SCASSERT(pieceScene != nullptr)
115 }
116 
117 //---------------------------------------------------------------------------------------------------------------------
118 /**
119  * @brief CreateEmptyFile create minimal empty file.
120  */
122 {
123  this->clear();
124  QDomElement patternElement = this->createElement(TagPattern);
125 
126  patternElement.appendChild(createComment(FileComment()));
127 
128  QDomElement version = createElement(TagVersion);
129  QDomText newNodeText = createTextNode(VPatternConverter::PatternMaxVerStr);
130  version.appendChild(newNodeText);
131  patternElement.appendChild(version);
132 
133  QDomElement unit = createElement(TagUnit);
134  newNodeText = createTextNode(UnitsToStr(qApp->patternUnit()));
135  unit.appendChild(newNodeText);
136  patternElement.appendChild(unit);
137 
138  patternElement.appendChild(createElement(TagDescription));
139  patternElement.appendChild(createElement(TagNotes));
140 
141  patternElement.appendChild(createElement(TagMeasurements));
142  patternElement.appendChild(createElement(TagIncrements));
143 
144  this->appendChild(patternElement);
145  insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
146 }
147 
148 //---------------------------------------------------------------------------------------------------------------------
149 void VPattern::setXMLContent(const QString &fileName)
150 {
151  VDomDocument::setXMLContent(fileName);
153 }
154 
155 //---------------------------------------------------------------------------------------------------------------------
156 /**
157  * @brief Parse parse file.
158  * @param parse parser file mode.
159  */
160 void VPattern::Parse(const Document &parse)
161 {
162  qCDebug(vXML, "Parsing pattern.");
163  switch (parse)
164  {
165  case Document::FullParse:
166  qCDebug(vXML, "Full parse.");
167  break;
168  case Document::LiteParse:
169  qCDebug(vXML, "Lite parse.");
170  break;
172  qCDebug(vXML, "Lite draft block parse.");
173  break;
174  default:
175  break;
176  }
177 
178  SCASSERT(draftScene != nullptr)
179  SCASSERT(pieceScene != nullptr)
180  QStringList tags = QStringList() << TagDraftBlock << TagIncrements << TagDescription << TagNotes
183  << TagPatternLabel;
184  PrepareForParse(parse);
185  QDomNode domNode = documentElement().firstChild();
186  while (domNode.isNull() == false)
187  {
188  if (domNode.isElement())
189  {
190  const QDomElement domElement = domNode.toElement();
191  if (domElement.isNull() == false)
192  {
193  switch (tags.indexOf(domElement.tagName()))
194  {
195  case 0: // TagDraftBlock
196  qCDebug(vXML, "Tag draw.");
197  if (parse == Document::FullParse)
198  {
199  if (activeDraftBlock.isEmpty())
200  {
202  }
203  else
204  {
206  }
207  patternPieces << GetParametrString(domElement, AttrName);
208  }
209  else
210  {
212  }
213  parseDraftBlockElement(domElement, parse);
214  break;
215  case 1: // TagIncrements
216  qCDebug(vXML, "Tag increments.");
217  ParseIncrementsElement(domElement);
218  break;
219  case 2: // TagDescription
220  qCDebug(vXML, "Tag description.");
221  break;
222  case 3: // TagNotes
223  qCDebug(vXML, "Tag notes.");
224  break;
225  case 4: // TagMeasurements
226  qCDebug(vXML, "Tag measurements.");
227  break;
228  case 5: // TagVersion
229  qCDebug(vXML, "Tag version.");
230  break;
231  case 6: // TagGradation
232  qCDebug(vXML, "Tag gradation.");
233  break;
234  case 7: // TagImage
235  qCDebug(vXML, "Tag image.");
236  break;
237  case 8: // TagUnit
238  qCDebug(vXML, "Tag unit.");
239  break;
240  case 9: // TagPatternName
241  qCDebug(vXML, "Pattern name.");
242  break;
243  case 10: // TagPatternNumber
244  qCDebug(vXML, "Pattern number.");
245  break;
246  case 11: // TagCompanyName
247  qCDebug(vXML, "Company name.");
248  break;
249  case 12: // TagCustomerName
250  qCDebug(vXML, "Customer name.");
251  break;
252  case 13: // TagPatternLabel
253  qCDebug(vXML, "Pattern label.");
254  break;
255  default:
256  qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
257  break;
258  }
259  }
260  }
261  domNode = domNode.nextSibling();
262  }
263  emit CheckLayout();
264 }
265 
266 //---------------------------------------------------------------------------------------------------------------------
267 /**
268  * @brief setCurrentData set current data set.
269  *
270  * Each time after parsing need set correct data set for current draft block. After parsing it is always last.
271  * Current data set for draft block it is data set for last object in draft block (point, arc, spline, spline path so
272  * on).
273  */
275 {
276  if (*mode == Draw::Calculation)
277  {
278  if (draftBlockCount() > 1)//don't need to update data if we have only one draft block
279  {
280  qCDebug(vXML, "Setting current data");
281  qCDebug(vXML, "Current Draft block name %s", qUtf8Printable(activeDraftBlock));
282  qCDebug(vXML, "Draftf block count %d", draftBlockCount());
283 
284  quint32 id = 0;
285  if (history.size() == 0)
286  {
287  qCDebug(vXML, "History is empty!");
288  return;
289  }
290  for (qint32 i = 0; i < history.size(); ++i)
291  {
292  const VToolRecord tool = history.at(i);
293  if (tool.getDraftBlockName() == activeDraftBlock)
294  {
295  id = tool.getId();
296  }
297  }
298  qCDebug(vXML, "Resoring data from tool with id %u", id);
299  if (id == NULL_ID)
300  {
301  qCDebug(vXML, "Could not find record for this current draft block %s",
302  qUtf8Printable(activeDraftBlock));
303 
304  const VToolRecord tool = history.at(history.size()-1);
305  id = tool.getId();
306  qCDebug(vXML, "Taking record with id %u from Draft block %s", id, qUtf8Printable(tool.getDraftBlockName()));
307  if (id == NULL_ID)
308  {
309  qCDebug(vXML, "Bad id for last record in history.");
310  return;
311  }
312  }
313  if (tools.size() > 0)
314  {
315  try
316  {
317  ToolExists(id);
318  }
319  catch (VExceptionBadId &e)
320  {
321  Q_UNUSED(e)
322  qCDebug(vXML, "List of tools doesn't contain id= %u", id);
323  return;
324  }
325 
326  const VDataTool *vTool = tools.value(id);
327  *data = vTool->getData();
328  //Delete special variables if exist
331  qCDebug(vXML, "Data successfully updated.");
332  }
333  else
334  {
335  qCDebug(vXML, "List of tools is empty!");
336  }
337  }
338  }
339 }
340 
341 //---------------------------------------------------------------------------------------------------------------------
342 /**
343  * @brief UpdateToolData update tool in list tools.
344  * @param id tool id.
345  * @param data container with variables.
346  */
347 void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
348 {
349  Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0"); //-V712 //-V654
350  SCASSERT(data != nullptr)
351  ToolExists(id);
352  VDataTool *tool = tools.value(id);
353  SCASSERT(tool != nullptr)
354  tool->VDataTool::setData(data);
355 }
356 
357 //---------------------------------------------------------------------------------------------------------------------
358 /**
359  * @brief getActiveBasePoint return id base point current draft block.
360  * @return id base point.
361  */
362 // cppcheck-suppress unusedFunction
364 {
365  QDomElement calcElement;
366  if (getActiveNodeElement(TagCalculation, calcElement))
367  {
368  const QDomNode domNode = calcElement.firstChild();
369  if (domNode.isNull() == false && domNode.isElement())
370  {
371  const QDomElement domElement = domNode.toElement();
372  if (domElement.isNull() == false)
373  {
374  if (domElement.tagName() == TagPoint && domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
375  {
376  return getParameterId(domElement);
377  }
378  }
379  }
380  }
381  return 0;
382 }
383 
384 //---------------------------------------------------------------------------------------------------------------------
386 {
387  QVector<quint32> pieces;
388  QDomElement drawElement;
389  if (getActiveDraftElement(drawElement))
390  {
391  const QDomElement elements = drawElement.firstChildElement(TagPieces);
392  if (!elements.isNull())
393  {
394  QDomElement piece = elements.firstChildElement(TagPiece);
395  while(!piece.isNull())
396  {
398  if (!united)
399  {
400  pieces.append(getParameterId(piece));
401  }
402  piece = piece.nextSiblingElement(TagPiece);
403  }
404  }
405  }
406  return pieces;
407 }
408 
409 //---------------------------------------------------------------------------------------------------------------------
410 bool VPattern::SaveDocument(const QString &fileName, QString &error)
411 {
412  try
413  {
414  TestUniqueId();
415  }
416  catch (const VExceptionWrongId &e)
417  {
418  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error not unique id.")),
419  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
420  return false;
421  }
422 
423  // Update comment with Seamly2D version
424  QDomNode commentNode = documentElement().firstChild();
425  if (commentNode.isComment())
426  {
427  QDomComment comment = commentNode.toComment();
428  comment.setData(FileComment());
429  }
430 
431  const bool saved = VAbstractPattern::SaveDocument(fileName, error);
432  if (saved && QFileInfo(fileName).suffix() != QLatin1String("autosave"))
433  {
434  modified = false;
435  }
436 
437  return saved;
438 }
439 
440 //---------------------------------------------------------------------------------------------------------------------
442 {
443  try
444  {
445  emit SetEnabledGUI(true);
446 
449 
450  const QDomNodeList tags = elementsByTagName(TagIncrements);
451  if (not tags.isEmpty())
452  {
453  const QDomNode domElement = tags.at(0);
454  if (not domElement.isNull())
455  {
456  ParseIncrementsElement(domElement);
457  }
458  }
459  }
460  catch (const VExceptionUndo &e)
461  {
462  Q_UNUSED(e)
463  /* If user want undo last operation before undo we need finish broken redo operation. For those we post event
464  * myself. Later in method customEvent call undo.*/
465  QApplication::postEvent(this, new UndoEvent());
466  return;
467  }
468  catch (const VExceptionObjectError &e)
469  {
470  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
471  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
472  emit SetEnabledGUI(false);
473  return;
474  }
475  catch (const VExceptionConversionError &e)
476  {
477  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
478  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
479  emit SetEnabledGUI(false);
480  return;
481  }
482  catch (const VExceptionEmptyParameter &e)
483  {
484  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
485  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
486  emit SetEnabledGUI(false);
487  return;
488  }
489  catch (const VExceptionWrongId &e)
490  {
491  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
492  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
493  emit SetEnabledGUI(false);
494  return;
495  }
496  catch (VException &e)
497  {
498  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
499  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
500  emit SetEnabledGUI(false);
501  return;
502  }
503  catch (const std::bad_alloc &)
504  {
505  qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
506  emit SetEnabledGUI(false);
507  return;
508  }
509 }
510 
511 //---------------------------------------------------------------------------------------------------------------------
512 /**
513  * @brief LiteParseTree lite parse file.
514  */
516 {
517  // Save current draft block name
518  QString draftBlockName = activeDraftBlock;
519 
520  try
521  {
522  emit SetEnabledGUI(true);
523  switch (parse)
524  {
527  break;
528  case Document::LiteParse:
529  Parse(parse);
530  break;
531  case Document::FullParse:
532  qCWarning(vXML, "Lite parsing doesn't support full parsing");
533  break;
534  default:
535  break;
536  }
537  }
538  catch (const VExceptionUndo &e)
539  {
540  Q_UNUSED(e)
541  /* If user want undo last operation before undo we need finish broken redo operation. For those we post event
542  * myself. Later in method customEvent call undo.*/
543  QApplication::postEvent(this, new UndoEvent());
544  return;
545  }
546  catch (const VExceptionObjectError &e)
547  {
548  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
549  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
550  emit SetEnabledGUI(false);
551  if (not VApplication::IsGUIMode())
552  {
553  qApp->exit(V_EX_NOINPUT);
554  }
555  return;
556  }
557  catch (const VExceptionConversionError &e)
558  {
559  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
560  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
561  emit SetEnabledGUI(false);
562  if (not VApplication::IsGUIMode())
563  {
564  qApp->exit(V_EX_NOINPUT);
565  }
566  return;
567  }
568  catch (const VExceptionEmptyParameter &e)
569  {
570  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
571  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
572  emit SetEnabledGUI(false);
573  if (not VApplication::IsGUIMode())
574  {
575  qApp->exit(V_EX_NOINPUT);
576  }
577  return;
578  }
579  catch (const VExceptionWrongId &e)
580  {
581  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
582  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
583  emit SetEnabledGUI(false);
584  if (not VApplication::IsGUIMode())
585  {
586  qApp->exit(V_EX_NOINPUT);
587  }
588  return;
589  }
590  catch (VException &e)
591  {
592  qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
593  qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
594  emit SetEnabledGUI(false);
595  if (not VApplication::IsGUIMode())
596  {
597  qApp->exit(V_EX_NOINPUT);
598  }
599  return;
600  }
601  catch (const std::bad_alloc &)
602  {
603  qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
604  emit SetEnabledGUI(false);
605  if (not VApplication::IsGUIMode())
606  {
607  qApp->exit(V_EX_NOINPUT);
608  }
609  return;
610  }
611 
612  // Restore name current draft block
613  activeDraftBlock = draftBlockName;
614  qCDebug(vXML, "Current draft block %s", qUtf8Printable(activeDraftBlock));
615  setCurrentData();
616  emit FullUpdateFromFile();
617  // Recalculate scene rect
620  qCDebug(vXML, "Scene size updated.");
621 }
622 
623 //---------------------------------------------------------------------------------------------------------------------
624 // cppcheck-suppress unusedFunction
625 void VPattern::customEvent(QEvent *event)
626 {
627  if (event->type() == UNDO_EVENT)
628  {
629  qApp->getUndoStack()->undo();
630  }
631  else if (event->type() == LITE_PARSE_EVENT)
632  {
634  }
635 }
636 
637 //---------------------------------------------------------------------------------------------------------------------
638 VNodeDetail VPattern::parsePieceNode(const QDomElement &domElement) const
639 {
640  const quint32 id = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
641  const qreal mx = GetParametrDouble(domElement, AttrMx, "0.0");
642  const qreal my = GetParametrDouble(domElement, AttrMy, "0.0");
643  const bool reverse = GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0");
644  const NodeDetail nodeType = NodeDetail::Contour;
645 
646  const QString t = GetParametrString(domElement, AttrType, "NodePoint");
647  Tool tool;
648 
649  QStringList types = QStringList() << VAbstractPattern::NodePoint
654  switch (types.indexOf(t))
655  {
656  case 0: // NodePoint
657  tool = Tool::NodePoint;
658  break;
659  case 1: // NodeArc
660  tool = Tool::NodeArc;
661  break;
662  case 2: // NodeSpline
663  tool = Tool::NodeSpline;
664  break;
665  case 3: // NodeSplinePath
666  tool = Tool::NodeSplinePath;
667  break;
668  case 4: // NodeElArc
669  tool = Tool::NodeElArc;
670  break;
671  default:
672  VException e(tr("Wrong tag name '%1'.").arg(t));
673  throw e;
674  }
675  return VNodeDetail(id, tool, nodeType, mx, my, reverse);
676 }
677 
678 //---------------------------------------------------------------------------------------------------------------------
679 /**
680  * @brief parseDraftBlockElement parse draw tag.
681  * @param node node.
682  * @param parse parser file mode.
683  */
684 void VPattern::parseDraftBlockElement(const QDomNode &node, const Document &parse)
685 {
686  QStringList tags = QStringList() << TagCalculation << TagModeling << TagPieces << TagGroups;
687  QDomNode domNode = node.firstChild();
688  while (domNode.isNull() == false)
689  {
690  if (domNode.isElement())
691  {
692  const QDomElement domElement = domNode.toElement();
693  if (domElement.isNull() == false)
694  {
695  switch (tags.indexOf(domElement.tagName()))
696  {
697  case 0: // TagCalculation
698  qCDebug(vXML, "Tag calculation.");
700  ParseDrawMode(domElement, parse, Draw::Calculation);
701  break;
702  case 1: // TagModeling
703  qCDebug(vXML, "Tag modeling.");
704  ParseDrawMode(domElement, parse, Draw::Modeling);
705  break;
706  case 2: // TagPieces
707  qCDebug(vXML, "Tag pieces.");
708  parsePatternPieces(domElement, parse);
709  break;
710  case 3: // TagGroups
711  qCDebug(vXML, "Tag groups.");
712  parseGroups(domElement);
713  break;
714  default:
715  VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
716  throw e;
717  }
718  }
719  }
720  domNode = domNode.nextSibling();
721  }
722 }
723 
724 //---------------------------------------------------------------------------------------------------------------------
725 /**
726  * @brief ParseDrawMode parse draw tag with draw mode.
727  * @param node node.
728  * @param parse parser file mode.
729  * @param mode draw mode.
730  */
731 void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const Draw &mode)
732 {
733  SCASSERT(draftScene != nullptr)
734  SCASSERT(pieceScene != nullptr)
735  VMainGraphicsScene *scene = nullptr;
736  if (mode == Draw::Calculation)
737  {
738  scene = draftScene;
739  }
740  else
741  {
742  scene = pieceScene;
743  }
744  const QStringList tags = QStringList() << TagPoint
745  << TagLine
746  << TagSpline
747  << TagArc
748  << TagTools
749  << TagOperation
750  << TagElArc
751  << TagPath;
752  const QDomNodeList nodeList = node.childNodes();
753  const qint32 num = nodeList.size();
754  for (qint32 i = 0; i < num; ++i)
755  {
756  QDomElement domElement = nodeList.at(i).toElement();
757  if (domElement.isNull() == false)
758  {
759  switch (tags.indexOf(domElement.tagName()))
760  {
761  case 0: // TagPoint
762  qCDebug(vXML, "Tag point.");
763  ParsePointElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
764  break;
765  case 1: // TagLine
766  qCDebug(vXML, "Tag line.");
767  ParseLineElement(scene, domElement, parse);
768  break;
769  case 2: // TagSpline
770  qCDebug(vXML, "Tag spline.");
771  ParseSplineElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
772  break;
773  case 3: // TagArc
774  qCDebug(vXML, "Tag arc.");
775  ParseArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
776  break;
777  case 4: // TagTools
778  qCDebug(vXML, "Tag tools.");
779  ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
780  break;
781  case 5: // TagOperation
782  qCDebug(vXML, "Tag operation.");
783  ParseOperationElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
784  break;
785  case 6: // TagElArc
786  qCDebug(vXML, "Tag elliptical arc.");
787  ParseEllipticalArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
788  break;
789  case 7: // TagPath
790  qCDebug(vXML, "Tag path.");
791  ParsePathElement(scene, domElement, parse);
792  break;
793  default:
794  VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
795  throw e;
796  }
797  }
798  }
799 }
800 
801 //---------------------------------------------------------------------------------------------------------------------
802 /**
803  * @brief parsePieceElement parse piece tag.
804  * @param domElement tag in xml tree.
805  * @param parse parser file mode.
806  */
807 void VPattern::parsePieceElement(QDomElement &domElement, const Document &parse)
808 {
809  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
810  try
811  {
812  VPiece piece;
813  const quint32 id = getParameterId(domElement);
814  piece.SetName(GetParametrString(domElement, AttrName, tr("Piece")));
815  piece.setColor(GetParametrString(domElement, PatternPieceTool::AttrPieceColor, tr("white")));
816  piece.setFill(GetParametrString(domElement, PatternPieceTool::AttrPieceFill, tr("nobrush")));
818 
819  piece.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0")));
820  piece.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0")));
823  QString().setNum(qApp->Seamly2DSettings()->isHideSeamLine())));
825  falseStr));
827  QString().setNum(qApp->Seamly2DSettings()->getForbidPieceFlipping())));
828  piece.SetInLayout(getParameterBool(domElement, AttrInLayout, trueStr));
830 
831  const QString width = GetParametrString(domElement, AttrWidth, "0.0");
832  QString w = width;//need for saving fixed formula;
833  const uint version = GetParametrUInt(domElement, PatternPieceTool::AttrVersion, "1");
834 
835  const QStringList tags = QStringList() << TagNodes
836  << TagData
837  << TagPatternInfo
838  << TagGrainline
842 
843  const QDomNodeList nodeList = domElement.childNodes();
844  for (qint32 i = 0; i < nodeList.size(); ++i)
845  {
846  const QDomElement element = nodeList.at(i).toElement();
847  if (not element.isNull())
848  {
849  switch (tags.indexOf(element.tagName()))
850  {
851  case 0:// TagNodes
852  if (version == 1)
853  {
854  // TODO. Delete if minimal supported version is 0.4.0
856  "Time to refactor the code.");
857  const bool closed = GetParametrUInt(domElement, AttrClosed, "1");
858  const qreal width = GetParametrDouble(domElement, AttrWidth, "0.0");
859  parsePieceNodes(element, piece, width, closed);
860  }
861  else
862  {
863  piece.SetPath(ParsePieceNodes(element));
864  }
865  break;
866  case 1:// TagData
867  ParsePieceDataTag(element, piece);
868  break;
869  case 2:// TagPatternInfo
870  ParsePiecePatternInfo(element, piece);
871  break;
872  case 3:// TagGrainline
873  ParsePieceGrainline(element, piece);
874  break;
875  case 4:// PatternPieceTool::TagCSA
877  break;
878  case 5:// PatternPieceTool::TagIPaths
880  break;
881  case 6:// PatternPieceTool::TagAnchors
882  piece.setAnchors(ParsePieceAnchors(element));
883  break;
884  default:
885  break;
886  }
887  }
888  }
889  PatternPieceTool::Create(id, piece, w, pieceScene, this, data, parse, Source::FromFile);
890  //Rewrite attribute formula. Need for situation when we have wrong formula.
891  if (w != width)
892  {
893  SetAttribute(domElement, AttrWidth, w);
894  modified = true;
895  haveLiteChange();
896  }
897  }
898  catch (const VExceptionBadId &e)
899  {
900  VExceptionObjectError excep(tr("Error creating or updating piece"), domElement);
901  excep.AddMoreInformation(e.ErrorMessage());
902  throw excep;
903  }
904 }
905 
906 //---------------------------------------------------------------------------------------------------------------------
907 void VPattern::parsePieceNodes(const QDomElement &domElement, VPiece &piece, qreal width, bool closed) const
908 {
909  QVector<VNodeDetail> oldNodes;
910  const QDomNodeList nodeList = domElement.childNodes();
911  for (qint32 i = 0; i < nodeList.size(); ++i)
912  {
913  const QDomElement element = nodeList.at(i).toElement();
914  if (not element.isNull()
915  && element.tagName() == VAbstractPattern::TagNode) // Old piece version need this check!
916  {
917  oldNodes.append(parsePieceNode(element));
918  }
919  }
920 
921  piece.GetPath().SetNodes(VNodeDetail::Convert(data, oldNodes, width, closed));
922 }
923 
924 //---------------------------------------------------------------------------------------------------------------------
925 void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &piece) const
926 {
927  VPieceLabelData &ppData = piece.GetPatternPieceData();
928  ppData.SetVisible(getParameterBool(domElement, AttrVisible, trueStr));
929  ppData.SetLetter(GetParametrEmptyString(domElement, AttrLetter));
933  ppData.SetTilt(GetParametrEmptyString(domElement, AttrTilt));
935  ppData.SetQuantity(static_cast<int>(GetParametrUInt(domElement, AttrQuantity, "1")));
936  ppData.SetOnFold(getParameterBool(domElement, AttrOnFold, falseStr));
937  ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
938  ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
940  ppData.SetFontSize(static_cast<int>(GetParametrUInt(domElement, PatternPieceTool::AttrFont, "0")));
941  ppData.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
945  ppData.SetLabelTemplate(GetLabelTemplate(domElement));
946 }
947 
948 //---------------------------------------------------------------------------------------------------------------------
949 void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &piece) const
950 {
951  VPatternLabelData &patternInfo = piece.GetPatternInfo();
952  patternInfo.SetVisible(getParameterBool(domElement, AttrVisible, trueStr));
953  patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
954  patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
955  patternInfo.SetLabelHeight(GetParametrString(domElement, PatternPieceTool::AttrHeight, "1"));
956  patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, PatternPieceTool::AttrFont, "0")));
957  patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
961 }
962 
963 //---------------------------------------------------------------------------------------------------------------------
964 void VPattern::ParsePieceGrainline(const QDomElement &domElement, VPiece &piece) const
965 {
966  VGrainlineData &gGeometry = piece.GetGrainlineGeometry();
967  gGeometry.SetVisible(getParameterBool(domElement, AttrVisible, falseStr));
968  gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
969  gGeometry.SetLength(GetParametrString(domElement, AttrLength, "1"));
970  gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, "90"));
971  gGeometry.SetArrowType(static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0")));
975 }
976 
977 //---------------------------------------------------------------------------------------------------------------------
978 /**
979  * @brief parsePatternPieces parse pieces tag.
980  * @param domElement tag in xml tree.
981  * @param parse parser file mode.
982  */
983 void VPattern::parsePatternPieces(const QDomElement &domElement, const Document &parse)
984 {
985  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
986  QDomNode domNode = domElement.firstChild();
987  while (domNode.isNull() == false)
988  {
989  if (domNode.isElement())
990  {
991  QDomElement domElement = domNode.toElement();
992  if (domElement.isNull() == false)
993  {
994  if (domElement.tagName() == TagPiece)
995  {
996  parsePieceElement(domElement, parse);
997  }
998  }
999  }
1000  domNode = domNode.nextSibling();
1001  }
1002 }
1003 
1004 //---------------------------------------------------------------------------------------------------------------------
1005 void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my,
1006  bool &isVisible, QString &lineType, QString &lineWeight, QString &lineColor)
1007 {
1008  PointsCommonAttributes(domElement, id, name, mx, my, isVisible);
1009  lineType = GetParametrString(domElement, AttrLineType, LineTypeSolidLine);
1010  lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
1011  lineColor = GetParametrString(domElement, AttrLineColor, qApp->Settings()->getPointNameColor());
1012 }
1013 
1014 //---------------------------------------------------------------------------------------------------------------------
1015 void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name,
1016  qreal &mx, qreal &my, bool &isVisible)
1017 {
1018  PointsCommonAttributes(domElement, id, mx, my);
1019  name = GetParametrString(domElement, AttrName, "A");
1020  isVisible = getParameterBool(domElement, AttrShowPointName, trueStr);
1021 
1022 }
1023 
1024 //---------------------------------------------------------------------------------------------------------------------
1025 void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my)
1026 {
1027  ToolsCommonAttributes(domElement, id);
1028  mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, "10.0"));
1029  my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, "15.0"));
1030 }
1031 
1032 //---------------------------------------------------------------------------------------------------------------------
1033 /**
1034  * @brief ParsePointElement parse point tag.
1035  * @param scene scene.
1036  * @param domElement tag in xml tree.
1037  * @param parse parser file mode.
1038  * @param type type of point.
1039  */
1040 void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
1041  const Document &parse, const QString &type)
1042 {
1043  SCASSERT(scene != nullptr)
1044  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1045  Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of point is empty");
1046 
1047  QStringList points = QStringList() << VToolBasePoint::ToolType /*0*/
1048  << VToolEndLine::ToolType /*1*/
1049  << VToolAlongLine::ToolType /*2*/
1051  << VToolNormal::ToolType /*4*/
1052  << VToolBisector::ToolType /*5*/
1055  << VNodePoint::ToolType /*8*/
1056  << VToolHeight::ToolType /*9*/
1057  << VToolTriangle::ToolType /*10*/
1059  << VToolCutSpline::ToolType /*12*/
1061  << VToolCutArc::ToolType /*14*/
1068  << VToolTrueDarts::ToolType /*21*/
1070  << AnchorPointTool::ToolType; /*23*/
1071  switch (points.indexOf(type))
1072  {
1073  case 0: //VToolBasePoint::ToolType
1074  ParseToolBasePoint(scene, domElement, parse);
1075  break;
1076  case 1: //VToolEndLine::ToolType
1077  ParseToolEndLine(scene, domElement, parse);
1078  break;
1079  case 2: //VToolAlongLine::ToolType
1080  ParseToolAlongLine(scene, domElement, parse);
1081  break;
1082  case 3: //VToolShoulderPoint::ToolType
1083  ParseToolShoulderPoint(scene, domElement, parse);
1084  break;
1085  case 4: //VToolNormal::ToolType
1086  ParseToolNormal(scene, domElement, parse);
1087  break;
1088  case 5: //VToolBisector::ToolType
1089  ParseToolBisector(scene, domElement, parse);
1090  break;
1091  case 6: //VToolLineIntersect::ToolType
1092  ParseToolLineIntersect(scene, domElement, parse);
1093  break;
1094  case 7: //VToolPointOfContact::ToolType
1095  ParseToolPointOfContact(scene, domElement, parse);
1096  break;
1097  case 8: //VNodePoint::ToolType
1098  ParseNodePoint(domElement, parse);
1099  break;
1100  case 9: //VToolHeight::ToolType
1101  ParseToolHeight(scene, domElement, parse);
1102  break;
1103  case 10: //VToolTriangle::ToolType
1104  ParseToolTriangle(scene, domElement, parse);
1105  break;
1106  case 11: //PointIntersectXYTool::ToolType
1107  parseIntersectXYTool(scene, domElement, parse);
1108  break;
1109  case 12: //VToolCutSpline::ToolType
1110  ParseToolCutSpline(scene, domElement, parse);
1111  break;
1112  case 13: //VToolCutSplinePath::ToolType
1113  ParseToolCutSplinePath(scene, domElement, parse);
1114  break;
1115  case 14: //VToolCutArc::ToolType
1116  ParseToolCutArc(scene, domElement, parse);
1117  break;
1118  case 15: //VToolLineIntersectAxis::ToolType
1119  ParseToolLineIntersectAxis(scene, domElement, parse);
1120  break;
1121  case 16: //VToolCurveIntersectAxis::ToolType
1122  ParseToolCurveIntersectAxis(scene, domElement, parse);
1123  break;
1124  case 17: //VToolPointOfIntersectionArcs::ToolType
1125  ParseToolPointOfIntersectionArcs(scene, domElement, parse);
1126  break;
1127  case 18: //IntersectCirclesTool::ToolType
1128  ParseToolPointOfIntersectionCircles(scene, domElement, parse);
1129  break;
1130  case 19: //IntersectCircleTangentTool::ToolType
1131  ParseToolPointFromCircleAndTangent(scene, domElement, parse);
1132  break;
1133  case 20: //VToolPointFromArcAndTangent::ToolType
1134  ParseToolPointFromArcAndTangent(scene, domElement, parse);
1135  break;
1136  case 21: //VToolTrueDarts::ToolType
1137  ParseToolTrueDarts(scene, domElement, parse);
1138  break;
1139  case 22: //VToolPointOfIntersectionCurves::ToolType
1140  ParseToolPointOfIntersectionCurves(scene, domElement, parse);
1141  break;
1142  case 23: //AnchorPointTool::ToolType
1143  ParseAnchorPoint(domElement, parse);
1144  break;
1145  default:
1146  VException e(tr("Unknown point type '%1'.").arg(type));
1147  throw e;
1148  }
1149 }
1150 
1151 //---------------------------------------------------------------------------------------------------------------------
1152 /**
1153  * @brief ParseLineElement parse line tag.
1154  * @param scene scene.
1155  * @param domElement tag in xml tree.
1156  * @param parse parser file mode.
1157  */
1158 void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
1159  const Document &parse)
1160 {
1161  SCASSERT(scene != nullptr)
1162  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1163  try
1164  {
1165  quint32 id = 0;
1166  ToolsCommonAttributes(domElement, id);
1167  const quint32 firstPoint = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1168  const quint32 secondPoint = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1169  const QString lineType = GetParametrString(domElement, AttrLineType, LineTypeSolidLine);
1170  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
1171  const QString lineColor = GetParametrString(domElement, AttrLineColor, ColorBlack);
1172 
1173  VToolLine::Create(id, firstPoint, secondPoint, lineType, lineWeight, lineColor, scene, this, data, parse, Source::FromFile);
1174  }
1175  catch (const VExceptionBadId &e)
1176  {
1177  VExceptionObjectError excep(tr("Error creating or updating line"), domElement);
1178  excep.AddMoreInformation(e.ErrorMessage());
1179  throw excep;
1180  }
1181 }
1182 
1183 //---------------------------------------------------------------------------------------------------------------------
1184 void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
1185 {
1186  ToolsCommonAttributes(domElement, id);
1187  idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
1188  idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
1189 }
1190 
1191 //---------------------------------------------------------------------------------------------------------------------
1193 {
1194  QDomElement domElement;
1195  if (getActiveDraftElement(domElement))
1196  {
1198  }
1199  emit CheckLayout();
1200 }
1201 
1202 //---------------------------------------------------------------------------------------------------------------------
1203 QString VPattern::GetLabelBase(quint32 index) const
1204 {
1205  const QStringList list = VApplication::LabelLanguages();
1206  const QString def = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
1207  QStringList alphabet;
1208  switch (list.indexOf(qApp->Seamly2DSettings()->GetLabelLanguage()))
1209  {
1210  case 0: // de
1211  {
1212  const QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z");
1213  alphabet = al.split(",");
1214  break;
1215  }
1216  case 2: // fr
1217  {
1218  const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
1219  alphabet = al.split(",");
1220  break;
1221  }
1222  case 3: // ru
1223  {
1224  const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я");
1225  alphabet = al.split(",");
1226  break;
1227  }
1228  case 4: // uk
1229  {
1230  const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я");
1231  alphabet = al.split(",");
1232  break;
1233  }
1234  case 5: // hr
1235  case 7: // bs
1236  {
1237  const QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž");
1238  alphabet = al.split(",");
1239  break;
1240  }
1241  case 6: // sr
1242  {
1243  const QString al = QStringLiteral("А,Б,В,Г,Д,Ђ,Е,Ж,З,И,Ј,К,Л,Љ,М,Н,Њ,О,П,Р,С,Т,Ћ,У,Ф,Х,Ц,Ч,Џ,Ш");
1244  alphabet = al.split(",");
1245  break;
1246  }
1247  case 1: // en
1248  default: // en
1249  {
1250  alphabet = def.split(",");
1251  break;
1252  }
1253  }
1254 
1255  QString base;
1256  const int count = qFloor(index/static_cast<quint32>(alphabet.size()));
1257  const int number = static_cast<int>(index) - alphabet.size() * count;
1258  int i = 0;
1259  do
1260  {
1261  base.append(alphabet.at(number));
1262  ++i;
1263  } while (i < count);
1264  return base;
1265 }
1266 
1267 //---------------------------------------------------------------------------------------------------------------------
1268 void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
1269 {
1270  SCASSERT(scene != nullptr)
1271  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1272 
1273  VToolBasePoint *spoint = nullptr;
1274  try
1275  {
1276  quint32 id = 0;
1277  QString name;
1278  qreal mx = 0;
1279  qreal my = 0;
1280  bool showPointName = true;
1281 
1282  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1283  const qreal x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0"));
1284  const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0"));
1285 
1286  VPointF *point = new VPointF(x, y, name, mx, my);
1287  point->setShowPointName(showPointName);
1288  spoint = VToolBasePoint::Create(id, activeDraftBlock, point, scene, this, data, parse, Source::FromFile);
1289  }
1290  catch (const VExceptionBadId &e)
1291  {
1292  VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
1293  excep.AddMoreInformation(e.ErrorMessage());
1294  scene->removeItem(spoint);
1295  delete spoint;
1296  throw excep;
1297  }
1298 }
1299 
1300 //---------------------------------------------------------------------------------------------------------------------
1301 void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1302 {
1303  SCASSERT(scene != nullptr)
1304  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1305 
1306  try
1307  {
1308  quint32 id = 0;
1309  QString name;
1310  qreal mx = 0;
1311  qreal my = 0;
1312  QString lineType;
1313  QString lineWeight;
1314  QString lineColor;
1315  bool showPointName = true;
1316 
1317  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1318 
1319  const QString formula = GetParametrString(domElement, AttrLength, "100.0");
1320  QString f = formula;//need for saving fixed formula;
1321 
1322  const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
1323 
1324  const QString angle = GetParametrString(domElement, AttrAngle, "0.0");
1325  QString angleFix = angle;
1326 
1327  VToolEndLine::Create(id, name, lineType, lineWeight, lineColor, f, angleFix, basePointId, mx, my, showPointName, scene, this, data,
1328  parse, Source::FromFile);
1329  //Rewrite attribute formula. Need for situation when we have wrong formula.
1330  if (f != formula || angleFix != angle)
1331  {
1332  SetAttribute(domElement, AttrLength, f);
1333  SetAttribute(domElement, AttrAngle, angleFix);
1334  modified = true;
1335  haveLiteChange();
1336  }
1337  }
1338  catch (const VExceptionBadId &e)
1339  {
1340  VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
1341  excep.AddMoreInformation(e.ErrorMessage());
1342  throw excep;
1343  }
1344  catch (qmu::QmuParserError &e)
1345  {
1346  VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
1347  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1348  throw excep;
1349  }
1350 }
1351 
1352 //---------------------------------------------------------------------------------------------------------------------
1353 void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1354 {
1355  SCASSERT(scene != nullptr)
1356  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1357 
1358  try
1359  {
1360  quint32 id = 0;
1361  QString name;
1362  qreal mx = 0;
1363  qreal my = 0;
1364  QString lineType;
1365  QString lineWeight;
1366  QString lineColor;
1367  bool showPointName = true;
1368 
1369  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1370  const QString formula = GetParametrString(domElement, AttrLength, "100.0");
1371  QString f = formula;//need for saving fixed formula;
1372  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1373  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1374 
1375  VToolAlongLine::Create(id, name, lineType, lineWeight, lineColor, f, firstPointId, secondPointId, mx, my, showPointName, scene,
1376  this, data, parse, Source::FromFile);
1377  //Rewrite attribute formula. Need for situation when we have wrong formula.
1378  if (f != formula)
1379  {
1380  SetAttribute(domElement, AttrLength, f);
1381  modified = true;
1382  haveLiteChange();
1383  }
1384  }
1385  catch (const VExceptionBadId &e)
1386  {
1387  VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
1388  excep.AddMoreInformation(e.ErrorMessage());
1389  throw excep;
1390  }
1391  catch (qmu::QmuParserError &e)
1392  {
1393  VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
1394  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1395  throw excep;
1396  }
1397 }
1398 
1399 //---------------------------------------------------------------------------------------------------------------------
1400 void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1401 {
1402  SCASSERT(scene != nullptr)
1403  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1404 
1405  try
1406  {
1407  quint32 id = 0;
1408  QString name;
1409  qreal mx = 0;
1410  qreal my = 0;
1411  QString lineType;
1412  QString lineWeight;
1413  QString lineColor;
1414  bool showPointName = true;
1415 
1416  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1417  const QString formula = GetParametrString(domElement, AttrLength, "100.0");
1418  QString f = formula;//need for saving fixed formula;
1419  const quint32 p1Line = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
1420  const quint32 p2Line = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
1421  const quint32 pShoulder = GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR);
1422 
1423  VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, lineType, lineWeight, lineColor, name, mx, my,
1424  showPointName, scene, this, data, parse, Source::FromFile);
1425  //Rewrite attribute formula. Need for situation when we have wrong formula.
1426  if (f != formula)
1427  {
1428  SetAttribute(domElement, AttrLength, f);
1429  modified = true;
1430  haveLiteChange();
1431  }
1432  }
1433  catch (const VExceptionBadId &e)
1434  {
1435  VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
1436  excep.AddMoreInformation(e.ErrorMessage());
1437  throw excep;
1438  }
1439  catch (qmu::QmuParserError &e)
1440  {
1441  VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
1442  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1443  throw excep;
1444  }
1445 }
1446 
1447 //---------------------------------------------------------------------------------------------------------------------
1448 void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1449 {
1450  SCASSERT(scene != nullptr)
1451  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1452 
1453  try
1454  {
1455  quint32 id = 0;
1456  QString name;
1457  qreal mx = 0;
1458  qreal my = 0;
1459  QString lineType;
1460  QString lineWeight;
1461  QString lineColor;
1462  bool showPointName = true;
1463 
1464  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1465  const QString formula = GetParametrString(domElement, AttrLength, "100.0");
1466  QString f = formula;//need for saving fixed formula;
1467  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1468  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1469  const qreal angle = GetParametrDouble(domElement, AttrAngle, "0.0");
1470 
1471  VToolNormal::Create(id, f, firstPointId, secondPointId, lineType, lineWeight, lineColor, name, angle,
1472  mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1473  //Rewrite attribute formula. Need for situation when we have wrong formula.
1474  if (f != formula)
1475  {
1476  SetAttribute(domElement, AttrLength, f);
1477  modified = true;
1478  haveLiteChange();
1479  }
1480  }
1481  catch (const VExceptionBadId &e)
1482  {
1483  VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
1484  excep.AddMoreInformation(e.ErrorMessage());
1485  throw excep;
1486  }
1487  catch (qmu::QmuParserError &e)
1488  {
1489  VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
1490  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1491  throw excep;
1492  }
1493 }
1494 
1495 //---------------------------------------------------------------------------------------------------------------------
1496 void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1497 {
1498  SCASSERT(scene != nullptr)
1499  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1500 
1501  try
1502  {
1503  quint32 id = 0;
1504  QString name;
1505  qreal mx = 0;
1506  qreal my = 0;
1507  QString lineType;
1508  QString lineWeight;
1509  QString lineColor;
1510  bool showPointName = true;
1511 
1512  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1513  const QString formula = GetParametrString(domElement, AttrLength, "100.0");
1514  QString f = formula;//need for saving fixed formula;
1515  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1516  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1517  const quint32 thirdPointId = GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR);
1518 
1519  VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId,
1520  lineType, lineWeight, lineColor, name, mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1521  //Rewrite attribute formula. Need for situation when we have wrong formula.
1522  if (f != formula)
1523  {
1524  SetAttribute(domElement, AttrLength, f);
1525  modified = true;
1526  haveLiteChange();
1527  }
1528  }
1529  catch (const VExceptionBadId &e)
1530  {
1531  VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
1532  excep.AddMoreInformation(e.ErrorMessage());
1533  throw excep;
1534  }
1535  catch (qmu::QmuParserError &e)
1536  {
1537  VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
1538  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1539  throw excep;
1540  }
1541 }
1542 
1543 //---------------------------------------------------------------------------------------------------------------------
1544 void VPattern::ParseToolLineIntersect(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
1545 {
1546  SCASSERT(scene != nullptr)
1547  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1548 
1549  try
1550  {
1551  quint32 id = 0;
1552  QString name;
1553  qreal mx = 0;
1554  qreal my = 0;
1555  bool showPointName = true;
1556 
1557  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1558  const quint32 p1Line1Id = GetParametrUInt(domElement, AttrP1Line1, NULL_ID_STR);
1559  const quint32 p2Line1Id = GetParametrUInt(domElement, AttrP2Line1, NULL_ID_STR);
1560  const quint32 p1Line2Id = GetParametrUInt(domElement, AttrP1Line2, NULL_ID_STR);
1561  const quint32 p2Line2Id = GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR);
1562 
1563  VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name,
1564  mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1565  }
1566  catch (const VExceptionBadId &e)
1567  {
1568  VExceptionObjectError excep(tr("Error creating or updating point of line intersection"), domElement);
1569  excep.AddMoreInformation(e.ErrorMessage());
1570  throw excep;
1571  }
1572 }
1573 
1574 //---------------------------------------------------------------------------------------------------------------------
1575 void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1576 {
1577  SCASSERT(scene != nullptr)
1578  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1579 
1580  try
1581  {
1582  quint32 id = 0;
1583  QString name;
1584  qreal mx = 0;
1585  qreal my = 0;
1586  bool showPointName = true;
1587 
1588  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1589  const QString radius = GetParametrString(domElement, AttrRadius, "0");
1590  QString f = radius;//need for saving fixed formula;
1591  const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
1592  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1593  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1594 
1595  VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, showPointName, scene, this,
1596  data, parse, Source::FromFile);
1597  //Rewrite attribute formula. Need for situation when we have wrong formula.
1598  if (f != radius)
1599  {
1600  SetAttribute(domElement, AttrRadius, f);
1601  modified = true;
1602  haveLiteChange();
1603  }
1604  }
1605  catch (const VExceptionBadId &e)
1606  {
1607  VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
1608  excep.AddMoreInformation(e.ErrorMessage());
1609  throw excep;
1610  }
1611  catch (qmu::QmuParserError &e)
1612  {
1613  VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
1614  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1615  throw excep;
1616  }
1617 }
1618 
1619 //---------------------------------------------------------------------------------------------------------------------
1620 void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &parse)
1621 {
1622  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1623 
1624  try
1625  {
1626  quint32 id = 0;
1627  qreal mx = 0;
1628  qreal my = 0;
1629 
1630  PointsCommonAttributes(domElement, id, mx, my);
1631  const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
1632  const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
1634  try
1635  {
1636  point = data->GeometricObject<VPointF>(idObject);
1637  }
1638  catch (const VExceptionBadId &e)
1639  { // Possible case. Parent was deleted, but the node object is still here.
1640  Q_UNUSED(e)
1641  return;// Just ignore
1642  }
1643 
1644  VPointF *nodePoint = new VPointF(static_cast<QPointF>(*point), point->name(), mx, my, idObject, Draw::Modeling);
1645  nodePoint->setShowPointName(getParameterBool(domElement, AttrShowPointName, trueStr));
1646 
1647  data->UpdateGObject(id, nodePoint);
1648  VNodePoint::Create(this, data, pieceScene, id, idObject, parse, Source::FromFile, "", idTool);
1649  }
1650  catch (const VExceptionBadId &e)
1651  {
1652  VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement);
1653  excep.AddMoreInformation(e.ErrorMessage());
1654  throw excep;
1655  }
1656 }
1657 
1658 //---------------------------------------------------------------------------------------------------------------------
1659 void VPattern::ParseAnchorPoint(const QDomElement &domElement, const Document &parse)
1660 {
1661  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1662 
1663  try
1664  {
1665  quint32 id = 0;
1666 
1667  ToolsCommonAttributes(domElement, id);
1668  const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
1669  const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
1670  AnchorPointTool::Create(id, idObject, NULL_ID, this, data, parse, Source::FromFile, "", idTool);
1671  }
1672  catch (const VExceptionBadId &e)
1673  {
1674  VExceptionObjectError excep(tr("Error creating or updating anchor point"), domElement);
1675  excep.AddMoreInformation(e.ErrorMessage());
1676  throw excep;
1677  }
1678 }
1679 
1680 //---------------------------------------------------------------------------------------------------------------------
1681 void VPattern::ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
1682 {
1683  SCASSERT(scene != nullptr)
1684  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1685 
1686  try
1687  {
1688  quint32 id = 0;
1689  QString name;
1690  qreal mx = 0;
1691  qreal my = 0;
1692  QString lineType;
1693  QString lineWeight;
1694  QString lineColor;
1695  bool showPointName = true;
1696 
1697  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1698  const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
1699  const quint32 p1LineId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
1700  const quint32 p2LineId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
1701 
1702  VToolHeight::Create(id, name, lineType, lineWeight, lineColor, basePointId, p1LineId, p2LineId,
1703  mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1704  }
1705  catch (const VExceptionBadId &e)
1706  {
1707  VExceptionObjectError excep(tr("Error creating or updating height"), domElement);
1708  excep.AddMoreInformation(e.ErrorMessage());
1709  throw excep;
1710  }
1711 }
1712 
1713 //---------------------------------------------------------------------------------------------------------------------
1714 void VPattern::ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
1715 {
1716  SCASSERT(scene != nullptr)
1717  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1718 
1719  try
1720  {
1721  quint32 id = 0;
1722  QString name;
1723  qreal mx = 0;
1724  qreal my = 0;
1725  bool showPointName = true;
1726 
1727  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1728  const quint32 axisP1Id = GetParametrUInt(domElement, AttrAxisP1, NULL_ID_STR);
1729  const quint32 axisP2Id = GetParametrUInt(domElement, AttrAxisP2, NULL_ID_STR);
1730  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1731  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1732 
1733  VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, showPointName, scene, this,
1734  data, parse, Source::FromFile);
1735  }
1736  catch (const VExceptionBadId &e)
1737  {
1738  VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement);
1739  excep.AddMoreInformation(e.ErrorMessage());
1740  throw excep;
1741  }
1742 }
1743 
1744 //---------------------------------------------------------------------------------------------------------------------
1745 void VPattern::parseIntersectXYTool(VMainGraphicsScene *scene, const QDomElement &domElement,
1746  const Document &parse)
1747 {
1748  SCASSERT(scene != nullptr)
1749  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1750 
1751  try
1752  {
1753  quint32 id = 0;
1754  QString name;
1755  qreal mx = 0;
1756  qreal my = 0;
1757  QString lineType;
1758  QString lineWeight;
1759  QString lineColor;
1760  bool showPointName = true;
1761 
1762  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1763  const quint32 firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
1764  const quint32 secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
1765 
1766  PointIntersectXYTool::Create(id, name, lineType, lineWeight, lineColor, firstPointId, secondPointId,
1767  mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1768  }
1769  catch (const VExceptionBadId &e)
1770  {
1771  VExceptionObjectError excep(tr("Error creating or updating Intersect XY tool"), domElement);
1772  excep.AddMoreInformation(e.ErrorMessage());
1773  throw excep;
1774  }
1775 }
1776 
1777 //---------------------------------------------------------------------------------------------------------------------
1778 void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1779 {
1780  SCASSERT(scene != nullptr)
1781  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1782 
1783  try
1784  {
1785  quint32 id = 0;
1786  QString name;
1787  qreal mx = 0;
1788  qreal my = 0;
1789  bool showPointName = true;
1790 
1791  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1792  const QString formula = GetParametrString(domElement, AttrLength, "0");
1793  QString f = formula;//need for saving fixed formula;
1794  const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
1795 
1796  VToolCutSpline::Create(id, name, f, splineId, mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1797  //Rewrite attribute formula. Need for situation when we have wrong formula.
1798  if (f != formula)
1799  {
1800  SetAttribute(domElement, AttrLength, f);
1801  modified = true;
1802  haveLiteChange();
1803  }
1804  }
1805  catch (const VExceptionBadId &e)
1806  {
1807  VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
1808  excep.AddMoreInformation(e.ErrorMessage());
1809  throw excep;
1810  }
1811  catch (qmu::QmuParserError &e)
1812  {
1813  VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
1814  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1815  throw excep;
1816  }
1817 }
1818 
1819 //---------------------------------------------------------------------------------------------------------------------
1820 void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1821 {
1822  SCASSERT(scene != nullptr)
1823  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1824 
1825  try
1826  {
1827  quint32 id = 0;
1828  QString name;
1829  qreal mx = 0;
1830  qreal my = 0;
1831  bool showPointName = true;
1832 
1833  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1834  const QString formula = GetParametrString(domElement, AttrLength, "0");
1835  QString f = formula;//need for saving fixed formula;
1836  const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath,
1837  NULL_ID_STR);
1838 
1839  VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1840  //Rewrite attribute formula. Need for situation when we have wrong formula.
1841  if (f != formula)
1842  {
1843  SetAttribute(domElement, AttrLength, f);
1844  modified = true;
1845  haveLiteChange();
1846  }
1847  }
1848  catch (const VExceptionBadId &e)
1849  {
1850  VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
1851  excep.AddMoreInformation(e.ErrorMessage());
1852  throw excep;
1853  }
1854  catch (qmu::QmuParserError &e)
1855  {
1856  VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
1857  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1858  throw excep;
1859  }
1860 }
1861 
1862 //---------------------------------------------------------------------------------------------------------------------
1863 void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
1864 {
1865  SCASSERT(scene != nullptr)
1866  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1867 
1868  try
1869  {
1870  quint32 id = 0;
1871  QString name;
1872  qreal mx = 0;
1873  qreal my = 0;
1874  bool showPointName = true;
1875 
1876  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
1877  const QString formula = GetParametrString(domElement, AttrLength, "0");
1878  QString f = formula;//need for saving fixed formula;
1879  const quint32 arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
1880 
1881  VToolCutArc::Create(id, name, f, arcId, mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1882  //Rewrite attribute formula. Need for situation when we have wrong formula.
1883  if (f != formula)
1884  {
1885  SetAttribute(domElement, AttrLength, f);
1886  modified = true;
1887  haveLiteChange();
1888  }
1889  }
1890  catch (const VExceptionBadId &e)
1891  {
1892  VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
1893  excep.AddMoreInformation(e.ErrorMessage());
1894  throw excep;
1895  }
1896  catch (qmu::QmuParserError &e)
1897  {
1898  VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
1899  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1900  throw excep;
1901  }
1902 }
1903 
1904 //---------------------------------------------------------------------------------------------------------------------
1905 void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement,
1906  const Document &parse)
1907 {
1908  SCASSERT(scene != nullptr)
1909  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1910 
1911  try
1912  {
1913  quint32 id = 0;
1914  QString name;
1915  qreal mx = 0;
1916  qreal my = 0;
1917  QString lineType;
1918  QString lineWeight;
1919  QString lineColor;
1920  bool showPointName = true;
1921 
1922  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1923 
1924  const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
1925  const quint32 firstPointId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
1926  const quint32 secondPointId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
1927 
1928  const QString angle = GetParametrString(domElement, AttrAngle, "0.0");
1929  QString angleFix = angle;
1930 
1931  VToolLineIntersectAxis::Create(id, name, lineType, lineWeight, lineColor, angleFix, basePointId, firstPointId,
1932  secondPointId, mx, my, showPointName, scene, this, data, parse, Source::FromFile);
1933  //Rewrite attribute formula. Need for situation when we have wrong formula.
1934  if (angleFix != angle)
1935  {
1936  SetAttribute(domElement, AttrAngle, angleFix);
1937  modified = true;
1938  haveLiteChange();
1939  }
1940  }
1941  catch (const VExceptionBadId &e)
1942  {
1943  VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
1944  domElement);
1945  excep.AddMoreInformation(e.ErrorMessage());
1946  throw excep;
1947  }
1948  catch (qmu::QmuParserError &e)
1949  {
1950  VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
1951  domElement);
1952  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
1953  throw excep;
1954  }
1955 }
1956 
1957 //---------------------------------------------------------------------------------------------------------------------
1958 void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement,
1959  const Document &parse)
1960 {
1961  SCASSERT(scene != nullptr)
1962  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
1963 
1964  try
1965  {
1966  quint32 id = 0;
1967  QString name;
1968  qreal mx = 0;
1969  qreal my = 0;
1970  QString lineType;
1971  QString lineWeight;
1972  QString lineColor;
1973  bool showPointName = true;
1974 
1975  PointsCommonAttributes(domElement, id, name, mx, my, showPointName, lineType, lineWeight, lineColor);
1976 
1977  const quint32 basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
1978  const quint32 curveId = GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
1979  const QString angle = GetParametrString(domElement, AttrAngle, "0.0");
1980  QString angleFix = angle;
1981 
1982  VToolCurveIntersectAxis::Create(id, name, lineType, lineWeight, lineColor, angleFix, basePointId, curveId, mx, my,
1983  showPointName, scene, this, data, parse, Source::FromFile);
1984  //Rewrite attribute formula. Need for situation when we have wrong formula.
1985  if (angleFix != angle)
1986  {
1987  SetAttribute(domElement, AttrAngle, angleFix);
1988  modified = true;
1989  haveLiteChange();
1990  }
1991  }
1992  catch (const VExceptionBadId &e)
1993  {
1994  VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"),
1995  domElement);
1996  excep.AddMoreInformation(e.ErrorMessage());
1997  throw excep;
1998  }
1999  catch (qmu::QmuParserError &e)
2000  {
2001  VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"),
2002  domElement);
2003  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2004  throw excep;
2005  }
2006 }
2007 
2008 //---------------------------------------------------------------------------------------------------------------------
2009 void VPattern::ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QDomElement &domElement,
2010  const Document &parse)
2011 {
2012  SCASSERT(scene != nullptr)
2013  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2014 
2015  try
2016  {
2017  quint32 id = 0;
2018  QString name;
2019  qreal mx = 0;
2020  qreal my = 0;
2021  bool showPointName = true;
2022 
2023  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
2024  const quint32 firstArcId = GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR);
2025  const quint32 secondArcId = GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR);
2026  const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
2028  "1"));
2029 
2030  VToolPointOfIntersectionArcs::Create(id, name, firstArcId, secondArcId, crossPoint, mx, my, scene, this,
2031  data, parse, Source::FromFile);
2032  }
2033  catch (const VExceptionBadId &e)
2034  {
2035  VExceptionObjectError excep(tr("Error creating or updating point of intersection arcs"), domElement);
2036  excep.AddMoreInformation(e.ErrorMessage());
2037  throw excep;
2038  }
2039 }
2040 
2041 //---------------------------------------------------------------------------------------------------------------------
2043  const Document &parse)
2044 {
2045  SCASSERT(scene != nullptr)
2046  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2047 
2048  try
2049  {
2050  quint32 id = 0;
2051  QString name;
2052  qreal mx = 0;
2053  qreal my = 0;
2054  bool showPointName = true;
2055 
2056  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
2057  const quint32 c1CenterId = GetParametrUInt(domElement, AttrC1Center, NULL_ID_STR);
2058  const quint32 c2CenterId = GetParametrUInt(domElement, AttrC2Center, NULL_ID_STR);
2059  const QString c1Radius = GetParametrString(domElement, AttrC1Radius);
2060  QString c1R = c1Radius;
2061  const QString c2Radius = GetParametrString(domElement, AttrC2Radius);
2062  QString c2R = c2Radius;
2063  const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
2064  AttrCrossPoint, "1"));
2065 
2066  IntersectCirclesTool::Create(id, name, c1CenterId, c2CenterId, c1R, c2R, crossPoint, mx, my,
2067  showPointName, scene, this, data, parse, Source::FromFile);
2068  //Rewrite attribute formula. Need for situation when we have wrong formula.
2069  if (c1R != c1Radius || c2R != c2Radius)
2070  {
2071  SetAttribute(domElement, AttrC1Center, c1R);
2072  SetAttribute(domElement, AttrC2Center, c2R);
2073  modified = true;
2074  haveLiteChange();
2075  }
2076  }
2077  catch (const VExceptionBadId &e)
2078  {
2079  VExceptionObjectError excep(tr("Error creating or updating point of intersection circles"), domElement);
2080  excep.AddMoreInformation(e.ErrorMessage());
2081  throw excep;
2082  }
2083 }
2084 
2085 //---------------------------------------------------------------------------------------------------------------------
2087  const Document &parse)
2088 {
2089  SCASSERT(scene != nullptr)
2090  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2091 
2092  try
2093  {
2094  quint32 id = 0;
2095  QString name;
2096  qreal mx = 0;
2097  qreal my = 0;
2098  bool showPointName = true;
2099 
2100  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
2101  const auto curve1Id = GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR);
2102  const auto curve2Id = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR);
2103  const auto vCrossPoint = static_cast<VCrossCurvesPoint>(GetParametrUInt(domElement, AttrVCrossPoint, "1"));
2104  const auto hCrossPoint = static_cast<HCrossCurvesPoint>(GetParametrUInt(domElement, AttrHCrossPoint, "1"));
2105 
2106  VToolPointOfIntersectionCurves::Create(id, name, curve1Id, curve2Id, vCrossPoint, hCrossPoint, mx, my,
2107  showPointName, scene, this, data, parse, Source::FromFile);
2108  }
2109  catch (const VExceptionBadId &e)
2110  {
2111  VExceptionObjectError excep(tr("Error creating or updating point of intersection curves"), domElement);
2112  excep.AddMoreInformation(e.ErrorMessage());
2113  throw excep;
2114  }
2115 }
2116 
2117 //---------------------------------------------------------------------------------------------------------------------
2119  const Document &parse)
2120 {
2121  SCASSERT(scene != nullptr)
2122  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2123 
2124  try
2125  {
2126  quint32 id = 0;
2127  QString name;
2128  qreal mx = 0;
2129  qreal my = 0;
2130  bool showPointName = true;
2131 
2132  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
2133  const quint32 cCenterId = GetParametrUInt(domElement, AttrCCenter, NULL_ID_STR);
2134  const quint32 tangentId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR);
2135  const QString cRadius = GetParametrString(domElement, AttrCRadius);
2136  QString cR = cRadius;
2137  const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
2139  "1"));
2140 
2141  IntersectCircleTangentTool::Create(id, name, cCenterId, cR, tangentId, crossPoint, mx, my,
2142  showPointName, scene, this, data, parse, Source::FromFile);
2143  //Rewrite attribute formula. Need for situation when we have wrong formula.
2144  if (cR != cRadius)
2145  {
2146  SetAttribute(domElement, AttrCCenter, cR);
2147  modified = true;
2148  haveLiteChange();
2149  }
2150  }
2151  catch (const VExceptionBadId &e)
2152  {
2153  VExceptionObjectError excep(tr("Error creating or updating point from circle and tangent"), domElement);
2154  excep.AddMoreInformation(e.ErrorMessage());
2155  throw excep;
2156  }
2157 }
2158 
2159 //---------------------------------------------------------------------------------------------------------------------
2160 void VPattern::ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QDomElement &domElement,
2161  const Document &parse)
2162 {
2163  SCASSERT(scene != nullptr)
2164  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2165 
2166  try
2167  {
2168  quint32 id = 0;
2169  QString name;
2170  qreal mx = 0;
2171  qreal my = 0;
2172  bool showPointName = true;
2173 
2174  PointsCommonAttributes(domElement, id, name, mx, my, showPointName);
2175  const quint32 arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
2176  const quint32 tangentId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR);
2177  const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
2179  "1"));
2180 
2181  VToolPointFromArcAndTangent::Create(id, name, arcId, tangentId, crossPoint, mx, my,
2182  showPointName, scene, this, data, parse, Source::FromFile);
2183  }
2184  catch (const VExceptionBadId &e)
2185  {
2186  VExceptionObjectError excep(tr("Error creating or updating point from arc and tangent"), domElement);
2187  excep.AddMoreInformation(e.ErrorMessage());
2188  throw excep;
2189  }
2190 }
2191 
2192 //---------------------------------------------------------------------------------------------------------------------
2193 void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2194 {
2195  SCASSERT(scene != nullptr)
2196  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2197 
2198  try
2199  {
2200  quint32 id = 0;
2201 
2202  ToolsCommonAttributes(domElement, id);
2203 
2204  const quint32 p1Id = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
2205  const quint32 p2Id = GetParametrUInt(domElement, AttrPoint2, NULL_ID_STR);
2206 
2207  const quint32 baseLineP1Id = GetParametrUInt(domElement, AttrBaseLineP1, NULL_ID_STR);
2208  const quint32 baseLineP2Id = GetParametrUInt(domElement, AttrBaseLineP2, NULL_ID_STR);
2209  const quint32 dartP1Id = GetParametrUInt(domElement, AttrDartP1, NULL_ID_STR);
2210  const quint32 dartP2Id = GetParametrUInt(domElement, AttrDartP2, NULL_ID_STR);
2211  const quint32 dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR);
2212 
2213  const QString name1 = GetParametrString(domElement, AttrName1, "A");
2214  const qreal mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, "10.0"));
2215  const qreal my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, "15.0"));
2216  const bool showPointName1 = getParameterBool(domElement, AttrShowPointName1, trueStr);
2217 
2218  const QString name2 = GetParametrString(domElement, AttrName2, "A");
2219  const qreal mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, "10.0"));
2220  const qreal my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, "15.0"));
2221  const bool showPointName2 = getParameterBool(domElement, AttrShowPointName2, trueStr);
2222 
2223 
2224  VToolTrueDarts::Create(id, p1Id, p2Id,
2225  baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id,
2226  name1, mx1, my1, showPointName1, name2, mx2, my2, showPointName2,
2227  scene, this, data, parse, Source::FromFile);
2228  }
2229  catch (const VExceptionBadId &e)
2230  {
2231  VExceptionObjectError excep(tr("Error creating or updating true darts"), domElement);
2232  excep.AddMoreInformation(e.ErrorMessage());
2233  throw excep;
2234  }
2235 }
2236 
2237 //---------------------------------------------------------------------------------------------------------------------
2238 // TODO. Delete if minimal supported version is 0.2.7
2239 void VPattern::ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2240 {
2241  SCASSERT(scene != nullptr)
2242  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2243 
2244  try
2245  {
2246  quint32 id = 0;
2247 
2248  ToolsCommonAttributes(domElement, id);
2249  const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
2250  const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
2251  const qreal angle1 = GetParametrDouble(domElement, AttrAngle1, "270.0");
2252  const qreal angle2 = GetParametrDouble(domElement, AttrAngle2, "90.0");
2253  const qreal kAsm1 = GetParametrDouble(domElement, AttrKAsm1, "1.0");
2254  const qreal kAsm2 = GetParametrDouble(domElement, AttrKAsm2, "1.0");
2255  const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
2256  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2257  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2258 
2259  const auto p1 = data->GeometricObject<VPointF>(point1);
2260  const auto p4 = data->GeometricObject<VPointF>(point4);
2261 
2262  auto spline = new VSpline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
2263  if (duplicate > 0)
2264  {
2265  spline->SetDuplicate(duplicate);
2266  }
2267  spline->setLineColor(color);
2268 
2269  VToolSpline::Create(id, spline, scene, this, data, parse, Source::FromFile);
2270  }
2271  catch (const VExceptionBadId &e)
2272  {
2273  VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
2274  excep.AddMoreInformation(e.ErrorMessage());
2275  throw excep;
2276  }
2277 }
2278 
2279 //---------------------------------------------------------------------------------------------------------------------
2280 void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2281 {
2282  SCASSERT(scene != nullptr)
2283  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2284 
2285  try
2286  {
2287  quint32 id = 0;
2288 
2289  ToolsCommonAttributes(domElement, id);
2290  const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
2291  const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
2292 
2293  const QString angle1 = GetParametrString(domElement, AttrAngle1, "0");
2294  QString a1 = angle1;//need for saving fixed formula;
2295 
2296  const QString angle2 = GetParametrString(domElement, AttrAngle2, "0");
2297  QString a2 = angle2;//need for saving fixed formula;
2298 
2299  const QString length1 = GetParametrString(domElement, AttrLength1, "0");
2300  QString l1 = length1;//need for saving fixed formula;
2301 
2302  const QString length2 = GetParametrString(domElement, AttrLength2, "0");
2303  QString l2 = length2;//need for saving fixed formula;
2304 
2305  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2306  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2307  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2308  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2309 
2310  VToolSpline *spl = VToolSpline::Create(id, point1, point4, a1, a2, l1, l2, duplicate, color, penStyle,
2311  lineWeight, scene, this, data, parse, Source::FromFile);
2312 
2313  if (spl != nullptr)
2314  {
2315  VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
2316  SCASSERT(window != nullptr)
2317  connect(spl, &VToolSpline::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
2318  }
2319 
2320  //Rewrite attribute formula. Need for situation when we have wrong formula.
2321  if (a1 != angle1 || a2 != angle2 || l1 != length1 || l2 != length2)
2322  {
2323  SetAttribute(domElement, AttrAngle1, a1);
2324  SetAttribute(domElement, AttrAngle2, a2);
2325  SetAttribute(domElement, AttrLength1, l1);
2326  SetAttribute(domElement, AttrLength2, l2);
2327  modified = true;
2328  haveLiteChange();
2329  }
2330  }
2331  catch (const VExceptionBadId &e)
2332  {
2333  VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
2334  excep.AddMoreInformation(e.ErrorMessage());
2335  throw excep;
2336  }
2337  catch (qmu::QmuParserError &e)
2338  {
2339  VExceptionObjectError excep(tr("Error creating or updating simple interactive spline"), domElement);
2340  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2341  throw excep;
2342  }
2343 }
2344 
2345 //---------------------------------------------------------------------------------------------------------------------
2346 void VPattern::ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2347 {
2348  SCASSERT(scene != nullptr)
2349  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2350 
2351  try
2352  {
2353  quint32 id = 0;
2354 
2355  ToolsCommonAttributes(domElement, id);
2356  const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
2357  const quint32 point2 = GetParametrUInt(domElement, AttrPoint2, NULL_ID_STR);
2358  const quint32 point3 = GetParametrUInt(domElement, AttrPoint3, NULL_ID_STR);
2359  const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
2360 
2361  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2362  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2363  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2364  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2365 
2366  auto p1 = data->GeometricObject<VPointF>(point1);
2367  auto p2 = data->GeometricObject<VPointF>(point2);
2368  auto p3 = data->GeometricObject<VPointF>(point3);
2369  auto p4 = data->GeometricObject<VPointF>(point4);
2370 
2371  VCubicBezier *spline = new VCubicBezier(*p1, *p2, *p3, *p4);
2372  if (duplicate > 0)
2373  {
2374  spline->SetDuplicate(duplicate);
2375  }
2376  spline->setLineColor(color);
2377  spline->SetPenStyle(penStyle);
2378  spline->setLineWeight(lineWeight);
2379 
2380  VToolCubicBezier::Create(id, spline, scene, this, data, parse, Source::FromFile);
2381  }
2382  catch (const VExceptionBadId &e)
2383  {
2384  VExceptionObjectError excep(tr("Error creating or updating cubic bezier curve"), domElement);
2385  excep.AddMoreInformation(e.ErrorMessage());
2386  throw excep;
2387  }
2388 }
2389 
2390 //---------------------------------------------------------------------------------------------------------------------
2391 void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2392 {
2393  SCASSERT(scene != nullptr)
2394  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2395 
2396  try
2397  {
2398  quint32 id = 0;
2399 
2400  ToolsCommonAttributes(domElement, id);
2401  const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
2402  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2403  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2404 
2405  QVector<VFSplinePoint> points;
2406 
2407  const QDomNodeList nodeList = domElement.childNodes();
2408  const qint32 num = nodeList.size();
2409  for (qint32 i = 0; i < num; ++i)
2410  {
2411  const QDomElement element = nodeList.at(i).toElement();
2412  if (element.isNull() == false)
2413  {
2414  if (element.tagName() == AttrPathPoint)
2415  {
2416  const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, "1.0");
2417  const qreal angle = GetParametrDouble(element, AttrAngle, "0");
2418  const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, "1.0");
2419  const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
2420  const VPointF p = *data->GeometricObject<VPointF>(pSpline);
2421 
2422  QLineF line(0, 0, 100, 0);
2423  line.setAngle(angle+180);
2424 
2425  VFSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle);
2426  points.append(splPoint);
2427  if (parse == Document::FullParse)
2428  {
2430  }
2431  }
2432  }
2433  }
2434 
2435  auto path = new VSplinePath(points, kCurve);
2436  if (duplicate > 0)
2437  {
2438  path->SetDuplicate(duplicate);
2439  }
2440  path->setLineColor(color);
2441 
2442  VToolSplinePath::Create(id, path, scene, this, data, parse, Source::FromFile);
2443  }
2444  catch (const VExceptionBadId &e)
2445  {
2446  VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
2447  excep.AddMoreInformation(e.ErrorMessage());
2448  throw excep;
2449  }
2450 }
2451 
2452 //---------------------------------------------------------------------------------------------------------------------
2453 void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2454 {
2455  SCASSERT(scene != nullptr)
2456  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2457 
2458  try
2459  {
2460  quint32 id = 0;
2461 
2462  ToolsCommonAttributes(domElement, id);
2463  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2464  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2465  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2466  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2467 
2468  QVector<quint32> points;
2469  QVector<QString> angle1, a1;
2470  QVector<QString> angle2, a2;
2471  QVector<QString> length1, l1;
2472  QVector<QString> length2, l2;
2473 
2474  const QDomNodeList nodeList = domElement.childNodes();
2475  const qint32 num = nodeList.size();
2476  for (qint32 i = 0; i < num; ++i)
2477  {
2478  const QDomElement element = nodeList.at(i).toElement();
2479  if (not element.isNull() && element.tagName() == AttrPathPoint)
2480  {
2481  angle1.append(GetParametrString(element, AttrAngle1, "0"));
2482  angle2.append(GetParametrString(element, AttrAngle2, "0"));
2483  length1.append(GetParametrString(element, AttrLength1, "0"));
2484  length2.append(GetParametrString(element, AttrLength2, "0"));
2485  const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
2486  points.append(pSpline);
2487 
2488  if (parse == Document::FullParse)
2489  {
2491  }
2492  }
2493  }
2494 
2495  //need for saving fixed formula;
2496  a1 = angle1;
2497  a2 = angle2;
2498  l1 = length1;
2499  l2 = length2;
2500 
2501  VToolSplinePath *spl = VToolSplinePath::Create(id, points, a1, a2, l1, l2, color, penStyle, lineWeight,
2502  duplicate, scene, this, data, parse, Source::FromFile);
2503 
2504  if (spl != nullptr)
2505  {
2506  VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
2507  SCASSERT(window != nullptr)
2509  }
2510 
2511  //Rewrite attribute formula. Need for situation when we have wrong formula.
2512  int count = 0;
2513  for (qint32 i = 0; i < num; ++i)
2514  {
2515  QDomElement element = nodeList.at(i).toElement();
2516  if (not element.isNull() && element.tagName() == AttrPathPoint)
2517  {
2518  if (a1.at(count) != angle1.at(count) || a2.at(count) != angle2.at(count) ||
2519  l1.at(count) != length1.at(count) || l2.at(count) != length2.at(count))
2520  {
2521  SetAttribute(element, AttrAngle1, a1.at(count));
2522  SetAttribute(element, AttrAngle2, a2.at(count));
2523  SetAttribute(element, AttrLength1, l1.at(count));
2524  SetAttribute(element, AttrLength2, l2.at(count));
2525  modified = true;
2526  haveLiteChange();
2527  }
2528  ++count;
2529  }
2530  }
2531  }
2532  catch (const VExceptionBadId &e)
2533  {
2534  VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
2535  excep.AddMoreInformation(e.ErrorMessage());
2536  throw excep;
2537  }
2538  catch (qmu::QmuParserError &e)
2539  {
2540  VExceptionObjectError excep(tr("Error creating or updating interactive spline path"), domElement);
2541  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2542  throw excep;
2543  }
2544 }
2545 
2546 //---------------------------------------------------------------------------------------------------------------------
2547 void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
2548 {
2549  SCASSERT(scene != nullptr)
2550  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2551 
2552  try
2553  {
2554  quint32 id = 0;
2555 
2556  ToolsCommonAttributes(domElement, id);
2557  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2558  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2559  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2560  const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
2561 
2562  QVector<VPointF> points;
2563 
2564  const QDomNodeList nodeList = domElement.childNodes();
2565  const qint32 num = nodeList.size();
2566  for (qint32 i = 0; i < num; ++i)
2567  {
2568  const QDomElement element = nodeList.at(i).toElement();
2569  if (element.isNull() == false)
2570  {
2571  if (element.tagName() == AttrPathPoint)
2572  {
2573  const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
2574  const VPointF p = *data->GeometricObject<VPointF>(pSpline);
2575  points.append(p);
2576  if (parse == Document::FullParse)
2577  {
2579  }
2580  }
2581  }
2582  }
2583 
2584  auto path = new VCubicBezierPath(points);
2585  if (duplicate > 0)
2586  {
2587  path->SetDuplicate(duplicate);
2588  }
2589  path->setLineColor(color);
2590  path->SetPenStyle(penStyle);
2591  path->setLineWeight(lineWeight);
2592 
2593  VToolCubicBezierPath::Create(id, path, scene, this, data, parse, Source::FromFile);
2594  }
2595  catch (const VExceptionBadId &e)
2596  {
2597  VExceptionObjectError excep(tr("Error creating or updating cubic bezier path curve"), domElement);
2598  excep.AddMoreInformation(e.ErrorMessage());
2599  throw excep;
2600  }
2601 }
2602 
2603 //---------------------------------------------------------------------------------------------------------------------
2604 void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &parse)
2605 {
2606  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2607 
2608  try
2609  {
2610  quint32 id = 0;
2611  quint32 idObject = 0;
2612  quint32 idTool = 0;
2613 
2614  SplinesCommonAttributes(domElement, id, idObject, idTool);
2615  try
2616  {
2617  const auto obj = data->GetGObject(idObject);
2618  if (obj->getType() == GOType::Spline)
2619  {
2620  VSpline *spl = new VSpline(*data->GeometricObject<VSpline>(idObject));
2621  spl->setIdObject(idObject);
2622  spl->setMode(Draw::Modeling);
2623  data->UpdateGObject(id, spl);
2624  }
2625  else
2626  {
2627  VCubicBezier *spl = new VCubicBezier(*data->GeometricObject<VCubicBezier>(idObject));
2628  spl->setIdObject(idObject);
2629  spl->setMode(Draw::Modeling);
2630  data->UpdateGObject(id, spl);
2631  }
2632  }
2633  catch (const VExceptionBadId &e)
2634  { // Possible case. Parent was deleted, but the node object is still here.
2635  Q_UNUSED(e)
2636  return;// Just ignore
2637  }
2638 
2639  VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool);
2640  }
2641  catch (const VExceptionBadId &e)
2642  {
2643  VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement);
2644  excep.AddMoreInformation(e.ErrorMessage());
2645  throw excep;
2646  }
2647 }
2648 
2649 //---------------------------------------------------------------------------------------------------------------------
2650 void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document &parse)
2651 {
2652  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2653 
2654  try
2655  {
2656  quint32 id = 0;
2657  quint32 idObject = 0;
2658  quint32 idTool = 0;
2659 
2660  SplinesCommonAttributes(domElement, id, idObject, idTool);
2661  try
2662  {
2663  const auto obj = data->GetGObject(idObject);
2664  if (obj->getType() == GOType::SplinePath)
2665  {
2666  VSplinePath *path = new VSplinePath(*data->GeometricObject<VSplinePath>(idObject));
2667  path->setIdObject(idObject);
2668  path->setMode(Draw::Modeling);
2669  data->UpdateGObject(id, path);
2670  }
2671  else
2672  {
2674  spl->setIdObject(idObject);
2675  spl->setMode(Draw::Modeling);
2676  data->UpdateGObject(id, spl);
2677  }
2678  }
2679  catch (const VExceptionBadId &e)
2680  { // Possible case. Parent was deleted, but the node object is still here.
2681  Q_UNUSED(e)
2682  return;// Just ignore
2683  }
2684  VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool);
2685  }
2686  catch (const VExceptionBadId &e)
2687  {
2688  VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement);
2689  excep.AddMoreInformation(e.ErrorMessage());
2690  throw excep;
2691  }
2692 }
2693 
2694 //---------------------------------------------------------------------------------------------------------------------
2695 void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2696 {
2697  SCASSERT(scene != nullptr)
2698  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2699 
2700  try
2701  {
2702  quint32 id = 0;
2703 
2704  ToolsCommonAttributes(domElement, id);
2705  const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
2706  const QString radius = GetParametrString(domElement, AttrRadius, "10");
2707  QString r = radius;//need for saving fixed formula;
2708  const QString f1 = GetParametrString(domElement, AttrAngle1, "180");
2709  QString f1Fix = f1;//need for saving fixed formula;
2710  const QString f2 = GetParametrString(domElement, AttrAngle2, "270");
2711  QString f2Fix = f2;//need for saving fixed formula;
2712  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2713  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2714  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2715 
2716  VToolArc::Create(id, center, r, f1Fix, f2Fix, color, penStyle, lineWeight, scene, this, data,
2717  parse, Source::FromFile);
2718  //Rewrite attribute formula. Need for situation when we have wrong formula.
2719  if (r != radius || f1Fix != f1 || f2Fix != f2)
2720  {
2721  SetAttribute(domElement, AttrRadius, r);
2722  SetAttribute(domElement, AttrAngle1, f1Fix);
2723  SetAttribute(domElement, AttrAngle2, f2Fix);
2724  modified = true;
2725  haveLiteChange();
2726  }
2727  }
2728  catch (const VExceptionBadId &e)
2729  {
2730  VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
2731  excep.AddMoreInformation(e.ErrorMessage());
2732  throw excep;
2733  }
2734  catch (qmu::QmuParserError &e)
2735  {
2736  VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
2737  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2738  throw excep;
2739  }
2740 }
2741 
2742 //---------------------------------------------------------------------------------------------------------------------
2743 void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2744 {
2745  SCASSERT(scene != nullptr)
2746  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2747 
2748  try
2749  {
2750  quint32 id = 0;
2751 
2752  ToolsCommonAttributes(domElement, id);
2753  const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
2754  const QString radius1 = GetParametrString(domElement, AttrRadius1, "10");
2755  const QString radius2 = GetParametrString(domElement, AttrRadius2, "10");
2756  QString r1 = radius1;//need for saving fixed formula;
2757  QString r2 = radius2;//need for saving fixed formula;
2758  const QString f1 = GetParametrString(domElement, AttrAngle1, "180");
2759  QString f1Fix = f1;//need for saving fixed formula;
2760  const QString f2 = GetParametrString(domElement, AttrAngle2, "270");
2761  QString f2Fix = f2;//need for saving fixed formula;
2762  const QString frotation = GetParametrString(domElement, AttrRotationAngle, "0");
2763  QString frotationFix = frotation;//need for saving fixed formula;
2764  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2765  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2766  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2767 
2768  VToolEllipticalArc::Create(id, center, r1, r2, f1Fix, f2Fix, frotationFix, color, penStyle, lineWeight,
2769  scene, this, data,
2770  parse, Source::FromFile);
2771  //Rewrite attribute formula. Need for situation when we have wrong formula.
2772  if (r1 != radius1 || r2 != radius2 || f1Fix != f1 || f2Fix != f2 || frotationFix != frotation)
2773  {
2774  SetAttribute(domElement, AttrRadius1, r1);
2775  SetAttribute(domElement, AttrRadius2, r2);
2776  SetAttribute(domElement, AttrAngle1, f1Fix);
2777  SetAttribute(domElement, AttrAngle2, f2Fix);
2778  SetAttribute(domElement, AttrRotationAngle, frotationFix);
2779  modified = true;
2780  haveLiteChange();
2781  }
2782  }
2783  catch (const VExceptionBadId &e)
2784  {
2785  VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement);
2786  excep.AddMoreInformation(e.ErrorMessage());
2787  throw excep;
2788  }
2789  catch (qmu::QmuParserError &e)
2790  {
2791  VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement);
2792  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2793  throw excep;
2794  }
2795 }
2796 
2797 //---------------------------------------------------------------------------------------------------------------------
2798 void VPattern::ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse)
2799 {
2800  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2801 
2802  try
2803  {
2804  quint32 id = 0;
2805 
2806  ToolsCommonAttributes(domElement, id);
2807  const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
2808  const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
2809  VEllipticalArc *arc = nullptr;
2810  try
2811  {
2812  arc = new VEllipticalArc(*data->GeometricObject<VEllipticalArc>(idObject));
2813  }
2814  catch (const VExceptionBadId &e)
2815  { // Possible case. Parent was deleted, but the node object is still here.
2816  Q_UNUSED(e)
2817  return;// Just ignore
2818  }
2819  arc->setIdObject(idObject);
2820  arc->setMode(Draw::Modeling);
2821  data->UpdateGObject(id, arc);
2822  VNodeEllipticalArc::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool);
2823  }
2824  catch (const VExceptionBadId &e)
2825  {
2826  VExceptionObjectError excep(tr("Error creating or updating modeling elliptical arc"), domElement);
2827  excep.AddMoreInformation(e.ErrorMessage());
2828  throw excep;
2829  }
2830 }
2831 
2832 //---------------------------------------------------------------------------------------------------------------------
2833 void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse)
2834 {
2835  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
2836 
2837  try
2838  {
2839  quint32 id = 0;
2840 
2841  ToolsCommonAttributes(domElement, id);
2842  const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
2843  const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
2844  VArc *arc = nullptr;
2845  try
2846  {
2847  arc = new VArc(*data->GeometricObject<VArc>(idObject));
2848  }
2849  catch (const VExceptionBadId &e)
2850  { // Possible case. Parent was deleted, but the node object is still here.
2851  Q_UNUSED(e)
2852  return;// Just ignore
2853  }
2854  arc->setIdObject(idObject);
2855  arc->setMode(Draw::Modeling);
2856  data->UpdateGObject(id, arc);
2857  VNodeArc::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool);
2858  }
2859  catch (const VExceptionBadId &e)
2860  {
2861  VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement);
2862  excep.AddMoreInformation(e.ErrorMessage());
2863  throw excep;
2864  }
2865 }
2866 
2867 //---------------------------------------------------------------------------------------------------------------------
2868 void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2869 {
2870  SCASSERT(scene != nullptr)
2871  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2872 
2873  try
2874  {
2875  quint32 id = 0;
2876 
2877  ToolsCommonAttributes(domElement, id);
2878  const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
2879  const QString radius = GetParametrString(domElement, AttrRadius, "10");
2880  QString r = radius;//need for saving fixed formula;
2881  const QString f1 = GetParametrString(domElement, AttrAngle1, "180");
2882  QString f1Fix = f1;//need for saving fixed formula;
2883  const QString length = GetParametrString(domElement, AttrLength, "10");
2884  QString lengthFix = length;//need for saving fixed length;
2885  const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
2886  const QString penStyle = GetParametrString(domElement, AttrPenStyle, LineTypeSolidLine);
2887  const QString lineWeight = GetParametrString(domElement, AttrLineWeight, "0.35");
2888 
2889  VToolArcWithLength::Create(id, center, r, f1Fix, lengthFix, color, penStyle, lineWeight, scene, this,
2890  data, parse,
2892  //Rewrite attribute formula. Need for situation when we have wrong formula.
2893  if (r != radius || f1Fix != f1 || lengthFix != length)
2894  {
2895  SetAttribute(domElement, AttrRadius, r);
2896  SetAttribute(domElement, AttrAngle1, f1Fix);
2897  SetAttribute(domElement, AttrLength, lengthFix);
2898  modified = true;
2899  haveLiteChange();
2900  }
2901  }
2902  catch (const VExceptionBadId &e)
2903  {
2904  VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
2905  excep.AddMoreInformation(e.ErrorMessage());
2906  throw excep;
2907  }
2908  catch (qmu::QmuParserError &e)
2909  {
2910  VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
2911  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2912  throw excep;
2913  }
2914 }
2915 
2916 //---------------------------------------------------------------------------------------------------------------------
2917 void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2918 {
2919  SCASSERT(scene != nullptr)
2920  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2921 
2922  try
2923  {
2924  quint32 id = NULL_ID;
2925 
2926  ToolsCommonAttributes(domElement, id);
2927  const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
2928  const QString angle = GetParametrString(domElement, AttrAngle, "10");
2929  QString a = angle;//need for saving fixed formula;
2930  const QString suffix = GetParametrString(domElement, AttrSuffix, "");
2931 
2932  QVector<SourceItem> source;
2933  QVector<DestinationItem> destination;
2934  VAbstractOperation::ExtractData(domElement, source, destination);
2935 
2936  VToolRotation::Create(id, center, a, suffix, source, destination, scene, this, data, parse, Source::FromFile);
2937  //Rewrite attribute formula. Need for situation when we have wrong formula.
2938  if (a != angle)
2939  {
2940  SetAttribute(domElement, AttrAngle, a);
2941  modified = true;
2942  haveLiteChange();
2943  }
2944  }
2945  catch (const VExceptionBadId &e)
2946  {
2947  VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
2948  excep.AddMoreInformation(e.ErrorMessage());
2949  throw excep;
2950  }
2951  catch (qmu::QmuParserError &e)
2952  {
2953  VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
2954  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
2955  throw excep;
2956  }
2957 }
2958 
2959 //---------------------------------------------------------------------------------------------------------------------
2960 void VPattern::ParseToolMirrorByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2961 {
2962  SCASSERT(scene != nullptr)
2963  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2964 
2965  try
2966  {
2967  quint32 id = NULL_ID;
2968 
2969  ToolsCommonAttributes(domElement, id);
2970  const quint32 p1 = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
2971  const quint32 p2 = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
2972  const QString suffix = GetParametrString(domElement, AttrSuffix, "");
2973 
2974  QVector<SourceItem> source;;
2975  QVector<DestinationItem> destination;
2976  VAbstractOperation::ExtractData(domElement, source, destination);
2977 
2978  VToolMirrorByLine::Create(id, p1, p2, suffix, source, destination, scene, this, data, parse,
2980  }
2981  catch (const VExceptionBadId &e)
2982  {
2983  VExceptionObjectError excep(tr("Error creating or updating operation of mirror by line"), domElement);
2984  excep.AddMoreInformation(e.ErrorMessage());
2985  throw excep;
2986  }
2987 }
2988 
2989 //---------------------------------------------------------------------------------------------------------------------
2990 void VPattern::ParseToolMirrorByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
2991 {
2992  SCASSERT(scene != nullptr)
2993  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
2994 
2995  try
2996  {
2997  quint32 id = NULL_ID;
2998 
2999  ToolsCommonAttributes(domElement, id);
3000  const quint32 origin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
3001  const auto axisType = static_cast<AxisType>(GetParametrUInt(domElement, AttrAxisType, "1"));
3002  const QString suffix = GetParametrString(domElement, AttrSuffix, "");
3003 
3004  QVector<SourceItem> source;;
3005  QVector<DestinationItem> destination;
3006  VAbstractOperation::ExtractData(domElement, source, destination);
3007 
3008  VToolMirrorByAxis::Create(id, origin, axisType, suffix, source, destination, scene, this, data, parse,
3010  }
3011  catch (const VExceptionBadId &e)
3012  {
3013  VExceptionObjectError excep(tr("Error creating or updating operation of mirror by axis"), domElement);
3014  excep.AddMoreInformation(e.ErrorMessage());
3015  throw excep;
3016  }
3017 }
3018 
3019 //---------------------------------------------------------------------------------------------------------------------
3020 void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
3021 {
3022  SCASSERT(scene != nullptr)
3023  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
3024 
3025  try
3026  {
3027  quint32 id = NULL_ID;
3028 
3029  ToolsCommonAttributes(domElement, id);
3030  const QString angle = GetParametrString(domElement, AttrAngle, "0");
3031  QString a = angle;//need for saving fixed formula;
3032  const QString length = GetParametrString(domElement, AttrLength, "0");
3033  QString len = length;//need for saving fixed formula;
3034 
3035  const QString rotation = GetParametrString(domElement, AttrRotationAngle, "0");
3036  QString rot = rotation;//need for saving fixed formula;
3037  quint32 originPointId = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
3038 
3039  const QString suffix = GetParametrString(domElement, AttrSuffix, "");
3040 
3041  QVector<SourceItem> source;;
3042  QVector<DestinationItem> destination;
3043  VAbstractOperation::ExtractData(domElement, source, destination);
3044 
3045  VToolMove::Create(id, a, len, rot, originPointId, suffix, source, destination,
3046  scene, this, data, parse, Source::FromFile);
3047  //Rewrite attribute formula. Need for situation when we have wrong formula.
3048  if (a != angle || len != length || rot != rotation)
3049  {
3050  SetAttribute(domElement, AttrAngle, angle);
3051  SetAttribute(domElement, AttrLength, length);
3052  SetAttribute(domElement, AttrRotationAngle, rotation);
3053  modified = true;
3054  haveLiteChange();
3055  }
3056  }
3057  catch (const VExceptionBadId &e)
3058  {
3059  VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
3060  excep.AddMoreInformation(e.ErrorMessage());
3061  throw excep;
3062  }
3063  catch (qmu::QmuParserError &e)
3064  {
3065  VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
3066  excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
3067  throw excep;
3068  }
3069 }
3070 
3071 //---------------------------------------------------------------------------------------------------------------------
3072 qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
3073 {
3074  if (formula.isEmpty())
3075  {
3076  *ok = true;
3077  return 0;
3078  }
3079  else
3080  {
3081  try
3082  {
3083  // Replace line return character with spaces for calc if exist
3084  QString f = formula;
3085  f.replace("\n", " ");
3086  QScopedPointer<Calculator> cal(new Calculator());
3087  const qreal result = cal->EvalFormula(data->DataVariables(), f);
3088 
3089  (qIsInf(result) || qIsNaN(result)) ? *ok = false : *ok = true;
3090  return result;
3091  }
3092  catch (qmu::QmuParserError &e)
3093  {
3094  Q_UNUSED(e)
3095  *ok = false;
3096  return 0;
3097  }
3098  }
3099 }
3100 
3101 //---------------------------------------------------------------------------------------------------------------------
3102 QDomElement VPattern::MakeEmptyIncrement(const QString &name)
3103 {
3104  QDomElement element = createElement(TagIncrement);
3105  SetAttribute(element, IncrementName, name);
3106  SetAttribute(element, IncrementFormula, QString("0"));
3107  SetAttribute(element, IncrementDescription, QString(""));
3108  return element;
3109 }
3110 
3111 //---------------------------------------------------------------------------------------------------------------------
3112 QDomElement VPattern::FindIncrement(const QString &name) const
3113 {
3114  QDomNodeList list = elementsByTagName(TagIncrement);
3115 
3116  for (int i=0; i < list.size(); ++i)
3117  {
3118  const QDomElement domElement = list.at(i).toElement();
3119  if (domElement.isNull() == false)
3120  {
3121  const QString parameter = domElement.attribute(IncrementName);
3122  if (parameter == name)
3123  {
3124  return domElement;
3125  }
3126  }
3127  }
3128 
3129  return QDomElement();
3130 }
3131 
3132 //---------------------------------------------------------------------------------------------------------------------
3134 {
3135  QDomNodeList modelingList = elementsByTagName(TagModeling);
3136  for (int i=0; i < modelingList.size(); ++i)
3137  {
3138  QDomElement modElement = modelingList.at(i).toElement();
3139  if (not modElement.isNull())
3140  {
3141  QDomElement modNode = modElement.firstChild().toElement();
3142  while (not modNode.isNull())
3143  {
3144  // First get next sibling because later will not have chance to get it
3145  QDomElement nextSibling = modNode.nextSibling().toElement();
3146  if (modNode.hasAttribute(VAbstractNode::AttrInUse))
3147  {
3148  const NodeUsage inUse = GetParametrUsage(modNode, VAbstractNode::AttrInUse);
3149  if (inUse == NodeUsage::InUse)
3150  { // It is dangerous to leave object with attribute 'inUse'
3151  // Each parse should confirm this status.
3153  }
3154  else
3155  { // Parent was deleted. We do not need this object anymore
3156  modElement.removeChild(modNode);
3157  }
3158  }
3159  else
3160  { // Each parse should confirm his status.
3162  }
3163 
3164  modNode = nextSibling;
3165  }
3166  }
3167  }
3168 }
3169 
3170 //---------------------------------------------------------------------------------------------------------------------
3171 /**
3172  * @brief ParseSplineElement parse spline tag.
3173  * @param scene scene.
3174  * @param domElement tag in xml tree.
3175  * @param parse parser file mode.
3176  * @param type type of spline.
3177  */
3178 void VPattern::ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement,
3179  const Document &parse, const QString &type)
3180 {
3181  SCASSERT(scene != nullptr)
3182  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
3183  Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
3184 
3185  QStringList splines = QStringList() << VToolSpline::OldToolType /*0*/
3186  << VToolSpline::ToolType /*1*/
3188  << VToolSplinePath::ToolType /*3*/
3189  << VNodeSpline::ToolType /*4*/
3190  << VNodeSplinePath::ToolType /*5*/
3193  switch (splines.indexOf(type))
3194  {
3195  case 0: //VToolSpline::OldToolType
3196  qCDebug(vXML, "VOldToolSpline.");
3197  ParseOldToolSpline(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7
3198  break;
3199  case 1: //VToolSpline::ToolType
3200  qCDebug(vXML, "VToolSpline.");
3201  ParseToolSpline(scene, domElement, parse);
3202  break;
3203  case 2: //VToolSplinePath::OldToolType
3204  qCDebug(vXML, "VOldToolSplinePath.");
3205  ParseOldToolSplinePath(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7
3206  break;
3207  case 3: //VToolSplinePath::ToolType
3208  qCDebug(vXML, "VToolSplinePath.");
3209  ParseToolSplinePath(scene, domElement, parse);
3210  break;
3211  case 4: //VNodeSpline::ToolType
3212  qCDebug(vXML, "VNodeSpline.");
3213  ParseNodeSpline(domElement, parse);
3214  break;
3215  case 5: //VNodeSplinePath::ToolType
3216  qCDebug(vXML, "VNodeSplinePath.");
3217  ParseNodeSplinePath(domElement, parse);
3218  break;
3219  case 6: //VToolCubicBezier::ToolType
3220  qCDebug(vXML, "VToolCubicBezier.");
3221  ParseToolCubicBezier(scene, domElement, parse);
3222  break;
3223  case 7: //VToolCubicBezierPath::ToolType
3224  qCDebug(vXML, "VToolCubicBezierPath.");
3225  ParseToolCubicBezierPath(scene, domElement, parse);
3226  break;
3227  default:
3228  VException e(tr("Unknown spline type '%1'.").arg(type));
3229  throw e;
3230  }
3231 }
3232 
3233 //---------------------------------------------------------------------------------------------------------------------
3234 /**
3235  * @brief ParseArcElement parse arc tag.
3236  * @param scene scene.
3237  * @param domElement tag in xml tree.
3238  * @param parse parser file mode.
3239  * @param type type of spline.
3240  */
3241 void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
3242  const QString &type)
3243 {
3244  SCASSERT(scene != nullptr)
3245  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
3246  Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of arc is empty");
3247 
3248  QStringList arcs = QStringList() << VToolArc::ToolType /*0*/
3249  << VNodeArc::ToolType /*1*/
3251 
3252  switch (arcs.indexOf(type))
3253  {
3254  case 0: //VToolArc::ToolType
3255  ParseToolArc(scene, domElement, parse);
3256  break;
3257  case 1: //VNodeArc::ToolType
3258  ParseNodeArc(domElement, parse);
3259  break;
3260  case 2: //VToolArcWithLength::ToolType
3261  ParseToolArcWithLength(scene, domElement, parse);
3262  break;
3263  default:
3264  VException e(tr("Unknown arc type '%1'.").arg(type));
3265  throw e;
3266  }
3267 }
3268 
3269 //---------------------------------------------------------------------------------------------------------------------
3270 /**
3271  * @brief ParseEllipticalArcElement parse elliptical arc tag.
3272  * @param scene scene.
3273  * @param domElement tag in xml tree.
3274  * @param parse parser file mode.
3275  * @param type type of spline.
3276  */
3277 void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
3278  const QString &type)
3279 {
3280  SCASSERT(scene != nullptr)
3281  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
3282  Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of elliptical arc is empty");
3283 
3284  const QStringList arcs = QStringList() << VToolEllipticalArc::ToolType /*0*/
3286 
3287  switch (arcs.indexOf(type))
3288  {
3289  case 0: //VToolArc::ToolType
3290  ParseToolEllipticalArc(scene, domElement, parse);
3291  break;
3292  case 1: //VNodeEllipticalArc::ToolType
3293  ParseNodeEllipticalArc(domElement, parse);
3294  break;
3295  default:
3296  VException e(tr("Unknown elliptical arc type '%1'.").arg(type));
3297  throw e;
3298  }
3299 }
3300 
3301 //---------------------------------------------------------------------------------------------------------------------
3302 /**
3303  * @brief ParseToolsElement parse tools tag.
3304  * @param scene scene.
3305  * @param domElement tag in xml tree.
3306  * @param parse parser file mode.
3307  * @param type type of spline.
3308  */
3309 void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement,
3310  const Document &parse, const QString &type)
3311 {
3312  SCASSERT(scene != nullptr)
3313  Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
3314  Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
3315 
3316  const QStringList tools = QStringList() << UnionTool::ToolType;
3317  switch (tools.indexOf(type))
3318  {
3319  case 0: //UnionTool::ToolType
3320  try
3321  {
3322  quint32 id = 0;
3323  ToolsCommonAttributes(domElement, id);
3324 
3325  UnionToolInitData initData;
3326  initData.piece1_Index = GetParametrUInt(domElement, UnionTool::AttrIndexD1, "-1");
3327  initData.piece2_Index = GetParametrUInt(domElement, UnionTool::AttrIndexD2, "-1");
3328  initData.scene = scene;
3329  initData.doc = this;
3330  initData.data = data;
3331  initData.parse = parse;
3332  initData.typeCreation = Source::FromFile;
3333 
3334  UnionTool::Create(id, initData);
3335  }
3336  catch (const VExceptionBadId &e)
3337  {
3338  VExceptionObjectError excep(tr("Error creating or updating union pieces"), domElement);
3339  excep.AddMoreInformation(e.ErrorMessage());
3340  throw excep;
3341  }
3342  break;
3343  default:
3344  VException e(tr("Unknown tools type '%1'.").arg(type));
3345  throw e;
3346  }
3347 }
3348 
3349 //---------------------------------------------------------------------------------------------------------------------
3350 void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
3351  const QString &type)
3352 {
3353  SCASSERT(scene != nullptr)
3354  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
3355  Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
3356 
3357  const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
3360  << VToolMove::ToolType; /*3*/
3361 
3362  switch (opers.indexOf(type))
3363  {
3364  case 0: //VToolRotation::ToolType
3365  ParseToolRotation(scene, domElement, parse);
3366  break;
3367  case 1: //VToolMirrorByLine::ToolType
3368  ParseToolMirrorByLine(scene, domElement, parse);
3369  break;
3370  case 2: //VToolMirrorByAxis::ToolType
3371  ParseToolMirrorByAxis(scene, domElement, parse);
3372  break;
3373  case 3: //VToolMove::ToolType
3374  ParseToolMove(scene, domElement, parse);
3375  break;
3376  default:
3377  VException e(tr("Unknown operation type '%1'.").arg(type));
3378  throw e;
3379  }
3380 }
3381 
3382 //---------------------------------------------------------------------------------------------------------------------
3383 void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
3384 {
3385  SCASSERT(scene != nullptr);
3386  Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
3387  try
3388  {
3389  quint32 id = 0;
3390  ToolsCommonAttributes(domElement, id);
3391  const QString name = GetParametrString(domElement, AttrName, tr("Unnamed path"));
3392  const QString defType = QString().setNum(static_cast<int>(PiecePathType::CustomSeamAllowance));
3393  const PiecePathType type = static_cast<PiecePathType>(GetParametrUInt(domElement, AttrType, defType));
3394  const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
3395  const QString penType = GetParametrString(domElement, AttrLineType, LineTypeSolidLine);
3396  const bool cut = getParameterBool(domElement, AttrCut, falseStr);
3397 
3398  VPiecePath path;
3399  const QDomElement element = domElement.firstChildElement(VAbstractPattern::TagNodes);
3400  if (not element.isNull())
3401  {
3402  path = ParsePathNodes(element);
3403  }
3404 
3405  path.SetType(type);
3406  path.SetName(name);
3407  path.SetPenType(lineTypeToPenStyle(penType));
3408  path.SetCutPath(cut);
3409 
3410  VToolInternalPath::Create(id, path, 0, scene, this, data, parse, Source::FromFile, "", idTool);
3411  }
3412  catch (const VExceptionBadId &e)
3413  {
3414  VExceptionObjectError excep(tr("Error creating or updating a piece path"), domElement);
3415  excep.AddMoreInformation(e.ErrorMessage());
3416  throw excep;
3417  }
3418 }
3419 
3420 //---------------------------------------------------------------------------------------------------------------------
3421 /**
3422  * @brief ParseIncrementsElement parse increments tag.
3423  * @param node tag in xml tree.
3424  */
3425 void VPattern::ParseIncrementsElement(const QDomNode &node)
3426 {
3427  int index = 0;
3428  QDomNode domNode = node.firstChild();
3429  while (domNode.isNull() == false)
3430  {
3431  if (domNode.isElement())
3432  {
3433  const QDomElement domElement = domNode.toElement();
3434  if (domElement.isNull() == false)
3435  {
3436  if (domElement.tagName() == TagIncrement)
3437  {
3438  const QString name = GetParametrString(domElement, IncrementName, "");
3439 
3440  QString desc;
3441  try
3442  {
3443  desc = GetParametrString(domElement, IncrementDescription);
3444  }
3445  catch (VExceptionEmptyParameter &e)
3446  {
3447  Q_UNUSED(e)
3448  }
3449 
3450  const QString formula = GetParametrString(domElement, IncrementFormula, "0");
3451  bool ok = false;
3452  const qreal value = EvalFormula(data, formula, &ok);
3453 
3454  data->AddVariable(name, new VIncrement(data, name, static_cast<quint32>(index), value, formula, ok,
3455  desc));
3456  ++index;
3457  }
3458  }
3459  }
3460  domNode = domNode.nextSibling();
3461  }
3462 }
3463 
3464 //---------------------------------------------------------------------------------------------------------------------
3465 void VPattern::addEmptyCustomVariable(const QString &name)
3466 {
3467  const QDomElement element = MakeEmptyIncrement(name);
3468 
3469  const QDomNodeList list = elementsByTagName(TagIncrements);
3470  list.at(0).appendChild(element);
3471  emit patternChanged(false);
3472 }
3473 
3474 //---------------------------------------------------------------------------------------------------------------------
3475 void VPattern::addEmptyCustomVariableAfter(const QString &after, const QString &name)
3476 {
3477  const QDomElement element = MakeEmptyIncrement(name);
3478  const QDomElement sibling = FindIncrement(after);
3479 
3480  const QDomNodeList list = elementsByTagName(TagIncrements);
3481 
3482  if (sibling.isNull())
3483  {
3484  list.at(0).appendChild(element);
3485  }
3486  else
3487  {
3488  list.at(0).insertAfter(element, sibling);
3489  }
3490  emit patternChanged(false);
3491 }
3492 
3493 //---------------------------------------------------------------------------------------------------------------------
3494 void VPattern::removeCustomVariable(const QString &name)
3495 {
3496  const QDomNodeList list = elementsByTagName(TagIncrements);
3497  list.at(0).removeChild(FindIncrement(name));
3498  emit patternChanged(false);
3499 }
3500 
3501 //---------------------------------------------------------------------------------------------------------------------
3502 void VPattern::MoveUpIncrement(const QString &name)
3503 {
3504  const QDomElement node = FindIncrement(name);
3505  if (not node.isNull())
3506  {
3507  const QDomElement prSibling = node.previousSiblingElement(TagIncrement);
3508  if (not prSibling.isNull())
3509  {
3510  const QDomNodeList list = elementsByTagName(TagIncrements);
3511  list.at(0).insertBefore(node, prSibling);
3512  }
3513  }
3514  emit patternChanged(false);
3515 }
3516 
3517 //---------------------------------------------------------------------------------------------------------------------
3518 void VPattern::MoveDownIncrement(const QString &name)
3519 {
3520  const QDomElement node = FindIncrement(name);
3521  if (not node.isNull())
3522  {
3523  const QDomElement nextSibling = node.nextSiblingElement(TagIncrement);
3524  if (not nextSibling.isNull())
3525  {
3526  const QDomNodeList list = elementsByTagName(TagIncrements);
3527  list.at(0).insertAfter(node, nextSibling);
3528  }
3529  }
3530  emit patternChanged(false);
3531 }
3532 
3533 //---------------------------------------------------------------------------------------------------------------------
3534 void VPattern::setIncrementName(const QString &name, const QString &text)
3535 {
3536  QDomElement node = FindIncrement(name);
3537  if (not node.isNull())
3538  {
3539  SetAttribute(node, IncrementName, text);
3540  emit patternChanged(false);
3541  }
3542 }
3543 
3544 //---------------------------------------------------------------------------------------------------------------------
3545 void VPattern::SetIncrementFormula(const QString &name, const QString &text)
3546 {
3547  QDomElement node = FindIncrement(name);
3548  if (not node.isNull())
3549  {
3550  SetAttribute(node, IncrementFormula, text);
3551  emit patternChanged(false);
3552  }
3553 }
3554 
3555 //---------------------------------------------------------------------------------------------------------------------
3556 void VPattern::setIncrementDescription(const QString &name, const QString &text)
3557 {
3558  QDomElement node = FindIncrement(name);
3559  if (not node.isNull())
3560  {
3561  SetAttribute(node, IncrementDescription, text);
3562  emit patternChanged(false);
3563  }
3564 }
3565 
3566 //---------------------------------------------------------------------------------------------------------------------
3567 void VPattern::replaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
3568 {
3569  const int bias = name.length() - newName.length();
3570 
3571  for(int i = 0; i < expressions.size(); ++i)
3572  {
3573  if (expressions.at(i).expression.indexOf(name) != -1)
3574  {
3575  QMap<int, QString> tokens;
3576 
3577  // Eval formula
3578  try
3579  {
3580  QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false,
3581  false));
3582  tokens = cal->GetTokens();// Tokens (variables, measurements)
3583 
3584  }
3585  catch (const qmu::QmuParserError &)
3586  {
3587  continue;// Because we not sure if used. A formula is broken.
3588  }
3589 
3590  QList<QString> tValues = tokens.values();
3591  if (not tValues.contains(name))
3592  {
3593  continue;
3594  }
3595 
3596  QList<int> tKeys = tokens.keys();// Take all tokens positions
3597  QString newFormula = expressions.at(i).expression;
3598 
3599  for (int i = 0; i < tKeys.size(); ++i)
3600  {
3601  if (tValues.at(i) != name)
3602  {
3603  continue;
3604  }
3605 
3606  newFormula.replace(tKeys.at(i), name.length(), newName);
3607 
3608  if (bias != 0)
3609  {// Translated token has different length than original. Position next tokens need to be corrected.
3610  VTranslateVars::BiasTokens(tKeys.at(i), bias, tokens);
3611  tKeys = tokens.keys();
3612  tValues = tokens.values();
3613  }
3614  }
3615 
3616  expressions[i].expression = newFormula;
3617  expressions[i].element.setAttribute(expressions.at(i).attribute, newFormula);
3618  emit patternChanged(false);
3619  }
3620  }
3621 }
3622 
3623 //---------------------------------------------------------------------------------------------------------------------
3624 /**
3625  * @brief GenerateLabel create name for draft block basepoint.
3626  * @param type type of the label.
3627  * @param reservedName reversed point name. Use when need reserve name, but point is not in data base yet.
3628  * @return unique name for current draft block.
3629  */
3630 QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedName) const
3631 {
3632  if (type == LabelType::NewPatternPiece)
3633  {
3634  const QDomNodeList blockList = elementsByTagName(TagDraftBlock);
3635  QString name;
3636  int i = 0;
3637  for (;;)
3638  {
3639  name = GetLabelBase(static_cast<quint32>(blockList.size() + i));
3640  if (data->IsUnique(name))
3641  {
3642  return name;
3643  }
3644  if (i == INT_MAX)
3645  {
3646  break;
3647  }
3648  ++i;
3649  }
3650  qCDebug(vXML, "Point name: %s", qUtf8Printable(name));
3651  return name;
3652  }
3653  else if (type == LabelType::NewLabel)
3654  {
3655  const QString labelBase = GetLabelBase(static_cast<quint32>(getActiveDraftBlockIndex()));
3656 
3657  qint32 num = 1;
3658  QString name;
3659  do
3660  {
3661  name = QString("%1%2").arg(labelBase).arg(num);
3662  num++;
3663  if (num == INT_MAX)
3664  {
3665  break;
3666  }
3667  } while (data->IsUnique(name) == false || name == reservedName);
3668  qCDebug(vXML, "Point name: %s", qUtf8Printable(name));
3669  return name;
3670  }
3671  qCDebug(vXML, "Got unknown type %d", static_cast<int>(type));
3672  return QString();
3673 }
3674 
3675 //---------------------------------------------------------------------------------------------------------------------
3676 QString VPattern::GenerateSuffix(const QString &type) const
3677 {
3678  const QString suffixBase = GetLabelBase(static_cast<quint32>(getActiveDraftBlockIndex())).toLower();
3679  const QStringList uniqueNames = VContainer::AllUniqueNames();
3680  qint32 num = 1;
3681  QString suffix;
3682  for (;;)
3683  {
3684  suffix = QString("_%1%2%3").arg(suffixBase).arg(num).arg(type);
3685 
3686  for (int i=0; i < uniqueNames.size(); ++i)
3687  {
3688  if (not data->IsUnique(uniqueNames.at(i) + suffix))
3689  {
3690  break;
3691  }
3692 
3693  if (i == uniqueNames.size()-1)
3694  {
3695  qCDebug(vXML, "Suffix is: %s", qUtf8Printable(suffix));
3696  return suffix;
3697  }
3698  }
3699 
3700  if (num == INT_MAX)
3701  {
3702  break;
3703  }
3704  ++num;
3705  }
3706  return QString();
3707 }
3708 
3709 //---------------------------------------------------------------------------------------------------------------------
3711 {
3712  QDomNodeList tags = elementsByTagName(TagGradation);
3713  if (tags.size() == 0)
3714  {
3715  return false;
3716  }
3717 
3718  const QDomNode domNode = tags.at(0);
3719  const QDomElement domElement = domNode.toElement();
3720  if (domElement.isNull() == false)
3721  {
3722  return getParameterBool(domElement, AttrCustom, falseStr);
3723  }
3724  else
3725  {
3726  return false;
3727  }
3728 }
3729 
3730 //---------------------------------------------------------------------------------------------------------------------
3731 void VPattern::SetDefCustom(bool value)
3732 {
3734  QDomNodeList tags = elementsByTagName(TagGradation);
3735  if (tags.isEmpty())
3736  {
3737  qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
3738  return;
3739  }
3740 
3741  QDomNode domNode = tags.at(0);
3742  QDomElement domElement = domNode.toElement();
3743  if (domElement.isNull() == false)
3744  {
3745  if (value == false)
3746  {
3747  domElement.removeAttribute(AttrDefHeight);
3748  SetDefCustomHeight(0);
3749  SetDefCustomSize(0);
3750  }
3751  else
3752  {
3753  SetAttribute(domElement, AttrCustom, value);
3754  }
3755  modified = true;
3756  }
3757  else
3758  {
3759  qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
3760  }
3761 }
3762 
3763 //---------------------------------------------------------------------------------------------------------------------
3765 {
3766  if (IsDefCustom())
3767  {
3768  QDomNodeList tags = elementsByTagName(TagGradation);
3769  if (tags.size() == 0)
3770  {
3771  return 0;
3772  }
3773 
3774  const QDomNode domNode = tags.at(0);
3775  const QDomElement domElement = domNode.toElement();
3776  if (domElement.isNull() == false)
3777  {
3778  return static_cast<int>(GetParametrUInt(domElement, AttrDefHeight, QStringLiteral("0")));
3779  }
3780  else
3781  {
3782  return 0;
3783  }
3784  }
3785  else
3786  {
3787  return 0;
3788  }
3789 }
3790 
3791 //---------------------------------------------------------------------------------------------------------------------
3793 {
3795  QDomNodeList tags = elementsByTagName(TagGradation);
3796  if (tags.isEmpty())
3797  {
3798  qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
3799  return;
3800  }
3801 
3802  QDomNode domNode = tags.at(0);
3803  QDomElement domElement = domNode.toElement();
3804  if (domElement.isNull() == false)
3805  {
3806  if (value == 0)
3807  {
3808  domElement.removeAttribute(AttrDefHeight);
3809  }
3810  else
3811  {
3812  SetAttribute(domElement, AttrDefHeight, value);
3813  }
3814  modified = true;
3815  }
3816  else
3817  {
3818  qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
3819  }
3820 }
3821 
3822 //---------------------------------------------------------------------------------------------------------------------
3824 {
3825  if (IsDefCustom())
3826  {
3827  QDomNodeList tags = elementsByTagName(TagGradation);
3828  if (tags.size() == 0)
3829  {
3830  return 0;
3831  }
3832 
3833  const QDomNode domNode = tags.at(0);
3834  const QDomElement domElement = domNode.toElement();
3835  if (domElement.isNull() == false)
3836  {
3837  return static_cast<int>(GetParametrUInt(domElement, AttrDefSize, QStringLiteral("0")));
3838  }
3839  else
3840  {
3841  return 0;
3842  }
3843  }
3844  else
3845  {
3846  return 0;
3847  }
3848 }
3849 
3850 //---------------------------------------------------------------------------------------------------------------------
3852 {
3854  QDomNodeList tags = elementsByTagName(TagGradation);
3855  if (tags.isEmpty())
3856  {
3857  qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
3858  return;
3859  }
3860 
3861  QDomNode domNode = tags.at(0);
3862  QDomElement domElement = domNode.toElement();
3863  if (domElement.isNull() == false)
3864  {
3865  if (value == 0)
3866  {
3867  domElement.removeAttribute(AttrDefSize);
3868  }
3869  else
3870  {
3871  SetAttribute(domElement, AttrDefSize, value);
3872  }
3873  modified = true;
3874  }
3875  else
3876  {
3877  qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
3878  }
3879 }
3880 
3881 //---------------------------------------------------------------------------------------------------------------------
3883 {
3884  const QDomElement pattern = documentElement();
3885 
3886  if (pattern.isNull())
3887  {
3888  return false;
3889  }
3890 
3891  return getParameterBool(pattern, AttrReadOnly, falseStr);
3892 }
3893 
3894 //---------------------------------------------------------------------------------------------------------------------
3895 void VPattern::SetReadOnly(bool rOnly)
3896 {
3897  QDomElement pattern = documentElement();
3898 
3899  if (not pattern.isNull())
3900  {
3901  if (rOnly)
3902  {
3903  SetAttribute(pattern, AttrReadOnly, rOnly);
3904  }
3905  else
3906  {// For better backward compatibility
3907  pattern.removeAttribute(AttrReadOnly);
3908  }
3909  modified = true;
3910  }
3911 }
3912 
3913 //---------------------------------------------------------------------------------------------------------------------
3915 {
3916  SCASSERT(draftScene != nullptr)
3917  SCASSERT(pieceScene != nullptr)
3918  if (parse == Document::FullParse)
3919  {
3920  TestUniqueId();
3921  draftScene->clear();
3923  pieceScene->clear();
3926  activeDraftBlock.clear();
3927  patternPieces.clear();
3928 
3929  qDeleteAll(toolsOnRemove);//Remove all invisible on a scene objects.
3930  toolsOnRemove.clear();
3931 
3932  tools.clear();
3933  cursor = 0;
3934  history.clear();
3935  }
3936  else if (parse == Document::LiteParse)
3937  {
3946  }
3947 }
3948 
3949 //---------------------------------------------------------------------------------------------------------------------
3950 void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
3951 {
3952  id = getParameterId(domElement);
3953 }
3954 
3955 //---------------------------------------------------------------------------------------------------------------------
3956 QT_WARNING_PUSH
3957 QT_WARNING_DISABLE_GCC("-Wswitch-default")
3958 
3959 QRectF VPattern::ActiveDrawBoundingRect() const
3960 {
3961  // This check helps to find missed tools in the switch
3962  Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were used.");
3963 
3964  QRectF rect;
3965 
3966  for (qint32 i = 0; i< history.size(); ++i)
3967  {
3968  const VToolRecord tool = history.at(i);
3969  if (tool.getDraftBlockName() == activeDraftBlock)
3970  {
3971  switch ( tool.getTypeTool() )
3972  {
3973  case Tool::Arrow:
3974  case Tool::SinglePoint:
3975  case Tool::DoublePoint:
3976  case Tool::LinePoint:
3977  case Tool::AbstractSpline:
3978  case Tool::Cut:
3979  case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type
3980  case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type
3982  Q_UNREACHABLE();
3983  break;
3984  case Tool::BasePoint:
3985  case Tool::LineIntersect:
3986  case Tool::PointOfContact:
3987  case Tool::Triangle:
3989  case Tool::CutArc:
3990  case Tool::CutSpline:
3991  case Tool::CutSplinePath:
3997  rect = ToolBoundingRect<VToolSinglePoint>(rect, tool.getId());
3998  break;
3999  case Tool::EndLine:
4000  case Tool::AlongLine:
4001  case Tool::ShoulderPoint:
4002  case Tool::Normal:
4003  case Tool::Bisector:
4004  case Tool::Height:
4007  rect = ToolBoundingRect<VToolLinePoint>(rect, tool.getId());
4008  break;
4009  case Tool::Line:
4010  rect = ToolBoundingRect<VToolLine>(rect, tool.getId());
4011  break;
4012  case Tool::Spline:
4013  case Tool::CubicBezier:
4014  case Tool::Arc:
4015  case Tool::SplinePath:
4016  case Tool::CubicBezierPath:
4017  case Tool::ArcWithLength:
4018  case Tool::EllipticalArc:
4019  rect = ToolBoundingRect<VAbstractSpline>(rect, tool.getId());
4020  break;
4021  case Tool::TrueDarts:
4022  rect = ToolBoundingRect<VToolDoublePoint>(rect, tool.getId());
4023  break;
4024  case Tool::Rotation:
4025  case Tool::MirrorByLine:
4026  case Tool::MirrorByAxis:
4027  case Tool::Move:
4028  rect = ToolBoundingRect<VAbstractOperation>(rect, tool.getId());
4029  break;
4030  //These tools are not accesseble in Draw mode, but still 'history' contains them.
4031  case Tool::Piece:
4032  case Tool::Union:
4033  case Tool::NodeArc:
4034  case Tool::NodeElArc:
4035  case Tool::NodePoint:
4036  case Tool::NodeSpline:
4037  case Tool::NodeSplinePath:
4038  case Tool::Group:
4039  case Tool::InternalPath:
4040  case Tool::AnchorPoint:
4041  case Tool::InsertNodes:
4042  break;
4043  }
4044  }
4045  }
4046  return rect;
4047 }
4048 
4050 
4051 //---------------------------------------------------------------------------------------------------------------------
4052 template <typename T>
4053 QRectF VPattern::ToolBoundingRect(const QRectF &rect, const quint32 &id) const
4054 {
4055  QRectF toolRect = rect;
4056  if (tools.contains(id))
4057  {
4058  const T *vTool = qobject_cast<T *>(tools.value(id));
4059  SCASSERT(vTool != nullptr)
4060 
4061  QRectF childrenRect = vTool->childrenBoundingRect();
4062  //map to scene coordinate.
4063  childrenRect.translate(vTool->scenePos());
4064 
4065  toolRect = toolRect.united(vTool->sceneBoundingRect());
4066  toolRect = toolRect.united(childrenRect);
4067  }
4068  else
4069  {
4070  qDebug()<<"Can't find tool with id="<<id;
4071  }
4072  return toolRect;
4073 }
4074 
4075 //---------------------------------------------------------------------------------------------------------------------
4076 /**
4077  * @brief IncrementReferens increment reference parent objects.
4078  * @param id parent object id.
4079  */
4080 void VPattern::IncrementReferens(quint32 id) const
4081 {
4082  Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
4083  ToolExists(id);
4084  VDataTool *tool = tools.value(id);
4085  SCASSERT(tool != nullptr)
4086  tool->incrementReferens();
4087 }
4088 
4089 //---------------------------------------------------------------------------------------------------------------------
4090 /**
4091  * @brief DecrementReferens decrement reference parent objects.
4092  * @param id parent object id.
4093  */
4094 void VPattern::DecrementReferens(quint32 id) const
4095 {
4096  Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
4097  ToolExists(id);
4098  VDataTool *tool = tools.value(id);
4099  SCASSERT(tool != nullptr)
4100  tool->decrementReferens();
4101 }
static AnchorPointTool * Create(QSharedPointer< DialogTool > dialog, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
The Calculator class for calculation formula.
Definition: calculator.h:84
static IntersectCircleTangentTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static IntersectCirclesTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static const QString TagCSA
static PatternPieceTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString AttrSeamAllowance
static const QString AttrHideSeamLine
static const QString AttrUnited
static const QString AttrPieceColor
static const QString AttrCenterAnchor
static const QString AttrHeight
static const QString AttrBottomAnchorPoint
static const QString AttrVersion
static const QString AttrFont
static const QString AttrTopLeftAnchor
static const QString AttrTopAnchorPoint
static const QString AttrSeamAllowanceBuiltIn
static const QString TagAnchors
static const QString TagIPaths
static const QString AttrPieceFill
static const QString AttrBottomRightAnchor
static const QString AttrForbidFlipping
static const QString ToolType
static PointIntersectXYTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString AttrIndexD2
Definition: union_tool.h:118
static const QString ToolType
Definition: union_tool.h:112
static UnionTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString AttrIndexD1
Definition: union_tool.h:117
void SetPos(const QPointF &ptPos)
virtual void ShowToolTip(const QString &toolTip)=0
static const QString AttrIdTool
Definition: vabstractnode.h:77
static void ExtractData(const QDomElement &domElement, QVector< SourceItem > &source, QVector< DestinationItem > &destination)
static const QString TagNode
static const QString AttrLetter
static const QString TagData
static const QString TagSpline
static const QString AttrAnnotation
void FullUpdateFromFile()
FullUpdateFromFile update tool data form file.
static const QString AttrType
static const QString AttrTilt
static const QString TagPieces
static QVector< quint32 > ParsePieceAnchors(const QDomElement &domElement)
static const QString NodeArc
static const QString AttrRotation
static const QString TagDescription
static const QString AttrFoldPosition
int draftBlockCount() const
static const QString NodePoint
static const QString AttrCustom
static const QString TagMeasurements
static const QString IncrementDescription
static const QString TagModeling
static const QString TagArc
static const QString TagPatternName
QString activeDraftBlock
activeBlockName name current pattern peace.
void setActiveDraftBlock(const QString &name)
setActiveDraftBlock set current draft block.
static const QString AttrDefSize
static const QString TagPattern
static const QString AttrOnFold
void haveLiteChange()
haveLiteChange we have unsaved change.
static const QString AttrWidth
static const QString TagNotes
static const QString TagTools
void patternChanged(bool saved)
patternChanged emit if we have unsaved change.
static const QString NodeSplinePath
static const QString TagCustomerName
static const QString TagPatternInfo
QVector< VToolRecord > history
history history records.
static const QString TagElArc
static const QString NodeSpline
static const QString AttrQuantity
static const QString AttrRotationWay
void parseGroups(const QDomElement &domElement)
static QHash< quint32, VDataTool * > tools
tools list with pointer on tools.
static const QString AttrOrientation
static const QString TagPatternLabel
static VPiecePath ParsePathNodes(const QDomElement &domElement)
static const QString TagLine
static const QString TagIncrement
static const QString TagGroups
bool getActiveDraftElement(QDomElement &element) const
getActiveDraftElement return draftBlock element for current draft block.
static const QString TagPatternNum
quint32 cursor
cursor cursor keep id tool after which we will add new tool in file.
void SetEnabledGUI(bool enabled)
static const QString AttrArrows
static const QString TagDraftBlock
static QVector< CustomSARecord > ParsePieceCSARecords(const QDomElement &domElement)
static VPiecePath ParsePieceNodes(const QDomElement &domElement)
static const QString IncrementName
static const QString NodeElArc
static const QString TagOperation
static const QString IncrementFormula
bool getActiveNodeElement(const QString &name, QDomElement &element) const
getActiveNodeElement find element in current draft block by name.
static const QString AttrNodeReverse
static const QString TagPath
static const QString TagPiece
static const QString TagCompanyName
QVector< VDataTool * > toolsOnRemove
QDomElement CheckTagExists(const QString &tag)
static void ToolExists(const quint32 &id)
static const QString TagImage
static const QString TagCalculation
static const QString TagGrainline
static const QString AttrName
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
void changeActiveDraftBlock(const QString &name, const Document &parse=Document::FullParse)
changeActiveDraftBlock set new active draft block name.
static const QString AttrDefHeight
static const QString TagNodes
static const QString TagIncrements
int getActiveDraftBlockIndex() const
QStringList patternPieces
patternPieces list of patern pieces names for combobox
static QVector< quint32 > ParsePieceInternalPaths(const QDomElement &domElement)
void setFill(const QString &value)
void SetMx(qreal value)
void SetForbidFlipping(bool value)
void setColor(const QString &value)
void setHideSeamLine(bool value)
void SetName(const QString &value)
void SetSeamAllowanceBuiltIn(bool value)
void SetSeamAllowance(bool value)
void SetMy(qreal value)
static const QString AttrInUse
Definition: vabstracttool.h:89
void ToolTip(const QString &toolTip)
static bool IsGUIMode()
static QStringList LabelLanguages()
VArc class for anticlockwise arc.
Definition: varc.h:74
The VContainer class container of all variables.
Definition: vcontainer.h:141
void AddVariable(const QString &name, T *var)
Definition: vcontainer.h:327
static void ClearUniqueNames()
Definition: vcontainer.cpp:629
void RemoveVariable(const QString &name)
Definition: vcontainer.cpp:481
void ClearCalculationGObjects()
Definition: vcontainer.cpp:322
static bool IsUnique(const QString &name)
Definition: vcontainer.cpp:585
void ClearVariables(const VarType &type=VarType::Unknown)
Definition: vcontainer.cpp:348
const QHash< QString, QSharedPointer< VInternalVariable > > * DataVariables() const
Definition: vcontainer.cpp:718
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
Definition: vcontainer.cpp:150
const QSharedPointer< T > GeometricObject(const quint32 &id) const
Definition: vcontainer.h:266
static QStringList AllUniqueNames()
Definition: vcontainer.cpp:591
void ClearForFullParse()
Definition: vcontainer.cpp:294
static void ClearUniqueIncrementNames()
Definition: vcontainer.cpp:635
void UpdateGObject(quint32 id, T *obj)
UpdateGObject update GObject by id.
Definition: vcontainer.h:374
The VDataTool class need for getting access to data container of tool.
Definition: vdatatool.h:71
virtual void decrementReferens()
decrementReferens decrement referens.
Definition: vdatatool.cpp:74
VContainer getData() const
getData return data container.
Definition: vdatatool.h:97
virtual void incrementReferens()
incrementReferens increment referens.
Definition: vdatatool.h:126
static QString GetParametrString(const QDomElement &domElement, const QString &name, const QString &defValue=QString())
Returns the string value of the given attribute. RENAME: see above.
static quint32 GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
static QString GetParametrEmptyString(const QDomElement &domElement, const QString &name)
static bool getParameterBool(const QDomElement &domElement, const QString &name, const QString &defValue)
void TestUniqueId() const
TestUniqueId test exist unique id in pattern file. Each id must be unique.
static void SetParametrUsage(QDomElement &domElement, const QString &name, const NodeUsage &value)
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
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
Definition: vdomdocument.h:185
virtual void setXMLContent(const QString &fileName)
virtual bool SaveDocument(const QString &fileName, QString &error)
static NodeUsage GetParametrUsage(const QDomElement &domElement, const QString &name)
QVector< VLabelTemplateLine > GetLabelTemplate(const QDomElement &element) const
static quint32 getParameterId(const QDomElement &domElement)
getParameterId return value id attribute.
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 VExceptionWrongId class for exception wrong id.
virtual QString DetailedInformation() const Q_DECL_OVERRIDE
DetailedInformation return detailed information about error.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
The VException class parent for all exception. Could be use for abstract exception.
Definition: vexception.h:66
virtual QString ErrorMessage() const
ErrorMessage return main error message.
Definition: vexception.cpp:97
void AddMoreInformation(const QString &info)
AddMoreInformation add more information for error.
Definition: vexception.cpp:107
virtual QString DetailedInformation() const
DetailedInformation return detailed information about error.
Definition: vexception.cpp:134
The VFSplinePoint class keep information about point in spline path. Each point have two angles and t...
Definition: vsplinepoint.h:70
void setMode(const Draw &value)
setMode set mode creation.
Definition: vgobject.cpp:178
void setIdObject(const quint32 &value)
setIdObject set parent id.
Definition: vgobject.cpp:138
quint32 getIdTool() const
Definition: vgobject.cpp:221
The VGrainlineData class holds information about a grainline like position, size, rotation and visibi...
void setBottomAnchorPoint(quint32 bottomAnchorPoint)
void SetRotation(const QString &qsRot)
void SetLength(const QString &qsLen)
void SetArrowType(ArrowType eAT)
void setCenterAnchorPoint(quint32 centerAnchor)
void setTopAnchorPoint(quint32 topAnchorPoint)
The VIncrement class keep data row of increment table.
Definition: vincrement.h:70
The VMainGraphicsScene class main scene.
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QGraphicsItem *item=nullptr)
NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
Definition: vnodearc.cpp:96
static const QString ToolType
Definition: vnodearc.h:76
The VNodeDetail class keep information about detail node.
Definition: vnodedetail.h:70
static QVector< VPieceNode > Convert(const VContainer *data, const QVector< VNodeDetail > &nodes, qreal width, bool closed)
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=NULL_ID)
static const QString ToolType
static const QString ToolType
Definition: vnodepoint.h:80
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idPoint, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
Definition: vnodepoint.cpp:134
static const QString ToolType
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
static VNodeSpline * Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
Definition: vnodespline.cpp:97
static const QString ToolType
Definition: vnodespline.h:78
static const QString PatternMaxVerStr
static Q_DECL_CONSTEXPR const int PatternMinVer
The VPatternLabelData class holds the information about pattern info label geometry.
void setBottomRightAnchorPoint(const quint32 &bottomRightAnchorPoint)
void setCenterAnchorPoint(const quint32 &centerAnchorPoint)
void SetLabelHeight(const QString &dLabelH)
void SetFontSize(int iSize)
void SetRotation(const QString &dRot)
void SetLabelWidth(const QString &dLabelW)
void setTopLeftAnchorPoint(const quint32 &topLeftAnchorPoint)
The VPattern class working with pattern file.
Definition: vpattern.h:68
void SetDefCustomSize(int value)
Definition: vpattern.cpp:3851
virtual void customEvent(QEvent *event) Q_DECL_OVERRIDE
Definition: vpattern.cpp:625
VMainGraphicsScene * draftScene
mode current draw mode.
Definition: vpattern.h:135
void ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1301
int GetDefCustomSize() const
Definition: vpattern.cpp:3823
void MoveDownIncrement(const QString &name)
Definition: vpattern.cpp:3518
void ParsePieceDataTag(const QDomElement &domElement, VPiece &piece) const
Definition: vpattern.cpp:925
void ParseNodeArc(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2833
void ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type)
Definition: vpattern.cpp:3350
void ParsePiecePatternInfo(const QDomElement &domElement, VPiece &piece) const
Definition: vpattern.cpp:949
QVector< quint32 > getActivePatternPieces() const
Definition: vpattern.cpp:385
QString GetLabelBase(quint32 index) const
Definition: vpattern.cpp:1203
VMainGraphicsScene * pieceScene
Definition: vpattern.h:136
void replaceNameInFormula(QVector< VFormulaField > &expressions, const QString &name, const QString &newName)
Definition: vpattern.cpp:3567
void ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2042
void ParsePathElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:3383
quint32 getActiveBasePoint()
getActiveBasePoint return id base point current draft block.
Definition: vpattern.cpp:363
static const QString AttrReadOnly
Definition: vpattern.h:122
void setIncrementDescription(const QString &name, const QString &text)
Definition: vpattern.cpp:3556
void ParseIncrementsElement(const QDomNode &node)
ParseIncrementsElement parse increments tag.
Definition: vpattern.cpp:3425
Draw * mode
data container with data.
Definition: vpattern.h:134
void ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2193
VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *draftScene, VMainGraphicsScene *pieceScene, QObject *parent=nullptr)
Definition: vpattern.cpp:105
void ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2086
void ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2160
void ParseAnchorPoint(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1659
void ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1681
void ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1496
void ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1820
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
Definition: vpattern.cpp:3950
int GetDefCustomHeight() const
Definition: vpattern.cpp:3764
void ParseNodeSplinePath(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2650
void PrepareForParse(const Document &parse)
Definition: vpattern.cpp:3914
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer< CONVERTER_VERSION_CHECK(0, 2, 7), "Time to refactor the code.")
void ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2798
void ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1905
virtual QString GenerateSuffix(const QString &type) const Q_DECL_OVERRIDE
Definition: vpattern.cpp:3676
VContainer * data
Definition: vpattern.h:133
void parseCurrentDraftBlock()
Definition: vpattern.cpp:1192
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2868
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const
void ParseToolLineIntersect(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1544
void ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1353
void parsePieceElement(QDomElement &domElement, const Document &parse)
parsePieceElement parse piece tag.
Definition: vpattern.cpp:807
void ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1958
void ParseNodePoint(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1620
void LiteParseIncrements()
Definition: vpattern.cpp:441
QDomElement FindIncrement(const QString &name) const
Definition: vpattern.cpp:3112
void addEmptyCustomVariable(const QString &name)
Definition: vpattern.cpp:3465
void ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2346
void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type)
ParseArcElement parse arc tag.
Definition: vpattern.cpp:3241
virtual void DecrementReferens(quint32 id) const Q_DECL_OVERRIDE
DecrementReferens decrement reference parent objects.
Definition: vpattern.cpp:4094
void parsePatternPieces(const QDomElement &domElement, const Document &parse)
parsePatternPieces parse pieces tag.
Definition: vpattern.cpp:983
void ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1575
void ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2118
virtual void CreateEmptyFile() Q_DECL_OVERRIDE
CreateEmptyFile create minimal empty file.
Definition: vpattern.cpp:121
void ParseOldToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2391
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my, bool &labelVisible, QString &lineType, QString &lineWeight, QString &lineColor)
Definition: vpattern.cpp:1005
QDomElement MakeEmptyIncrement(const QString &name)
Definition: vpattern.cpp:3102
void ParseNodeSpline(const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2604
void ParsePieceGrainline(const QDomElement &domElement, VPiece &piece) const
Definition: vpattern.cpp:964
bool IsReadOnly() const
Definition: vpattern.cpp:3882
void SetIncrementFormula(const QString &name, const QString &text)
Definition: vpattern.cpp:3545
void ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2453
void ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2695
void ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1400
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName=QString()) const Q_DECL_OVERRIDE
GenerateLabel create name for draft block basepoint.
Definition: vpattern.cpp:3630
void GarbageCollector()
Definition: vpattern.cpp:3133
void ParseToolMirrorByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2960
void SetReadOnly(bool rOnly)
Definition: vpattern.cpp:3895
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type)
ParsePointElement parse point tag.
Definition: vpattern.cpp:1040
void MoveUpIncrement(const QString &name)
Definition: vpattern.cpp:3502
bool IsDefCustom() const
Definition: vpattern.cpp:3710
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse, const QString &type)
ParseToolsElement parse tools tag.
Definition: vpattern.cpp:3309
void ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2743
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2917
VNodeDetail parsePieceNode(const QDomElement &domElement) const
Definition: vpattern.cpp:638
void setIncrementName(const QString &name, const QString &text)
Definition: vpattern.cpp:3534
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
Definition: vpattern.cpp:1184
void ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1268
void removeCustomVariable(const QString &name)
Definition: vpattern.cpp:3494
void ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1778
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE
Definition: vpattern.cpp:149
virtual void UpdateToolData(const quint32 &id, VContainer *data) Q_DECL_OVERRIDE
UpdateToolData update tool in list tools.
Definition: vpattern.cpp:347
void parseIntersectXYTool(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1745
void ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1863
virtual bool SaveDocument(const QString &fileName, QString &error) Q_DECL_OVERRIDE
Definition: vpattern.cpp:410
void ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2547
virtual void IncrementReferens(quint32 id) const Q_DECL_OVERRIDE
IncrementReferens increment reference parent objects.
Definition: vpattern.cpp:4080
void ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1448
void ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type)
ParseEllipticalArcElement parse elliptical arc tag.
Definition: vpattern.cpp:3277
void ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type)
ParseSplineElement parse spline tag.
Definition: vpattern.cpp:3178
void parseDraftBlockElement(const QDomNode &node, const Document &parse)
parseDraftBlockElement parse draw tag.
Definition: vpattern.cpp:684
virtual void LiteParseTree(const Document &parse) Q_DECL_OVERRIDE
LiteParseTree lite parse file.
Definition: vpattern.cpp:515
void ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2280
void ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:3020
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
ParseLineElement parse line tag.
Definition: vpattern.cpp:1158
void ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:1714
void SetDefCustom(bool value)
Definition: vpattern.cpp:3731
void SetDefCustomHeight(int value)
Definition: vpattern.cpp:3792
void addEmptyCustomVariableAfter(const QString &after, const QString &name)
Definition: vpattern.cpp:3475
void ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2239
void Parse(const Document &parse)
Parse parse file.
Definition: vpattern.cpp:160
void setCurrentData()
setCurrentData set current data set.
Definition: vpattern.cpp:274
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const
Definition: vpattern.cpp:3072
void ParseDrawMode(const QDomNode &node, const Document &parse, const Draw &mode)
ParseDrawMode parse draw tag with draw mode.
Definition: vpattern.cpp:731
void ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2009
void parsePieceNodes(const QDomElement &domElement, VPiece &piece, qreal width, bool closed) const
Definition: vpattern.cpp:907
void ParseToolMirrorByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
Definition: vpattern.cpp:2990
The VPieceLabelData class holds some information about a single piece like letter,...
void SetAnnotation(const QString &val)
void SetOnFold(bool onFold)
void SetLabelTemplate(const QVector< VLabelTemplateLine > &lines)
void SetTilt(const QString &val)
void SetRotationWay(const QString &val)
void SetFoldPosition(const QString &val)
void SetQuantity(int val)
void SetOrientation(const QString &val)
void SetLetter(const QString &qsLetter)
void SetType(PiecePathType type)
Definition: vpiecepath.cpp:245
void SetCutPath(bool cut)
Definition: vpiecepath.cpp:281
void SetNodes(const QVector< VPieceNode > &nodes)
Definition: vpiecepath.cpp:233
void SetPenType(const Qt::PenStyle &type)
Definition: vpiecepath.cpp:269
void SetName(const QString &name)
Definition: vpiecepath.cpp:257
Definition: vpiece.h:88
void setIsLocked(bool isLocked)
Definition: vpiece.cpp:394
VPieceLabelData & GetPatternPieceData()
Returns full access to the pattern piece data object.
Definition: vpiece.cpp:532
void SetPath(const VPiecePath &path)
Definition: vpiece.cpp:168
void SetInLayout(bool inLayout)
Definition: vpiece.cpp:382
void setAnchors(const QVector< quint32 > &anchors)
Definition: vpiece.cpp:474
void SetCustomSARecords(const QVector< CustomSARecord > &records)
Definition: vpiece.cpp:456
void SetInternalPaths(const QVector< quint32 > &iPaths)
Definition: vpiece.cpp:438
void SetUnited(bool united)
Definition: vpiece.cpp:406
VGrainlineData & GetGrainlineGeometry()
VDetail::GetGrainlineGeometry full access to the grainline geometry object.
Definition: vpiece.cpp:578
VPatternLabelData & GetPatternInfo()
Returns full access to the pattern info geometry object.
Definition: vpiece.cpp:558
VPiecePath GetPath() const
Definition: vpiece.cpp:156
The VPointF class keep data of point.
Definition: vpointf.h:75
void setShowPointName(bool show)
Definition: vpointf.cpp:265
The VSplinePath class keep information about splinePath.
Definition: vsplinepath.h:72
VSpline class that implements the spline.
Definition: vspline.h:75
static VToolAlongLine * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
static const QString ToolType
static const QString ToolType
static VToolArcWithLength * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static VToolArc * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool.
Definition: vtoolarc.cpp:126
static const QString ToolType
Definition: vtoolarc.h:81
The VToolBasePoint class tool for creation pattern base point. Only base point can move....
static const QString ToolType
static VToolBasePoint * Create(quint32 _id, const QString &activeDraftBlock, VPointF *point, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
static const QString ToolType
Definition: vtoolbisector.h:91
static VToolBisector * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
static VToolCubicBezierPath * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static VToolCubicBezier * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static const QString ToolType
static VToolCurveIntersectAxis * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
Definition: vtoolcutarc.h:85
static VToolCutArc * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
static VToolCutSplinePath * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
static const QString AttrSplinePath
static const QString ToolType
static const QString AttrSpline
static VToolCutSpline * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
static const QString ToolType
static VToolEllipticalArc * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool.
static VToolEndLine * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
Definition: vtoolendline.h:90
static VToolHeight * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
Definition: vtoolheight.h:90
static VToolInternalPath * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static VToolLineIntersectAxis * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static VToolLineIntersect * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
static VToolLine * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
Definition: vtoolline.cpp:133
static VToolMirrorByAxis * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static const QString ToolType
static VToolMirrorByLine * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static VToolMove * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Definition: vtoolmove.cpp:178
static const QString ToolType
Definition: vtoolmove.h:86
static const QString ToolType
Definition: vtoolnormal.h:91
static VToolNormal * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static VToolPointFromArcAndTangent * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static VToolPointOfContact * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static VToolPointOfIntersectionArcs * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static VToolPointOfIntersectionCurves * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
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
static VToolRotation * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
Definition: vtoolrotation.h:85
static VToolShoulderPoint * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
The VToolSplinePath class tool for creation spline path.
static VToolSplinePath * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
static const QString OldToolType
The VToolSpline class tool for creation spline. I mean bezier curve.
Definition: vtoolspline.h:74
static const QString OldToolType
Definition: vtoolspline.h:89
static VToolSpline * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString ToolType
Definition: vtoolspline.h:88
static const QString ToolType
Definition: vtooltriangle.h:90
static VToolTriangle * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static VToolTrueDarts * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
static const QString ToolType
static void BiasTokens(int position, int bias, QMap< int, QString > &tokens)
BiasTokens change position for each token that have position more then "position".
Error class of the parser.
const QEvent::Type LITE_PARSE_EVENT
Definition: customevents.h:73
const QEvent::Type UNDO_EVENT
Definition: customevents.h:61
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
Definition: def.cpp:702
const QString trueStr
Definition: def.cpp:197
const QString falseStr
Definition: def.cpp:198
#define SCASSERT(cond)
Definition: def.h:317
NodeDetail
Definition: def.h:102
@ CurveCLength
PiecePathType
Definition: def.h:157
Tool
Definition: def.h:161
@ CubicBezierPath
@ PointOfIntersectionCurves
@ PointOfIntersectionCircles
@ LineIntersectAxis
@ ArcWithLength
@ AlongLine
@ EndLine
@ SinglePoint
@ PointFromCircleAndTangent
@ InternalPath
@ MirrorByLine
@ ShoulderPoint
@ Spline
@ Bisector
@ NodeSplinePath
@ NodeSpline
@ NodeElArc
@ TrueDarts
@ Triangle
@ SplinePath
@ CurveIntersectAxis
@ LineIntersect
@ LinePoint
@ NodeArc
@ BasePoint
@ Midpoint
@ CutArc
@ ArcIntersectAxis
@ Normal
@ DoublePoint
@ EllipticalArc
@ PointOfContact
@ CutSplinePath
@ PointFromArcAndTangent
@ AbstractSpline
@ PointOfIntersection
@ NodePoint
@ CubicBezier
@ LAST_ONE_DO_NOT_USE
@ MirrorByAxis
@ PointOfIntersectionArcs
@ InsertNodes
@ Height
@ Rotation
@ CutSpline
@ AnchorPoint
NodeUsage
Definition: def.h:107
ArrowType
Definition: floatitemdef.h:60
const QString AttrPoint2
Definition: ifcdef.cpp:116
const QString AttrBasePoint
Definition: ifcdef.cpp:95
const QString AttrC1Radius
Definition: ifcdef.cpp:141
const QString AttrKAsm2
Definition: ifcdef.cpp:120
const QString AttrDuplicate
Definition: ifcdef.cpp:122
const QString AttrLength
Definition: ifcdef.cpp:94
const QString AttrPShoulder
Definition: ifcdef.cpp:114
const QString AttrName1
Definition: ifcdef.cpp:79
const QString AttrLineType
Definition: ifcdef.cpp:90
const QString AttrBaseLineP1
Definition: ifcdef.cpp:83
const QString AttrSecondPoint
Definition: ifcdef.cpp:97
const QString AttrC2Radius
Definition: ifcdef.cpp:142
const QString AttrCurve2
Definition: ifcdef.cpp:129
const QString LineTypeSolidLine
Definition: ifcdef.cpp:159
const QString AttrFirstPoint
Definition: ifcdef.cpp:96
const QString AttrLineWeight
Definition: ifcdef.cpp:91
const QString AttrP1Line1
Definition: ifcdef.cpp:110
const QString AttrPSpline
Definition: ifcdef.cpp:124
const QString AttrShowPointName2
Definition: ifcdef.cpp:155
const QString AttrP1Line
Definition: ifcdef.cpp:108
const QString AttrPenStyle
Definition: ifcdef.cpp:132
const QString AttrSecondArc
Definition: ifcdef.cpp:134
const QString AttrAngle
Definition: ifcdef.cpp:103
const QString AttrCurve
Definition: ifcdef.cpp:127
const QString AttrShowPointName1
Definition: ifcdef.cpp:154
const QString AttrFirstArc
Definition: ifcdef.cpp:133
const QString AttrMx
Definition: ifcdef.cpp:74
const QString AttrRadius2
Definition: ifcdef.cpp:102
const QString AttrShowPointName
Definition: ifcdef.cpp:153
const QString AttrCurve1
Definition: ifcdef.cpp:128
const QString AttrP2Line
Definition: ifcdef.cpp:109
const QString AttrAxisType
Definition: ifcdef.cpp:138
const QString AttrY
Definition: ifcdef.cpp:89
const QString AttrC1Center
Definition: ifcdef.cpp:139
const QString AttrCrossPoint
Definition: ifcdef.cpp:135
const QString AttrX
Definition: ifcdef.cpp:88
const QString AttrTangent
Definition: ifcdef.cpp:144
const QString AttrPoint3
Definition: ifcdef.cpp:117
const QString AttrMx2
Definition: ifcdef.cpp:80
const QString AttrDartP2
Definition: ifcdef.cpp:86
const QString AttrLength2
Definition: ifcdef.cpp:107
const QString AttrPoint1
Definition: ifcdef.cpp:115
const QString AttrAxisP2
Definition: ifcdef.cpp:126
const QString currentSeamAllowance
Definition: ifcdef.cpp:442
const QString AttrPieceLocked
Definition: ifcdef.cpp:150
const QString AttrRotationAngle
Definition: ifcdef.cpp:151
const QString ColorBlack
Definition: ifcdef.cpp:373
const QString AttrBaseLineP2
Definition: ifcdef.cpp:84
const QString AttrClosed
Definition: ifcdef.cpp:152
const QString AttrDartP1
Definition: ifcdef.cpp:85
const QString AttrRadius1
Definition: ifcdef.cpp:101
const QString AttrRadius
Definition: ifcdef.cpp:100
const QString AttrName2
Definition: ifcdef.cpp:82
const QString AttrHCrossPoint
Definition: ifcdef.cpp:137
const QString AttrLength1
Definition: ifcdef.cpp:106
const QString AttrInLayout
Definition: ifcdef.cpp:149
const QString AttrC2Center
Definition: ifcdef.cpp:140
const QString AttrKCurve
Definition: ifcdef.cpp:121
const QString AttrThirdPoint
Definition: ifcdef.cpp:98
const QString currentLength
Definition: ifcdef.cpp:441
const QString AttrVCrossPoint
Definition: ifcdef.cpp:136
const QString AttrDartP3
Definition: ifcdef.cpp:87
const QString AttrAxisP1
Definition: ifcdef.cpp:125
const QString AttrCRadius
Definition: ifcdef.cpp:145
const QString AttrMy
Definition: ifcdef.cpp:75
const QString AttrLineColor
Definition: ifcdef.cpp:130
const QString AttrAngle2
Definition: ifcdef.cpp:105
const QString AttrPathPoint
Definition: ifcdef.cpp:123
const QString AttrMx1
Definition: ifcdef.cpp:77
const QString AttrP2Line2
Definition: ifcdef.cpp:113
const QString AttrP1Line2
Definition: ifcdef.cpp:112
const QString AttrPoint4
Definition: ifcdef.cpp:118
const QString AttrColor
Definition: ifcdef.cpp:131
const QString AttrIdObject
Definition: ifcdef.cpp:148
const QString AttrMy1
Definition: ifcdef.cpp:78
const QString AttrSuffix
Definition: ifcdef.cpp:147
const QString AttrMy2
Definition: ifcdef.cpp:81
const QString AttrP2Line1
Definition: ifcdef.cpp:111
const QString AttrCCenter
Definition: ifcdef.cpp:143
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.
Definition: ifcdef.cpp:183
const QString AttrArc
Definition: ifcdef.cpp:146
const QString AttrAngle1
Definition: ifcdef.cpp:104
const QString AttrCenter
Definition: ifcdef.cpp:99
const QString AttrCut
Definition: ifcdef.cpp:93
const QString AttrKAsm1
Definition: ifcdef.cpp:119
#define NULL_ID
Definition: ifcdef.h:76
#define NULL_ID_STR
Definition: ifcdef.h:77
const QString APP_VERSION_STR
Source typeCreation
Definition: union_tool.h:97
VAbstractPattern * doc
Definition: union_tool.h:94
Document parse
Definition: union_tool.h:96
VContainer * data
Definition: union_tool.h:95
quint32 piece1_Index
Definition: union_tool.h:91
VMainGraphicsScene * scene
Definition: union_tool.h:93
quint32 piece2_Index
Definition: union_tool.h:92
#define CONVERTER_VERSION_CHECK(major, minor, patch)
Document
@ LiteBlockParse
HCrossCurvesPoint
VCrossCurvesPoint
AxisType
LabelType
CrossCirclesPoint
#define qApp
Definition: vapplication.h:67
@ SplinePath
Draw
Definition: vgeometrydef.h:55
@ Modeling
@ Calculation
static const auto V_EX_NOINPUT
Definition: vsysexits.h:71