Seamly2D
Code documentation
vabstractoperation.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
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 12 9, 2016
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) 2016 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 #include <QtDebug>
52 
53 #include "vabstractoperation.h"
54 #include "../../../undocommands/label/moveoperationlabel.h"
55 #include "../../../undocommands/label/showoperationpointname.h"
56 #include "../vgeometry/vpointf.h"
57 
58 const QString VAbstractOperation::TagItem = QStringLiteral("item");
59 const QString VAbstractOperation::TagSource = QStringLiteral("source");
60 const QString VAbstractOperation::TagDestination = QStringLiteral("destination");
61 
62 //---------------------------------------------------------------------------------------------------------------------
64 {
65  QVector<quint32> ids;
66  ids.reserve(source.size());
67 
68  for (auto s: source)
69  {
70  ids.append(s.id);
71  }
72 
73  return ids;
74 }
75 
76 //---------------------------------------------------------------------------------------------------------------------
78 {
80 }
81 
82 //---------------------------------------------------------------------------------------------------------------------
84 {
85  return suffix;
86 }
87 
88 //---------------------------------------------------------------------------------------------------------------------
89 void VAbstractOperation::setSuffix(const QString &suffix)
90 {
91  // Don't know if need check name here.
92  this->suffix = suffix;
94  SaveOption(obj);
95 }
96 
97 //---------------------------------------------------------------------------------------------------------------------
98 void VAbstractOperation::GroupVisibility(quint32 object, bool visible)
99 {
100  if (operatedObjects.contains(object))
101  {
102  VAbstractSimple *obj = operatedObjects.value(object);
103  if (obj && obj->GetType() == GOType::Point)
104  {
105  VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
106  SCASSERT(item != nullptr)
107  item->setVisible(visible);
108  }
109  else
110  {
111  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
112  SCASSERT(item != nullptr)
113  item->setVisible(visible);
114  }
115  }
116 }
117 
118 //---------------------------------------------------------------------------------------------------------------------
119 void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
120 {
121  Q_UNUSED(painter)
122  Q_UNUSED(option)
123  Q_UNUSED(widget)
124 }
125 
126 //---------------------------------------------------------------------------------------------------------------------
128 {
129  if (operatedObjects.contains(id))
130  {
131  VAbstractSimple *obj = operatedObjects.value(id);
132  if (obj && obj->GetType() == GOType::Point)
133  {
134  return VAbstractTool::data.GeometricObject<VPointF>(id)->isShowPointName();
135  }
136  }
137 
138  return false;
139 }
140 
141 //---------------------------------------------------------------------------------------------------------------------
142 void VAbstractOperation::setPointNameVisiblity(quint32 id, bool visible)
143 {
144  if (operatedObjects.contains(id))
145  {
146  VAbstractSimple *obj = operatedObjects.value(id);
147  if (obj && obj->GetType() == GOType::Point)
148  {
149  VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
150  SCASSERT(item != nullptr)
152  point->setShowPointName(visible);
153  item->refreshPointGeometry(*point);
154  }
155  }
156 }
157 
158 //---------------------------------------------------------------------------------------------------------------------
159 void VAbstractOperation::updatePointNameVisibility(quint32 id, bool visible)
160 {
161  if (operatedObjects.contains(id))
162  {
163  VAbstractSimple *obj = operatedObjects.value(id);
164  if (obj && obj->GetType() == GOType::Point)
165  {
166  auto dItem = std::find_if(destination.begin(), destination.end(),
167  [id](const DestinationItem &dItem) { return dItem.id == id; });
168  if (dItem != destination.end())
169  {
170  dItem->showPointName = visible;
171  }
172  qApp->getUndoStack()->push(new ShowOperationPointName(doc, m_id, id, visible));
173  }
174  }
175 }
176 
177 //---------------------------------------------------------------------------------------------------------------------
178 void VAbstractOperation::setPointNamePosition(quint32 id, const QPointF &pos)
179 {
180  if (operatedObjects.contains(id))
181  {
182  VAbstractSimple *obj = operatedObjects.value(id);
183  if (obj && obj->GetType() == GOType::Point)
184  {
185  VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
186  SCASSERT(item != nullptr)
188  point->setMx(pos.x());
189  point->setMy(pos.y());
190  item->refreshPointGeometry(*(point.data()));
191 
192  if (QGraphicsScene *sc = scene())
193  {
194  VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), item);
195  }
196  }
197  }
198 }
199 
200 //---------------------------------------------------------------------------------------------------------------------
201 void VAbstractOperation::pointNamePositionChanged(const QPointF &pos, quint32 labelId)
202 {
203  if (operatedObjects.contains(labelId))
204  {
205  VAbstractSimple *obj = operatedObjects.value(labelId);
206  if (obj && obj->GetType() == GOType::Point)
207  {
208  VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
209  SCASSERT(item != nullptr)
210  updatePointNamePosition(labelId, pos - item->pos());
211  }
212  }
213 }
214 
215 //---------------------------------------------------------------------------------------------------------------------
216 void VAbstractOperation::updatePointNamePosition(quint32 id, const QPointF &pos)
217 {
218  if (operatedObjects.contains(id))
219  {
220  VAbstractSimple *obj = operatedObjects.value(id);
221  if (obj && obj->GetType() == GOType::Point)
222  {
223  auto dItem = std::find_if(destination.begin(), destination.end(),
224  [id](const DestinationItem &dItem) { return dItem.id == id; });
225  if (dItem != destination.end())
226  {
227  dItem->mx = pos.x();
228  dItem->my = pos.y();
229  }
230  qApp->getUndoStack()->push(new MoveOperationLabel(m_id, doc, pos, id));
231  }
232  }
233 }
234 
235 //---------------------------------------------------------------------------------------------------------------------
236 void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<SourceItem> &source,
237  QVector<DestinationItem> &destination)
238 {
239  const QDomNodeList nodeList = domElement.childNodes();
240  for (qint32 i = 0; i < nodeList.size(); ++i)
241  {
242  const QDomElement dataElement = nodeList.at(i).toElement();
243  if (not dataElement.isNull() && dataElement.tagName() == TagSource)
244  {
245  source.clear();
246  const QDomNodeList srcList = dataElement.childNodes();
247  for (qint32 j = 0; j < srcList.size(); ++j)
248  {
249  const QDomElement element = srcList.at(j).toElement();
250  if (not element.isNull())
251  {
252  SourceItem item;
256  item.color = VDomDocument::GetParametrString(element, AttrColor, "black");
257  source.append(item);
258  }
259  }
260  }
261 
262  if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
263  {
264  destination.clear();
265  const QDomNodeList srcList = dataElement.childNodes();
266  for (qint32 j = 0; j < srcList.size(); ++j)
267  {
268  const QDomElement element = srcList.at(j).toElement();
269  if (not element.isNull())
270  {
271  DestinationItem d;
273  d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
274  d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
276  destination.append(d);
277  }
278  }
279  }
280  }
281 }
282 
283 //---------------------------------------------------------------------------------------------------------------------
285 {
286  ReadAttributes();
287  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
288  while (i.hasNext())
289  {
290  i.next();
291  if (i.value()->GetType() == GOType::Point)
292  {
293  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
294  SCASSERT(item != nullptr)
295  item->setToolTip(complexPointToolTip(i.key()));
296  item->refreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
297  }
298  else
299  {
300  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
301  SCASSERT(item != nullptr)
302  item->setToolTip(complexCurveToolTip(i.key()));
303  item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
304  }
305  }
307 }
308 
309 //---------------------------------------------------------------------------------------------------------------------
311 {
312  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
313  while (i.hasNext())
314  {
315  i.next();
316  if (i.value()->GetType() == GOType::Point)
317  {
318  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
319  SCASSERT(item != nullptr)
320  item->setAcceptHoverEvents(enabled);
321  }
322  else
323  {
324  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
325  SCASSERT(item != nullptr)
326  item->setAcceptHoverEvents(enabled);
327  }
328  }
329 }
330 
331 //---------------------------------------------------------------------------------------------------------------------
333 {
334  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
335  while (i.hasNext())
336  {
337  i.next();
338  if (i.value()->GetType() == GOType::Point)
339  {
340  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
341  SCASSERT(item != nullptr)
342  item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
343  }
344  else
345  {
346  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
347  SCASSERT(item != nullptr)
348  item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
349  }
350  }
351 }
352 
353 //---------------------------------------------------------------------------------------------------------------------
355 {
356  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
357  while (i.hasNext())
358  {
359  i.next();
360  if (i.value()->GetType() == GOType::Point)
361  {
362  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
363  SCASSERT(item != nullptr)
364  item->EnableToolMove(move);
365  }
366  }
367 }
368 
369 //---------------------------------------------------------------------------------------------------------------------
371 {
372  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
373  while (i.hasNext())
374  {
375  i.next();
376  if (i.value()->GetType() == GOType::Point)
377  {
378  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
379  SCASSERT(item != nullptr)
380  item->setAcceptHoverEvents(enabled);
381  }
382  }
383 }
384 
385 //---------------------------------------------------------------------------------------------------------------------
387 {
388  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
389  while (i.hasNext())
390  {
391  i.next();
392  if (i.value()->GetType() == GOType::Point)
393  {
394  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
395  SCASSERT(item != nullptr)
396  item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
397  }
398  }
399 }
400 
401 //---------------------------------------------------------------------------------------------------------------------
403 {
404  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
405  while (i.hasNext())
406  {
407  i.next();
408  if (i.value()->GetType() == GOType::Point)
409  {
410  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
411  SCASSERT(item != nullptr)
412  item->allowTextHover(enabled);
413  }
414  }
415 }
416 
417 //---------------------------------------------------------------------------------------------------------------------
419 {
420  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
421  while (i.hasNext())
422  {
423  i.next();
424  if (i.value()->GetType() == GOType::Point)
425  {
426  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
427  SCASSERT(item != nullptr)
428  item->allowTextSelectable(enabled);
429  }
430  }
431 }
432 
433 //---------------------------------------------------------------------------------------------------------------------
435 {
438 }
439 
440 //---------------------------------------------------------------------------------------------------------------------
442 {
445 }
446 
447 //---------------------------------------------------------------------------------------------------------------------
449 {
452 }
453 
454 //---------------------------------------------------------------------------------------------------------------------
456 {
459 }
460 
461 //---------------------------------------------------------------------------------------------------------------------
463 {
464  AllowCurveHover(enabled, GOType::Arc);
465 }
466 
467 //---------------------------------------------------------------------------------------------------------------------
469 {
471 }
472 
473 //---------------------------------------------------------------------------------------------------------------------
475 {
477 }
478 
479 //---------------------------------------------------------------------------------------------------------------------
481 {
483 }
484 
485 //---------------------------------------------------------------------------------------------------------------------
487 {
489  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
490  while (i.hasNext())
491  {
492  i.next();
493  if (i.value()->GetType() == GOType::Point)
494  {
495  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
496  SCASSERT(item != nullptr)
498  }
499  }
500 }
501 
502 //---------------------------------------------------------------------------------------------------------------------
503 void VAbstractOperation::Disable(bool disable, const QString &draftBlockName)
504 {
505  const bool enabled = !CorrectDisable(disable, draftBlockName);
506  setEnabled(enabled);
507 
508  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
509  while (i.hasNext())
510  {
511  i.next();
512  if (i.value()->GetType() == GOType::Point)
513  {
514  VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
515  SCASSERT(item != nullptr)
516  item->SetEnabled(enabled);
517  }
518  else
519  {
520  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
521  SCASSERT(item != nullptr)
522  item->setEnabled(enabled);
523  }
524  }
525 }
526 
527 //---------------------------------------------------------------------------------------------------------------------
528 void VAbstractOperation::ObjectSelected(bool selected, quint32 objId)
529 {
530  emit ChangedToolSelection(selected, objId, m_id);
531 }
532 
533 //---------------------------------------------------------------------------------------------------------------------
535 {
536  try
537  {
538  deleteTool();
539  }
540  catch(const VExceptionToolWasDeleted &e)
541  {
542  Q_UNUSED(e)
543  return;//Leave this method immediately!!!
544  }
545 }
546 
547 //---------------------------------------------------------------------------------------------------------------------
548 VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
549  const QVector<SourceItem> &source, const QVector<DestinationItem> &destination,
550  QGraphicsItem *parent)
551  : VDrawTool(doc, data, id)
552  , QGraphicsLineItem(parent)
553  , suffix(suffix)
554  , source(source)
555  , destination(destination)
556  , operatedObjects()
557 {
558 }
559 
560 //---------------------------------------------------------------------------------------------------------------------
562 {
563  QDomElement domElement = doc->createElement(getTagName());
565  SaveOptions(domElement, obj);
566  AddToCalculation(domElement);
567 }
568 
569 //---------------------------------------------------------------------------------------------------------------------
570 void VAbstractOperation::ReadToolAttributes(const QDomElement &domElement)
571 {
572  ExtractData(domElement, source, destination);
573  suffix = doc->GetParametrString(domElement, AttrSuffix);
574 }
575 
576 //---------------------------------------------------------------------------------------------------------------------
578 {
579  VDrawTool::SaveOptions(tag, obj);
580 
582 
584 }
585 
586 //---------------------------------------------------------------------------------------------------------------------
588 {
589  doc->RemoveAllChildren(tag);
590 
591  QDomElement tagObjects = doc->createElement(TagSource);
592  for (auto sourceItem : qAsConst(source))
593  {
594  QDomElement item = doc->createElement(TagItem);
595  doc->SetAttribute(item, AttrIdObject, sourceItem.id);
596  doc->SetAttribute(item, AttrAlias, sourceItem.alias);
597  doc->SetAttribute(item, AttrLineType, sourceItem.lineType);
598  doc->SetAttribute(item, AttrColor, sourceItem.color);
599  tagObjects.appendChild(item);
600  }
601  tag.appendChild(tagObjects);
602 
603  tagObjects = doc->createElement(TagDestination);
604  for (auto destinationItem : qAsConst(destination))
605  {
606  QDomElement item = doc->createElement(TagItem);
607  doc->SetAttribute(item, AttrIdObject, destinationItem.id);
608 
609  if (not VFuzzyComparePossibleNulls(destinationItem.mx, INT_MAX) &&
610  not VFuzzyComparePossibleNulls(destinationItem.my, INT_MAX))
611  {
612  doc->SetAttribute(item, AttrMx, qApp->fromPixel(destinationItem.mx));
613  doc->SetAttribute(item, AttrMy, qApp->fromPixel(destinationItem.my));
614  doc->SetAttribute<bool>(item, AttrShowPointName, destinationItem.showPointName);
615  }
616 
617  tagObjects.appendChild(item);
618  }
619  tag.appendChild(tagObjects);
620 }
621 
622 //---------------------------------------------------------------------------------------------------------------------
623 void VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType, SceneObject sceneType)
624 {
626  VSimpleCurve *curve = new VSimpleCurve(id, initCurve);
627  curve->setParentItem(this);
628  curve->SetType(curveType);
629  curve->setToolTip(complexCurveToolTip(id));
631  connect(curve, &VSimpleCurve::showContextMenu, this, [this](QGraphicsSceneContextMenuEvent * event, quint32 id)
632  {
633  showContextMenu(event, id);
634  });
635  connect(curve, &VSimpleCurve::Choosed, this, [this, sceneType](quint32 id)
636  {
637  emit chosenTool(id, sceneType);
638  });
639  connect(curve, &VSimpleCurve::Delete, this, &VAbstractOperation::deletePoint);
640  curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
641  operatedObjects.insert(id, curve);
642 }
643 
644 //---------------------------------------------------------------------------------------------------------------------
646 {
647  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
648  while (i.hasNext())
649  {
650  i.next();
651  if (i.value()->GetType() != GOType::Point)
652  {
653  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
654  SCASSERT(item != nullptr)
655  if (item->GetType() == type)
656  {
657  item->setAcceptHoverEvents(enabled);
658  }
659  }
660  }
661 }
662 
663 //---------------------------------------------------------------------------------------------------------------------
665 {
666  QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
667  while (i.hasNext())
668  {
669  i.next();
670  if (i.value()->GetType() != GOType::Point)
671  {
672  VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
673  SCASSERT(item != nullptr)
674  if (item->GetType() == type)
675  {
676  item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
677  }
678  }
679  }
680 }
681 
682 //---------------------------------------------------------------------------------------------------------------------
684 {
685  for (int i = 0; i < destination.size(); ++i)
686  {
687  const DestinationItem item = destination.at(i);
689 
690  // This check helps to find missed objects in the switch
691  Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
692 
693 QT_WARNING_PUSH
694 QT_WARNING_DISABLE_GCC("-Wswitch-default")
695  switch(static_cast<GOType>(object->getType()))
696  {
697  case GOType::Point:
698  {
699  VSimplePoint *point = new VSimplePoint(item.id, QColor(Qt::black));
700  point->setParentItem(this);
701  point->SetType(GOType::Point);
702  point->setToolTip(complexPointToolTip(item.id));
703  connect(point, &VSimplePoint::Choosed, this, [this](quint32 id)
704  {
705  emit chosenTool(id, SceneObject::Point);
706  });
708  connect(point, &VSimplePoint::showContextMenu,
709  this, [this](QGraphicsSceneContextMenuEvent * event, quint32 id)
710  {
711  showContextMenu(event, id);
712  });
713  connect(point, &VSimplePoint::Delete, this, &VAbstractOperation::deletePoint);
715  point->refreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(item.id));
716  operatedObjects.insert(item.id, point);
717  break;
718  }
719  case GOType::Arc:
720  InitCurve(item.id, &(VAbstractTool::data), object->getType(), SceneObject::Arc);
721  break;
723  InitCurve(item.id, &(VAbstractTool::data), object->getType(), SceneObject::ElArc);
724  break;
725  case GOType::Spline:
726  case GOType::CubicBezier:
727  InitCurve(item.id, &(VAbstractTool::data), object->getType(), SceneObject::Spline);
728  break;
729  case GOType::SplinePath:
731  InitCurve(item.id, &(VAbstractTool::data), object->getType(), SceneObject::SplinePath);
732  break;
733  case GOType::Unknown:
734  case GOType::Curve:
735  case GOType::Path:
736  case GOType::AllCurves:
737  default:
738  break;
739  }
741  }
742 }
743 
744 //---------------------------------------------------------------------------------------------------------------------
745 QString VAbstractOperation::complexPointToolTip(quint32 itemId) const
746 {
748 
749  const QString toolTipStr = QString("<table>"
750  "<tr> <td><b>%1:</b> %2</td> </tr>"
751  "%3"
752  "</table>")
753  .arg(tr("Name"), point->name(), makeToolTip());
754  return toolTipStr;
755 }
756 
757 //---------------------------------------------------------------------------------------------------------------------
758 QString VAbstractOperation::complexCurveToolTip(quint32 itemId) const
759 {
761 
762  const QString toolTipStr = QString("<table>"
763  "<tr> <td><b> %1:</b> %2</td> </tr>"
764  "<tr> <td><b>%3:</b> %4 %5</td> </tr>"
765  "%6"
766  "</table>")
767  .arg(tr("Name"))
768  .arg(curve->name())
769  .arg(tr("Length"))
770  .arg(qApp->fromPixel(curve->GetLength()))
771  .arg(UnitsToStr(qApp->patternUnit(), true))
772  .arg(makeToolTip());
773  return toolTipStr;
774 }
void AllowArcSelecting(bool enabled)
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE
QMap< quint32, VAbstractSimple * > operatedObjects
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix, const QVector< SourceItem > &source, const QVector< DestinationItem > &destination, QGraphicsItem *parent=nullptr)
void updatePointNamePosition(quint32 id, const QPointF &pos)
virtual void setPointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE
void AllowElArcSelecting(bool enabled)
QVector< SourceItem > source
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
static const QString TagDestination
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
void pointNamePositionChanged(const QPointF &pos, quint32 labelId)
void AllowArcHover(bool enabled)
static const QString TagItem
void SaveSourceDestination(QDomElement &tag)
QString Suffix() const
void AllowPointLabelSelecting(bool enabled)
void AllowPointSelecting(bool enabled)
static void ExtractData(const QDomElement &domElement, QVector< SourceItem > &source, QVector< DestinationItem > &destination)
void AllowCurveSelecting(bool enabled, GOType type)
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE
void ObjectSelected(bool selected, quint32 objId)
void AllowSplinePathHover(bool enabled)
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE
void setSuffix(const QString &suffix)
void AllowPointLabelHover(bool enabled)
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE
void AllowSplineHover(bool enabled)
QString complexPointToolTip(quint32 itemId) const
void AllowPointHover(bool enabled)
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE
QVector< DestinationItem > destination
static const QString TagSource
virtual void setPointNameVisiblity(quint32 id, bool visible) Q_DECL_OVERRIDE
void AllowSplinePathSelecting(bool enabled)
virtual void updatePointNameVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE
virtual bool isPointNameVisible(quint32 id) const Q_DECL_OVERRIDE
QString complexCurveToolTip(quint32 itemId) const
void AllowCurveHover(bool enabled, GOType type)
virtual QString getTagName() const Q_DECL_OVERRIDE
void AllowSplineSelecting(bool enabled)
void InitCurve(quint32 id, VContainer *data, GOType curveType, SceneObject sceneType)
void AllowElArcHover(bool enabled)
static const QString TagOperation
GOType GetType() const
void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=null_id)
void SetType(const GOType &value)
VAbstractPattern * doc
doc dom document container
virtual void deleteTool(bool ask=true)
deleteTool full delete object form scene and file.
void chosenTool(quint32 id, SceneObject type)
chosenTool emit if object was clicked.
const quint32 m_id
id object id.
virtual void SetVisualization()=0
virtual void ToolSelectionType(const SelectionType &type)
SelectionType selectionType
The VContainer class container of all variables.
Definition: vcontainer.h:141
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 const QSharedPointer< VGObject > GetFakeGObject(quint32 id)
Definition: vcontainer.cpp:156
VContainer data
data container with data
Definition: vdatatool.h:84
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)
static qreal GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the double value of the given attribute.
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
Definition: vdomdocument.h:185
static void RemoveAllChildren(QDomElement &domElement)
RemoveAllChildren remove all children from file.
The VDrawTool abstract class for all draw tool.
Definition: vdrawtool.h:68
virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID)=0
virtual QString makeToolTip() const
Definition: vdrawtool.cpp:171
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj)
Definition: vdrawtool.cpp:163
void SaveOption(QSharedPointer< VGObject > &obj)
Definition: vdrawtool.cpp:142
void AddToCalculation(const QDomElement &domElement)
typeLine line weight.
Definition: vdrawtool.cpp:229
bool CorrectDisable(bool disable, const QString &draftBlockName) const
Definition: vdrawtool.cpp:177
void ChangedToolSelection(bool selected, quint32 object, quint32 tool)
void ReadAttributes()
Definition: vdrawtool.cpp:190
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.
The VPointF class keep data of point.
Definition: vpointf.h:75
virtual void refreshPointGeometry(const VPointF &point)
void RefreshGeometry(const QSharedPointer< VAbstractCurve > &curve)
void Selected(bool selected, quint32 id)
void Choosed(quint32 id)
Choosed send id when clicked.
void nameChangedPosition(const QPointF &pos, quint32 id)
void SetEnabled(bool enabled)
void EnableToolMove(bool move)
void Choosed(quint32 id)
Choosed send id when clicked.
void allowTextHover(bool enabled)
void allowTextSelectable(bool enabled)
void Selected(bool selected, quint32 id)
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
Definition: def.cpp:702
const QString trueStr
Definition: def.cpp:197
#define SCASSERT(cond)
Definition: def.h:317
static Q_REQUIRED_RESULT bool VFuzzyComparePossibleNulls(double p1, double p2)
Definition: def.h:490
SceneObject
Definition: def.h:103
SelectionType
Definition: def.h:108
const QString AttrLineType
Definition: ifcdef.cpp:90
const QString LineTypeSolidLine
Definition: ifcdef.cpp:159
const QString AttrMx
Definition: ifcdef.cpp:74
const QString AttrShowPointName
Definition: ifcdef.cpp:153
const QString AttrMy
Definition: ifcdef.cpp:75
const QString AttrColor
Definition: ifcdef.cpp:131
const QString AttrIdObject
Definition: ifcdef.cpp:148
const QString AttrSuffix
Definition: ifcdef.cpp:147
const QString AttrAlias
Definition: ifcdef.cpp:156
#define NULL_ID_STR
Definition: ifcdef.h:77
QVector< quint32 > sourceToObjects(const QVector< SourceItem > &source)
#define qApp
Definition: vapplication.h:67
GOType
Definition: vgeometrydef.h:56
@ CubicBezierPath
@ SplinePath
@ EllipticalArc
@ CubicBezier