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"
69 m_timerWidth(nullptr),
70 m_timerWidthBefore(nullptr),
71 m_timerWidthAfter(nullptr),
73 m_beforeWidthFormula(0),
74 m_afterWidthFormula(0)
77 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
78 setWindowIcon(QIcon(
":/toolicon/32x32/path.png"));
92 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->seamAllowance_Tab));
93 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->notches_Tab));
95 connect(
ui->piece_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, [
this]()
97 ValidObjects(PathIsValid());
120 bool reverse =
false;
121 if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
148 qDebug() <<
"Got wrong scene object. Ignore.";
154 if (
ui->listWidget->count() > 1)
164 auto visPath = qobject_cast<VisToolInternalPath *>(
vis);
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 "));
174 if (not
qApp->getCurrentScene()->items().contains(visPath))
180 visPath->RefreshGeometry();
185 visPath->RefreshGeometry();
203 auto visPath = qobject_cast<VisToolInternalPath *>(
vis);
206 visPath->RefreshGeometry();
224 AddVisualization<VisToolInternalPath>();
230 auto visPath = qobject_cast<VisToolInternalPath *>(
vis);
232 visPath->setParentItem(tool);
239 ui->widthFormula_PlainTextEdit->blockSignals(
true);
240 ui->beforeWidthFormula_PlainTextEdit->blockSignals(
true);
241 ui->afterWidthFormula_PlainTextEdit->blockSignals(
true);
248 const int row =
ui->listWidget->currentRow();
249 if (
ui->listWidget->count() == 0 || row == -1 || row >=
ui->listWidget->count())
255 QScopedPointer<QMenu> menu(
new QMenu(
ui->listWidget));
259 QListWidgetItem *rowItem =
ui->listWidget->item(row);
261 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
264 QAction *actionReverse =
nullptr;
267 actionReverse = menu->addAction(tr(
"Reverse"));
268 actionReverse->setCheckable(
true);
269 actionReverse->setChecked(rowNode.
GetReverse());
278 QAction *actionDelete = menu->addAction(QIcon::fromTheme(
"edit-delete"), tr(
"Delete"));
280 QAction *selectedAction = menu->exec(
ui->listWidget->viewport()->mapToGlobal(pos));
281 if (selectedAction == actionDelete)
283 delete ui->listWidget->item(row);
289 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
290 rowItem->setIcon(QIcon(info.
icon));
291 rowItem->setText(info.
name);
311 auto visPath = qobject_cast<VisToolInternalPath *>(
vis);
314 visPath->RefreshGeometry();
324 if (
ui->pathName_LineEdit->text().isEmpty())
340 ui->beforeWidthFormula_PlainTextEdit->setDisabled(
true);
341 ui->beforeExpr_ToolButton->setDisabled(
true);
342 ui->beforeDefault_PushButton->setDisabled(
true);
344 ui->afterWidthFormula_PlainTextEdit->setDisabled(
true);
345 ui->afterExpr_ToolButton->setDisabled(
true);
346 ui->afterDefault_PushButton->setDisabled(
true);
348 ui->angle_ComboBox->setDisabled(
true);
350 ui->angle_ComboBox->blockSignals(
true);
355 const int nodeIndex = path.
indexOfNode(
ui->nodes_ComboBox->currentData().toUInt());
361 ui->beforeWidthFormula_PlainTextEdit->setEnabled(
true);
362 ui->beforeExpr_ToolButton->setEnabled(
true);
367 ui->beforeDefault_PushButton->setEnabled(
true);
369 if (w1Formula.length() > 80)
373 w1Formula =
qApp->TrVars()->FormulaToUser(w1Formula,
qApp->Settings()->GetOsSeparator());
374 ui->beforeWidthFormula_PlainTextEdit->setPlainText(w1Formula);
378 ui->afterWidthFormula_PlainTextEdit->setEnabled(
true);
379 ui->afterExpr_ToolButton->setEnabled(
true);
384 ui->afterDefault_PushButton->setEnabled(
true);
386 if (w2Formula.length() > 80)
390 w2Formula =
qApp->TrVars()->FormulaToUser(w2Formula,
qApp->Settings()->GetOsSeparator());
391 ui->afterWidthFormula_PlainTextEdit->setPlainText(w2Formula);
395 ui->angle_ComboBox->setEnabled(
true);
396 const int index =
ui->angle_ComboBox->findData(
static_cast<unsigned char>(node.
GetAngleType()));
399 ui->angle_ComboBox->setCurrentIndex(index);
405 ui->beforeWidthFormula_PlainTextEdit->setPlainText(
"");
406 ui->afterWidthFormula_PlainTextEdit->setPlainText(
"");
407 ui->angle_ComboBox->setCurrentIndex(-1);
410 ui->angle_ComboBox->blockSignals(
false);
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);
424 ui->straightforward_RadioButton->setDisabled(
true);
425 ui->bisector_RadioButton->setDisabled(
true);
426 ui->intersection_RadioButton->setDisabled(
true);
428 ui->showSeamlineNotch_CheckBox->setDisabled(
true);
429 ui->showSeamlineNotch_CheckBox->blockSignals(
true);
431 ui->notchType_GroupBox->blockSignals(
true);
432 ui->notchSubType_GroupBox->blockSignals(
true);
437 const int nodeIndex = path.
indexOfNode(
ui->notches_ComboBox->currentData().toUInt());
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);
454 ui->slitNotch_RadioButton->setChecked(
true);
457 ui->tNotch_RadioButton->setChecked(
true);
460 ui->uNotch_RadioButton->setChecked(
true);
463 ui->vInternalNotch_RadioButton->setChecked(
true);
466 ui->vExternalNotch_RadioButton->setChecked(
true);
469 ui->castleNotch_RadioButton->setChecked(
true);
472 ui->diamondNotch_RadioButton->setChecked(
true);
479 ui->straightforward_RadioButton->setEnabled(
true);
480 ui->bisector_RadioButton->setEnabled(
true);
481 ui->intersection_RadioButton->setEnabled(
true);
486 ui->straightforward_RadioButton->setChecked(
true);
489 ui->bisector_RadioButton->setChecked(
true);
492 ui->intersection_RadioButton->setChecked(
true);
499 ui->notchType_GroupBox->blockSignals(
false);
500 ui->notchSubType_GroupBox->blockSignals(
false);
507 if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
509 button->setEnabled(
false);
517 if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
519 button->setEnabled(
false);
526 const int i =
ui->notches_ComboBox->currentIndex();
529 QListWidgetItem *rowItem =
getItemById(
ui->notches_ComboBox->currentData().toUInt());
532 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
536 if (
id ==
ui->notchType_ButtonGroup->id(
ui->slitNotch_RadioButton))
540 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->tNotch_RadioButton))
544 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->uNotch_RadioButton))
548 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->vInternalNotch_RadioButton))
552 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->vExternalNotch_RadioButton))
556 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->castleNotch_RadioButton))
560 else if (
id ==
ui->notchType_ButtonGroup->id(
ui->diamondNotch_RadioButton))
566 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
567 rowItem->setIcon(QIcon(info.
icon));
568 rowItem->setText(info.
name);
578 const int i =
ui->notches_ComboBox->currentIndex();
581 QListWidgetItem *rowItem =
getItemById(
ui->notches_ComboBox->currentData().toUInt());
584 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
587 if (
id ==
ui->notchSubType_ButtonGroup->id(
ui->straightforward_RadioButton))
591 else if (
id ==
ui->notchSubType_ButtonGroup->id(
ui->bisector_RadioButton))
595 else if (
id ==
ui->notchSubType_ButtonGroup->id(
ui->intersection_RadioButton))
601 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
614 const QString formula =
ui->widthFormula_PlainTextEdit->toPlainText();
622 tr(
"Current seam allowance")));
634 QString formula =
ui->beforeWidthFormula_PlainTextEdit->toPlainText();
641 ui->beforeDefault_PushButton->setEnabled(
true);
652 QString formula =
ui->afterWidthFormula_PlainTextEdit->toPlainText();
659 ui->afterDefault_PushButton->setEnabled(
true);
669 dialog->setWindowTitle(tr(
"Edit seam allowance width"));
673 if (dialog->exec() == QDialog::Accepted)
684 dialog->setWindowTitle(tr(
"Edit seam allowance width before"));
688 if (dialog->exec() == QDialog::Accepted)
699 dialog->setWindowTitle(tr(
"Edit seam allowance width after"));
703 if (dialog->exec() == QDialog::Accepted)
760 ui->pathName_LineEdit->setClearButtonEnabled(
true);
765 ui->penType_ComboBox->removeItem(index);
771 connect(
ui->type_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
774 ui->penType_ComboBox->setEnabled(GetType() == PiecePathType::InternalPath);
775 ui->cutOnFabric_CheckBox->setEnabled(GetType() == PiecePathType::InternalPath);
776 ValidObjects(PathIsValid());
779 ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
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);});
797 ui->widthFormula_PlainTextEdit->installEventFilter(
this);
798 ui->beforeWidthFormula_PlainTextEdit->installEventFilter(
this);
799 ui->afterWidthFormula_PlainTextEdit->installEventFilter(
this);
812 ui->widthFormula_PlainTextEdit->setPlainText(
qApp->LocaleToString(
m_saWidth));
815 connect(
ui->nodes_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this,
822 connect(
ui->angle_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this,
830 connect(
ui->beforeWidthFormula_PlainTextEdit, &QPlainTextEdit::textChanged,
this,
832 connect(
ui->afterWidthFormula_PlainTextEdit, &QPlainTextEdit::textChanged,
this,
836 connect(
ui->beforeWidthGrow_PushButton, &QPushButton::clicked,
838 connect(
ui->afterWidthGrow_PushButton, &QPushButton::clicked,
this,
846 connect(
ui->notches_ComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
866 const quint32
id =
ui->nodes_ComboBox->currentData().toUInt();
868 ui->nodes_ComboBox->blockSignals(
true);
869 ui->nodes_ComboBox->clear();
879 ui->nodes_ComboBox->addItem(info.
name, node.
GetId());
882 ui->nodes_ComboBox->blockSignals(
false);
884 const int index =
ui->nodes_ComboBox->findData(
id);
887 ui->nodes_ComboBox->setCurrentIndex(index);
899 const quint32
id =
ui->notches_ComboBox->currentData().toUInt();
901 ui->notches_ComboBox->blockSignals(
true);
902 ui->notches_ComboBox->clear();
906 for (
int i = 0; i < nodes.size(); ++i)
913 ui->notches_ComboBox->addItem(QIcon(info.
icon), info.
name, node.
GetId());
916 ui->notches_ComboBox->blockSignals(
false);
918 const int index =
ui->notches_ComboBox->findData(
id);
921 ui->notches_ComboBox->setCurrentIndex(index);
933 const int i =
ui->nodes_ComboBox->currentIndex();
934 if (i != -1 && index != -1)
936 QListWidgetItem *rowItem =
getItemById(
ui->nodes_ComboBox->currentData().toUInt());
940 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
942 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
958 ui->listWidget->clear();
965 ui->pathName_LineEdit->setText(path.
GetName());
981 return static_cast<PiecePathType>(
ui->type_ComboBox->currentData().toInt());
987 const qint32 index =
ui->type_ComboBox->findData(
static_cast<int>(type));
990 ui->type_ComboBox->setCurrentIndex(index);
1007 vis->setLineStyle(type);
1013 return ui->cutOnFabric_CheckBox->isChecked();
1019 ui->cutOnFabric_CheckBox->setChecked(value);
1025 for (qint32 i = 0; i <
ui->listWidget->count(); ++i)
1027 QListWidgetItem *item =
ui->listWidget->item(i);
1028 const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
1030 if (node.
GetId() ==
id)
1041 const int count =
ui->listWidget->count();
1044 QListWidgetItem *item =
ui->listWidget->item(count-1);
1045 const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
1046 return node.
GetId();
1071 const int index =
ui->nodes_ComboBox->currentIndex();
1074 QListWidgetItem *rowItem =
getItemById(
ui->nodes_ComboBox->currentData().toUInt());
1077 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
1079 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
1087 const int index =
ui->nodes_ComboBox->currentIndex();
1090 QListWidgetItem *rowItem =
getItemById(
ui->nodes_ComboBox->currentData().toUInt());
1093 VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
1095 rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
1103 if (formula.isEmpty())
1108 const QString width =
qApp->TrVars()->FormulaToUser(formula,
qApp->Settings()->GetOsSeparator());
1110 if (width.length() > 80)
1114 ui->widthFormula_PlainTextEdit->setPlainText(width);
1120 if (
ui->tabWidget->indexOf(
ui->seamAllowance_Tab) == -1)
1122 ui->tabWidget->addTab(
ui->seamAllowance_Tab, tr(
"Seam allowance"));
1125 if (
ui->tabWidget->indexOf(
ui->notches_Tab) == -1)
1127 ui->tabWidget->addTab(
ui->notches_Tab, tr(
"Notches"));
1142 if (
ui->piece_ComboBox->count() <= 0)
1148 const qint32 index =
ui->piece_ComboBox->findData(
id);
1151 ui->piece_ComboBox->setCurrentIndex(index);
1155 ui->piece_ComboBox->setCurrentIndex(0);
1163 QString width =
ui->widthFormula_PlainTextEdit->toPlainText();
1164 width.replace(
"\n",
" ");
1165 return qApp->TrVars()->TryFormulaFromUser(width,
qApp->Settings()->GetOsSeparator());
1178 for (qint32 i = 0; i <
ui->listWidget->count(); ++i)
1180 QListWidgetItem *item =
ui->listWidget->item(i);
1181 path.
Append(qvariant_cast<VPieceNode>(item->data(Qt::UserRole)));
1185 path.
SetName(
ui->pathName_LineEdit->text());
1199 url += tr(
"You need more points!");
1200 ui->status_Label->setText(url);
1207 url += tr(
"First point of <b>custom seam allowance</b> cannot be equal to the last point!");
1208 ui->status_Label->setText(url);
1213 url += tr(
"You have double points!");
1214 ui->status_Label->setText(url);
1219 url += tr(
"Each point in the <b>custom seam allowance</b> path must be unique!");
1220 ui->status_Label->setText(url);
1225 if (not
m_showMode &&
ui->piece_ComboBox->count() <= 0)
1227 url += tr(
"List of details is empty!");
1228 ui->status_Label->setText(url);
1231 else if (not
m_showMode &&
ui->piece_ComboBox->currentIndex() == -1)
1233 url += tr(
"Please, select a detail to insert into!");
1234 ui->status_Label->setText(url);
1238 ui->status_Label->setText(tr(
"Ready!"));
1258 QString width =
ui->beforeWidthFormula_PlainTextEdit->toPlainText();
1259 width.replace(
"\n",
" ");
1260 return qApp->TrVars()->TryFormulaFromUser(width,
qApp->Settings()->GetOsSeparator());
1266 QString width =
ui->afterWidthFormula_PlainTextEdit->toPlainText();
1267 width.replace(
"\n",
" ");
1268 return qApp->TrVars()->TryFormulaFromUser(width,
qApp->Settings()->GetOsSeparator());
1274 ui->moveTop_ToolButton->setEnabled(
false);
1275 ui->moveUp_ToolButton->setEnabled(
false);
1276 ui->moveDown_ToolButton->setEnabled(
false);
1277 ui->moveBottom_ToolButton->setEnabled(
false);
1279 if (
ui->listWidget->count() > 1)
1281 if (
ui->listWidget->currentRow() == 0)
1283 ui->moveDown_ToolButton->setEnabled(
true);
1284 ui->moveBottom_ToolButton->setEnabled(
true);
1286 else if (
ui->listWidget->currentRow() ==
ui->listWidget->count() - 1)
1288 ui->moveTop_ToolButton->setEnabled(
true);
1289 ui->moveUp_ToolButton->setEnabled(
true);
1293 ui->moveTop_ToolButton->setEnabled(
true);
1294 ui->moveUp_ToolButton->setEnabled(
true);
1295 ui->moveDown_ToolButton->setEnabled(
true);
1296 ui->moveBottom_ToolButton->setEnabled(
true);
void SetPiecePath(const VPiecePath &path)
void editAfterSeamAllowanceWidth()
void editDefaultSeamAllowanceWidth()
void editBeforeSeamAllowanceWidth()
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 initializeNotchesList()
void initializeNodesList()
virtual ~DialogInternalPath()
void notchSubTypeChanged(int id)
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
void enableDefaultBeforeButton()
void InitSeamAllowanceTab()
void SetCurrentSABefore(const QString &formula)
void evaluateAfterWidth()
quint32 GetPieceId() const
void beforeWidthChanged()
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)
QTimer * m_timerWidthBefore
void EnbleShowMode(bool disable)
void NewItem(const VPieceNode &node)
void notchTypeChanged(int id)
virtual void ShowVisualization() Q_DECL_OVERRIDE
QTimer * m_timerWidthAfter
void setSeamAllowanceWidthFormula(const QString &formula)
void SetCutPath(bool value)
QString getSeamAllowanceWidthFormulaBefore() const
void defaultWidthChanged()
void SetType(PiecePathType type)
void nodeAngleChanged(int index)
VPiecePath GetPiecePath() const
void expandWidthAfterFormulaTextEdit()
void updateNodeAfterSeamAllowance(const QString &formula)
void ShowContextMenu(const QPoint &pos)
Qt::PenStyle GetPenType() const
void enableDefaultAfterButton()
void expandWidthFormulaTextEdit()
QListWidgetItem * getItemById(quint32 id)
PiecePathType GetType() const
DialogInternalPath(const VContainer *data, quint32 toolId, QWidget *parent=nullptr)
void evaluateDefaultWidth()
void SetPieceId(quint32 id)
QString getSeamAllowanceWidthFormulaAfter() const
void evaluateBeforeWidth()
quint32 GetLastId() const
void SetPenType(const Qt::PenStyle &type)
QString getSeamAllowanceWidthFormula() const
void expandWidthBeforeFormulaTextEdit()
virtual void SetPiecesList(const QVector< quint32 > &list) Q_DECL_OVERRIDE
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
The VContainer class container of all variables.
void AddVariable(const QString &name, T *var)
VPiece GetPiece(quint32 id) const
The VIncrement class keep data row of increment table.
void setBeforeSAFormula(const QString &formula)
void setNotchType(NotchType notchType)
void setAfterSAFormula(const QString &formula)
PieceNodeAngle GetAngleType() const
NotchType getNotchType() const
QString GetFormulaSAAfter() const
QString GetFormulaSABefore() const
void SetAngleType(PieceNodeAngle type)
void SetReverse(bool reverse)
NotchSubType getNotchSubType() const
void setNotchSubType(NotchSubType notchSubType)
PiecePathType GetType() const
void SetType(PiecePathType type)
qint32 CountNodes() const
void SetCutPath(bool cut)
void Append(const VPieceNode &node)
void SetPenType(const Qt::PenStyle &type)
void SetName(const QString &name)
Qt::PenStyle GetPenType() const
const VPieceNode & at(int indx) const
int indexOfNode(quint32 id) const
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
const QString LineTypeSolidLine
const QString currentSeamAllowance
const QString LineTypeNone
QString PenStyleToLineType(Qt::PenStyle penStyle)
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.