Seamly2D
Code documentation
vabstracttool.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vabstracttool.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "vabstracttool.h"
53 
54 #include <QBrush>
55 #include <QDialog>
56 #include <QDialogButtonBox>
57 #include <QFlags>
58 #include <QGraphicsEllipseItem>
59 #include <QGraphicsLineItem>
60 #include <QHash>
61 #include <QIcon>
62 #include <QLineF>
63 #include <QMessageBox>
64 #include <QPainter>
65 #include <QPen>
66 #include <QPixmap>
67 #include <QPoint>
68 #include <QPointF>
69 #include <QRectF>
70 #include <QSharedPointer>
71 #include <QStaticStringData>
72 #include <QStringData>
73 #include <QStringDataPtr>
74 #include <QStyle>
75 #include <QUndoStack>
76 #include <QVector>
77 #include <new>
78 #include <qnumeric.h>
79 
80 #include "../vgeometry/vpointf.h"
81 #include "../vpropertyexplorer/checkablemessagebox.h"
82 #include "../vwidgets/vmaingraphicsview.h"
83 #include "../ifc/exception/vexception.h"
84 #include "../ifc/exception/vexceptionundo.h"
85 #include "../ifc/xml/vtoolrecord.h"
86 #include "../undocommands/deltool.h"
87 #include "../vgeometry/../ifc/ifcdef.h"
88 #include "../vgeometry/vgeometrydef.h"
89 #include "../vgeometry/vgobject.h"
90 #include "../vgeometry/vcubicbezier.h"
91 #include "../vgeometry/vcubicbezierpath.h"
92 #include "../vgeometry/vsplinepath.h"
93 #include "../vgeometry/varc.h"
94 #include "../vgeometry/vellipticalarc.h"
95 #include "../vmisc/vcommonsettings.h"
96 #include "../vmisc/logging.h"
97 #include "../vpatterndb/vcontainer.h"
98 #include "../vpatterndb/vpiecenode.h"
99 #include "../vpatterndb/calculator.h"
100 #include "../vwidgets/vgraphicssimpletextitem.h"
101 #include "nodeDetails/nodedetails.h"
102 #include "../dialogs/support/dialogundo.h"
103 #include "../dialogs/support/edit_formula_dialog.h"
104 
105 template <class T> class QSharedPointer;
106 
108 const QString VAbstractTool::AttrInUse = QStringLiteral("inUse");
109 
110 namespace
111 {
112 //---------------------------------------------------------------------------------------------------------------------
113 quint32 CreateNodeSpline(VContainer *data, quint32 id)
114 {
115  if (data->GetGObject(id)->getType() == GOType::Spline)
116  {
117  return VAbstractTool::CreateNode<VSpline>(data, id);
118  }
119  else
120  {
121  return VAbstractTool::CreateNode<VCubicBezier>(data, id);
122  }
123 }
124 
125 //---------------------------------------------------------------------------------------------------------------------
126 quint32 CreateNodeSplinePath(VContainer *data, quint32 id)
127 {
128  if (data->GetGObject(id)->getType() == GOType::SplinePath)
129  {
130  return VAbstractTool::CreateNode<VSplinePath>(data, id);
131  }
132  else
133  {
134  return VAbstractTool::CreateNode<VCubicBezierPath>(data, id);
135  }
136 }
137 }//static functions
138 
139 //---------------------------------------------------------------------------------------------------------------------
140 /**
141  * @brief VAbstractTool container.
142  * @param doc dom document container.
143  * @param data container with data.
144  * @param id object id in container.
145  * @param parent parent object.
146  */
147 VAbstractTool::VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent)
148  : VDataTool(data, parent)
149  , doc(doc)
150  , m_id(id)
151  , vis()
152  , selectionType(SelectionType::ByMouseRelease)
153 {
154  SCASSERT(doc != nullptr)
158 }
159 
160 //---------------------------------------------------------------------------------------------------------------------
162 {
163  if (not vis.isNull())
164  {
165  delete vis;
166  }
167 }
168 
169 //---------------------------------------------------------------------------------------------------------------------
170 /**
171  * @brief CheckFormula check formula.
172  *
173  * Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
174  * successes case return result calculation and fixed formula string. If formula ok don't touch formula.
175  *
176  * @param toolId [in] tool's id.
177  * @param formula [in|out] string with formula.
178  * @param data [in] container with variables. Need for math parser.
179  * @throw QmuParserError.
180  * @return result of calculation formula.
181  */
182 qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VContainer *data)
183 {
184  SCASSERT(data != nullptr)
185  qreal result = 0;
186  try
187  {
188  QScopedPointer<Calculator> cal(new Calculator());
189  result = cal->EvalFormula(data->DataVariables(), formula);
190 
191  if (qIsInf(result) || qIsNaN(result))
192  {
193  qDebug() << "Invalid the formula value";
194  return 0;
195  }
196  }
197  catch (qmu::QmuParserError &e)
198  {
199  qDebug() << "\nMath parser error:\n"
200  << "--------------------------------------\n"
201  << "Message: " << e.GetMsg() << "\n"
202  << "Expression: " << e.GetExpr() << "\n"
203  << "--------------------------------------";
204 
205  if (qApp->IsAppInGUIMode())
206  {
207  QScopedPointer<DialogUndo> dialogUndo(new DialogUndo(qApp->getMainWindow()));
208  forever
209  {
210  if (dialogUndo->exec() == QDialog::Accepted)
211  {
212  const UndoButton resultUndo = dialogUndo->Result();
213  if (resultUndo == UndoButton::Fix)
214  {
215  auto *dialog = new EditFormulaDialog(data, toolId, qApp->getMainWindow());
216  dialog->setWindowTitle(tr("Edit wrong formula"));
217  dialog->SetFormula(formula);
218  if (dialog->exec() == QDialog::Accepted)
219  {
220  formula = dialog->GetFormula();
221  /* Need delete dialog here because parser in dialog don't allow use correct separator for
222  * parsing here. */
223  delete dialog;
224  QScopedPointer<Calculator> cal1(new Calculator());
225  result = cal1->EvalFormula(data->DataVariables(), formula);
226 
227  if (qIsInf(result) || qIsNaN(result))
228  {
229  qDebug() << "Invalid the formula value";
230  return 0;
231  }
232 
233  break;
234  }
235  else
236  {
237  delete dialog;
238  }
239  }
240  else
241  {
242  throw VExceptionUndo(QString("Undo wrong formula %1").arg(formula));
243  }
244  }
245  else
246  {
247  throw;
248  }
249  }
250  }
251  else
252  {
253  throw;
254  }
255  }
256  return result;
257 }
258 
259 //---------------------------------------------------------------------------------------------------------------------
260 /**
261  * @brief deleteTool full delete object form scene and file.
262  */
264 {
265  qCDebug(vTool, "Deleting abstract tool.");
266  if (_referens <= 1)
267  {
268  qCDebug(vTool, "No children.");
269  qApp->getSceneView()->itemClicked(nullptr);
270  if (ask)
271  {
272  qCDebug(vTool, "Asking.");
273  if (ConfirmDeletion() == QMessageBox::No)
274  {
275  qCDebug(vTool, "User said no.");
276  return;
277  }
278  }
279 
280  qCDebug(vTool, "Begin deleting.");
281  DelTool *delTool = new DelTool(doc, m_id);
283  qApp->getUndoStack()->push(delTool);
284 
285  // Throw exception, this will help prevent case when we forget to immediately quit function.
286  VExceptionToolWasDeleted e("Tool was used after deleting.");
287  throw e;
288  }
289  else
290  {
291  qCDebug(vTool, "Can't delete, tool has children.");
292  }
293 }
294 
295 //---------------------------------------------------------------------------------------------------------------------
297 {
298  if (false == qApp->Settings()->getConfirmItemDelete())
299  {
300  return QMessageBox::Yes;
301  }
302 
303  Utils::CheckableMessageBox msgBox(qApp->getMainWindow());
304  msgBox.setWindowTitle(tr("Confirm deletion"));
305  msgBox.setText(tr("Do you really want to delete?"));
306  msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
307  msgBox.setDefaultButton(QDialogButtonBox::No);
308  msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32) );
309 
310  int dialogResult = msgBox.exec();
311 
312  if (dialogResult == QDialog::Accepted)
313  {
314  qApp->Settings()->setConfirmItemDelete(not msgBox.isChecked());
315  }
316 
317  return dialogResult == QDialog::Accepted ? QMessageBox::Yes : QMessageBox::No;
318 }
319 
320 //---------------------------------------------------------------------------------------------------------------------
321 const QStringList VAbstractTool::Colors()
322 {
323  const QStringList colors = QStringList() << ColorBlack << ColorGreen << ColorBlue
329  return colors;
330 }
331 
332 //---------------------------------------------------------------------------------------------------------------------
334 {
336 
337  const QStringList colorNames = Colors();
338  for (int i = 0; i < colorNames.size(); ++i)
339  {
340  QString name;
341  switch (i)
342  {
343  case 1: // ColorGreen
344  name = tr("Green");
345  break;
346  case 2: // ColorBlue
347  name = tr("Blue");
348  break;
349  case 3: // ColorDarkRed
350  name = tr("Dark Red");
351  break;
352  case 4: // ColorDarkGreen
353  name = tr("Dark Green");
354  break;
355  case 5: // ColorDarkBlue
356  name = tr("Dark Blue");
357  break;
358  case 6: // ColorYellow
359  name = tr("Yellow");
360  break;
361  case 7: // ColorLightSalmon
362  name = tr("Light Salmon");
363  break;
364  case 8: // ColorGoldenRod
365  name = tr("Goldenrod");
366  break;
367  case 9: // ColorOrange
368  name = tr("Orange");
369  break;
370  case 10: // ColorDeepPink
371  name = tr("Deep Pink");
372  break;
373  case 11: // ColorViolet
374  name = tr("Violet");
375  break;
376  case 12: // ColorDarkViolet
377  name = tr("Dark Violet");
378  break;
379  case 13: // ColorMediumSeaGreen
380  name = tr("Medium Sea Green");
381  break;
382  case 14: // ColorLime
383  name = tr("Lime");
384  break;
385  case 15: // ColorDeepSkyBlue
386  name = tr("Deep Sky Blue");
387  break;
388  case 16: // ColorCornFlowerBlue
389  name = tr("Corn Flower Blue");
390  break;
391  case 0: // ColorBlack
392  default:
393  name = tr("Black");
394  break;
395  }
396 
397  map.insert(colorNames.at(i), name);
398  }
399  return map;
400 }
401 
402 //---------------------------------------------------------------------------------------------------------------------
404 {
406  map.insert("gold", tr("Gold"));
407  map.insert("forestgreen", tr("Forest Green"));
408  map.insert("lawngreen", tr("Lawn Green"));
409  map.insert("limegreen", tr("Lime Green"));
410  map.insert("greenyellow", tr("Green Yellow"));
411  map.insert("sandybrown", tr("Sandy Brown"));
412  map.insert("orangered", tr("Orange Red"));
413  map.insert("maroon", tr("Maroon"));
414  map.insert("pink", tr("Pink"));
415  map.insert("hotpink", tr("Hot Pink"));
416  map.insert("blueviolet", tr("Blue Violet"));
417  map.insert("mediumvioletred", tr("Medium Violet Red"));
418  map.insert("indigo", tr("Indigo"));
419  map.insert("purple", tr("Purple"));
420  map.insert("plum", tr("Plum"));
421  map.insert("turquoise", tr("Turquoise"));
422  map.insert("mediumturquoise", tr("Medium Turquoise"));
423  map.insert("powderblue", tr("Powder Blue"));
424  map.insert("lightskyblue", tr("Light Sky Blue"));
425  map.insert("navy", tr("Navy"));
426  map.insert("magenta", tr("Magenta"));
427  return map;
428 }
429 
430 //---------------------------------------------------------------------------------------------------------------------
432 {
434 
435  map.insert("darkslategrey", tr("Dark Slate Grey"));
436  map.insert("grey", tr("Grey"));
437  map.insert("gainsboro", tr("Gainsboro"));
438  map.insert("darkseagreen", tr("Dark Sea Green"));
439  map.insert("lightgrey", tr("Light Grey"));
440  map.insert("darkslategrey", tr("Dark Slate Grey"));
441  map.insert("lightsteelblue", tr("Light Steel Blue"));
442  map.insert("biege", tr("Biege"));
443  map.insert("thistle", tr("Thistle"));
444  map.insert("silver", tr("Silver"));
445  map.insert("whitesmoke", tr("White Smoke"));
446  map.insert("white", tr("White"));
447  map.insert("darkgrey", tr("Dark Grey"));
448  map.insert("cadetblue", tr("Cadet Blue"));
449  map.insert("darkkhaki", tr("Dark Khaki"));
450  map.insert("tan", tr("Tan"));
451 
452  return map;
453 }
454 
455 QPixmap VAbstractTool::createColorIcon(const int w, const int h, const QString &color)
456 {
457  QPixmap pixmap(w, h);
458  pixmap.fill(QColor(Qt::black));
459 
460  QPainter painter(&pixmap);
461  painter.setPen(Qt::black);
462 
463  const QRect rectangle = QRect(1, 1, w-2, h-2);
464 
465  qDebug()<<"createColorIcon - color = "<< color;
466 
467  if (color == "No Group")
468  {
469  painter.fillRect(rectangle, QColor(Qt::white));
470  painter.drawLine(0, 0, w, h);
471  painter.drawLine(0, h, w, 0);
472  }
473  else if (color == "By Group")
474  {
475  QFont font = painter.font();
476  font.setPixelSize(10);
477  painter.setFont(font);
478  painter.fillRect(rectangle, QColor(Qt::white));
479  painter.drawText(rectangle, Qt::AlignCenter, "GROUP");
480  }
481  else
482  {
483  painter.fillRect(rectangle, QColor(color));
484  }
485 
486  return pixmap;
487 }
488 
489 //---------------------------------------------------------------------------------------------------------------------
490 const QStringList VAbstractTool::fills()
491 {
492  const QStringList fills = QStringList() << FillNone << FillSolid << FillDense1
497  return fills;
498 }
499 
500 //---------------------------------------------------------------------------------------------------------------------
501 // cppcheck-suppress unusedFunction
503 {
506  QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
507  for (i = objs->constBegin(); i != objs->constEnd(); ++i)
508  {
509  if (i.key() != m_id)
510  {
511  QSharedPointer<VGObject> obj = i.value();
512  if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
513  {
514  const QSharedPointer<VPointF> point = data.GeometricObject<VPointF>(i.key());
515  list[point->name()] = i.key();
516  }
517  }
518  }
519  return list;
520 }
521 
522 //---------------------------------------------------------------------------------------------------------------------
523 void VAbstractTool::setPointNamePosition(quint32 id, const QPointF &pos)
524 {
525  Q_UNUSED(id)
526  Q_UNUSED(pos)
527 }
528 
529 //---------------------------------------------------------------------------------------------------------------------
530 void VAbstractTool::setPointNameVisiblity(quint32 id, bool visible)
531 {
532  Q_UNUSED(id)
533  Q_UNUSED(visible)
534 }
535 
536 //---------------------------------------------------------------------------------------------------------------------
538 {
539  selectionType = type;
540 }
541 
542 //---------------------------------------------------------------------------------------------------------------------
544 {
545  // do nothing
546 }
547 
548 //---------------------------------------------------------------------------------------------------------------------
549 void VAbstractTool::ToolCreation(const Source &typeCreation)
550 {
551  if (typeCreation == Source::FromGui)
552  {
553  AddToFile();
554  }
555  else
556  {
558  }
559 }
560 
561 //---------------------------------------------------------------------------------------------------------------------
562 /**
563  * @brief AddRecord add record about tool in history.
564  * @param id object id in container
565  * @param toolType tool type
566  * @param doc dom document container
567  */
568 void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc)
569 {
570  QVector<VToolRecord> *history = doc->getHistory();
571  VToolRecord record = VToolRecord(id, toolType, doc->getActiveDraftBlockName());
572  if (history->contains(record))
573  {
574  return;
575  }
576 
577  quint32 cursor = doc->getCursor();
578  if (cursor == NULL_ID)
579  {
580  history->append(record);
581  }
582  else
583  {
584  qint32 index = 0;
585  for (qint32 i = 0; i<history->size(); ++i)
586  {
587  VToolRecord rec = history->at(i);
588  if (rec.getId() == cursor)
589  {
590  index = i;
591  break;
592  }
593  }
594  history->insert(index+1, record);
595  }
596 }
597 
598 //---------------------------------------------------------------------------------------------------------------------
599 void VAbstractTool::AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiecePath &path)
600 {
601  if (path.CountNodes() > 0)
602  {
603  QDomElement nodesElement = doc->createElement(VAbstractPattern::TagNodes);
604  for (int i = 0; i < path.CountNodes(); ++i)
605  {
606  AddNode(doc, nodesElement, path.at(i));
607  }
608  domElement.appendChild(nodesElement);
609  }
610 }
611 
612 //---------------------------------------------------------------------------------------------------------------------
613 void VAbstractTool::AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece)
614 {
615  AddNodes(doc, domElement, piece.GetPath());
616 }
617 
618 //---------------------------------------------------------------------------------------------------------------------
619 QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, const VPieceNode &node)
620 {
621  QDomElement nod = doc->createElement(tagName);
622 
623  doc->SetAttribute(nod, AttrIdObject, node.GetId());
624 
625  const Tool type = node.GetTypeTool();
626  if (type != Tool::NodePoint)
627  {
628  doc->SetAttribute(nod, VAbstractPattern::AttrNodeReverse, static_cast<quint8>(node.GetReverse()));
629  }
630  else
631  {
633  {
635  }
636 
638  {
640  }
641  }
642 
643  {
644  const bool excluded = node.isExcluded();
645  if (excluded)
646  {
648  }
649  else
650  { // For backward compatebility.
651  nod.removeAttribute(VAbstractPattern::AttrNodeExcluded);
652  }
653  }
654 
655  switch (type)
656  {
657  case (Tool::NodeArc):
659  break;
660  case (Tool::NodeElArc):
662  break;
663  case (Tool::NodePoint):
665  break;
666  case (Tool::NodeSpline):
668  break;
669  case (Tool::NodeSplinePath):
671  break;
672  default:
673  qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
674  break;
675  }
676 
677  {
678  const unsigned char angleType = static_cast<unsigned char>(node.GetAngleType());
679 
680  if (angleType > 0)
681  {
682  doc->SetAttribute(nod, AttrAngle, angleType);
683  }
684  }
685 
686  if (type == Tool::NodePoint)
687  {
688  if (node.isNotch())
689  {
699  }
700 
701  if (not node.isNotch() && node.getNotchType() == NotchType::Slit
703  { // For backward compatebility.
704  nod.removeAttribute(VAbstractPattern::AttrNodeIsNotch);
705  nod.removeAttribute(VAbstractPattern::AttrNodeNotchType);
706  nod.removeAttribute(VAbstractPattern::AttrNodeNotchSubType);
707  }
708  }
709  else
710  { // Wrong configuration.
711  nod.removeAttribute(VAbstractPattern::AttrNodeIsNotch);
712  nod.removeAttribute(VAbstractPattern::AttrNodeNotchType);
713  nod.removeAttribute(VAbstractPattern::AttrNodeNotchSubType);
714  }
715 
716  return nod;
717 }
718 
719 //---------------------------------------------------------------------------------------------------------------------
720 void VAbstractTool::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node)
721 {
722  domElement.appendChild(AddSANode(doc, VAbstractPattern::TagNode, node));
723 }
724 
725 //---------------------------------------------------------------------------------------------------------------------
727  VAbstractPattern *doc, VContainer *data)
728 {
729  QVector<VPieceNode> nodes;
730  for (int i = 0; i< path.CountNodes(); ++i)
731  {
732  VPieceNode node = path.at(i);
733  const quint32 id = PrepareNode(node, scene, doc, data);
734  if (id > NULL_ID)
735  {
736  node.SetId(id);
737  nodes.append(node);
738  }
739  }
740  return nodes;
741 }
742 
743 //---------------------------------------------------------------------------------------------------------------------
745  VAbstractPattern *doc, VContainer *data)
746 {
747  SCASSERT(scene != nullptr)
748  SCASSERT(doc != nullptr)
749  SCASSERT(data != nullptr)
750 
751  quint32 id = NULL_ID;
752  switch (node.GetTypeTool())
753  {
754  case (Tool::NodePoint):
755  id = CreateNode<VPointF>(data, node.GetId());
757  break;
758  case (Tool::NodeArc):
759  id = CreateNode<VArc>(data, node.GetId());
761  break;
762  case (Tool::NodeElArc):
763  id = CreateNode<VEllipticalArc>(data, node.GetId());
765  break;
766  case (Tool::NodeSpline):
767  id = CreateNodeSpline(data, node.GetId());
769  break;
770  case (Tool::NodeSplinePath):
771  id = CreateNodeSplinePath(data, node.GetId());
773  break;
774  default:
775  qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
776  break;
777  }
778  return id;
779 }
The Calculator class for calculation formula.
Definition: calculator.h:84
The EditFormulaDialog class dialog for editing wrong formula.
The CheckableMessageBox class implements a message box suitable for questions with a "Do not ask me a...
void setStandardButtons(QDialogButtonBox::StandardButtons s)
void setIconPixmap(const QPixmap &p)
void setDefaultButton(QDialogButtonBox::StandardButton s)
static const QString TagNode
virtual void LiteParseTree(const Document &parse)=0
void FullUpdateFromFile()
FullUpdateFromFile update tool data form file.
static const QString NodeArc
static const QString AttrNodeNotchType
static const QString NodePoint
void haveLiteChange()
haveLiteChange we have unsaved change.
static const QString AttrNodeNotchSubType
static const QString NodeSplinePath
static const QString NodeSpline
static const QString AttrNodeShowSecondNotch
static const QString AttrSAAfter
static const QString AttrNodeNotchLength
static const QString AttrNodeNotchCount
static const QString AttrSABefore
static const QString NodeElArc
static const QString AttrNodeReverse
QString getActiveDraftBlockName() const
getActiveDraftBlockName return current draft block name.
quint32 getCursor() const
static const QString AttrNodeExcluded
static const QString AttrNodeNotchAngle
static const QString AttrNodeIsNotch
static const QString AttrNodeNotchWidth
QVector< VToolRecord > * getHistory()
getHistory return list with list of history records.
static const QString TagNodes
static const QString AttrNodeShowNotch
static void AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiecePath &path)
static const QString AttrInUse
Definition: vabstracttool.h:89
VAbstractPattern * doc
doc dom document container
virtual void AddToFile()=0
AddToFile add tag with Information about tool into file.
virtual void setPointNamePosition(quint32 id, const QPointF &pos)
QPointer< Visualization > vis
virtual void FullUpdateFromFile()=0
FullUpdateFromFile update tool data form file.
virtual void deleteTool(bool ask=true)
deleteTool full delete object form scene and file.
static bool m_suppressContextMenu
Definition: vabstracttool.h:87
static QVector< VPieceNode > PrepareNodes(const VPiecePath &path, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
void toolHasChanges()
toolHasChanges emit if tool create change that need save.
static QDomElement AddSANode(VAbstractPattern *doc, const QString &tagName, const VPieceNode &node)
VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent=nullptr)
VAbstractTool container.
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node)
static const QStringList Colors()
virtual void ToolCreation(const Source &typeCreation)
static int ConfirmDeletion()
static QMap< QString, QString > supportColorsList()
static QMap< QString, QString > ColorsList()
static void AddRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc)
AddRecord add record about tool in history.
static const QStringList fills()
QMap< QString, quint32 > PointsList() const
void LiteUpdateTree(const Document &parse)
FullUpdateTree emit if need reparse pattern file.
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data)
CheckFormula check formula.
const quint32 m_id
id object id.
virtual ~VAbstractTool() Q_DECL_OVERRIDE
static quint32 PrepareNode(const VPieceNode &node, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
virtual void RefreshDataInFile()
RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
static QPixmap createColorIcon(const int w, const int h, const QString &color)
virtual void ToolSelectionType(const SelectionType &type)
SelectionType selectionType
virtual void setPointNameVisiblity(quint32 id, bool visible)
static QMap< QString, QString > backgroundColorsList()
The VContainer class container of all variables.
Definition: vcontainer.h:141
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
const QHash< quint32, QSharedPointer< VGObject > > * DataGObjects() const
data container with datagObjects return container of gObjects
Definition: vcontainer.cpp:706
The VDataTool class need for getting access to data container of tool.
Definition: vdatatool.h:71
quint32 _referens
_referens keep count tools what use this tool. If value more than 1 you can't delete tool.
Definition: vdatatool.h:87
VContainer data
data container with data
Definition: vdatatool.h:84
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
Definition: vdomdocument.h:185
The VMainGraphicsScene class main scene.
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 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 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 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
Tool GetTypeTool() const
Definition: vpiecenode.cpp:161
bool showNotch() const
Definition: vpiecenode.cpp:338
quint32 GetId() const
Definition: vpiecenode.cpp:149
bool isExcluded() const
Definition: vpiecenode.cpp:411
PieceNodeAngle GetAngleType() const
Definition: vpiecenode.cpp:272
NotchType getNotchType() const
Definition: vpiecenode.cpp:314
QString GetFormulaSAAfter() const
Definition: vpiecenode.cpp:257
qreal getNotchAngle() const
Definition: vpiecenode.cpp:393
QString GetFormulaSABefore() const
Definition: vpiecenode.cpp:215
bool GetReverse() const
Definition: vpiecenode.cpp:173
qreal getNotchLength() const
Definition: vpiecenode.cpp:369
bool isNotch() const
Definition: vpiecenode.cpp:287
int getNotchCount() const
Definition: vpiecenode.cpp:405
NotchSubType getNotchSubType() const
Definition: vpiecenode.cpp:326
void SetId(quint32 id)
Definition: vpiecenode.cpp:155
qreal getNotchWidth() const
Definition: vpiecenode.cpp:381
bool showSeamlineNotch() const
Definition: vpiecenode.cpp:350
qint32 CountNodes() const
Definition: vpiecepath.cpp:209
const VPieceNode & at(int indx) const
Definition: vpiecepath.cpp:221
Definition: vpiece.h:88
VPiecePath GetPath() const
Definition: vpiece.cpp:156
The VPointF class keep data of point.
Definition: vpointf.h:75
The VToolRecord class record about tool in history.
Definition: vtoolrecord.h:64
quint32 getId() const
getId return tool id.
Definition: vtoolrecord.h:94
void NeedFullParsing()
Error class of the parser.
const QString & GetMsg() const
Returns the message string for this error.
const QString & GetExpr() const
gets the expression related tp this error.
QString notchSubTypeToString(NotchSubType type)
Definition: def.cpp:632
QString notchTypeToString(NotchType type)
Definition: def.cpp:574
#define SCASSERT(cond)
Definition: def.h:317
Tool
Definition: def.h:161
@ NodeSplinePath
@ NodeSpline
@ NodeElArc
@ NodeArc
@ NodePoint
SelectionType
Definition: def.h:108
Source
Definition: def.h:106
UndoButton
Definition: dialogundo.h:67
const QString ColorDarkRed
Definition: ifcdef.cpp:376
const QString ColorCornFlowerBlue
Definition: ifcdef.cpp:389
const QString FillDense6
Definition: ifcdef.cpp:402
const QString ColorBlue
Definition: ifcdef.cpp:375
const QString FilldDiagonalCross
Definition: ifcdef.cpp:409
const QString FillBackwardDiagonal
Definition: ifcdef.cpp:407
const QString FillDense4
Definition: ifcdef.cpp:400
const QString ColorMediumSeaGreen
Definition: ifcdef.cpp:386
const QString ColorYellow
Definition: ifcdef.cpp:379
const QString AttrAngle
Definition: ifcdef.cpp:103
const QString FillDense3
Definition: ifcdef.cpp:399
const QString FillHorizLines
Definition: ifcdef.cpp:404
const QString ColorGoldenRod
Definition: ifcdef.cpp:381
const QString ColorDarkBlue
Definition: ifcdef.cpp:378
const QString ColorViolet
Definition: ifcdef.cpp:384
const QString FillNone
Definition: ifcdef.cpp:395
const QString FillCross
Definition: ifcdef.cpp:406
const QString FillDense2
Definition: ifcdef.cpp:398
const QString currentSeamAllowance
Definition: ifcdef.cpp:442
const QString FillDense5
Definition: ifcdef.cpp:401
const QString ColorLightSalmon
Definition: ifcdef.cpp:380
const QString ColorBlack
Definition: ifcdef.cpp:373
const QString ColorDarkGreen
Definition: ifcdef.cpp:377
const QString FillSolid
Definition: ifcdef.cpp:396
const QString AttrType
Definition: ifcdef.cpp:73
const QString ColorDeepPink
Definition: ifcdef.cpp:383
const QString AttrIdObject
Definition: ifcdef.cpp:148
const QString FillDense1
Definition: ifcdef.cpp:397
const QString FillVertLines
Definition: ifcdef.cpp:405
const QString FillDense7
Definition: ifcdef.cpp:403
const QString ColorGreen
Definition: ifcdef.cpp:374
const QString ColorOrange
Definition: ifcdef.cpp:382
const QString ColorLime
Definition: ifcdef.cpp:387
const QString ColorDeepSkyBlue
Definition: ifcdef.cpp:388
const QString ColorDarkViolet
Definition: ifcdef.cpp:385
const QString FillForwardDiagonal
Definition: ifcdef.cpp:408
#define NULL_ID
Definition: ifcdef.h:76
quint32 CreateNodeSpline(VContainer *data, quint32 id)
quint32 CreateNodeSplinePath(VContainer *data, quint32 id)
#define qApp
Definition: vapplication.h:67
@ SplinePath
@ Calculation