Seamly2D
Code documentation
edit_formula_dialog.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 * @file edit_formula_dialog.cpp
3 ** @author DSCaskey <dscaskey@gmail.com>
4 ** @date 10 Jun, 2023
5 **
6 ** @brief
7 ** @copyright
8 ** This source code is part of the Seamly2D project, a pattern making
9 ** program to create and model patterns of clothing.
10 ** Copyright (C) 2017-2023 Seamly2D project
11 ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12 **
13 ** Seamly2D is free software: you can redistribute it and/or modify
14 ** it under the terms of the GNU General Public License as published by
15 ** the Free Software Foundation, either version 3 of the License, or
16 ** (at your option) any later version.
17 **
18 ** Seamly2D is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
22 **
23 ** You should have received a copy of the GNU General Public License
24 ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25 **
26 *************************************************************************/
27 
28 /************************************************************************
29  **
30  ** @file dialogeditwrongformula.cpp
31  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
32  ** @date 29 5, 2014
33  **
34  ** @brief
35  ** @copyright
36  ** This source code is part of the Valentina project, a pattern making
37  ** program, whose allow create and modeling patterns of clothing.
38  ** Copyright (C) 2013-2015 Valentina project
39  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
40  **
41  ** Valentina is free software: you can redistribute it and/or modify
42  ** it under the terms of the GNU General Public License as published by
43  ** the Free Software Foundation, either version 3 of the License, or
44  ** (at your option) any later version.
45  **
46  ** Valentina is distributed in the hope that it will be useful,
47  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
48  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49  ** GNU General Public License for more details.
50  **
51  ** You should have received a copy of the GNU General Public License
52  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
53  **
54  *************************************************************************/
55 
56 #include "edit_formula_dialog.h"
57 #include "ui_edit_formula_dialog.h"
58 
59 #include <qiterator.h>
60 #include <QAbstractItemView>
61 #include <QApplication>
62 #include <QCheckBox>
63 #include <QCursor>
64 #include <QDialog>
65 #include <QFont>
66 #include <QHeaderView>
67 #include <QLabel>
68 #include <QListWidget>
69 #include <QMapIterator>
70 #include <QPlainTextEdit>
71 #include <QPushButton>
72 #include <QSharedPointer>
73 #include <QShowEvent>
74 #include <QGuiApplication>
75 #include <QScreen>
76 #include <QSize>
77 #include <QTableWidget>
78 #include <QTableWidgetItem>
79 #include <QTextCursor>
80 #include <QToolButton>
81 #include <QWidget>
82 #include <Qt>
83 #include <new>
84 
85 #include "../ifc/xml/vdomdocument.h"
86 #include "../tools/dialogtool.h"
87 #include "../vmisc/def.h"
88 #include "../vmisc/vabstractapplication.h"
89 #include "../vmisc/vcommonsettings.h"
90 #include "../vpatterndb/vcontainer.h"
91 #include "../vpatterndb/vtranslatevars.h"
92 #include "../vpatterndb/variables/varcradius.h"
93 #include "../vpatterndb/variables/vcurveangle.h"
94 #include "../vpatterndb/variables/vcurvelength.h"
95 #include "../vpatterndb/variables/vincrement.h"
96 #include "../vpatterndb/variables/vlineangle.h"
97 #include "../vpatterndb/variables/vlinelength.h"
98 #include "../vpatterndb/variables/vmeasurement.h"
99 
100 template <class T> class QSharedPointer;
101 
103 
104 //---------------------------------------------------------------------------------------------------------------------
105 EditFormulaDialog::EditFormulaDialog(const VContainer *data, const quint32 &toolId, QWidget *parent)
106  : DialogTool(data, toolId, parent)
107  , ui(new Ui::EditFormulaDialog)
108  , m_formula(QString())
109  , m_undoFormula(QString())
110  , m_checkZero(false)
111  , m_checkLessThanZero(false)
112  , m_postfix(QString())
113  , m_restoreCursor(false)
114 {
115  ui->setupUi(this);
116  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
117 
120  ui->plainTextEditFormula->installEventFilter(this);
121  ui->menuTab_ListWidget->setCurrentRow(VariableTab::Measurements);
122 
123  connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &EditFormulaDialog::filterVariables);
124 
126  flagFormula = false;
127  CheckState();
128 
129  connect(ui->insert_PushButton, &QPushButton::clicked, this, &EditFormulaDialog::insertVariable);
130  connect(ui->clear_PushButton, &QPushButton::clicked, this, &EditFormulaDialog::clearFormula);
131  connect(ui->undo_PushButton, &QPushButton::clicked, this, &EditFormulaDialog::undoFormula);
132  connect(ui->tableWidget, &QTableWidget::itemDoubleClicked, this, &EditFormulaDialog::insertValue);
133  connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &EditFormulaDialog::FormulaChanged);
134 
135  //Disable Qt::WaitCursor
136 #ifndef QT_NO_CURSOR
137  if (QGuiApplication::overrideCursor() != nullptr)
138  {
139  if (QGuiApplication::overrideCursor()->shape() == Qt::WaitCursor)
140  {
141  m_restoreCursor = true;
142  QGuiApplication::restoreOverrideCursor();
143  }
144  }
145 #endif
146 
147  ui->tableWidget->setColumnCount(2);
148  ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);
149  ui->tableWidget->verticalHeader()->hide();
150  ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
151 }
152 
153 //---------------------------------------------------------------------------------------------------------------------
155 {
156 #ifndef QT_NO_CURSOR
157  if (m_restoreCursor)
158  {
159  QGuiApplication::setOverrideCursor(Qt::WaitCursor);
160  }
161 #endif
162  delete ui;
163 }
164 
165 //---------------------------------------------------------------------------------------------------------------------
167 {
168  m_formula = ui->plainTextEditFormula->toPlainText();
169  m_formula.replace("\n", " ");
170  emit DialogClosed(QDialog::Accepted);
171  accepted();
172 }
173 
174 //---------------------------------------------------------------------------------------------------------------------
176 {
177  emit DialogClosed(QDialog::Rejected);
178  rejected();
179 }
180 
181 //---------------------------------------------------------------------------------------------------------------------
183 {
184  SCASSERT(plainTextEditFormula != nullptr)
185  SCASSERT(labelResultCalculation != nullptr)
188 }
189 
190 //---------------------------------------------------------------------------------------------------------------------
191 /**
192  * @brief valueChanged show description when current variable changed
193  * @param row number of row
194  */
196 {
197  if (ui->tableWidget->rowCount() == 0)
198  {
199  ui->description_Label->setText("");
200  return;
201  }
202  QTableWidgetItem *item = ui->tableWidget->item( row, ColumnName );
203 
204  switch (ui->menuTab_ListWidget->currentRow())
205  {
207  {
208  const QString name = qApp->TrVars()->VarFromUser(item->text());
210  const QString desc = (measurements->getGuiText() == "") ? "" : QString("\nDescription: %1").arg(measurements->getGuiText());
211  setDescription(item->text(), *data->DataVariables()->value(name)->GetValue(),
212  UnitsToStr(qApp->patternUnit(), true), tr("Measurement"), desc);
213  break;
214  }
215  case VariableTab::Custom:
216  {
217  const QSharedPointer<VIncrement> variables = data->GetVariable<VIncrement>(item->text());
218  const QString desc =(variables->GetDescription() == "") ? "" : QString("\nDescription: %1").arg(variables->GetDescription());
219  setDescription(item->text(), *data->DataVariables()->value(item->text())->GetValue(),
220  UnitsToStr(qApp->patternUnit(), true), tr("Custom Variable"), desc);
221  break;
222  }
224  {
225  setDescription(item->text(),
226  *data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
227  UnitsToStr(qApp->patternUnit(), true), tr("Line length"), "");
228  break;
229  }
231  {
232  setDescription(item->text(),
233  *data->GetVariable<VCurveLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
234  UnitsToStr(qApp->patternUnit(), true), tr("Curve length"), "");
235  break;
236  }
238  {
239  setDescription(item->text(),
240  *data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
241  degreeSymbol, tr("Line Angle"), "");
242  break;
243  }
245  {
246  setDescription(item->text(),
247  *data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
248  UnitsToStr(qApp->patternUnit(), true), tr("Arc radius"), "");
249  break;
250  }
252  {
253  setDescription(item->text(),
254  *data->GetVariable<VCurveAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
255  degreeSymbol, tr("Curve angle"), "");
256  break;
257  }
259  {
260  ui->description_Label->setText(item->toolTip());
261  break;
262  }
263  }
264  return;
265 }
266 
267 //---------------------------------------------------------------------------------------------------------------------
268 /**
269  * @brief menu tabChanged
270  * @param row number of row
271  */
273 {
274  switch (row)
275  {
277  {
278  measurements();
279  break;
280  }
281  case VariableTab::Custom:
282  {
283  customVariables();
284  break;
285  }
287  {
288  lineLengths();
289  break;
290  }
292  {
293  lineAngles();
294  break;
295  }
297  {
298  curveLengths();
299  break;
300  }
302  {
303  curveAngles();
304  break;
305  }
307  {
309  break;
310  }
312  {
313  arcRadii();
314  break;
315  }
317  {
318  functions();
319  break;
320  }
321  }
322  return;
323 }
324 
325 //---------------------------------------------------------------------------------------------------------------------
326 /**
327  * @brief insertVariable insert variable into line edit
328  */
330 {
331  insertValue(ui->tableWidget->currentItem());
332 }
333 
334 //---------------------------------------------------------------------------------------------------------------------
335 /**
336  * @brief insertValue insert variable into line edit
337  * @param item chosen item of table widget
338  */
339 void EditFormulaDialog::insertValue(QTableWidgetItem *item)
340 {
341  if (item != nullptr)
342  {
343  QTextCursor cursor = ui->plainTextEditFormula->textCursor();
344  if (ui->menuTab_ListWidget->currentRow() == VariableTab::Functions)
345  {
346  if (cursor.hasSelection())
347  {
348  QString selected = cursor.selectedText();
349  cursor.insertText(ui->tableWidget->item(item->row(), ColumnName)->text() +
350  QStringLiteral("(") + selected + QStringLiteral(")"));
351  cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
352  ui->plainTextEditFormula->setTextCursor(cursor);
353  }
354  else
355  {
356  cursor.insertText(ui->tableWidget->item(item->row(), ColumnName)->text() + QStringLiteral("()"));
357  cursor.setPosition(cursor.position() - 1);
358  }
359  }
360  else
361  {
362  cursor.insertText(ui->tableWidget->item(item->row(), ColumnName)->text());
363  }
364  ui->plainTextEditFormula->setTextCursor(cursor);
365  ui->plainTextEditFormula->setFocus();
366  }
367 }
368 
369 //---------------------------------------------------------------------------------------------------------------------
370 /**
371  * @brief measurements show measurements in list
372  */
374 {
375  ui->checkBoxHideEmpty->setEnabled(true);
377 }
378 
379 //---------------------------------------------------------------------------------------------------------------------
380 /**
381  * @brief lineLengths show lengths of line variables in list
382  */
384 {
385  ui->checkBoxHideEmpty->setEnabled(false);
387 }
388 
389 //---------------------------------------------------------------------------------------------------------------------
390 /**
391  * @brief arcRadii show radii of arc variables in list
392  */
394 {
395  ui->checkBoxHideEmpty->setEnabled(false);
397 }
398 
399 //---------------------------------------------------------------------------------------------------------------------
400 /**
401  * @brief curveAngles show angles of curve variables in list
402  */
404 {
405  ui->checkBoxHideEmpty->setEnabled(false);
407 }
408 
409 //---------------------------------------------------------------------------------------------------------------------
410 /**
411  * @brief curveLengths show lengths of curve variables in list
412  */
414 {
415  ui->checkBoxHideEmpty->setEnabled(false);
417 }
418 
419 //---------------------------------------------------------------------------------------------------------------------
420 /**
421  * @brief controlPointLengths show lengths of control point variables in list
422  */
424 {
425  ui->checkBoxHideEmpty->setEnabled(false);
427 }
428 
429 //---------------------------------------------------------------------------------------------------------------------
430 /**
431  * @brief lineAngles show angles of line variables in list
432  */
434 {
435  ui->checkBoxHideEmpty->setEnabled(false);
437 }
438 
439 //---------------------------------------------------------------------------------------------------------------------
440 /**
441  * @brief customVariables show custom variables in list
442  */
444 {
445  ui->checkBoxHideEmpty->setEnabled(false);
447 }
448 
449 //---------------------------------------------------------------------------------------------------------------------
450 /**
451  * @brief functions show functions in list
452  */
454 {
455  ui->checkBoxHideEmpty->setEnabled(false);
456  showFunctions();
457 }
458 
459 //---------------------------------------------------------------------------------------------------------------------
461 {
462  SCASSERT(ok_Button != nullptr)
463  ok_Button->setEnabled(flagFormula);
464 }
465 
466 //---------------------------------------------------------------------------------------------------------------------
467 void EditFormulaDialog::closeEvent(QCloseEvent *event)
468 {
469  ui->plainTextEditFormula->blockSignals(true);
470  DialogTool::closeEvent(event);
471 }
472 
473 //---------------------------------------------------------------------------------------------------------------------
474 void EditFormulaDialog::showEvent(QShowEvent *event)
475 {
476  QDialog::showEvent(event);
477  if (event->spontaneous())
478  {
479  return;
480  }
481 
482  if (isInitialized)
483  {
484  return;
485  }
486  // do your init stuff here
487 
488  const QSize size = qApp->Settings()->GetFormulaWizardDialogSize();
489  if (!size.isEmpty())
490  {
491  resize(size);
492  }
493 
494  QScreen *screen = QGuiApplication::primaryScreen();
495  QRect position = frameGeometry();
496  position.moveCenter(screen->availableGeometry().center());
497  move(position.topLeft());
498 
499  isInitialized = true;//first show windows are held
500 }
501 
502 //---------------------------------------------------------------------------------------------------------------------
503 void EditFormulaDialog::resizeEvent(QResizeEvent *event)
504 {
505  // remember the size for the next time this dialog is opened, but only
506  // if widget was already initialized.
507  if (isInitialized)
508  {
509  qApp->Settings()->SetFormulaWizardDialogSize(size());
510  }
511  DialogTool::resizeEvent(event);
512 }
513 
514 //---------------------------------------------------------------------------------------------------------------------
515 void EditFormulaDialog::SetFormula(const QString &value)
516 {
517  m_formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
519  ui->plainTextEditFormula->setPlainText(m_formula);
520  MoveCursorToEnd(ui->plainTextEditFormula);
521 }
522 
523 //---------------------------------------------------------------------------------------------------------------------
525 {
526  m_checkZero = value;
527 }
528 
529 //---------------------------------------------------------------------------------------------------------------------
531 {
532  m_checkLessThanZero = value;
533 }
534 
535 //---------------------------------------------------------------------------------------------------------------------
536 void EditFormulaDialog::setPostfix(const QString &value)
537 {
538  m_postfix = value;
539 }
540 
541 //---------------------------------------------------------------------------------------------------------------------
543 {
544  return qApp->TrVars()->TryFormulaFromUser(m_formula, qApp->Settings()->GetOsSeparator());
545 }
546 
547 //---------------------------------------------------------------------------------------------------------------------
549 {
550  connect(ui->tableWidget, &QTableWidget::currentCellChanged, this, &EditFormulaDialog::valueChanged);
551 
552  measurements();
553 
554  // clear text filter whenever list widget row changes
555  auto ClearFilterFormulaInputs = [this] () { ui->filterFormulaInputs->clear(); };
556 
557  connect(ui->menuTab_ListWidget, &QListWidget::currentRowChanged, this, &EditFormulaDialog::tabChanged);
558  connect(ui->menuTab_ListWidget, &QListWidget::currentRowChanged, this, ClearFilterFormulaInputs);
559  connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &EditFormulaDialog::measurements);
560 
561  // Set the selection highlight rect larger than just the item text
562  for (int i = 0; i < ui->menuTab_ListWidget->count(); ++i)
563  {
564  ui->menuTab_ListWidget->item(i)->setSizeHint(QSize(ui->menuTab_ListWidget->width(), 50));
565  }
566 }
567 
568 //---------------------------------------------------------------------------------------------------------------------
569 void EditFormulaDialog::setDescription(const QString &name, qreal value, const QString &unit,
570  const QString &type, const QString &description)
571 {
572  const QString desc = QString("%5: %1(%2 %3)%4").arg(name).arg(value).arg(unit).arg(description).arg(type);
573  ui->description_Label->setText(desc);
574 }
575 
576 //---------------------------------------------------------------------------------------------------------------------
577 /**
578  * @brief showVariable show variables in list
579  * @param var container with variables
580  */
581 template <class key, class val>
583 {
584  ui->tableWidget->blockSignals(true);
585  ui->tableWidget->clearContents();
586  ui->tableWidget->setRowCount(0);
587  ui->tableWidget->setColumnHidden(ColumnFullName, true);
588  ui->description_Label->setText("");
589 
590  QMapIterator<key, val> iMap(var);
591  while (iMap.hasNext())
592  {
593  iMap.next();
594  if (ui->checkBoxHideEmpty->isEnabled() && ui->checkBoxHideEmpty->isChecked() && iMap.value()->isNotUsed())
595  {
596  continue; //skip this measurement
597  }
598  if (iMap.value()->Filter(toolId) == false)
599  {// If we create this variable don't show
600  ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
601  QTableWidgetItem *item = new QTableWidgetItem(iMap.key());
602  ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item);
603  }
604  }
605  ui->tableWidget->blockSignals(false);
606  ui->tableWidget->selectRow(0);
607  ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
608 }
609 
610 //---------------------------------------------------------------------------------------------------------------------
611 /**
612  * @brief showMeasurements show measurements in table
613  * @param var container with measurements
614  */
616 {
617  ui->tableWidget->blockSignals(true);
618  ui->tableWidget->clearContents();
619  ui->tableWidget->setRowCount(0);
620  ui->tableWidget->setColumnHidden(ColumnFullName, false);
621  ui->description_Label->setText("");
622 
623  QMapIterator<QString, QSharedPointer<VMeasurement>> iMap(var);
624  while (iMap.hasNext())
625  {
626  iMap.next();
627  if (ui->checkBoxHideEmpty->isEnabled() && ui->checkBoxHideEmpty->isChecked() && iMap.value()->isNotUsed())
628  {
629  continue; //skip this measurement
630  }
631  if (iMap.value()->Filter(toolId) == false)
632  {// If we create this variable don't show
633  ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
634  QTableWidgetItem *itemName = new QTableWidgetItem(iMap.key());
635  itemName->setToolTip(itemName->text());
636 
637  QTableWidgetItem *itemFullName = new QTableWidgetItem();
638  if (iMap.value()->isCustom())
639  {
640  itemFullName->setText(iMap.value()->getGuiText());
641  }
642  else
643  {
644  itemFullName->setText(qApp->TrVars()->guiText(iMap.value()->GetName()));
645  }
646 
647  itemFullName->setToolTip(itemFullName->text());
648  ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, itemName);
649  ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnFullName, itemFullName);
650  }
651  }
652  ui->tableWidget->blockSignals(false);
653  ui->tableWidget->selectRow(0);
654  ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
655 }
656 
657 //---------------------------------------------------------------------------------------------------------------------
658 /**
659  * @brief showFunctions show functions in list
660  */
662 {
663  ui->tableWidget->blockSignals(true);
664  ui->tableWidget->clearContents();
665  ui->tableWidget->setRowCount(0);
666  ui->tableWidget->setColumnHidden(ColumnFullName, true);
667  ui->description_Label->setText("");
668 
669  QMap<QString, qmu::QmuTranslation>::const_iterator i = qApp->TrVars()->getFunctions().constBegin();
670  while (i != qApp->TrVars()->getFunctions().constEnd())
671  {
672  ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
673  QTableWidgetItem *item = new QTableWidgetItem(i.value().translate());
674  ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item);
675  item->setToolTip(i.value().getMdisambiguation());
676  ++i;
677  }
678 
679  ui->tableWidget->blockSignals(false);
680  ui->tableWidget->selectRow(0);
681  ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
682 }
683 
684 //---------------------------------------------------------------------------------------------------------------------
685 void EditFormulaDialog::filterVariables(const QString &filter)
686 {
687  ui->tableWidget->blockSignals(true);
688 
689  // If filter is empty findItems() for unknown reason returns nullptr items.
690  if (filter.isEmpty())
691  {
692  // show all rows
693  for (auto i = 0; i < ui->tableWidget->rowCount(); ++i)
694  {
695  ui->tableWidget->showRow(i);
696  }
697  }
698  else
699  {
700  // hide all rows
701  for (auto i = 0; i < ui->tableWidget->rowCount(); i++)
702  {
703  ui->tableWidget->hideRow(i);
704  }
705 
706  // show rows with matched filter
707  for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains))
708  {
709  // If filter is empty findItems() for unknown reason returns nullptr items.
710  if (item)
711  {
712  ui->tableWidget->showRow(item->row());
713  }
714  }
715  }
716 
717  ui->tableWidget->blockSignals(false);
718 }
719 
721 {
722  ui->plainTextEditFormula->clear();
723 }
724 
726 {
727  ui->plainTextEditFormula->setPlainText(m_undoFormula);
728 }
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
void DialogClosed(int result)
DialogClosed signal dialog closed.
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const
Definition: dialogtool.cpp:432
QPushButton * ok_Button
ok_Button button ok
Definition: dialogtool.h:199
void FormulaChanged()
formula check formula
bool flagFormula
flagFormula true if formula correct
Definition: dialogtool.h:186
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
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
Definition: dialogtool.cpp:192
bool isInitialized
isInitialized true if window is initialized
Definition: dialogtool.h:180
quint32 toolId
Definition: dialogtool.h:225
const VContainer * data
data container with data
Definition: dialogtool.h:177
QPlainTextEdit * plainTextEditFormula
plainTextEditFormula formula
Definition: dialogtool.h:208
QLabel * labelResultCalculation
labelResultCalculation label with result of calculation
Definition: dialogtool.h:211
void initializeFormulaUi(T *ui)
initializeFormulaUi initialize ui object for the formula field
Definition: dialogtool.h:398
The EditFormulaDialog class dialog for editing wrong formula.
QString GetFormula() const
void SetFormula(const QString &value)
void insertVariable()
insertVariable insert variable into line edit
void customVariables()
customVariables show custom variables in list
void curveLengths()
curveLengths show lengths of curve variables in list
void filterVariables(const QString &filter)
virtual void EvalFormula() Q_DECL_OVERRIDE
void setCheckZero(bool value)
void insertValue(QTableWidgetItem *item)
insertValue insert variable into line edit
void measurements()
measurements show measurements in list
bool m_checkZero
copy of formula string used to perform undo
virtual void DialogAccepted() Q_DECL_OVERRIDE
EditFormulaDialog(const VContainer *data, const quint32 &toolId, QWidget *parent=nullptr)
virtual ~EditFormulaDialog() Q_DECL_OVERRIDE
void controlPointLengths()
controlPointLengths show lengths of control point variables in list
void setCheckLessThanZero(bool value)
void lineAngles()
lineAngles show angles of line variables in list
void curveAngles()
curveAngles show angles of curve variables in list
QString m_undoFormula
formula string with formula
void valueChanged(int row)
valueChanged show description when current variable changed
void showFunctions()
showFunctions show functions in list
void lineLengths()
lineLengths show lengths of line variables in list
void arcRadii()
arcRadii show radii of arc variables in list
void tabChanged(int row)
menu tabChanged
virtual void CheckState() Q_DECL_FINAL
CheckState enable, when all is correct, or disable, when something wrong, button ok.
void functions()
functions show functions in list
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
virtual void DialogRejected() Q_DECL_OVERRIDE
void showVariable(const QMap< key, val > &var)
showVariable show variables in list
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
Ui::EditFormulaDialog * ui
void showMeasurements(const QMap< QString, QSharedPointer< VMeasurement > > &var)
showMeasurements show measurements in table
void setPostfix(const QString &value)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
showEvent handle when window show
void setDescription(const QString &name, qreal value, const QString &unit, const QString &type, const QString &description)
The VContainer class container of all variables.
Definition: vcontainer.h:141
const QMap< QString, QSharedPointer< VArcRadius > > arcRadiusesData() const
Definition: vcontainer.cpp:573
const QMap< QString, QSharedPointer< VLineAngle > > lineAnglesData() const
Definition: vcontainer.cpp:567
const QMap< QString, QSharedPointer< VCurveAngle > > curveAnglesData() const
Definition: vcontainer.cpp:579
const QMap< QString, QSharedPointer< VCurveCLength > > controlPointLengthsData() const
Definition: vcontainer.cpp:561
const QMap< QString, QSharedPointer< VCurveLength > > curveLengthsData() const
Definition: vcontainer.cpp:555
const QMap< QString, QSharedPointer< VLengthLine > > lineLengthsData() const
Definition: vcontainer.cpp:549
const QHash< QString, QSharedPointer< VInternalVariable > > * DataVariables() const
Definition: vcontainer.cpp:718
const QMap< QString, QSharedPointer< VIncrement > > variablesData() const
Definition: vcontainer.cpp:543
QSharedPointer< T > GetVariable(QString name) const
GetVariable return varible by name.
Definition: vcontainer.h:303
const QMap< QString, QSharedPointer< VMeasurement > > DataMeasurements() const
Definition: vcontainer.cpp:537
The VIncrement class keep data row of increment table.
Definition: vincrement.h:70
virtual qreal GetValue() const
The VMeasurement class keep data row of multisize table.
Definition: vmeasurement.h:74
const QString degreeSymbol
Definition: def.cpp:196
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
Definition: def.cpp:702
#define SCASSERT(cond)
Definition: def.h:317
@ ColumnFullName
@ Custom
@ LineAngles
@ ArcRadii
@ CurveLengths
@ Functions
@ CurveAngles
@ CPLengths
@ Measurements
@ LineLengths
#define qApp
Definition: vapplication.h:67