Seamly2D
Code documentation
dialoginternalpath.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 dialoginternalpath.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 22 11, 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 
52 #include "dialoginternalpath.h"
53 #include "ui_dialoginternalpath.h"
54 #include "../vpatterndb/vpiecenode.h"
56 #include "../../../tools/vabstracttool.h"
57 #include "../../../tools/pattern_piece_tool.h"
58 #include "../../support/edit_formula_dialog.h"
59 
60 #include <QMenu>
61 #include <QTimer>
62 
63 //---------------------------------------------------------------------------------------------------------------------
64 DialogInternalPath::DialogInternalPath(const VContainer *data, quint32 toolId, QWidget *parent)
65  : DialogTool(data, toolId, parent),
66  ui(new Ui::DialogInternalPath),
67  m_showMode(false),
68  m_saWidth(0),
69  m_timerWidth(nullptr),
70  m_timerWidthBefore(nullptr),
71  m_timerWidthAfter(nullptr),
72  m_widthFormula(0),
73  m_beforeWidthFormula(0),
74  m_afterWidthFormula(0)
75 {
76  ui->setupUi(this);
77  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
78  setWindowIcon(QIcon(":/toolicon/32x32/path.png"));
79 
81 
82  InitPathTab();
85 
86  flagName = true;//We have default name of piece.
88  CheckState();
89 
91 
92  ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->seamAllowance_Tab));
93  ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->notches_Tab));
94 
95  connect(ui->piece_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
96  {
97  ValidObjects(PathIsValid());
98  });
99 }
100 
101 //---------------------------------------------------------------------------------------------------------------------
103 {
104  delete ui;
105 }
106 
107 //---------------------------------------------------------------------------------------------------------------------
109 {
110  m_showMode = disable;
111  ui->type_ComboBox->setDisabled(m_showMode);
112  ui->piece_ComboBox->setDisabled(m_showMode);
113 }
114 
115 //---------------------------------------------------------------------------------------------------------------------
116 void DialogInternalPath::ChosenObject(quint32 id, const SceneObject &type)
117 {
118  if (not prepare)
119  {
120  bool reverse = false;
121  if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
122  {
123  reverse = true;
124  }
125  if (id != GetLastId())
126  {
127  switch (type)
128  {
129  case SceneObject::Arc:
130  NewItem(VPieceNode(id, Tool::NodeArc, reverse));
131  break;
132  case SceneObject::ElArc:
133  NewItem(VPieceNode(id, Tool::NodeElArc, reverse));
134  break;
135  case SceneObject::Point:
137  break;
138  case SceneObject::Spline:
139  NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
140  break;
142  NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
143  break;
144  case (SceneObject::Line):
145  case (SceneObject::Piece):
146  case (SceneObject::Unknown):
147  default:
148  qDebug() << "Got wrong scene object. Ignore.";
149  break;
150  }
151  }
152  else
153  {
154  if (ui->listWidget->count() > 1)
155  {
156  delete getItemById(id);
157  }
158  }
159 
161 
162  if (not m_showMode)
163  {
164  auto visPath = qobject_cast<VisToolInternalPath *>(vis);
165  SCASSERT(visPath != nullptr);
166  const VPiecePath p = CreatePath();
167  visPath->SetPath(p);
168 
169  if (p.CountNodes() == 1)
170  {
171  emit ToolTip(tr("Select main path objects, Use <b>SHIFT</b> to reverse curve direction, "
172  "Press <b>ENTER</b> to finish path creation "));
173 
174  if (not qApp->getCurrentScene()->items().contains(visPath))
175  {
176  visPath->VisualMode(NULL_ID);
177  }
178  else
179  {
180  visPath->RefreshGeometry();
181  }
182  }
183  else
184  {
185  visPath->RefreshGeometry();
186  }
187  }
188  }
189 }
190 
191 //---------------------------------------------------------------------------------------------------------------------
193 {
194  if (click == false)
195  {
196  if (CreatePath().CountNodes() > 0)
197  {
198  emit ToolTip("");
199  prepare = true;
200 
201  if (not m_showMode)
202  {
203  auto visPath = qobject_cast<VisToolInternalPath *>(vis);
204  SCASSERT(visPath != nullptr);
205  visPath->SetMode(Mode::Show);
206  visPath->RefreshGeometry();
207  }
208  setModal(true);
209  show();
210  }
211  }
212 }
213 
214 //---------------------------------------------------------------------------------------------------------------------
216 {
217  SCASSERT(ok_Button != nullptr);
218  ok_Button->setEnabled(flagName && flagError);
219 }
220 
221 //---------------------------------------------------------------------------------------------------------------------
223 {
224  AddVisualization<VisToolInternalPath>();
225 
226  if (m_showMode)
227  {
228  PatternPieceTool *tool = qobject_cast<PatternPieceTool*>(VAbstractPattern::getTool(GetPieceId()));
229  SCASSERT(tool != nullptr);
230  auto visPath = qobject_cast<VisToolInternalPath *>(vis);
231  SCASSERT(visPath != nullptr);
232  visPath->setParentItem(tool);
233  }
234 }
235 
236 //---------------------------------------------------------------------------------------------------------------------
237 void DialogInternalPath::closeEvent(QCloseEvent *event)
238 {
239  ui->widthFormula_PlainTextEdit->blockSignals(true);
240  ui->beforeWidthFormula_PlainTextEdit->blockSignals(true);
241  ui->afterWidthFormula_PlainTextEdit->blockSignals(true);
242  DialogTool::closeEvent(event);
243 }
244 
245 //---------------------------------------------------------------------------------------------------------------------
246 void DialogInternalPath::ShowContextMenu(const QPoint &pos)
247 {
248  const int row = ui->listWidget->currentRow();
249  if (ui->listWidget->count() == 0 || row == -1 || row >= ui->listWidget->count())
250  {
251  return;
252  }
253 
254  // workaround for https://bugreports.qt.io/browse/QTBUG-97559: assign parent to QMenu
255  QScopedPointer<QMenu> menu(new QMenu(ui->listWidget));
256 
257  NodeInfo info;
258 
259  QListWidgetItem *rowItem = ui->listWidget->item(row);
260  SCASSERT(rowItem != nullptr);
261  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
262 
263  //QAction *actionNotch = nullptr;
264  QAction *actionReverse = nullptr;
265  if (rowNode.GetTypeTool() != Tool::NodePoint)
266  {
267  actionReverse = menu->addAction(tr("Reverse"));
268  actionReverse->setCheckable(true);
269  actionReverse->setChecked(rowNode.GetReverse());
270  }
271  //else
272  //{
273  // actionNotch = menu->addAction(tr("Notch"));
274  // actionNotch->setCheckable(true);
275  // actionNotch->setChecked(rowNode.isNotch());
276  //}
277 
278  QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
279 
280  QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos));
281  if (selectedAction == actionDelete)
282  {
283  delete ui->listWidget->item(row);
284  }
285  else if (rowNode.GetTypeTool() != Tool::NodePoint && selectedAction == actionReverse)
286  {
287  rowNode.SetReverse(not rowNode.GetReverse());
288  info = getNodeInfo(rowNode, true);
289  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
290  rowItem->setIcon(QIcon(info.icon));
291  rowItem->setText(info.name);
292  }
293  //else if (selectedAction == actionNotch)
294  //{
295  // rowNode.setNotch(not rowNode.isNotch());
296  // info = getNodeInfo(rowNode, true);
297  // rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
298  // rowItem->setIcon(QIcon(info.icon));
299  // rowItem->setText(info.name);
300  //}
301 
303  ListChanged();
304 }
305 
306 //---------------------------------------------------------------------------------------------------------------------
308 {
309  if (not m_showMode)
310  {
311  auto visPath = qobject_cast<VisToolInternalPath *>(vis);
312  SCASSERT(visPath != nullptr);
313  visPath->SetPath(CreatePath());
314  visPath->RefreshGeometry();
315  }
316 
319 }
320 
321 //---------------------------------------------------------------------------------------------------------------------
323 {
324  if (ui->pathName_LineEdit->text().isEmpty())
325  {
326  flagName = false;
327  ChangeColor(ui->name_Label, Qt::red);
328  }
329  else
330  {
331  flagName = true;
332  ChangeColor(ui->name_Label, okColor);
333  }
334  CheckState();
335 }
336 
337 //---------------------------------------------------------------------------------------------------------------------
339 {
340  ui->beforeWidthFormula_PlainTextEdit->setDisabled(true);
341  ui->beforeExpr_ToolButton->setDisabled(true);
342  ui->beforeDefault_PushButton->setDisabled(true);
343 
344  ui->afterWidthFormula_PlainTextEdit->setDisabled(true);
345  ui->afterExpr_ToolButton->setDisabled(true);
346  ui->afterDefault_PushButton->setDisabled(true);
347 
348  ui->angle_ComboBox->setDisabled(true);
349 
350  ui->angle_ComboBox->blockSignals(true);
351 
352  if (index != -1)
353  {
354  const VPiecePath path = CreatePath();
355  const int nodeIndex = path.indexOfNode(ui->nodes_ComboBox->currentData().toUInt());
356  if (nodeIndex != -1)
357  {
358  const VPieceNode &node = path.at(nodeIndex);
359 
360  // Seam allowance before
361  ui->beforeWidthFormula_PlainTextEdit->setEnabled(true);
362  ui->beforeExpr_ToolButton->setEnabled(true);
363 
364  QString w1Formula = node.GetFormulaSABefore();
365  if (w1Formula != currentSeamAllowance)
366  {
367  ui->beforeDefault_PushButton->setEnabled(true);
368  }
369  if (w1Formula.length() > 80)// increase height if needed.
370  {
372  }
373  w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator());
374  ui->beforeWidthFormula_PlainTextEdit->setPlainText(w1Formula);
375  MoveCursorToEnd(ui->beforeWidthFormula_PlainTextEdit);
376 
377  // Seam allowance after
378  ui->afterWidthFormula_PlainTextEdit->setEnabled(true);
379  ui->afterExpr_ToolButton->setEnabled(true);
380 
381  QString w2Formula = node.GetFormulaSAAfter();
382  if (w2Formula != currentSeamAllowance)
383  {
384  ui->afterDefault_PushButton->setEnabled(true);
385  }
386  if (w2Formula.length() > 80)// increase height if needed.
387  {
389  }
390  w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator());
391  ui->afterWidthFormula_PlainTextEdit->setPlainText(w2Formula);
392  MoveCursorToEnd(ui->afterWidthFormula_PlainTextEdit);
393 
394  // Angle type
395  ui->angle_ComboBox->setEnabled(true);
396  const int index = ui->angle_ComboBox->findData(static_cast<unsigned char>(node.GetAngleType()));
397  if (index != -1)
398  {
399  ui->angle_ComboBox->setCurrentIndex(index);
400  }
401  }
402  }
403  else
404  {
405  ui->beforeWidthFormula_PlainTextEdit->setPlainText("");
406  ui->afterWidthFormula_PlainTextEdit->setPlainText("");
407  ui->angle_ComboBox->setCurrentIndex(-1);
408  }
409 
410  ui->angle_ComboBox->blockSignals(false);
411 }
412 
413 //---------------------------------------------------------------------------------------------------------------------
415 {
416  ui->slitNotch_RadioButton->setDisabled(true);
417  ui->tNotch_RadioButton->setDisabled(true);
418  ui->uNotch_RadioButton->setDisabled(true);
419  ui->vInternalNotch_RadioButton->setDisabled(true);
420  ui->vExternalNotch_RadioButton->setDisabled(true);
421  ui->castleNotch_RadioButton->setDisabled(true);
422  ui->diamondNotch_RadioButton->setDisabled(true);
423 
424  ui->straightforward_RadioButton->setDisabled(true);
425  ui->bisector_RadioButton->setDisabled(true);
426  ui->intersection_RadioButton->setDisabled(true);
427 
428  ui->showSeamlineNotch_CheckBox->setDisabled(true);
429  ui->showSeamlineNotch_CheckBox->blockSignals(true);
430 
431  ui->notchType_GroupBox->blockSignals(true);
432  ui->notchSubType_GroupBox->blockSignals(true);
433 
434  if (index != -1)
435  {
436  const VPiecePath path = CreatePath();
437  const int nodeIndex = path.indexOfNode(ui->notches_ComboBox->currentData().toUInt());
438  if (nodeIndex != -1)
439  {
440  const VPieceNode &node = path.at(nodeIndex);
441 
442  // Notch type
443  ui->slitNotch_RadioButton->setEnabled(true);
444  ui->tNotch_RadioButton->setEnabled(true);
445  ui->uNotch_RadioButton->setEnabled(true);
446  ui->vInternalNotch_RadioButton->setEnabled(true);
447  ui->vExternalNotch_RadioButton->setEnabled(true);
448  ui->castleNotch_RadioButton->setEnabled(true);
449  ui->diamondNotch_RadioButton->setEnabled(true);
450 
451  switch(node.getNotchType())
452  {
453  case NotchType::Slit:
454  ui->slitNotch_RadioButton->setChecked(true);
455  break;
456  case NotchType::TNotch:
457  ui->tNotch_RadioButton->setChecked(true);
458  break;
459  case NotchType::UNotch:
460  ui->uNotch_RadioButton->setChecked(true);
461  break;
463  ui->vInternalNotch_RadioButton->setChecked(true);
464  break;
466  ui->vExternalNotch_RadioButton->setChecked(true);
467  break;
468  case NotchType::Castle:
469  ui->castleNotch_RadioButton->setChecked(true);
470  break;
471  case NotchType::Diamond:
472  ui->diamondNotch_RadioButton->setChecked(true);
473  break;
474  default:
475  break;
476  }
477 
478  // Sub type
479  ui->straightforward_RadioButton->setEnabled(true);
480  ui->bisector_RadioButton->setEnabled(true);
481  ui->intersection_RadioButton->setEnabled(true);
482 
483  switch(node.getNotchSubType())
484  {
486  ui->straightforward_RadioButton->setChecked(true);
487  break;
489  ui->bisector_RadioButton->setChecked(true);
490  break;
492  ui->intersection_RadioButton->setChecked(true);
493  break;
494  default:
495  break;
496  }
497  }
498  }
499  ui->notchType_GroupBox->blockSignals(false);
500  ui->notchSubType_GroupBox->blockSignals(false);
501 }
502 
503 //---------------------------------------------------------------------------------------------------------------------
505 {
506  ui->beforeWidthFormula_PlainTextEdit->setPlainText(currentSeamAllowance);
507  if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
508  {
509  button->setEnabled(false);
510  }
511 }
512 
513 //---------------------------------------------------------------------------------------------------------------------
515 {
516  ui->afterWidthFormula_PlainTextEdit->setPlainText(currentSeamAllowance);
517  if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
518  {
519  button->setEnabled(false);
520  }
521 }
522 
523 //---------------------------------------------------------------------------------------------------------------------
525 {
526  const int i = ui->notches_ComboBox->currentIndex();
527  if (i != -1)
528  {
529  QListWidgetItem *rowItem = getItemById(ui->notches_ComboBox->currentData().toUInt());
530  if (rowItem)
531  {
532  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
533  const NodeInfo info = getNodeInfo(rowNode, true);
534 
535  NotchType notchType = NotchType::Slit;
536  if (id == ui->notchType_ButtonGroup->id(ui->slitNotch_RadioButton))
537  {
538  notchType = NotchType::Slit;
539  }
540  else if (id == ui->notchType_ButtonGroup->id(ui->tNotch_RadioButton))
541  {
542  notchType = NotchType::TNotch;
543  }
544  else if (id == ui->notchType_ButtonGroup->id(ui->uNotch_RadioButton))
545  {
546  notchType = NotchType::UNotch;
547  }
548  else if (id == ui->notchType_ButtonGroup->id(ui->vInternalNotch_RadioButton))
549  {
550  notchType = NotchType::VInternal;
551  }
552  else if (id == ui->notchType_ButtonGroup->id(ui->vExternalNotch_RadioButton))
553  {
554  notchType = NotchType::VExternal;
555  }
556  else if (id == ui->notchType_ButtonGroup->id(ui->castleNotch_RadioButton))
557  {
558  notchType = NotchType::Castle;
559  }
560  else if (id == ui->notchType_ButtonGroup->id(ui->diamondNotch_RadioButton))
561  {
562  notchType = NotchType::Diamond;
563  }
564 
565  rowNode.setNotchType(notchType);
566  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
567  rowItem->setIcon(QIcon(info.icon));
568  rowItem->setText(info.name);
569 
570  ListChanged();
571  }
572  }
573 }
574 
575 //---------------------------------------------------------------------------------------------------------------------
577 {
578  const int i = ui->notches_ComboBox->currentIndex();
579  if (i != -1)
580  {
581  QListWidgetItem *rowItem = getItemById(ui->notches_ComboBox->currentData().toUInt());
582  if (rowItem)
583  {
584  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
585 
587  if (id == ui->notchSubType_ButtonGroup->id(ui->straightforward_RadioButton))
588  {
589  notchSubType = NotchSubType::Straightforward;
590  }
591  else if (id == ui->notchSubType_ButtonGroup->id(ui->bisector_RadioButton))
592  {
593  notchSubType = NotchSubType::Bisector;
594  }
595  else if (id == ui->notchSubType_ButtonGroup->id(ui->intersection_RadioButton))
596  {
597  notchSubType = NotchSubType::Intersection;
598  }
599 
600  rowNode.setNotchSubType(notchSubType);
601  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
602  //rowItem->setText(getNodeInfo(rowNode, true));
603 
604  ListChanged();
605  }
606  }
607 }
608 
609 //---------------------------------------------------------------------------------------------------------------------
611 {
612  labelEditFormula = ui->widthEdit_Label;
613  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
614  const QString formula = ui->widthFormula_PlainTextEdit->toPlainText();
615  m_saWidth = Eval(formula, flagFormula, ui->widthResult_Label, postfix, false, true);
616 
617  if (m_saWidth >= 0)
618  {
619  VContainer *locData = const_cast<VContainer *> (data);
621  QString().setNum(m_saWidth), true,
622  tr("Current seam allowance")));
623 
626  }
627 }
628 
629 //---------------------------------------------------------------------------------------------------------------------
631 {
632  labelEditFormula = ui->beforeWidthEdit_Label;
633  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
634  QString formula = ui->beforeWidthFormula_PlainTextEdit->toPlainText();
635  bool flagFormula = false; // fake flag
636  Eval(formula, flagFormula, ui->beforeWidthResult_Label, postfix, false, true);
637 
639  if (formula != currentSeamAllowance)
640  {
641  ui->beforeDefault_PushButton->setEnabled(true);
642  }
643 
645 }
646 
647 //---------------------------------------------------------------------------------------------------------------------
649 {
650  labelEditFormula = ui->afterWidthEdit_Label;
651  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
652  QString formula = ui->afterWidthFormula_PlainTextEdit->toPlainText();
653  bool flagFormula = false; // fake flag
654  Eval(formula, flagFormula, ui->afterWidthResult_Label, postfix, false, true);
655 
657  if (formula != currentSeamAllowance)
658  {
659  ui->afterDefault_PushButton->setEnabled(true);
660  }
661 
663 }
664 
665 //---------------------------------------------------------------------------------------------------------------------
667 {
668  EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
669  dialog->setWindowTitle(tr("Edit seam allowance width"));
671  dialog->setCheckLessThanZero(true);
672  dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
673  if (dialog->exec() == QDialog::Accepted)
674  {
676  }
677  delete dialog;
678 }
679 
680 //---------------------------------------------------------------------------------------------------------------------
682 {
683  EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
684  dialog->setWindowTitle(tr("Edit seam allowance width before"));
686  dialog->setCheckLessThanZero(true);
687  dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
688  if (dialog->exec() == QDialog::Accepted)
689  {
690  SetCurrentSABefore(dialog->GetFormula());
691  }
692  delete dialog;
693 }
694 
695 //---------------------------------------------------------------------------------------------------------------------
697 {
698  EditFormulaDialog *dialog = new EditFormulaDialog(data, toolId, this);
699  dialog->setWindowTitle(tr("Edit seam allowance width after"));
701  dialog->setCheckLessThanZero(true);
702  dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
703  if (dialog->exec() == QDialog::Accepted)
704  {
706  }
707  delete dialog;
708 }
709 
710 //---------------------------------------------------------------------------------------------------------------------
712 {
713  labelEditFormula = ui->widthEdit_Label;
714  labelResultCalculation = ui->widthResult_Label;
715  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
716  ValFormulaChanged(flagFormula, ui->widthFormula_PlainTextEdit, m_timerWidth, postfix);
717 }
718 
719 //---------------------------------------------------------------------------------------------------------------------
721 {
722  labelEditFormula = ui->beforeWidthEdit_Label;
723  labelResultCalculation = ui->beforeWidthResult_Label;
724  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
725  bool flagFormula = false;
726  ValFormulaChanged(flagFormula, ui->beforeWidthFormula_PlainTextEdit, m_timerWidthBefore, postfix);
727 }
728 
729 //---------------------------------------------------------------------------------------------------------------------
731 {
732  labelEditFormula = ui->afterWidthEdit_Label;
733  labelResultCalculation = ui->afterWidthResult_Label;
734  const QString postfix = UnitsToStr(qApp->patternUnit(), true);
735  bool flagFormula = false;
736  ValFormulaChanged(flagFormula, ui->afterWidthFormula_PlainTextEdit, m_timerWidthAfter, postfix);
737 }
738 
739 //---------------------------------------------------------------------------------------------------------------------
741 {
742  DeployFormula(ui->widthFormula_PlainTextEdit, ui->widthGrow_PushButton, m_widthFormula);
743 }
744 
745 //---------------------------------------------------------------------------------------------------------------------
747 {
748  DeployFormula(ui->beforeWidthFormula_PlainTextEdit, ui->beforeWidthGrow_PushButton, m_beforeWidthFormula);
749 }
750 
751 //---------------------------------------------------------------------------------------------------------------------
753 {
754  DeployFormula(ui->afterWidthFormula_PlainTextEdit, ui->afterWidthGrow_PushButton, m_afterWidthFormula);
755 }
756 
757 //---------------------------------------------------------------------------------------------------------------------
759 {
760  ui->pathName_LineEdit->setClearButtonEnabled(true);
761 
762  int index = ui->penType_ComboBox->findData(LineTypeNone);
763  if (index != -1)
764  {
765  ui->penType_ComboBox->removeItem(index);
766  }
767 
768  connect(ui->pathName_LineEdit, &QLineEdit::textChanged, this, &DialogInternalPath::NameChanged);
769 
770  InitPathTypes();
771  connect(ui->type_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
772  [this]()
773  {
774  ui->penType_ComboBox->setEnabled(GetType() == PiecePathType::InternalPath);
775  ui->cutOnFabric_CheckBox->setEnabled(GetType() == PiecePathType::InternalPath);
776  ValidObjects(PathIsValid());
777  });
778 
779  ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
780  connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogInternalPath::ShowContextMenu);
781 
782  connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogInternalPath::setMoveExclusions);
783  connect(ui->moveTop_ToolButton, &QToolButton::clicked, this, [this](){moveListRowTop(ui->listWidget);});
784  connect(ui->moveUp_ToolButton, &QToolButton::clicked, this, [this](){moveListRowTop(ui->listWidget);});
785  connect(ui->moveDown_ToolButton, &QToolButton::clicked, this, [this](){moveListRowDown(ui->listWidget);});
786  connect(ui->moveBottom_ToolButton, &QToolButton::clicked, this, [this](){moveListRowBottom(ui->listWidget);});
787 }
788 
789 //---------------------------------------------------------------------------------------------------------------------
791 {
792  plainTextEditFormula = ui->widthFormula_PlainTextEdit;
793  this->m_widthFormula = ui->widthFormula_PlainTextEdit->height();
794  this->m_beforeWidthFormula = ui->beforeWidthFormula_PlainTextEdit->height();
795  this->m_afterWidthFormula = ui->afterWidthFormula_PlainTextEdit->height();
796 
797  ui->widthFormula_PlainTextEdit->installEventFilter(this);
798  ui->beforeWidthFormula_PlainTextEdit->installEventFilter(this);
799  ui->afterWidthFormula_PlainTextEdit->installEventFilter(this);
800 
801  m_timerWidth = new QTimer(this);
802  connect(m_timerWidth, &QTimer::timeout, this, &DialogInternalPath::evaluateDefaultWidth);
803 
804  m_timerWidthBefore = new QTimer(this);
805  connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogInternalPath::evaluateBeforeWidth);
806 
807  m_timerWidthAfter = new QTimer(this);
808  connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogInternalPath::evaluateAfterWidth);
809 
810  // Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
811  m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
812  ui->widthFormula_PlainTextEdit->setPlainText(qApp->LocaleToString(m_saWidth));
813 
815  connect(ui->nodes_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
817 
818  connect(ui->beforeDefault_PushButton, &QPushButton::clicked, this, &DialogInternalPath::enableDefaultBeforeButton);
819  connect(ui->afterDefault_PushButton, &QPushButton::clicked, this, &DialogInternalPath::enableDefaultAfterButton);
820 
821  initializeNodeAngles(ui->angle_ComboBox);
822  connect(ui->angle_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
824 
825  connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogInternalPath::editDefaultSeamAllowanceWidth);
826  connect(ui->beforeExpr_ToolButton, &QPushButton::clicked, this, &DialogInternalPath::editBeforeSeamAllowanceWidth);
827  connect(ui->afterExpr_ToolButton, &QPushButton::clicked, this, &DialogInternalPath::editAfterSeamAllowanceWidth);
828 
829  connect(ui->widthFormula_PlainTextEdit, &QPlainTextEdit::textChanged, this, &DialogInternalPath::defaultWidthChanged);
830  connect(ui->beforeWidthFormula_PlainTextEdit, &QPlainTextEdit::textChanged, this,
832  connect(ui->afterWidthFormula_PlainTextEdit, &QPlainTextEdit::textChanged, this,
834 
835  connect(ui->widthGrow_PushButton, &QPushButton::clicked, this, &DialogInternalPath::expandWidthFormulaTextEdit);
836  connect(ui->beforeWidthGrow_PushButton, &QPushButton::clicked,
838  connect(ui->afterWidthGrow_PushButton, &QPushButton::clicked, this,
840 }
841 
842 //---------------------------------------------------------------------------------------------------------------------
844 {
846  connect(ui->notches_ComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
848 
849  connect(ui->notchType_ButtonGroup, &QButtonGroup::idClicked, this, &DialogInternalPath::notchTypeChanged);
850  connect(ui->notchSubType_ButtonGroup, &QButtonGroup::idClicked, this, &DialogInternalPath::notchSubTypeChanged);
851 }
852 
853 //---------------------------------------------------------------------------------------------------------------------
855 {
856  ui->type_ComboBox->addItem(tr("Internal path"), static_cast<int>(PiecePathType::InternalPath));
857  ui->type_ComboBox->addItem(tr("Custom seam allowance"), static_cast<int>(PiecePathType::CustomSeamAllowance));
858 
859  ui->penType_ComboBox->setEnabled(GetType() == PiecePathType::InternalPath);
860  ui->cutOnFabric_CheckBox->setEnabled(GetType() == PiecePathType::InternalPath);
861 }
862 
863 //---------------------------------------------------------------------------------------------------------------------
865 {
866  const quint32 id = ui->nodes_ComboBox->currentData().toUInt();
867 
868  ui->nodes_ComboBox->blockSignals(true);
869  ui->nodes_ComboBox->clear();
870 
871  const VPiecePath path = CreatePath();
872 
873  for (int i = 0; i < path.CountNodes(); ++i)
874  {
875  const VPieceNode node = path.at(i);
876  if (node.GetTypeTool() == Tool::NodePoint)
877  {
878  const NodeInfo info = getNodeInfo(node);
879  ui->nodes_ComboBox->addItem(info.name, node.GetId());
880  }
881  }
882  ui->nodes_ComboBox->blockSignals(false);
883 
884  const int index = ui->nodes_ComboBox->findData(id);
885  if (index != -1)
886  {
887  ui->nodes_ComboBox->setCurrentIndex(index);
888  nodeChanged(index);// Need in case combox index was not changed
889  }
890  else
891  {
892  ui->nodes_ComboBox->count() > 0 ? nodeChanged(0) : nodeChanged(-1);
893  }
894 }
895 
896 //---------------------------------------------------------------------------------------------------------------------
898 {
899  const quint32 id = ui->notches_ComboBox->currentData().toUInt();
900 
901  ui->notches_ComboBox->blockSignals(true);
902  ui->notches_ComboBox->clear();
903 
904  const QVector<VPieceNode> nodes = GetListInternals<VPieceNode>(ui->listWidget);
905 
906  for (int i = 0; i < nodes.size(); ++i)
907  {
908  const VPieceNode node = nodes.at(i);
909  if (node.GetTypeTool() == Tool::NodePoint && node.isNotch())
910  {
911  const NodeInfo info = getNodeInfo(node);
912 
913  ui->notches_ComboBox->addItem(QIcon(info.icon), info.name, node.GetId());
914  }
915  }
916  ui->notches_ComboBox->blockSignals(false);
917 
918  const int index = ui->notches_ComboBox->findData(id);
919  if (index != -1)
920  {
921  ui->notches_ComboBox->setCurrentIndex(index);
922  notchChanged(index);// Need in case combox index was not changed
923  }
924  else
925  {
926  ui->notches_ComboBox->count() > 0 ? notchChanged(0) : notchChanged(-1);
927  }
928 }
929 
930 //---------------------------------------------------------------------------------------------------------------------
932 {
933  const int i = ui->nodes_ComboBox->currentIndex();
934  if (i != -1 && index != -1)
935  {
936  QListWidgetItem *rowItem = getItemById(ui->nodes_ComboBox->currentData().toUInt());
937  if (rowItem)
938  {
939  const PieceNodeAngle angle = static_cast<PieceNodeAngle>(ui->angle_ComboBox->currentData().toUInt());
940  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
941  rowNode.SetAngleType(angle);
942  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
943 
944  ListChanged();
945  }
946  }
947 }
948 
949 //---------------------------------------------------------------------------------------------------------------------
951 {
952  return CreatePath();
953 }
954 
955 //---------------------------------------------------------------------------------------------------------------------
957 {
958  ui->listWidget->clear();
959  for (int i = 0; i < path.CountNodes(); ++i)
960  {
961  NewItem(path.at(i));
962  }
963 
964  SetType(path.GetType());
965  ui->pathName_LineEdit->setText(path.GetName());
966 
967  VisToolInternalPath *visPath = qobject_cast<VisToolInternalPath *>(vis);
968  SCASSERT(visPath != nullptr);
969  visPath->SetPath(path);
970  SetPenType(path.GetPenType());
971  SetCutPath(path.IsCutPath());
972 
974 
975  ListChanged();
976 }
977 
978 //---------------------------------------------------------------------------------------------------------------------
980 {
981  return static_cast<PiecePathType>(ui->type_ComboBox->currentData().toInt());
982 }
983 
984 //---------------------------------------------------------------------------------------------------------------------
986 {
987  const qint32 index = ui->type_ComboBox->findData(static_cast<int>(type));
988  if (index != -1)
989  {
990  ui->type_ComboBox->setCurrentIndex(index);
991  }
992 
993  ui->penType_ComboBox->setEnabled(type == PiecePathType::InternalPath);
994  ui->cutOnFabric_CheckBox->setEnabled(type == PiecePathType::InternalPath);
995 }
996 
997 //---------------------------------------------------------------------------------------------------------------------
998 Qt::PenStyle DialogInternalPath::GetPenType() const
999 {
1000  return lineTypeToPenStyle(GetComboBoxCurrentData(ui->penType_ComboBox, LineTypeSolidLine));
1001 }
1002 
1003 //---------------------------------------------------------------------------------------------------------------------
1004 void DialogInternalPath::SetPenType(const Qt::PenStyle &type)
1005 {
1006  ChangeCurrentData(ui->penType_ComboBox, PenStyleToLineType(type));
1007  vis->setLineStyle(type);
1008 }
1009 
1010 //---------------------------------------------------------------------------------------------------------------------
1012 {
1013  return ui->cutOnFabric_CheckBox->isChecked();
1014 }
1015 
1016 //---------------------------------------------------------------------------------------------------------------------
1018 {
1019  ui->cutOnFabric_CheckBox->setChecked(value);
1020 }
1021 
1022 //---------------------------------------------------------------------------------------------------------------------
1023 QListWidgetItem *DialogInternalPath::getItemById(quint32 id)
1024 {
1025  for (qint32 i = 0; i < ui->listWidget->count(); ++i)
1026  {
1027  QListWidgetItem *item = ui->listWidget->item(i);
1028  const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
1029 
1030  if (node.GetId() == id)
1031  {
1032  return item;
1033  }
1034  }
1035  return nullptr;
1036 }
1037 
1038 //---------------------------------------------------------------------------------------------------------------------
1040 {
1041  const int count = ui->listWidget->count();
1042  if (count > 0)
1043  {
1044  QListWidgetItem *item = ui->listWidget->item(count-1);
1045  const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
1046  return node.GetId();
1047  }
1048  else
1049  {
1050  return NULL_ID;
1051  }
1052 }
1053 
1054 //---------------------------------------------------------------------------------------------------------------------
1055 void DialogInternalPath::SetCurrentSABefore(const QString &formula)
1056 {
1058  ListChanged();
1059 }
1060 
1061 //---------------------------------------------------------------------------------------------------------------------
1063 {
1065  ListChanged();
1066 }
1067 
1068 //---------------------------------------------------------------------------------------------------------------------
1070 {
1071  const int index = ui->nodes_ComboBox->currentIndex();
1072  if (index != -1)
1073  {
1074  QListWidgetItem *rowItem = getItemById(ui->nodes_ComboBox->currentData().toUInt());
1075  if (rowItem)
1076  {
1077  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
1078  rowNode.setBeforeSAFormula(formula);
1079  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
1080  }
1081  }
1082 }
1083 
1084 //---------------------------------------------------------------------------------------------------------------------
1086 {
1087  const int index = ui->nodes_ComboBox->currentIndex();
1088  if (index != -1)
1089  {
1090  QListWidgetItem *rowItem = getItemById(ui->nodes_ComboBox->currentData().toUInt());
1091  if (rowItem)
1092  {
1093  VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
1094  rowNode.setAfterSAFormula(formula);
1095  rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
1096  }
1097  }
1098 }
1099 
1100 //---------------------------------------------------------------------------------------------------------------------
1102 {
1103  if (formula.isEmpty())
1104  {
1105  return;
1106  }
1107 
1108  const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
1109  // increase height if needed.
1110  if (width.length() > 80)
1111  {
1113  }
1114  ui->widthFormula_PlainTextEdit->setPlainText(width);
1115 
1116  VisToolInternalPath *path = qobject_cast<VisToolInternalPath *>(vis);
1117  SCASSERT(path != nullptr)
1118  path->SetPath(CreatePath());
1119 
1120  if (ui->tabWidget->indexOf(ui->seamAllowance_Tab) == -1)
1121  {
1122  ui->tabWidget->addTab(ui->seamAllowance_Tab, tr("Seam allowance"));
1123  }
1124 
1125  if (ui->tabWidget->indexOf(ui->notches_Tab) == -1)
1126  {
1127  ui->tabWidget->addTab(ui->notches_Tab, tr("Notches"));
1128  }
1129 
1130  MoveCursorToEnd(ui->widthFormula_PlainTextEdit);
1131 }
1132 
1133 //---------------------------------------------------------------------------------------------------------------------
1135 {
1136  return getCurrentObjectId(ui->piece_ComboBox);
1137 }
1138 
1139 //---------------------------------------------------------------------------------------------------------------------
1141 {
1142  if (ui->piece_ComboBox->count() <= 0)
1143  {
1144  ui->piece_ComboBox->addItem(data->GetPiece(id).GetName(), id);
1145  }
1146  else
1147  {
1148  const qint32 index = ui->piece_ComboBox->findData(id);
1149  if (index != -1)
1150  {
1151  ui->piece_ComboBox->setCurrentIndex(index);
1152  }
1153  else
1154  {
1155  ui->piece_ComboBox->setCurrentIndex(0);
1156  }
1157  }
1158 }
1159 
1160 //---------------------------------------------------------------------------------------------------------------------
1162 {
1163  QString width = ui->widthFormula_PlainTextEdit->toPlainText();
1164  width.replace("\n", " ");
1165  return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
1166 }
1167 
1168 //---------------------------------------------------------------------------------------------------------------------
1170 {
1171  FillComboBoxPiecesList(ui->piece_ComboBox, list);
1172 }
1173 
1174 //---------------------------------------------------------------------------------------------------------------------
1176 {
1177  VPiecePath path;
1178  for (qint32 i = 0; i < ui->listWidget->count(); ++i)
1179  {
1180  QListWidgetItem *item = ui->listWidget->item(i);
1181  path.Append(qvariant_cast<VPieceNode>(item->data(Qt::UserRole)));
1182  }
1183 
1184  path.SetType(GetType());
1185  path.SetName(ui->pathName_LineEdit->text());
1186  path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine);
1188 
1189  return path;
1190 }
1191 
1192 //---------------------------------------------------------------------------------------------------------------------
1194 {
1195  QString url = DialogWarningIcon();
1196 
1197  if(CreatePath().PathPoints(data).count() < 2)
1198  {
1199  url += tr("You need more points!");
1200  ui->status_Label->setText(url);
1201  return false;
1202  }
1203  else
1204  {
1206  {
1207  url += tr("First point of <b>custom seam allowance</b> cannot be equal to the last point!");
1208  ui->status_Label->setText(url);
1209  return false;
1210  }
1211  else if (doublePointsExist(ui->listWidget))
1212  {
1213  url += tr("You have double points!");
1214  ui->status_Label->setText(url);
1215  return false;
1216  }
1217  else if (GetType() == PiecePathType::CustomSeamAllowance && not isEachPointNameUnique(ui->listWidget))
1218  {
1219  url += tr("Each point in the <b>custom seam allowance</b> path must be unique!");
1220  ui->status_Label->setText(url);
1221  return false;
1222  }
1223  }
1224 
1225  if (not m_showMode && ui->piece_ComboBox->count() <= 0)
1226  {
1227  url += tr("List of details is empty!");
1228  ui->status_Label->setText(url);
1229  return false;
1230  }
1231  else if (not m_showMode && ui->piece_ComboBox->currentIndex() == -1)
1232  {
1233  url += tr("Please, select a detail to insert into!");
1234  ui->status_Label->setText(url);
1235  return false;
1236  }
1237 
1238  ui->status_Label->setText(tr("Ready!"));
1239  return true;
1240 }
1241 
1242 //---------------------------------------------------------------------------------------------------------------------
1244 {
1245  flagError = value;
1246  CheckState();
1247 }
1248 
1249 //---------------------------------------------------------------------------------------------------------------------
1251 {
1252  newNodeItem(ui->listWidget, node);
1253 }
1254 
1255 //---------------------------------------------------------------------------------------------------------------------
1257 {
1258  QString width = ui->beforeWidthFormula_PlainTextEdit->toPlainText();
1259  width.replace("\n", " ");
1260  return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
1261 }
1262 
1263 //---------------------------------------------------------------------------------------------------------------------
1265 {
1266  QString width = ui->afterWidthFormula_PlainTextEdit->toPlainText();
1267  width.replace("\n", " ");
1268  return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
1269 }
1270 
1271 //---------------------------------------------------------------------------------------------------------------------
1273 {
1274  ui->moveTop_ToolButton->setEnabled(false);
1275  ui->moveUp_ToolButton->setEnabled(false);
1276  ui->moveDown_ToolButton->setEnabled(false);
1277  ui->moveBottom_ToolButton->setEnabled(false);
1278 
1279  if (ui->listWidget->count() > 1)
1280  {
1281  if (ui->listWidget->currentRow() == 0)
1282  {
1283  ui->moveDown_ToolButton->setEnabled(true);
1284  ui->moveBottom_ToolButton->setEnabled(true);
1285  }
1286  else if (ui->listWidget->currentRow() == ui->listWidget->count() - 1)
1287  {
1288  ui->moveTop_ToolButton->setEnabled(true);
1289  ui->moveUp_ToolButton->setEnabled(true);
1290  }
1291  else
1292  {
1293  ui->moveTop_ToolButton->setEnabled(true);
1294  ui->moveUp_ToolButton->setEnabled(true);
1295  ui->moveDown_ToolButton->setEnabled(true);
1296  ui->moveBottom_ToolButton->setEnabled(true);
1297  }
1298  }
1299 }
void SetPiecePath(const VPiecePath &path)
void ValidObjects(bool value)
virtual void CheckState() Q_DECL_FINAL
CheckState enable, when all is correct, or disable, when something wrong, button ok.
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE
void notchSubTypeChanged(int id)
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
void SetCurrentSABefore(const QString &formula)
quint32 GetPieceId() const
VPiecePath CreatePath() const
void nodeChanged(int index)
Ui::DialogInternalPath * ui
void notchChanged(int index)
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
void updateNodeBeforeSeamAllowance(const QString &formula)
void setCurrentAfterSeamAllowance(const QString &formula)
void EnbleShowMode(bool disable)
void NewItem(const VPieceNode &node)
virtual void ShowVisualization() Q_DECL_OVERRIDE
void setSeamAllowanceWidthFormula(const QString &formula)
void SetCutPath(bool value)
QString getSeamAllowanceWidthFormulaBefore() const
void SetType(PiecePathType type)
void nodeAngleChanged(int index)
VPiecePath GetPiecePath() const
void updateNodeAfterSeamAllowance(const QString &formula)
void ShowContextMenu(const QPoint &pos)
Qt::PenStyle GetPenType() const
QListWidgetItem * getItemById(quint32 id)
PiecePathType GetType() const
DialogInternalPath(const VContainer *data, quint32 toolId, QWidget *parent=nullptr)
void SetPieceId(quint32 id)
QString getSeamAllowanceWidthFormulaAfter() const
void SetPenType(const Qt::PenStyle &type)
QString getSeamAllowanceWidthFormula() const
virtual void SetPiecesList(const QVector< quint32 > &list) Q_DECL_OVERRIDE
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
void ChangeCurrentData(QComboBox *box, const QVariant &value) const
ChangeCurrentData select item in combobox by id.
Definition: dialogtool.cpp:419
const QColor okColor
Definition: dialogtool.h:219
static bool isFirstPointSameAsLast(QListWidget *listWidget)
Definition: dialogtool.cpp:552
void ToolTip(const QString &toolTip)
ToolTip emit tooltipe for tool.
bool flagName
flagName true if name is correct
Definition: dialogtool.h:183
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const
Definition: dialogtool.cpp:432
QPushButton * ok_Button
ok_Button button ok
Definition: dialogtool.h:199
bool flagFormula
flagFormula true if formula correct
Definition: dialogtool.h:186
static bool doublePointsExist(QListWidget *listWidget)
Definition: dialogtool.cpp:565
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, bool checkZero=true, bool checkLessThanZero=false)
Eval evaluate formula and show result.
Definition: dialogtool.cpp:805
void initializeOkCancel(T *ui)
initializeOkCancel initialize OK and Cancel buttons
Definition: dialogtool.h:379
NodeInfo getNodeInfo(const VPieceNode &node, bool showNotch=false) const
Definition: dialogtool.cpp:628
void newNodeItem(QListWidget *listWidget, const VPieceNode &node, bool nodeExcluded=true, bool isDuplicate=false)
Definition: dialogtool.cpp:679
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
Definition: dialogtool.cpp:192
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer, const QString &postfix=QString())
ValFormulaChanged handle change formula.
Definition: dialogtool.cpp:744
quint32 toolId
Definition: dialogtool.h:225
QLabel * labelEditFormula
labelEditFormula label used when need show wrong formula
Definition: dialogtool.h:217
bool flagError
flagError use this flag if for you do not enought
Definition: dialogtool.h:193
const VContainer * data
data container with data
Definition: dialogtool.h:177
QPlainTextEdit * plainTextEditFormula
plainTextEditFormula formula
Definition: dialogtool.h:208
QString GetComboBoxCurrentData(const QComboBox *box, const QString &def) const
Definition: dialogtool.cpp:400
bool prepare
prepare show if we prepare. Show dialog after finish working with visual part of tool
Definition: dialogtool.h:228
static bool isEachPointNameUnique(QListWidget *listWidget)
Definition: dialogtool.cpp:583
QLabel * labelResultCalculation
labelResultCalculation label with result of calculation
Definition: dialogtool.h:211
void initializeNodeAngles(QComboBox *box)
Definition: dialogtool.cpp:717
static QString DialogWarningIcon()
Definition: dialogtool.cpp:604
void FillComboBoxPiecesList(QComboBox *box, const QVector< quint32 > &list)
Definition: dialogtool.cpp:224
QPointer< Visualization > vis
Definition: dialogtool.h:236
void ChangeColor(QWidget *widget, const QColor &color)
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
Definition: dialogtool.cpp:992
quint32 getCurrentObjectId(QComboBox *box) const
getCurrentPointId return current point id stored in combobox
Definition: dialogtool.cpp:959
The EditFormulaDialog class dialog for editing wrong formula.
QString GetFormula() const
void SetFormula(const QString &value)
void setCheckLessThanZero(bool value)
void setPostfix(const QString &value)
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
QString GetName() const
The VContainer class container of all variables.
Definition: vcontainer.h:141
void AddVariable(const QString &name, T *var)
Definition: vcontainer.h:327
VPiece GetPiece(quint32 id) const
Definition: vcontainer.cpp:185
The VIncrement class keep data row of increment table.
Definition: vincrement.h:70
void setBeforeSAFormula(const QString &formula)
Definition: vpiecenode.cpp:221
Tool GetTypeTool() const
Definition: vpiecenode.cpp:161
quint32 GetId() const
Definition: vpiecenode.cpp:149
void setNotchType(NotchType notchType)
Definition: vpiecenode.cpp:320
void setAfterSAFormula(const QString &formula)
Definition: vpiecenode.cpp:263
PieceNodeAngle GetAngleType() const
Definition: vpiecenode.cpp:272
NotchType getNotchType() const
Definition: vpiecenode.cpp:314
QString GetFormulaSAAfter() const
Definition: vpiecenode.cpp:257
QString GetFormulaSABefore() const
Definition: vpiecenode.cpp:215
bool GetReverse() const
Definition: vpiecenode.cpp:173
void SetAngleType(PieceNodeAngle type)
Definition: vpiecenode.cpp:278
bool isNotch() const
Definition: vpiecenode.cpp:287
void SetReverse(bool reverse)
Definition: vpiecenode.cpp:179
NotchSubType getNotchSubType() const
Definition: vpiecenode.cpp:326
void setNotchSubType(NotchSubType notchSubType)
Definition: vpiecenode.cpp:332
PiecePathType GetType() const
Definition: vpiecepath.cpp:239
void SetType(PiecePathType type)
Definition: vpiecepath.cpp:245
qint32 CountNodes() const
Definition: vpiecepath.cpp:209
void SetCutPath(bool cut)
Definition: vpiecepath.cpp:281
void Append(const VPieceNode &node)
Definition: vpiecepath.cpp:197
void SetPenType(const Qt::PenStyle &type)
Definition: vpiecepath.cpp:269
void SetName(const QString &name)
Definition: vpiecepath.cpp:257
Qt::PenStyle GetPenType() const
Definition: vpiecepath.cpp:263
const VPieceNode & at(int indx) const
Definition: vpiecepath.cpp:221
bool IsCutPath() const
Definition: vpiecepath.cpp:275
int indexOfNode(quint32 id) const
Definition: vpiecepath.cpp:507
QString GetName() const
Definition: vpiecepath.cpp:251
void SetPath(const VPiecePath &path)
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
Definition: def.cpp:702
qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
Definition: def.cpp:269
NotchType
Definition: def.h:123
#define SCASSERT(cond)
Definition: def.h:317
PieceNodeAngle
Definition: def.h:113
NotchSubType
Definition: def.h:137
SceneObject
Definition: def.h:103
PiecePathType
Definition: def.h:157
@ NodeSplinePath
@ NodeSpline
@ NodeElArc
@ NodeArc
@ NodePoint
const QString LineTypeSolidLine
Definition: ifcdef.cpp:159
const QString currentSeamAllowance
Definition: ifcdef.cpp:442
const QString LineTypeNone
Definition: ifcdef.cpp:158
QString PenStyleToLineType(Qt::PenStyle penStyle)
Definition: ifcdef.cpp:204
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.
Definition: ifcdef.cpp:183
#define NULL_ID
Definition: ifcdef.h:76
QString name
Definition: dialogtool.h:89
QString icon
Definition: dialogtool.h:88
#define qApp
Definition: vapplication.h:67