2016-11-04 15:16:11 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogseamallowance.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 3 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "dialogseamallowance.h"
|
|
|
|
#include "ui_dialogseamallowance.h"
|
2017-03-17 15:38:18 +01:00
|
|
|
#include "ui_tabpaths.h"
|
|
|
|
#include "ui_tablabels.h"
|
|
|
|
#include "ui_tabgrainline.h"
|
|
|
|
#include "ui_tabpins.h"
|
|
|
|
#include "../vwidgets/fancytabbar/fancytabbar.h"
|
2016-11-04 15:16:11 +01:00
|
|
|
#include "../vpatterndb/vpiecenode.h"
|
2016-11-23 11:54:46 +01:00
|
|
|
#include "../vpatterndb/vpiecepath.h"
|
2017-01-12 18:09:00 +01:00
|
|
|
#include "../vpatterndb/calculator.h"
|
2016-11-05 11:49:20 +01:00
|
|
|
#include "visualization/path/vistoolpiece.h"
|
2017-02-14 16:33:30 +01:00
|
|
|
#include "visualization/path/vispiecepins.h"
|
2017-03-16 13:49:40 +01:00
|
|
|
#include "../dialogpiecepath.h"
|
|
|
|
#include "../../../undocommands/savepiecepathoptions.h"
|
|
|
|
#include "../../support/dialogeditwrongformula.h"
|
2016-11-04 15:16:11 +01:00
|
|
|
|
2016-11-04 16:04:18 +01:00
|
|
|
#include <QMenu>
|
2017-01-21 14:24:40 +01:00
|
|
|
#include <QTimer>
|
2017-01-12 18:09:00 +01:00
|
|
|
#include <QtNumeric>
|
2016-11-04 15:16:11 +01:00
|
|
|
|
2017-03-18 13:06:40 +01:00
|
|
|
enum TabOrder {Paths=0, Labels=1, Grainline=2, Pins=3, Count=4};
|
2017-03-17 15:38:18 +01:00
|
|
|
|
2017-02-12 14:42:21 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void EnableDefButton(QPushButton *defButton, const QString &formula)
|
|
|
|
{
|
|
|
|
SCASSERT(defButton != nullptr)
|
|
|
|
|
|
|
|
if (formula != currentSeamAllowance)
|
|
|
|
{
|
|
|
|
defButton->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2017-02-13 07:30:34 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString GetFormulaFromUser(QPlainTextEdit *textEdit)
|
|
|
|
{
|
|
|
|
SCASSERT(textEdit != nullptr)
|
|
|
|
|
|
|
|
QString formula = textEdit->toPlainText();
|
|
|
|
formula.replace("\n", " ");
|
|
|
|
return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
|
|
|
|
}
|
2017-02-12 14:42:21 +01:00
|
|
|
}
|
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogSeamAllowance),
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths(new Ui::TabPaths),
|
|
|
|
uiTabLabels(new Ui::TabLabels),
|
|
|
|
uiTabGrainline(new Ui::TabGrainline),
|
|
|
|
uiTabPins(new Ui::TabPins),
|
|
|
|
m_tabPaths(new QWidget),
|
|
|
|
m_tabLabels(new QWidget),
|
|
|
|
m_tabGrainline(new QWidget),
|
|
|
|
m_tabPins(new QWidget),
|
|
|
|
m_ftb(new FancyTabBar(FancyTabBar::Left, this)),
|
|
|
|
dialogIsInitialized(false),
|
2016-11-12 14:41:15 +01:00
|
|
|
applyAllowed(false),// By default disabled
|
2017-02-23 15:33:15 +01:00
|
|
|
flagGPin(true),
|
|
|
|
flagDPin(true),
|
|
|
|
flagPPin(true),
|
2017-03-11 15:39:04 +01:00
|
|
|
flagGFormulas(true),
|
|
|
|
flagDLAngle(true),
|
|
|
|
flagDLFormulas(true),
|
|
|
|
flagPLAngle(true),
|
|
|
|
flagPLFormulas(true),
|
2017-01-12 18:09:00 +01:00
|
|
|
m_bAddMode(true),
|
2016-11-12 14:41:15 +01:00
|
|
|
m_mx(0),
|
2016-11-28 09:47:36 +01:00
|
|
|
m_my(0),
|
2017-01-12 18:09:00 +01:00
|
|
|
m_dialog(),
|
2017-02-14 16:33:30 +01:00
|
|
|
m_visPins(),
|
2017-01-12 18:09:00 +01:00
|
|
|
m_qslMaterials(),
|
|
|
|
m_qslPlacements(),
|
|
|
|
m_conMCP(),
|
|
|
|
m_oldData(),
|
|
|
|
m_oldGeom(),
|
|
|
|
m_oldGrainline(),
|
|
|
|
m_iRotBaseHeight(0),
|
2017-01-21 14:24:40 +01:00
|
|
|
m_iLenBaseHeight(0),
|
2017-03-11 14:25:21 +01:00
|
|
|
m_DLWidthBaseHeight(0),
|
|
|
|
m_DLHeightBaseHeight(0),
|
|
|
|
m_DLAngleBaseHeight(0),
|
|
|
|
m_PLWidthBaseHeight(0),
|
|
|
|
m_PLHeightBaseHeight(0),
|
|
|
|
m_PLAngleBaseHeight(0),
|
2017-01-21 14:24:40 +01:00
|
|
|
m_formulaBaseWidth(0),
|
|
|
|
m_formulaBaseWidthBefore(0),
|
|
|
|
m_formulaBaseWidthAfter(0),
|
|
|
|
m_timerWidth(nullptr),
|
|
|
|
m_timerWidthBefore(nullptr),
|
|
|
|
m_timerWidthAfter(nullptr),
|
|
|
|
m_saWidth(0)
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
InitOkCancelApply(ui);
|
2017-03-17 15:38:18 +01:00
|
|
|
InitFancyTabBar();
|
2016-11-04 18:36:36 +01:00
|
|
|
EnableApply(applyAllowed);
|
2016-11-04 15:16:11 +01:00
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
InitMainPathTab();
|
|
|
|
InitSeamAllowanceTab();
|
|
|
|
InitInternalPathsTab();
|
|
|
|
InitPatternPieceDataTab();
|
2017-03-11 14:25:21 +01:00
|
|
|
InitLabelsTab();
|
2017-01-12 18:09:00 +01:00
|
|
|
InitGrainlineTab();
|
2017-02-14 14:11:54 +01:00
|
|
|
InitPinsTab();
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
flagName = true;//We have default name of piece.
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabLabels->labelEditName, okColor);
|
2016-11-04 15:16:11 +01:00
|
|
|
flagError = MainPathIsValid();
|
|
|
|
CheckState();
|
2016-11-04 16:04:18 +01:00
|
|
|
|
2016-11-08 18:11:47 +01:00
|
|
|
if (not applyAllowed)
|
|
|
|
{
|
|
|
|
vis = new VisToolPiece(data);
|
|
|
|
}
|
2016-11-19 12:44:12 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start.
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogSeamAllowance::~DialogSeamAllowance()
|
|
|
|
{
|
2017-02-24 11:14:28 +01:00
|
|
|
delete m_visPins;
|
2017-03-17 15:38:18 +01:00
|
|
|
delete m_tabPins;
|
|
|
|
delete m_tabGrainline;
|
|
|
|
delete m_tabLabels;
|
|
|
|
delete m_tabPaths;
|
|
|
|
delete uiTabPins;
|
|
|
|
delete uiTabGrainline;
|
|
|
|
delete uiTabLabels;
|
|
|
|
delete uiTabPaths;
|
2016-11-04 15:16:11 +01:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2016-11-04 18:36:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EnableApply(bool enable)
|
|
|
|
{
|
|
|
|
SCASSERT(bApply != nullptr);
|
|
|
|
bApply->setEnabled(enable);
|
|
|
|
applyAllowed = enable;
|
2017-03-17 15:38:18 +01:00
|
|
|
|
|
|
|
uiTabPaths->tabSeamAllowance->setEnabled(applyAllowed);
|
|
|
|
uiTabPaths->tabInternalPaths->setEnabled(applyAllowed);
|
|
|
|
m_ftb->SetTabEnabled(TabOrder::Labels, applyAllowed);
|
|
|
|
m_ftb->SetTabEnabled(TabOrder::Grainline, applyAllowed);
|
|
|
|
m_ftb->SetTabEnabled(TabOrder::Pins, applyAllowed);
|
2016-11-04 18:36:36 +01:00
|
|
|
}
|
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece DialogSeamAllowance::GetPiece() const
|
|
|
|
{
|
2016-11-12 14:41:15 +01:00
|
|
|
return CreatePiece();
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetMainPath->clear();
|
2016-11-23 11:54:46 +01:00
|
|
|
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
2016-11-28 09:47:36 +01:00
|
|
|
NewMainPathItem(piece.GetPath().at(i));
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetCustomSA->blockSignals(true);
|
|
|
|
uiTabPaths->listWidgetCustomSA->clear();
|
2017-01-31 15:26:28 +01:00
|
|
|
for (int i = 0; i < piece.GetCustomSARecords().size(); ++i)
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2017-01-31 15:26:28 +01:00
|
|
|
NewCustomSA(piece.GetCustomSARecords().at(i));
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetCustomSA->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetInternalPaths->clear();
|
2017-01-31 15:26:28 +01:00
|
|
|
for (int i = 0; i < piece.GetInternalPaths().size(); ++i)
|
2016-12-03 17:01:39 +01:00
|
|
|
{
|
2017-01-31 15:26:28 +01:00
|
|
|
NewInternalPath(piece.GetInternalPaths().at(i));
|
2016-12-03 17:01:39 +01:00
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPins->listWidgetPins->clear();
|
2017-02-14 14:11:54 +01:00
|
|
|
for (int i = 0; i < piece.GetPins().size(); ++i)
|
|
|
|
{
|
|
|
|
NewPin(piece.GetPins().at(i));
|
|
|
|
}
|
|
|
|
|
2017-02-15 14:32:48 +01:00
|
|
|
InitAllPinComboboxes();
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxStartPoint->clear();
|
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxEndPoint->clear();
|
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
|
|
|
CustomSAChanged(0);
|
2016-11-04 15:16:11 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
|
|
|
|
uiTabPaths->checkBoxSeams->setChecked(piece.IsSeamAllowance());
|
|
|
|
uiTabLabels->lineEditName->setText(piece.GetName());
|
2016-11-12 14:41:15 +01:00
|
|
|
|
2017-02-10 14:02:03 +01:00
|
|
|
const QString width = qApp->TrVars()->FormulaToUser(piece.GetFormulaSAWidth(), qApp->Settings()->GetOsSeparator());
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidth->setPlainText(width);
|
2017-01-21 14:24:40 +01:00
|
|
|
m_saWidth = piece.GetSAWidth();
|
|
|
|
|
2016-11-12 14:41:15 +01:00
|
|
|
m_mx = piece.GetMx();
|
|
|
|
m_my = piece.GetMy();
|
2016-11-10 10:56:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
m_conMCP.clear();
|
|
|
|
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
|
|
|
|
{
|
|
|
|
m_conMCP << piece.GetPatternPieceData().GetMCP(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateList();
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabGrainline->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
m_oldData = piece.GetPatternPieceData();
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->groupBoxDetailLabel->setChecked(m_oldData.IsVisible());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxDLCenterPin, m_oldData.CenterPin());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxDLTopLeftPin, m_oldData.TopLeftPin());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxDLBottomRightPin, m_oldData.BottomRightPin());
|
2017-03-13 13:27:29 +01:00
|
|
|
SetDLWidth(m_oldData.GetLabelWidth());
|
|
|
|
SetDLHeight(m_oldData.GetLabelHeight());
|
2017-03-13 14:00:44 +01:00
|
|
|
SetDLAngle(m_oldData.GetRotation());
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
m_oldGeom = piece.GetPatternInfo();
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->groupBoxPatternLabel->setChecked(m_oldGeom.IsVisible());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxPLCenterPin, m_oldGeom.CenterPin());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxPLTopLeftPin, m_oldGeom.TopLeftPin());
|
|
|
|
ChangeCurrentData(uiTabLabels->comboBoxPLBottomRightPin, m_oldGeom.BottomRightPin());
|
2017-03-13 13:27:29 +01:00
|
|
|
SetPLWidth(m_oldGeom.GetLabelWidth());
|
|
|
|
SetPLHeight(m_oldGeom.GetLabelHeight());
|
2017-03-13 14:00:44 +01:00
|
|
|
SetPLAngle(m_oldGeom.GetRotation());
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
m_oldGrainline = piece.GetGrainlineGeometry();
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabGrainline->groupBoxGrainline->setChecked(m_oldGrainline.IsVisible());
|
|
|
|
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineCenterPin, m_oldGrainline.CenterPin());
|
|
|
|
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineTopPin, m_oldGrainline.TopPin());
|
|
|
|
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineBottomPin, m_oldGrainline.BottomPin());
|
2017-03-13 13:27:29 +01:00
|
|
|
SetGrainlineAngle(m_oldGrainline.GetRotation());
|
|
|
|
SetGrainlineLength(m_oldGrainline.GetLength());
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
ValidObjects(MainPathIsValid());
|
2017-03-11 14:25:21 +01:00
|
|
|
EnabledGrainline();
|
|
|
|
EnabledDetailLabel();
|
|
|
|
EnabledPatternLabel();
|
2016-11-12 11:41:04 +01:00
|
|
|
|
|
|
|
ListChanged();
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
|
|
|
* @param id id of objects (points, arcs, splines, spline paths)
|
|
|
|
* @param type type of object
|
|
|
|
*/
|
|
|
|
void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
|
|
|
|
{
|
2016-11-05 14:27:19 +01:00
|
|
|
if (not prepare)
|
2016-11-04 15:25:57 +01:00
|
|
|
{
|
2016-11-05 14:27:19 +01:00
|
|
|
bool reverse = false;
|
|
|
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
|
|
|
{
|
|
|
|
reverse = true;
|
|
|
|
}
|
2016-12-03 18:18:58 +01:00
|
|
|
if (id != GetLastId())
|
2016-11-05 14:27:19 +01:00
|
|
|
{
|
2016-12-03 18:18:58 +01:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SceneObject::Arc:
|
|
|
|
NewMainPathItem(VPieceNode(id, Tool::NodeArc, reverse));
|
|
|
|
break;
|
2017-02-10 15:47:15 +01:00
|
|
|
case SceneObject::ElArc:
|
|
|
|
NewMainPathItem(VPieceNode(id, Tool::NodeElArc, reverse));
|
2016-12-03 18:18:58 +01:00
|
|
|
break;
|
|
|
|
case SceneObject::Point:
|
|
|
|
NewMainPathItem(VPieceNode(id, Tool::NodePoint));
|
|
|
|
break;
|
|
|
|
case SceneObject::Spline:
|
|
|
|
NewMainPathItem(VPieceNode(id, Tool::NodeSpline, reverse));
|
|
|
|
break;
|
|
|
|
case SceneObject::SplinePath:
|
|
|
|
NewMainPathItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
|
|
|
|
break;
|
|
|
|
case (SceneObject::Line):
|
|
|
|
case (SceneObject::Detail):
|
|
|
|
case (SceneObject::Unknown):
|
|
|
|
default:
|
|
|
|
qDebug() << "Got wrong scene object. Ignore.";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (uiTabPaths->listWidgetMainPath->count() > 1)
|
2016-12-03 18:18:58 +01:00
|
|
|
{
|
|
|
|
delete GetItemById(id);
|
|
|
|
}
|
2016-11-05 14:27:19 +01:00
|
|
|
}
|
2016-11-04 15:16:11 +01:00
|
|
|
|
2016-11-05 14:27:19 +01:00
|
|
|
ValidObjects(MainPathIsValid());
|
2016-11-05 11:49:20 +01:00
|
|
|
|
2016-11-08 18:11:47 +01:00
|
|
|
if (not applyAllowed)
|
2016-11-05 14:27:19 +01:00
|
|
|
{
|
2016-11-08 18:11:47 +01:00
|
|
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
|
|
|
SCASSERT(visPath != nullptr);
|
|
|
|
const VPiece p = CreatePiece();
|
|
|
|
visPath->SetPiece(p);
|
|
|
|
|
2016-11-23 11:54:46 +01:00
|
|
|
if (p.GetPath().CountNodes() == 1)
|
2016-11-08 18:11:47 +01:00
|
|
|
{
|
|
|
|
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
|
|
|
|
"<b>Enter</b> - finish creation"));
|
|
|
|
|
2016-12-03 18:18:58 +01:00
|
|
|
if (not qApp->getCurrentScene()->items().contains(visPath))
|
|
|
|
{
|
|
|
|
visPath->VisualMode(NULL_ID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visPath->RefreshGeometry();
|
|
|
|
}
|
2016-11-08 18:11:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visPath->RefreshGeometry();
|
|
|
|
}
|
2016-11-05 14:27:19 +01:00
|
|
|
}
|
2016-11-05 11:49:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ShowDialog(bool click)
|
|
|
|
{
|
|
|
|
if (click == false)
|
|
|
|
{
|
|
|
|
emit ToolTip("");
|
2016-11-05 14:27:19 +01:00
|
|
|
prepare = true;
|
|
|
|
|
2016-11-08 18:11:47 +01:00
|
|
|
if (not applyAllowed)
|
|
|
|
{
|
|
|
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
|
|
|
SCASSERT(visPath != nullptr);
|
|
|
|
visPath->SetMode(Mode::Show);
|
|
|
|
visPath->RefreshGeometry();
|
|
|
|
}
|
2016-11-05 14:27:19 +01:00
|
|
|
|
|
|
|
// Fix issue #526. Dialog Detail is not on top after selection second object on Mac.
|
|
|
|
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
2016-11-05 11:49:20 +01:00
|
|
|
show();
|
|
|
|
}
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SaveData()
|
2016-11-12 14:41:15 +01:00
|
|
|
{}
|
2016-11-04 15:16:11 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::CheckState()
|
|
|
|
{
|
|
|
|
SCASSERT(bOk != nullptr);
|
2017-03-11 15:39:04 +01:00
|
|
|
bOk->setEnabled(flagName && flagError && flagFormula && (flagGFormulas || flagGPin)
|
|
|
|
&& flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle && (flagPLFormulas || flagPPin));
|
2016-11-04 15:16:11 +01:00
|
|
|
// In case dialog hasn't apply button
|
2016-11-04 18:36:36 +01:00
|
|
|
if ( bApply != nullptr && applyAllowed)
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
|
|
|
bApply->setEnabled(bOk->isEnabled());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 13:27:13 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidth->blockSignals(true);
|
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->blockSignals(true);
|
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->blockSignals(true);
|
|
|
|
uiTabGrainline->lineEditRotFormula->blockSignals(true);
|
|
|
|
uiTabGrainline->lineEditLenFormula->blockSignals(true);
|
2017-01-31 13:27:13 +01:00
|
|
|
DialogTool::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
DialogTool::showEvent( event );
|
|
|
|
if ( event->spontaneous() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dialogIsInitialized)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// do your init stuff here
|
|
|
|
|
|
|
|
m_ftb->setMaximumSize(m_ftb->size());
|
|
|
|
m_ftb->setMinimumSize(m_ftb->size());
|
|
|
|
|
|
|
|
dialogIsInitialized = true;//first show windows are held
|
|
|
|
}
|
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::UpdateList()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->listWidgetMCP->clear();
|
2017-01-12 18:09:00 +01:00
|
|
|
for (int i = 0; i < m_conMCP.count(); ++i)
|
|
|
|
{
|
|
|
|
MaterialCutPlacement mcp = m_conMCP.at(i);
|
|
|
|
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
|
|
|
|
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
|
|
|
|
{
|
|
|
|
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
|
|
|
|
}
|
|
|
|
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
|
|
|
|
{
|
|
|
|
qsText = qsText.arg(QLatin1String(" ") + tr("on Fold"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qsText = qsText.arg("");
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->listWidgetMCP->addItem(qsText);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::AddUpdate()
|
|
|
|
{
|
|
|
|
MaterialCutPlacement mcp;
|
|
|
|
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int i = CURRENT_DATA(uiTabLabels->comboBoxMaterial).toInt();
|
|
|
|
QString qsMat = uiTabLabels->comboBoxMaterial->currentText();
|
2017-01-12 18:09:00 +01:00
|
|
|
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
|
|
|
|
{
|
|
|
|
mcp.m_eMaterial = MaterialType(i);
|
|
|
|
mcp.m_qsMaterialUserDef.clear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mcp.m_eMaterial = MaterialType::mtUserDefined;
|
|
|
|
mcp.m_qsMaterialUserDef = qsMat;
|
|
|
|
// check if we have new user defined material
|
|
|
|
bool bFound = false;
|
|
|
|
for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i)
|
|
|
|
{
|
|
|
|
if (mcp.m_qsMaterialUserDef == qslUserMaterials[i])
|
|
|
|
{
|
|
|
|
bFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bFound == false)
|
|
|
|
{
|
|
|
|
qApp->Settings()->AddUserDefinedMaterial(mcp.m_qsMaterialUserDef);
|
|
|
|
qApp->Settings()->sync();
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
mcp.m_iCutNumber = uiTabLabels->spinBoxCutNumber->value();
|
|
|
|
mcp.m_ePlacement = PlacementType(uiTabLabels->comboBoxPlacement->currentIndex());
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
if (m_bAddMode == true)
|
|
|
|
{
|
|
|
|
m_conMCP << mcp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
int iR = uiTabLabels->listWidgetMCP->currentRow();
|
2017-01-12 18:09:00 +01:00
|
|
|
SCASSERT(iR >= 0)
|
|
|
|
m_conMCP[iR] = mcp;
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::Cancel()
|
|
|
|
{
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::Remove()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
int iR = uiTabLabels->listWidgetMCP->currentRow();
|
2017-01-12 18:09:00 +01:00
|
|
|
SCASSERT(iR >= 0)
|
|
|
|
m_conMCP.removeAt(iR);
|
|
|
|
UpdateList();
|
|
|
|
ClearFields();
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::NameDetailChanged()
|
|
|
|
{
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
if (edit->text().isEmpty())
|
|
|
|
{
|
|
|
|
flagName = false;
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabLabels->labelEditName, Qt::red);
|
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*"));
|
2017-01-12 18:09:00 +01:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabPieceLabelData), icon);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagName = true;
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabLabels->labelEditName, okColor);
|
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels"));
|
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabPieceLabelData),
|
|
|
|
QIcon());
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::MaterialChanged()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->pushButtonAdd->setEnabled(uiTabLabels->comboBoxMaterial->currentText().isEmpty() == false);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
2016-11-04 16:04:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-28 09:47:36 +01:00
|
|
|
void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
|
2016-11-04 16:04:18 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetMainPath->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetMainPath->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetMainPath->count())
|
2016-11-04 16:04:18 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-22 07:02:28 +01:00
|
|
|
QScopedPointer<QMenu> menu(new QMenu());
|
2016-11-04 16:04:18 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetMainPath->item(row);
|
2016-11-04 16:04:18 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
|
|
|
|
|
|
|
QAction *actionReverse = nullptr;
|
|
|
|
if (rowNode.GetTypeTool() != Tool::NodePoint)
|
|
|
|
{
|
|
|
|
actionReverse = menu->addAction(tr("Reverse"));
|
|
|
|
actionReverse->setCheckable(true);
|
|
|
|
actionReverse->setChecked(rowNode.GetReverse());
|
|
|
|
}
|
|
|
|
|
2017-03-22 11:05:53 +01:00
|
|
|
QAction *actionExcluded = menu->addAction(tr("Excluded"));
|
|
|
|
actionExcluded->setCheckable(true);
|
|
|
|
actionExcluded->setChecked(rowNode.IsExcluded());
|
|
|
|
|
2016-12-03 17:57:43 +01:00
|
|
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QAction *selectedAction = menu->exec(uiTabPaths->listWidgetMainPath->viewport()->mapToGlobal(pos));
|
2016-11-04 16:04:18 +01:00
|
|
|
if (selectedAction == actionDelete)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
delete uiTabPaths->listWidgetMainPath->item(row);
|
2016-11-04 16:04:18 +01:00
|
|
|
ValidObjects(MainPathIsValid());
|
|
|
|
}
|
2016-12-03 18:51:25 +01:00
|
|
|
else if (rowNode.GetTypeTool() != Tool::NodePoint && selectedAction == actionReverse)
|
2016-11-04 16:04:18 +01:00
|
|
|
{
|
|
|
|
rowNode.SetReverse(not rowNode.GetReverse());
|
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
|
|
|
rowItem->setText(GetNodeName(rowNode));
|
|
|
|
ValidObjects(MainPathIsValid());
|
|
|
|
}
|
2017-03-22 11:05:53 +01:00
|
|
|
else if (selectedAction == actionExcluded)
|
|
|
|
{
|
|
|
|
rowNode.SetExcluded(not rowNode.IsExcluded());
|
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
|
|
|
rowItem->setText(GetNodeName(rowNode));
|
|
|
|
rowItem->setFont(NodeFont(rowNode.IsExcluded()));
|
|
|
|
ValidObjects(MainPathIsValid());
|
|
|
|
}
|
2016-11-05 14:27:19 +01:00
|
|
|
|
|
|
|
ListChanged();
|
|
|
|
}
|
|
|
|
|
2016-11-28 09:47:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetCustomSA->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetCustomSA->count())
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-22 07:02:28 +01:00
|
|
|
QScopedPointer<QMenu> menu(new QMenu());
|
2016-12-03 17:57:43 +01:00
|
|
|
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-28 09:47:36 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
|
|
|
|
|
|
|
QAction *actionReverse = menu->addAction(tr("Reverse"));
|
|
|
|
actionReverse->setCheckable(true);
|
|
|
|
actionReverse->setChecked(record.reverse);
|
|
|
|
|
2016-12-03 17:57:43 +01:00
|
|
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QAction *selectedAction = menu->exec(uiTabPaths->listWidgetCustomSA->viewport()->mapToGlobal(pos));
|
2016-11-28 09:47:36 +01:00
|
|
|
if (selectedAction == actionDelete)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
delete uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
else if (selectedAction == actionReverse)
|
|
|
|
{
|
|
|
|
record.reverse = not record.reverse;
|
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
2016-12-03 17:01:39 +01:00
|
|
|
rowItem->setText(GetPathName(record.path, record.reverse));
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
else if (selectedAction == actionOption)
|
|
|
|
{
|
|
|
|
auto *dialog = new DialogPiecePath(data, record.path, this);
|
|
|
|
dialog->SetPiecePath(data->GetPiecePath(record.path));
|
|
|
|
dialog->SetPieceId(toolId);
|
2016-11-28 13:52:31 +01:00
|
|
|
if (record.includeType == PiecePathIncludeType::AsMainPath)
|
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
dialog->SetFormulaSAWidth(GetFormulaSAWidth());
|
2016-11-28 13:52:31 +01:00
|
|
|
}
|
2016-11-28 09:47:36 +01:00
|
|
|
dialog->EnbleShowMode(true);
|
|
|
|
m_dialog = dialog;
|
|
|
|
m_dialog->setModal(true);
|
|
|
|
connect(m_dialog.data(), &DialogTool::DialogClosed, this, &DialogSeamAllowance::PathDialogClosed);
|
|
|
|
m_dialog->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetInternalPaths->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetInternalPaths->count() == 0 || row == -1
|
|
|
|
|| row >= uiTabPaths->listWidgetInternalPaths->count())
|
2016-12-03 17:01:39 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-22 07:02:28 +01:00
|
|
|
QScopedPointer<QMenu> menu(new QMenu());
|
2016-12-03 17:01:39 +01:00
|
|
|
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
2016-12-03 17:57:43 +01:00
|
|
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
2016-12-03 17:01:39 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QAction *selectedAction = menu->exec(uiTabPaths->listWidgetInternalPaths->viewport()->mapToGlobal(pos));
|
2016-12-03 17:01:39 +01:00
|
|
|
if (selectedAction == actionDelete)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
delete uiTabPaths->listWidgetInternalPaths->item(row);
|
2016-12-03 17:01:39 +01:00
|
|
|
}
|
|
|
|
else if (selectedAction == actionOption)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetInternalPaths->item(row);
|
2016-12-03 17:57:43 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
const quint32 pathId = qvariant_cast<quint32>(rowItem->data(Qt::UserRole));
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
auto *dialog = new DialogPiecePath(data, pathId, this);
|
|
|
|
dialog->SetPiecePath(data->GetPiecePath(pathId));
|
|
|
|
dialog->SetPieceId(toolId);
|
|
|
|
dialog->EnbleShowMode(true);
|
|
|
|
m_dialog = dialog;
|
|
|
|
m_dialog->setModal(true);
|
|
|
|
connect(m_dialog.data(), &DialogTool::DialogClosed, this, &DialogSeamAllowance::PathDialogClosed);
|
|
|
|
m_dialog->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:11:54 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPins->listWidgetPins->currentRow();
|
|
|
|
if (uiTabPins->listWidgetPins->count() == 0 || row == -1 || row >= uiTabPins->listWidgetPins->count())
|
2017-02-14 14:11:54 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-02 12:14:19 +01:00
|
|
|
QScopedPointer<QMenu> menu(new QMenu());
|
2017-02-14 14:11:54 +01:00
|
|
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QAction *selectedAction = menu->exec(uiTabPins->listWidgetPins->viewport()->mapToGlobal(pos));
|
2017-02-14 14:11:54 +01:00
|
|
|
if (selectedAction == actionDelete)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
delete uiTabPins->listWidgetPins->item(row);
|
|
|
|
FancyTabChanged(m_ftb->CurrentIndex());
|
2017-02-15 14:32:48 +01:00
|
|
|
InitAllPinComboboxes();
|
2017-02-14 14:11:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-05 14:27:19 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ListChanged()
|
|
|
|
{
|
2016-11-08 18:11:47 +01:00
|
|
|
if (not applyAllowed)
|
|
|
|
{
|
|
|
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
|
|
|
SCASSERT(visPath != nullptr);
|
|
|
|
visPath->SetPiece(CreatePiece());
|
|
|
|
visPath->RefreshGeometry();
|
|
|
|
}
|
2016-11-12 11:41:04 +01:00
|
|
|
InitNodesList();
|
2017-03-17 15:38:18 +01:00
|
|
|
CustomSAChanged(uiTabPaths->listWidgetCustomSA->currentRow());
|
2016-11-04 16:04:18 +01:00
|
|
|
}
|
|
|
|
|
2016-11-10 11:53:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EnableSeamAllowance(bool enable)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->groupBoxAutomatic->setEnabled(enable);
|
|
|
|
uiTabPaths->groupBoxCustom->setEnabled(enable);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
|
|
|
if (enable)
|
|
|
|
{
|
|
|
|
InitNodesList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::NodeChanged(int index)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->setDisabled(true);
|
|
|
|
uiTabPaths->toolButtonExprBefore->setDisabled(true);
|
|
|
|
uiTabPaths->pushButtonDefBefore->setDisabled(true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->setDisabled(true);
|
|
|
|
uiTabPaths->toolButtonExprAfter->setDisabled(true);
|
|
|
|
uiTabPaths->pushButtonDefAfter->setDisabled(true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxAngle->setDisabled(true);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxAngle->blockSignals(true);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
const VPiece piece = CreatePiece();
|
2017-03-17 15:38:18 +01:00
|
|
|
const int nodeIndex = piece.GetPath().indexOfNode(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
2016-11-12 11:41:04 +01:00
|
|
|
if (nodeIndex != -1)
|
|
|
|
{
|
2016-11-23 11:54:46 +01:00
|
|
|
const VPieceNode &node = piece.GetPath().at(nodeIndex);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
// Seam alowance before
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->setEnabled(true);
|
|
|
|
uiTabPaths->toolButtonExprBefore->setEnabled(true);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
QString w1Formula = node.GetFormulaSABefore();
|
2017-03-17 15:38:18 +01:00
|
|
|
EnableDefButton(uiTabPaths->pushButtonDefBefore, w1Formula);
|
2017-02-10 14:02:03 +01:00
|
|
|
w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator());
|
2017-01-21 14:24:40 +01:00
|
|
|
if (w1Formula.length() > 80)// increase height if needed.
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
this->DeployWidthBeforeFormulaTextEdit();
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->setPlainText(w1Formula);
|
|
|
|
MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidthBefore);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
// Seam alowance after
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->setEnabled(true);
|
|
|
|
uiTabPaths->toolButtonExprAfter->setEnabled(true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
|
|
|
QString w2Formula = node.GetFormulaSAAfter();
|
2017-03-17 15:38:18 +01:00
|
|
|
EnableDefButton(uiTabPaths->pushButtonDefAfter, w2Formula);
|
2017-02-10 14:02:03 +01:00
|
|
|
w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator());
|
2017-01-21 14:24:40 +01:00
|
|
|
if (w2Formula.length() > 80)// increase height if needed.
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
this->DeployWidthAfterFormulaTextEdit();
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->setPlainText(w2Formula);
|
|
|
|
MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidthAfter);
|
2016-11-19 12:44:12 +01:00
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
// Angle type
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxAngle->setEnabled(true);
|
|
|
|
const int index = uiTabPaths->comboBoxAngle->findData(static_cast<unsigned char>(node.GetAngleType()));
|
2016-11-19 12:44:12 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxAngle->setCurrentIndex(index);
|
2016-11-19 12:44:12 +01:00
|
|
|
}
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->setPlainText("");
|
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->setPlainText("");
|
|
|
|
uiTabPaths->comboBoxAngle->setCurrentIndex(-1);
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxAngle->blockSignals(false);
|
2016-11-19 12:44:12 +01:00
|
|
|
}
|
|
|
|
|
2016-11-28 09:47:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::CSAStartPointChanged(int index)
|
|
|
|
{
|
2017-02-15 14:32:48 +01:00
|
|
|
Q_UNUSED(index);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetCustomSA->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetCustomSA->count())
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-28 09:47:36 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
2017-03-17 15:38:18 +01:00
|
|
|
record.startPoint = CURRENT_DATA(uiTabPaths->comboBoxStartPoint).toUInt();
|
2016-11-28 09:47:36 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::CSAEndPointChanged(int index)
|
|
|
|
{
|
2017-02-15 14:32:48 +01:00
|
|
|
Q_UNUSED(index);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetCustomSA->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetCustomSA->count())
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-28 09:47:36 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
2017-03-17 15:38:18 +01:00
|
|
|
record.endPoint = CURRENT_DATA(uiTabPaths->comboBoxEndPoint).toUInt();
|
2016-11-28 09:47:36 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
|
|
|
}
|
|
|
|
|
2016-11-28 13:52:31 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::CSAIncludeTypeChanged(int index)
|
|
|
|
{
|
2017-02-15 14:32:48 +01:00
|
|
|
Q_UNUSED(index);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetCustomSA->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetCustomSA->count())
|
2016-11-28 13:52:31 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-28 13:52:31 +01:00
|
|
|
SCASSERT(rowItem != nullptr);
|
|
|
|
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
2017-03-17 15:38:18 +01:00
|
|
|
record.includeType = static_cast<PiecePathIncludeType>(CURRENT_DATA(uiTabPaths->comboBoxIncludeType).toUInt());
|
2016-11-28 13:52:31 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
|
|
|
}
|
|
|
|
|
2016-11-19 12:44:12 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::NodeAngleChanged(int index)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int i = uiTabPaths->comboBoxNodes->currentIndex();
|
2016-11-19 12:44:12 +01:00
|
|
|
if (i != -1 && index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
2016-11-19 12:44:12 +01:00
|
|
|
if (rowItem)
|
|
|
|
{
|
|
|
|
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
2017-03-17 15:38:18 +01:00
|
|
|
rowNode.SetAngleType(static_cast<PieceNodeAngle>(CURRENT_DATA(uiTabPaths->comboBoxAngle).toUInt()));
|
2016-11-19 12:44:12 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
|
|
|
|
|
|
|
ListChanged();
|
|
|
|
}
|
|
|
|
}
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ReturnDefBefore()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->setPlainText(currentSeamAllowance);
|
2017-02-12 14:42:21 +01:00
|
|
|
if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
|
|
|
|
{
|
|
|
|
button->setEnabled(false);
|
|
|
|
}
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ReturnDefAfter()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->setPlainText(currentSeamAllowance);
|
2017-02-12 14:42:21 +01:00
|
|
|
if (QPushButton* button = qobject_cast<QPushButton*>(sender()))
|
|
|
|
{
|
|
|
|
button->setEnabled(false);
|
|
|
|
}
|
2016-11-10 11:53:02 +01:00
|
|
|
}
|
|
|
|
|
2016-11-28 09:47:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::CustomSAChanged(int row)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1 || row >= uiTabPaths->listWidgetCustomSA->count())
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxStartPoint->clear();
|
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(false);
|
2016-11-29 15:50:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxEndPoint->clear();
|
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(false);
|
2016-11-29 15:50:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxIncludeType->clear();
|
|
|
|
uiTabPaths->comboBoxIncludeType->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QListWidgetItem *item = uiTabPaths->listWidgetCustomSA->item( row );
|
2016-11-28 09:47:36 +01:00
|
|
|
SCASSERT(item != nullptr);
|
|
|
|
const CustomSARecord record = qvariant_cast<CustomSARecord>(item->data(Qt::UserRole));
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(true);
|
|
|
|
InitCSAPoint(uiTabPaths->comboBoxStartPoint);
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxStartPoint->findData(record.startPoint);
|
2016-11-28 09:47:36 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxStartPoint->setCurrentIndex(index);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxStartPoint->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(true);
|
|
|
|
InitCSAPoint(uiTabPaths->comboBoxEndPoint);
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxEndPoint->findData(record.endPoint);
|
2016-11-28 09:47:36 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxEndPoint->setCurrentIndex(index);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxEndPoint->blockSignals(false);
|
2016-11-28 13:52:31 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->blockSignals(true);
|
2016-11-28 13:52:31 +01:00
|
|
|
InitSAIncludeType();
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxIncludeType->findData(static_cast<unsigned char>(record.includeType));
|
2016-11-28 13:52:31 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->setCurrentIndex(index);
|
2016-11-28 13:52:31 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->blockSignals(false);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::PathDialogClosed(int result)
|
|
|
|
{
|
|
|
|
if (result == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SCASSERT(not m_dialog.isNull());
|
|
|
|
DialogPiecePath *dialogTool = qobject_cast<DialogPiecePath*>(m_dialog.data());
|
|
|
|
SCASSERT(dialogTool != nullptr);
|
2016-11-29 15:29:09 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
const VPiecePath newPath = dialogTool->GetPiecePath();
|
|
|
|
const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetToolId());
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2016-11-29 15:29:09 +01:00
|
|
|
SavePiecePathOptions *saveCommand = new SavePiecePathOptions(oldPath, newPath, qApp->getCurrentDocument(),
|
|
|
|
const_cast<VContainer *>(data),
|
|
|
|
dialogTool->GetToolId());
|
|
|
|
qApp->getUndoStack()->push(saveCommand);
|
2016-12-03 17:01:39 +01:00
|
|
|
UpdateCurrentCustomSARecord();
|
|
|
|
UpdateCurrentInternalPathRecord();
|
2016-11-29 15:29:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
}
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
delete m_dialog;
|
|
|
|
}
|
|
|
|
|
2017-02-14 16:33:30 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-17 15:38:18 +01:00
|
|
|
void DialogSeamAllowance::FancyTabChanged(int index)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (index < 0 || index >= TabOrder::Count)
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-02-14 16:33:30 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_tabPaths->hide();
|
|
|
|
m_tabLabels->hide();
|
|
|
|
m_tabGrainline->hide();
|
|
|
|
m_tabPins->hide();
|
2017-02-14 16:33:30 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case TabOrder::Paths:
|
|
|
|
m_tabPaths->show();
|
|
|
|
break;
|
|
|
|
case TabOrder::Labels:
|
|
|
|
m_tabLabels->show();
|
|
|
|
break;
|
|
|
|
case TabOrder::Grainline:
|
|
|
|
m_tabGrainline->show();
|
|
|
|
break;
|
|
|
|
case TabOrder::Pins:
|
|
|
|
m_tabPins->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QT_WARNING_POP
|
|
|
|
|
|
|
|
if (index == TabOrder::Pins || index == TabOrder::Grainline
|
|
|
|
|| (index == TabOrder::Labels &&
|
|
|
|
uiTabLabels->tabWidget->currentIndex() == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels)))
|
|
|
|
{
|
|
|
|
ShowPins();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (not m_visPins.isNull())
|
2017-02-14 16:33:30 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
delete m_visPins;
|
2017-02-14 16:33:30 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::TabChanged(int index)
|
|
|
|
{
|
|
|
|
if (index == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels))
|
|
|
|
{
|
|
|
|
ShowPins();
|
|
|
|
}
|
2017-02-14 16:33:30 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (not m_visPins.isNull())
|
|
|
|
{
|
|
|
|
delete m_visPins;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::UpdateGrainlineValues()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QPlainTextEdit* apleSender[2] = {uiTabGrainline->lineEditRotFormula, uiTabGrainline->lineEditLenFormula};
|
2017-03-11 15:39:04 +01:00
|
|
|
bool bFormulasOK[2] = {true, true};
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
QLabel* plbVal;
|
|
|
|
QLabel* plbText;
|
|
|
|
QString qsUnit;
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabGrainline->labelRot;
|
|
|
|
plbText = uiTabGrainline->labelEditRot;
|
2017-01-22 14:08:59 +01:00
|
|
|
qsUnit = degreeSymbol;
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabGrainline->labelLen;
|
|
|
|
plbText = uiTabGrainline->labelEditLen;
|
2017-01-12 18:09:00 +01:00
|
|
|
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
|
|
|
|
}
|
|
|
|
|
|
|
|
plbVal->setToolTip(tr("Value"));
|
|
|
|
|
|
|
|
QString qsFormula = apleSender[i]->toPlainText().simplified();
|
|
|
|
QString qsVal;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qsFormula.replace("\n", " ");
|
|
|
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
2017-02-13 07:30:34 +01:00
|
|
|
Calculator cal;
|
|
|
|
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
|
2017-01-12 18:09:00 +01:00
|
|
|
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Infinite/undefined result"));
|
|
|
|
}
|
|
|
|
else if (i == 1 && dVal <= 0.0)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Length should be positive"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qsVal.setNum(dVal, 'f', 2);
|
|
|
|
ChangeColor(plbText, okColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
2017-03-11 14:56:39 +01:00
|
|
|
qsVal = tr("Error");
|
2017-03-11 15:39:04 +01:00
|
|
|
not flagGPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
|
|
|
bFormulasOK[i] = false;
|
2017-01-12 18:09:00 +01:00
|
|
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
if (bFormulasOK[i] && qsVal.isEmpty() == false)
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
|
|
|
qsVal += qsUnit;
|
|
|
|
}
|
|
|
|
plbVal->setText(qsVal);
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
flagGFormulas = bFormulasOK[0] && bFormulasOK[1];
|
2017-02-24 18:42:06 +01:00
|
|
|
if (not flagGFormulas && not flagGPin)
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Grainline, tr("Grainline") + QLatin1String("*"));
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-11 14:25:21 +01:00
|
|
|
ResetGrainlineWarning();
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::UpdateDetailLabelValues()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QPlainTextEdit* apleSender[3] = {uiTabLabels->lineEditDLWidthFormula, uiTabLabels->lineEditDLHeightFormula,
|
|
|
|
uiTabLabels->lineEditDLAngleFormula};
|
2017-03-11 15:39:04 +01:00
|
|
|
bool bFormulasOK[3] = {true, true, true};
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
QLabel* plbVal;
|
|
|
|
QLabel* plbText;
|
|
|
|
QString qsUnit;
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelDLWidth;
|
|
|
|
plbText = uiTabLabels->labelEditDLWidth;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
|
|
|
|
}
|
|
|
|
else if (i == 1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelDLHeight;
|
|
|
|
plbText = uiTabLabels->labelEditDLHeight;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelDLAngle;
|
|
|
|
plbText = uiTabLabels->labelEditDLAngle;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = degreeSymbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
plbVal->setToolTip(tr("Value"));
|
|
|
|
|
|
|
|
QString qsFormula = apleSender[i]->toPlainText().simplified();
|
|
|
|
QString qsVal;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qsFormula.replace("\n", " ");
|
|
|
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
Calculator cal;
|
|
|
|
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
|
|
|
|
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Infinite/undefined result"));
|
|
|
|
}
|
|
|
|
else if ((i == 0 || i == 1) && dVal <= 0.0)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Length should be positive"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qsVal.setNum(dVal, 'f', 2);
|
|
|
|
ChangeColor(plbText, okColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
2017-03-11 14:56:39 +01:00
|
|
|
qsVal = tr("Error");
|
2017-03-11 15:39:04 +01:00
|
|
|
not flagDPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
|
|
|
bFormulasOK[i] = false;
|
2017-03-11 14:25:21 +01:00
|
|
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
if (bFormulasOK[i] && qsVal.isEmpty() == false)
|
2017-03-11 14:56:39 +01:00
|
|
|
{
|
2017-03-11 15:39:04 +01:00
|
|
|
qsVal += qsUnit;
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
plbVal->setText(qsVal);
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
flagDLAngle = bFormulasOK[2];
|
|
|
|
flagDLFormulas = bFormulasOK[0] && bFormulasOK[1];
|
2017-03-14 11:39:03 +01:00
|
|
|
if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin))
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*"));
|
2017-03-11 14:25:21 +01:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ResetLabelsWarning();
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::UpdatePatternLabelValues()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QPlainTextEdit* apleSender[3] = {uiTabLabels->lineEditPLWidthFormula, uiTabLabels->lineEditPLHeightFormula,
|
|
|
|
uiTabLabels->lineEditPLAngleFormula};
|
2017-03-11 15:39:04 +01:00
|
|
|
bool bFormulasOK[3] = {true, true, true};
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
QLabel* plbVal;
|
|
|
|
QLabel* plbText;
|
|
|
|
QString qsUnit;
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelPLWidth;
|
|
|
|
plbText = uiTabLabels->labelEditPLWidth;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
|
|
|
|
}
|
|
|
|
else if (i == 1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelPLHeight;
|
|
|
|
plbText = uiTabLabels->labelEditPLHeight;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plbVal = uiTabLabels->labelPLAngle;
|
|
|
|
plbText = uiTabLabels->labelEditPLAngle;
|
2017-03-11 14:25:21 +01:00
|
|
|
qsUnit = degreeSymbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
plbVal->setToolTip(tr("Value"));
|
|
|
|
|
|
|
|
QString qsFormula = apleSender[i]->toPlainText().simplified();
|
|
|
|
QString qsVal;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qsFormula.replace("\n", " ");
|
|
|
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
Calculator cal;
|
|
|
|
qreal dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
|
|
|
|
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Infinite/undefined result"));
|
|
|
|
}
|
|
|
|
else if ((i == 0 || i == 1) && dVal <= 0.0)
|
|
|
|
{
|
|
|
|
throw qmu::QmuParserError(tr("Length should be positive"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qsVal.setNum(dVal, 'f', 2);
|
|
|
|
ChangeColor(plbText, okColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
2017-03-11 14:56:39 +01:00
|
|
|
qsVal = tr("Error");
|
2017-03-11 15:39:04 +01:00
|
|
|
not flagPPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
|
|
|
bFormulasOK[i] = false;
|
2017-03-11 14:25:21 +01:00
|
|
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
if (bFormulasOK[i] && qsVal.isEmpty() == false)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-11 15:39:04 +01:00
|
|
|
qsVal += qsUnit;
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
plbVal->setText(qsVal);
|
|
|
|
}
|
|
|
|
|
2017-03-11 15:39:04 +01:00
|
|
|
flagPLAngle = bFormulasOK[2];
|
|
|
|
flagPLFormulas = bFormulasOK[0] && bFormulasOK[1];
|
2017-03-14 11:39:03 +01:00
|
|
|
if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin))
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*"));
|
2017-03-11 14:25:21 +01:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ResetLabelsWarning();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
2017-02-23 15:33:15 +01:00
|
|
|
CheckState();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SetAddMode()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->pushButtonAdd->setText(tr("Add"));
|
|
|
|
uiTabLabels->pushButtonCancel->hide();
|
|
|
|
uiTabLabels->pushButtonRemove->hide();
|
|
|
|
uiTabLabels->listWidgetMCP->setCurrentRow(-1);
|
2017-01-12 18:09:00 +01:00
|
|
|
m_bAddMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SetEditMode()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
int iR = uiTabLabels->listWidgetMCP->currentRow();
|
2017-01-12 18:09:00 +01:00
|
|
|
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
|
|
|
|
if (iR < 0 || iR >= m_conMCP.count())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->pushButtonAdd->setText(tr("Update"));
|
|
|
|
uiTabLabels->pushButtonCancel->show();
|
|
|
|
uiTabLabels->pushButtonRemove->show();
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
MaterialCutPlacement mcp = m_conMCP.at(iR);
|
|
|
|
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
|
|
|
|
{
|
|
|
|
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
|
|
|
|
if (iRow >= 0)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->spinBoxCutNumber->setValue(mcp.m_iCutNumber);
|
|
|
|
uiTabLabels->comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
m_bAddMode = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::EnabledGrainline()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (uiTabGrainline->groupBoxGrainline->isChecked() == true)
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-11 14:25:21 +01:00
|
|
|
UpdateGrainlineValues();
|
2017-02-24 16:23:02 +01:00
|
|
|
GrainlinePinPointChanged();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-23 15:33:15 +01:00
|
|
|
flagGFormulas = true;
|
2017-03-11 14:25:21 +01:00
|
|
|
ResetGrainlineWarning();
|
2017-03-11 15:39:04 +01:00
|
|
|
CheckState();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::EnabledDetailLabel()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (uiTabLabels->groupBoxDetailLabel->isChecked() == true)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
UpdateDetailLabelValues();
|
|
|
|
DetailPinPointChanged();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagDLAngle = true;
|
|
|
|
flagDLFormulas = true;
|
|
|
|
ResetLabelsWarning();
|
2017-03-11 15:39:04 +01:00
|
|
|
CheckState();
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EnabledPatternLabel()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
if (uiTabLabels->groupBoxPatternLabel->isChecked() == true)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
UpdatePatternLabelValues();
|
|
|
|
PatternPinPointChanged();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagPLAngle = true;
|
|
|
|
flagPLFormulas = true;
|
|
|
|
ResetLabelsWarning();
|
2017-03-11 15:39:04 +01:00
|
|
|
CheckState();
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EditGrainlineFormula()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
|
|
|
QPlainTextEdit* pleFormula;
|
|
|
|
bool bCheckZero;
|
2017-03-11 14:25:21 +01:00
|
|
|
QString title;
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabGrainline->pushButtonLen)
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabGrainline->lineEditLenFormula;
|
2017-01-12 18:09:00 +01:00
|
|
|
bCheckZero = true;
|
2017-03-11 14:25:21 +01:00
|
|
|
title = tr("Edit length");
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabGrainline->pushButtonRot)
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabGrainline->lineEditRotFormula;
|
2017-01-12 18:09:00 +01:00
|
|
|
bCheckZero = false;
|
2017-03-11 14:25:21 +01:00
|
|
|
title = tr("Edit angle");
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogEditWrongFormula dlg(data, NULL_ID, this);
|
2017-03-11 14:25:21 +01:00
|
|
|
dlg.setWindowTitle(title);
|
|
|
|
dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator()));
|
2017-01-12 18:09:00 +01:00
|
|
|
dlg.setCheckZero(bCheckZero);
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
QString qsFormula = dlg.GetFormula();
|
|
|
|
qsFormula.replace("\n", " ");
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabGrainline->pushButtonLen)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetGrainlineLength(qsFormula);
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabGrainline->pushButtonRot)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetGrainlineAngle(qsFormula);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
pleFormula->setPlainText(qsFormula);
|
|
|
|
}
|
|
|
|
UpdateGrainlineValues();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::EditDLFormula()
|
|
|
|
{
|
|
|
|
QPlainTextEdit* pleFormula;
|
|
|
|
bool bCheckZero;
|
|
|
|
QString title;
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabLabels->pushButtonDLHeight)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditDLHeightFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = true;
|
|
|
|
title = tr("Edit height");
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonDLWidth)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditDLWidthFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = true;
|
|
|
|
title = tr("Edit width");
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonDLAngle)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditDLAngleFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = false;
|
|
|
|
title = tr("Edit angle");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogEditWrongFormula dlg(data, NULL_ID, this);
|
|
|
|
dlg.setWindowTitle(title);
|
|
|
|
dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator()));
|
|
|
|
dlg.setCheckZero(bCheckZero);
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
QString qsFormula = dlg.GetFormula();
|
|
|
|
qsFormula.replace("\n", " ");
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabLabels->pushButtonDLHeight)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetDLHeight(qsFormula);
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonDLWidth)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetDLWidth(qsFormula);
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonDLAngle)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetDLAngle(qsFormula);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
pleFormula->setPlainText(qsFormula);
|
|
|
|
}
|
|
|
|
UpdateDetailLabelValues();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EditPLFormula()
|
|
|
|
{
|
|
|
|
QPlainTextEdit* pleFormula;
|
|
|
|
bool bCheckZero;
|
|
|
|
QString title;
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabLabels->pushButtonPLHeight)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditPLHeightFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = true;
|
|
|
|
title = tr("Edit height");
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonPLWidth)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditPLWidthFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = true;
|
|
|
|
title = tr("Edit width");
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonPLAngle)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
pleFormula = uiTabLabels->lineEditPLAngleFormula;
|
2017-03-11 14:25:21 +01:00
|
|
|
bCheckZero = false;
|
|
|
|
title = tr("Edit angle");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogEditWrongFormula dlg(data, NULL_ID, this);
|
|
|
|
dlg.setWindowTitle(title);
|
|
|
|
dlg.SetFormula(qApp->TrVars()->TryFormulaFromUser(pleFormula->toPlainText(), qApp->Settings()->GetOsSeparator()));
|
|
|
|
dlg.setCheckZero(bCheckZero);
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
QString qsFormula = dlg.GetFormula();
|
|
|
|
qsFormula.replace("\n", " ");
|
2017-03-17 15:38:18 +01:00
|
|
|
if (sender() == uiTabLabels->pushButtonPLHeight)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetPLHeight(qsFormula);
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonPLWidth)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetPLWidth(qsFormula);
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (sender() == uiTabLabels->pushButtonPLAngle)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
|
|
|
SetPLAngle(qsFormula);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// should not get here!
|
|
|
|
pleFormula->setPlainText(qsFormula);
|
|
|
|
}
|
|
|
|
UpdatePatternLabelValues();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployGrainlineRotation()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabGrainline->lineEditRotFormula, uiTabGrainline->pushButtonShowRot, m_iRotBaseHeight);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::DeployGrainlineLength()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabGrainline->lineEditLenFormula, uiTabGrainline->pushButtonShowLen, m_iLenBaseHeight);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-11 14:25:21 +01:00
|
|
|
void DialogSeamAllowance::DeployDLWidth()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditDLWidthFormula, uiTabLabels->pushButtonShowDLWidth, m_DLWidthBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployDLHeight()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditDLHeightFormula, uiTabLabels->pushButtonShowDLHeight, m_DLHeightBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployDLAngle()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditDLAngleFormula, uiTabLabels->pushButtonShowDLAngle, m_DLAngleBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployPLWidth()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditPLWidthFormula, uiTabLabels->pushButtonShowPLWidth, m_PLWidthBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployPLHeight()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditPLHeightFormula, uiTabLabels->pushButtonShowPLHeight, m_PLHeightBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployPLAngle()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabLabels->lineEditPLAngleFormula, uiTabLabels->pushButtonShowPLAngle, m_PLAngleBaseHeight);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ResetGrainlineWarning()
|
2017-01-12 18:09:00 +01:00
|
|
|
{
|
2017-02-24 16:23:02 +01:00
|
|
|
if (flagGFormulas || flagGPin)
|
2017-02-23 15:33:15 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Grainline, tr("Grainline"));
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ResetLabelsWarning()
|
|
|
|
{
|
|
|
|
if (flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle && (flagPLFormulas || flagPPin))
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels"));
|
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), QIcon());
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EvalWidth()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditWidth;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
2017-03-17 15:38:18 +01:00
|
|
|
const QString formula = uiTabPaths->plainTextEditFormulaWidth->toPlainText();
|
|
|
|
m_saWidth = Eval(formula, flagFormula, uiTabPaths->labelResultWidth, postfix, false, true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
|
|
|
if (m_saWidth >= 0)
|
|
|
|
{
|
|
|
|
VContainer *locData = const_cast<VContainer *> (data);
|
|
|
|
locData->AddVariable(currentSeamAllowance, new VIncrement(locData, currentSeamAllowance, 0, m_saWidth,
|
|
|
|
QString().setNum(m_saWidth), true,
|
|
|
|
tr("Current seam allowance")));
|
|
|
|
|
|
|
|
EvalWidthBefore();
|
|
|
|
EvalWidthAfter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EvalWidthBefore()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditBefore;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
2017-03-17 15:38:18 +01:00
|
|
|
const QString formula = uiTabPaths->plainTextEditFormulaWidthBefore->toPlainText();
|
2017-01-21 14:24:40 +01:00
|
|
|
bool flagFormula = false; // fake flag
|
2017-03-17 15:38:18 +01:00
|
|
|
Eval(formula, flagFormula, uiTabPaths->labelResultBefore, postfix, false, true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QString formulaSABefore = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore);
|
2017-02-12 14:42:21 +01:00
|
|
|
UpdateNodeSABefore(formulaSABefore);
|
2017-03-17 15:38:18 +01:00
|
|
|
EnableDefButton(uiTabPaths->pushButtonDefBefore, formulaSABefore);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::EvalWidthAfter()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditAfter;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
2017-03-17 15:38:18 +01:00
|
|
|
const QString formula = uiTabPaths->plainTextEditFormulaWidthAfter->toPlainText();
|
2017-01-21 14:24:40 +01:00
|
|
|
bool flagFormula = false; // fake flag
|
2017-03-17 15:38:18 +01:00
|
|
|
Eval(formula, flagFormula, uiTabPaths->labelResultAfter, postfix, false, true);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QString formulaSAAfter = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter);
|
2017-02-12 14:42:21 +01:00
|
|
|
UpdateNodeSAAfter(formulaSAAfter);
|
2017-03-17 15:38:18 +01:00
|
|
|
EnableDefButton(uiTabPaths->pushButtonDefAfter, formulaSAAfter);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::FXWidth()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit seam allowance width"));
|
|
|
|
dialog->SetFormula(GetFormulaSAWidth());
|
|
|
|
dialog->setCheckLessThanZero(true);
|
|
|
|
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetFormulaSAWidth(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::FXWidthBefore()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit seam allowance width before"));
|
2017-03-17 15:38:18 +01:00
|
|
|
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore));
|
2017-01-21 14:24:40 +01:00
|
|
|
dialog->setCheckLessThanZero(true);
|
|
|
|
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetCurrentSABefore(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::FXWidthAfter()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit seam allowance width after"));
|
2017-03-17 15:38:18 +01:00
|
|
|
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter));
|
2017-01-21 14:24:40 +01:00
|
|
|
dialog->setCheckLessThanZero(true);
|
|
|
|
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetCurrentSAAfter(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::WidthChanged()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditWidth;
|
|
|
|
labelResultCalculation = uiTabPaths->labelResultWidth;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
2017-03-17 15:38:18 +01:00
|
|
|
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidth, m_timerWidth, postfix);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::WidthBeforeChanged()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditBefore;
|
|
|
|
labelResultCalculation = uiTabPaths->labelResultBefore;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
|
|
|
bool flagFormula = false;
|
2017-03-17 15:38:18 +01:00
|
|
|
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::WidthAfterChanged()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
labelEditFormula = uiTabPaths->labelEditAfter;
|
|
|
|
labelResultCalculation = uiTabPaths->labelResultAfter;
|
2017-01-21 14:24:40 +01:00
|
|
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
|
|
|
bool flagFormula = false;
|
2017-03-17 15:38:18 +01:00
|
|
|
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployWidthFormulaTextEdit()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabPaths->plainTextEditFormulaWidth, uiTabPaths->pushButtonGrowWidth, m_formulaBaseWidth);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabPaths->plainTextEditFormulaWidthBefore, uiTabPaths->pushButtonGrowWidthBefore,
|
|
|
|
m_formulaBaseWidthBefore);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
DeployFormula(uiTabPaths->plainTextEditFormulaWidthAfter, uiTabPaths->pushButtonGrowWidthAfter,
|
|
|
|
m_formulaBaseWidthAfter);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
2017-02-23 15:33:15 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::GrainlinePinPointChanged()
|
|
|
|
{
|
|
|
|
QColor color = okColor;
|
2017-03-17 15:38:18 +01:00
|
|
|
const quint32 topPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin);
|
|
|
|
const quint32 bottomPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin);
|
2017-03-11 14:56:39 +01:00
|
|
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
2017-02-23 15:33:15 +01:00
|
|
|
{
|
|
|
|
flagGPin = true;
|
|
|
|
color = okColor;
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
ResetGrainlineWarning();
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagGPin = false;
|
2017-03-11 14:56:39 +01:00
|
|
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-02-24 18:42:06 +01:00
|
|
|
if (not flagGFormulas && not flagGPin)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Grainline, tr("Grainline"));
|
2017-02-24 18:42:06 +01:00
|
|
|
}
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
2017-03-11 14:56:39 +01:00
|
|
|
UpdateGrainlineValues();
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabGrainline->labelGrainlineTopPin, color);
|
|
|
|
ChangeColor(uiTabGrainline->labelGrainlineBottomPin, color);
|
2017-02-23 15:33:15 +01:00
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::DetailPinPointChanged()
|
|
|
|
{
|
|
|
|
QColor color = okColor;
|
2017-03-17 15:38:18 +01:00
|
|
|
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin);
|
|
|
|
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin);
|
2017-03-11 15:39:04 +01:00
|
|
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
2017-02-23 15:33:15 +01:00
|
|
|
{
|
|
|
|
flagDPin = true;
|
|
|
|
color = okColor;
|
|
|
|
|
|
|
|
if (flagPPin)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels"));
|
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), QIcon());
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagDPin = false;
|
2017-03-11 15:39:04 +01:00
|
|
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*"));
|
2017-02-23 15:33:15 +01:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
2017-03-11 14:56:39 +01:00
|
|
|
UpdateDetailLabelValues();
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabLabels->labelDLTopLeftPin, color);
|
|
|
|
ChangeColor(uiTabLabels->labelDLBottomRightPin, color);
|
2017-02-23 15:33:15 +01:00
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::PatternPinPointChanged()
|
|
|
|
{
|
|
|
|
QColor color = okColor;
|
2017-03-17 15:38:18 +01:00
|
|
|
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin);
|
|
|
|
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin);
|
2017-03-11 15:39:04 +01:00
|
|
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
2017-02-23 15:33:15 +01:00
|
|
|
{
|
|
|
|
flagPPin = true;
|
|
|
|
color = okColor;
|
|
|
|
|
|
|
|
if (flagDPin)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels"));
|
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), QIcon());
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagPPin = false;
|
2017-03-11 15:39:04 +01:00
|
|
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + QLatin1String("*"));
|
2017-02-23 15:33:15 +01:00
|
|
|
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
2017-02-23 15:33:15 +01:00
|
|
|
}
|
2017-03-11 14:56:39 +01:00
|
|
|
UpdatePatternLabelValues();
|
2017-03-17 15:38:18 +01:00
|
|
|
ChangeColor(uiTabLabels->labelPLTopLeftPin, color);
|
|
|
|
ChangeColor(uiTabLabels->labelPLBottomRightPin, color);
|
2017-02-23 15:33:15 +01:00
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece DialogSeamAllowance::CreatePiece() const
|
|
|
|
{
|
|
|
|
VPiece piece;
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.GetPath().SetNodes(GetPieceInternals<VPieceNode>(uiTabPaths->listWidgetMainPath));
|
|
|
|
piece.SetCustomSARecords(GetPieceInternals<CustomSARecord>(uiTabPaths->listWidgetCustomSA));
|
|
|
|
piece.SetInternalPaths(GetPieceInternals<quint32>(uiTabPaths->listWidgetInternalPaths));
|
|
|
|
piece.SetPins(GetPieceInternals<quint32>(uiTabPins->listWidgetPins));
|
|
|
|
piece.SetForbidFlipping(uiTabPaths->checkBoxForbidFlipping->isChecked());
|
|
|
|
piece.SetSeamAllowance(uiTabPaths->checkBoxSeams->isChecked());
|
|
|
|
piece.SetName(uiTabLabels->lineEditName->text());
|
2016-11-12 14:41:15 +01:00
|
|
|
piece.SetMx(m_mx);
|
|
|
|
piece.SetMy(m_my);
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth);
|
|
|
|
piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text());
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < m_conMCP.count(); ++i)
|
|
|
|
{
|
|
|
|
piece.GetPatternPieceData().Append(m_conMCP[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
piece.GetPatternPieceData().SetPos(m_oldData.GetPos());
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditDLWidthFormula));
|
|
|
|
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditDLHeightFormula));
|
2017-01-12 18:09:00 +01:00
|
|
|
piece.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.GetPatternPieceData().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditDLAngleFormula));
|
|
|
|
piece.GetPatternPieceData().SetVisible(uiTabLabels->groupBoxDetailLabel->isChecked());
|
|
|
|
piece.GetPatternPieceData().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxDLCenterPin));
|
|
|
|
piece.GetPatternPieceData().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin));
|
|
|
|
piece.GetPatternPieceData().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
piece.GetPatternInfo() = m_oldGeom;
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.GetPatternInfo().SetVisible(uiTabLabels->groupBoxPatternLabel->isChecked());
|
|
|
|
piece.GetPatternInfo().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxPLCenterPin));
|
|
|
|
piece.GetPatternInfo().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin));
|
|
|
|
piece.GetPatternInfo().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin));
|
|
|
|
piece.GetPatternInfo().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditPLWidthFormula));
|
|
|
|
piece.GetPatternInfo().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditPLHeightFormula));
|
|
|
|
piece.GetPatternInfo().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditPLAngleFormula));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
piece.GetGrainlineGeometry() = m_oldGrainline;
|
2017-03-17 15:38:18 +01:00
|
|
|
piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->groupBoxGrainline->isChecked());
|
|
|
|
piece.GetGrainlineGeometry().SetRotation(GetFormulaFromUser(uiTabGrainline->lineEditRotFormula));
|
|
|
|
piece.GetGrainlineGeometry().SetLength(GetFormulaFromUser(uiTabGrainline->lineEditLenFormula));
|
|
|
|
piece.GetGrainlineGeometry().SetArrowType(static_cast<ArrowType>(uiTabGrainline->comboBoxArrow->currentIndex()));
|
|
|
|
piece.GetGrainlineGeometry().SetCenterPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineCenterPin));
|
|
|
|
piece.GetGrainlineGeometry().SetTopPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin));
|
|
|
|
piece.GetGrainlineGeometry().SetBottomPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2016-11-04 15:16:11 +01:00
|
|
|
return piece;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-28 09:47:36 +01:00
|
|
|
void DialogSeamAllowance::NewMainPathItem(const VPieceNode &node)
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
NewNodeItem(uiTabPaths->listWidgetMainPath, node);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::NewCustomSA(const CustomSARecord &record)
|
|
|
|
{
|
|
|
|
if (record.path > NULL_ID)
|
|
|
|
{
|
2016-12-03 17:01:39 +01:00
|
|
|
const QString name = GetPathName(record.path, record.reverse);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(record));
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetCustomSA->addItem(item);
|
|
|
|
uiTabPaths->listWidgetCustomSA->setCurrentRow(uiTabPaths->listWidgetCustomSA->count()-1);
|
2016-11-28 09:47:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-12-03 17:01:39 +01:00
|
|
|
void DialogSeamAllowance::NewInternalPath(quint32 path)
|
|
|
|
{
|
|
|
|
if (path > NULL_ID)
|
|
|
|
{
|
|
|
|
const QString name = GetPathName(path);
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(path));
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetInternalPaths->addItem(item);
|
|
|
|
uiTabPaths->listWidgetInternalPaths->setCurrentRow(uiTabPaths->listWidgetInternalPaths->count()-1);
|
2016-12-03 17:01:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 14:11:54 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::NewPin(quint32 pinPoint)
|
|
|
|
{
|
|
|
|
if (pinPoint > NULL_ID)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VGObject> pin = data->GetGObject(pinPoint);
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(pin->name());
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(pinPoint));
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPins->listWidgetPins->addItem(item);
|
|
|
|
uiTabPins->listWidgetPins->setCurrentRow(uiTabPins->listWidgetPins->count()-1);
|
2017-02-14 14:11:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
if (path > NULL_ID)
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2016-12-03 17:01:39 +01:00
|
|
|
name = data->GetPiecePath(path).GetName();
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2016-12-03 17:01:39 +01:00
|
|
|
if (reverse)
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
name = QLatin1String("- ") + name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogSeamAllowance::MainPathIsValid() const
|
|
|
|
{
|
2016-11-22 12:04:34 +01:00
|
|
|
QString url = DialogWarningIcon();
|
2017-03-22 11:05:53 +01:00
|
|
|
bool valid = true;
|
2016-11-04 15:16:11 +01:00
|
|
|
|
|
|
|
if(CreatePiece().MainPathPoints(data).count() < 3)
|
|
|
|
{
|
|
|
|
url += tr("You need more points!");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->helpLabel->setText(url);
|
2017-03-22 11:05:53 +01:00
|
|
|
valid = false;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(not MainPathIsClockwise())
|
|
|
|
{
|
|
|
|
url += tr("You have to choose points in a clockwise direction!");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->helpLabel->setText(url);
|
2017-03-22 11:05:53 +01:00
|
|
|
valid = false;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
if (FirstPointEqualLast(uiTabPaths->listWidgetMainPath))
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
|
|
|
url += tr("First point cannot be equal to the last point!");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->helpLabel->setText(url);
|
2017-03-22 11:05:53 +01:00
|
|
|
valid = false;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
else if (DoublePoints(uiTabPaths->listWidgetMainPath))
|
2016-11-04 15:16:11 +01:00
|
|
|
{
|
2016-11-22 12:04:34 +01:00
|
|
|
url += tr("You have double points!");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->helpLabel->setText(url);
|
2017-03-22 11:05:53 +01:00
|
|
|
valid = false;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-22 11:05:53 +01:00
|
|
|
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
m_ftb->SetTabText(TabOrder::Paths, tr("Paths"));
|
|
|
|
uiTabPaths->helpLabel->setText(tr("Ready!"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ftb->SetTabText(TabOrder::Paths, tr("Paths") + QLatin1String("*"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
2016-11-04 15:16:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ValidObjects(bool value)
|
|
|
|
{
|
|
|
|
flagError = value;
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogSeamAllowance::MainPathIsClockwise() const
|
|
|
|
{
|
|
|
|
const QVector<QPointF> points = CreatePiece().MainPathPoints(data);
|
|
|
|
|
|
|
|
if(points.count() < 3)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const qreal res = VPiece::SumTrapezoids(points);
|
|
|
|
if (res < 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-04 16:04:18 +01:00
|
|
|
|
2016-11-12 11:41:04 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitNodesList()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const quint32 id = CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt();
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxNodes->blockSignals(true);
|
|
|
|
uiTabPaths->comboBoxNodes->clear();
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QVector<VPieceNode> nodes = GetPieceInternals<VPieceNode>(uiTabPaths->listWidgetMainPath);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-02-15 14:32:48 +01:00
|
|
|
for (int i = 0; i < nodes.size(); ++i)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-02-15 14:32:48 +01:00
|
|
|
const VPieceNode node = nodes.at(i);
|
2017-03-22 11:05:53 +01:00
|
|
|
if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded())
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
|
|
|
const QString name = GetNodeName(node);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxNodes->addItem(name, node.GetId());
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxNodes->blockSignals(false);
|
2016-11-12 11:41:04 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxNodes->findData(id);
|
2016-11-12 11:41:04 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxNodes->setCurrentIndex(index);
|
2016-11-12 11:41:04 +01:00
|
|
|
NodeChanged(index);// Need in case combox index was not changed
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxNodes->count() > 0 ? NodeChanged(0) : NodeChanged(-1);
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-19 12:44:12 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-11-12 11:41:04 +01:00
|
|
|
QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
for (qint32 i = 0; i < uiTabPaths->listWidgetMainPath->count(); ++i)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *item = uiTabPaths->listWidgetMainPath->item(i);
|
2016-11-12 11:41:04 +01:00
|
|
|
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
|
|
|
|
|
|
|
|
if (node.GetId() == id)
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-03 18:18:58 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogSeamAllowance::GetLastId() const
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int count = uiTabPaths->listWidgetMainPath->count();
|
2016-12-03 18:18:58 +01:00
|
|
|
if (count > 0)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *item = uiTabPaths->listWidgetMainPath->item(count-1);
|
2016-12-03 18:18:58 +01:00
|
|
|
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
|
|
|
|
return node.GetId();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL_ID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-12 11:41:04 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-21 14:24:40 +01:00
|
|
|
void DialogSeamAllowance::SetCurrentSABefore(const QString &formula)
|
|
|
|
{
|
|
|
|
UpdateNodeSABefore(formula);
|
|
|
|
ListChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SetCurrentSAAfter(const QString &formula)
|
|
|
|
{
|
|
|
|
UpdateNodeSAAfter(formula);
|
|
|
|
ListChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::UpdateNodeSABefore(const QString &formula)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxNodes->currentIndex();
|
2016-11-12 11:41:04 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
2016-11-12 11:41:04 +01:00
|
|
|
if (rowItem)
|
|
|
|
{
|
|
|
|
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
2017-01-21 14:24:40 +01:00
|
|
|
rowNode.SetFormulaSABefore(formula);
|
2016-11-12 11:41:04 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-21 14:24:40 +01:00
|
|
|
void DialogSeamAllowance::UpdateNodeSAAfter(const QString &formula)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxNodes->currentIndex();
|
2016-11-12 11:41:04 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
2016-11-12 11:41:04 +01:00
|
|
|
if (rowItem)
|
|
|
|
{
|
|
|
|
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
2017-01-21 14:24:40 +01:00
|
|
|
rowNode.SetFormulaSAAfter(formula);
|
2016-11-12 11:41:04 +01:00
|
|
|
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitFancyTabBar()
|
|
|
|
{
|
|
|
|
m_ftb->InsertTab(TabOrder::Paths, QIcon("://icon/32x32/paths.png"), tr("Paths"));
|
|
|
|
m_ftb->InsertTab(TabOrder::Labels, QIcon("://icon/32x32/labels.png"), tr("Labels"));
|
|
|
|
m_ftb->InsertTab(TabOrder::Grainline, QIcon("://icon/32x32/grainline.png"), tr("Grainline"));
|
|
|
|
m_ftb->InsertTab(TabOrder::Pins, QIcon("://icon/32x32/pins.png"), tr("Pins"));
|
|
|
|
|
|
|
|
ui->horizontalLayout->addWidget(m_ftb, 0, Qt::AlignLeft);
|
|
|
|
|
|
|
|
m_ftb->SetTabEnabled(TabOrder::Paths, true);
|
|
|
|
|
|
|
|
m_tabPaths->hide();
|
|
|
|
uiTabPaths->setupUi(m_tabPaths);
|
|
|
|
ui->horizontalLayout->addWidget(m_tabPaths, 1);
|
|
|
|
|
|
|
|
m_tabLabels->hide();
|
|
|
|
uiTabLabels->setupUi(m_tabLabels);
|
|
|
|
ui->horizontalLayout->addWidget(m_tabLabels, 1);
|
|
|
|
|
|
|
|
m_tabGrainline->hide();
|
|
|
|
uiTabGrainline->setupUi(m_tabGrainline);
|
|
|
|
ui->horizontalLayout->addWidget(m_tabGrainline, 1);
|
|
|
|
|
|
|
|
m_tabPins->hide();
|
|
|
|
uiTabPins->setupUi(m_tabPins);
|
|
|
|
ui->horizontalLayout->addWidget(m_tabPins, 1);
|
|
|
|
|
|
|
|
connect(m_ftb, &FancyTabBar::CurrentChanged, this, &DialogSeamAllowance::FancyTabChanged);
|
|
|
|
connect(uiTabLabels->tabWidget, &QTabWidget::currentChanged, this, &DialogSeamAllowance::TabChanged);
|
|
|
|
}
|
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitMainPathTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(uiTabPaths->listWidgetMainPath, &QListWidget::customContextMenuRequested, this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::ShowMainPathContextMenu);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this,
|
|
|
|
&DialogSeamAllowance::ListChanged);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitSeamAllowanceTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
plainTextEditFormula = uiTabPaths->plainTextEditFormulaWidth;
|
|
|
|
this->m_formulaBaseWidth = uiTabPaths->plainTextEditFormulaWidth->height();
|
|
|
|
this->m_formulaBaseWidthBefore = uiTabPaths->plainTextEditFormulaWidthBefore->height();
|
|
|
|
this->m_formulaBaseWidthAfter = uiTabPaths->plainTextEditFormulaWidthAfter->height();
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidth->installEventFilter(this);
|
|
|
|
uiTabPaths->plainTextEditFormulaWidthBefore->installEventFilter(this);
|
|
|
|
uiTabPaths->plainTextEditFormulaWidthAfter->installEventFilter(this);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
|
|
|
m_timerWidth = new QTimer(this);
|
|
|
|
connect(m_timerWidth, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidth);
|
|
|
|
|
|
|
|
m_timerWidthBefore = new QTimer(this);
|
|
|
|
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthBefore);
|
|
|
|
|
|
|
|
m_timerWidthAfter = new QTimer(this);
|
|
|
|
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthAfter);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
|
2017-01-21 14:24:40 +01:00
|
|
|
m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
InitNodesList();
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::NodeChanged);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->pushButtonDefBefore, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefBefore);
|
|
|
|
connect(uiTabPaths->pushButtonDefAfter, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefAfter);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
InitNodeAngles(uiTabPaths->comboBoxAngle);
|
|
|
|
connect(uiTabPaths->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::NodeAngleChanged);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetCustomSA->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(uiTabPaths->listWidgetCustomSA, &QListWidget::customContextMenuRequested, this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::ShowCustomSAContextMenu);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->listWidgetCustomSA, &QListWidget::currentRowChanged, this,
|
|
|
|
&DialogSeamAllowance::CustomSAChanged);
|
|
|
|
connect(uiTabPaths->comboBoxStartPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::CSAStartPointChanged);
|
|
|
|
connect(uiTabPaths->comboBoxEndPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::CSAEndPointChanged);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->comboBoxIncludeType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::CSAIncludeTypeChanged);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->toolButtonExprWidth, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidth);
|
|
|
|
connect(uiTabPaths->toolButtonExprBefore, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthBefore);
|
|
|
|
connect(uiTabPaths->toolButtonExprAfter, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthAfter);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this,
|
|
|
|
&DialogSeamAllowance::WidthChanged);
|
|
|
|
connect(uiTabPaths->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this,
|
2017-01-21 14:24:40 +01:00
|
|
|
&DialogSeamAllowance::WidthBeforeChanged);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this,
|
2017-01-21 14:24:40 +01:00
|
|
|
&DialogSeamAllowance::WidthAfterChanged);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->pushButtonGrowWidth, &QPushButton::clicked, this,
|
|
|
|
&DialogSeamAllowance::DeployWidthFormulaTextEdit);
|
|
|
|
connect(uiTabPaths->pushButtonGrowWidthBefore, &QPushButton::clicked,
|
2017-01-21 14:24:40 +01:00
|
|
|
this, &DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabPaths->pushButtonGrowWidthAfter, &QPushButton::clicked, this,
|
2017-01-21 14:24:40 +01:00
|
|
|
&DialogSeamAllowance::DeployWidthAfterFormulaTextEdit);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
2016-11-28 09:47:36 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
|
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
box->clear();
|
|
|
|
box->addItem(tr("Empty"), NULL_ID);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QVector<VPieceNode> nodes = GetPieceInternals<VPieceNode>(uiTabPaths->listWidgetMainPath);
|
2016-11-28 09:47:36 +01:00
|
|
|
|
2017-02-15 14:32:48 +01:00
|
|
|
for (int i = 0; i < nodes.size(); ++i)
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
2017-02-15 14:32:48 +01:00
|
|
|
const VPieceNode &node = nodes.at(i);
|
2017-03-22 11:05:53 +01:00
|
|
|
if (node.GetTypeTool() == Tool::NodePoint && not node.IsExcluded())
|
2016-11-28 09:47:36 +01:00
|
|
|
{
|
|
|
|
const QString name = GetNodeName(node);
|
|
|
|
box->addItem(name, node.GetId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-28 13:52:31 +01:00
|
|
|
|
2017-02-15 14:32:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitPinPoint(QComboBox *box)
|
|
|
|
{
|
|
|
|
SCASSERT(box != nullptr);
|
|
|
|
|
|
|
|
quint32 currentId = NULL_ID;
|
|
|
|
if (box->count() > 0)
|
|
|
|
{
|
|
|
|
currentId = CURRENT_DATA(box).toUInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
box->clear();
|
|
|
|
box->addItem(QLatin1String("<") + tr("no pin") + QLatin1String(">"), NULL_ID);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const QVector<quint32> pins = GetPieceInternals<quint32>(uiTabPins->listWidgetPins);
|
2017-02-15 14:32:48 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < pins.size(); ++i)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VGObject> pin = data->GetGObject(pins.at(i));
|
|
|
|
box->addItem(pin->name(), pins.at(i));
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
const int index = uiTabPaths->comboBoxNodes->findData(currentId);
|
2017-02-15 14:32:48 +01:00
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-28 13:52:31 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitSAIncludeType()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->clear();
|
2016-11-28 13:52:31 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->comboBoxIncludeType->addItem(tr("main path"),
|
|
|
|
static_cast<unsigned char>(PiecePathIncludeType::AsMainPath));
|
|
|
|
uiTabPaths->comboBoxIncludeType->addItem(tr("custom seam allowance"),
|
|
|
|
static_cast<unsigned char>(PiecePathIncludeType::AsCustomSA));
|
2016-11-28 13:52:31 +01:00
|
|
|
}
|
2016-11-29 16:39:13 +01:00
|
|
|
|
2017-01-12 18:09:00 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitInternalPathsTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->listWidgetInternalPaths->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(uiTabPaths->listWidgetInternalPaths, &QListWidget::customContextMenuRequested, this,
|
2017-01-12 18:09:00 +01:00
|
|
|
&DialogSeamAllowance::ShowInternalPathsContextMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitPatternPieceDataTab()
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditName->setClearButtonEnabled(true);
|
|
|
|
uiTabLabels->lineEditLetter->setClearButtonEnabled(true);
|
2017-01-12 18:09:00 +01:00
|
|
|
#endif
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
m_qslMaterials << QApplication::translate("Detail", "Fabric", 0)
|
|
|
|
<< QApplication::translate("Detail", "Lining", 0)
|
|
|
|
<< QApplication::translate("Detail", "Interfacing", 0)
|
|
|
|
<< QApplication::translate("Detail", "Interlining", 0);
|
|
|
|
|
|
|
|
for (int i = 0; i < m_qslMaterials.count(); ++i)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->addItem(m_qslMaterials[i], i);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
|
|
|
|
for (int i = 0; i < qsl.count(); ++i)
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->addItem(qsl.at(i), int(MaterialType::mtUserDefined));
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_qslPlacements << tr("None") << tr("Cut on fold");
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxPlacement->addItems(m_qslPlacements);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->pushButtonAdd, &QPushButton::clicked, this, &DialogSeamAllowance::AddUpdate);
|
|
|
|
connect(uiTabLabels->pushButtonCancel, &QPushButton::clicked, this, &DialogSeamAllowance::Cancel);
|
|
|
|
connect(uiTabLabels->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove);
|
|
|
|
connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode);
|
|
|
|
connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
SetAddMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitLabelsTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
m_DLWidthBaseHeight = uiTabLabels->lineEditDLWidthFormula->height();
|
|
|
|
m_DLHeightBaseHeight = uiTabLabels->lineEditDLHeightFormula->height();
|
|
|
|
m_DLAngleBaseHeight = uiTabLabels->lineEditDLAngleFormula->height();
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->groupBoxDetailLabel, &QGroupBox::toggled, this, &DialogSeamAllowance::EnabledDetailLabel);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLCenterPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLTopLeftPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLBottomRightPin);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->comboBoxDLTopLeftPin,
|
2017-03-11 14:25:21 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::DetailPinPointChanged);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->comboBoxDLBottomRightPin,
|
2017-03-11 14:25:21 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::DetailPinPointChanged);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->pushButtonDLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::EditDLFormula);
|
|
|
|
connect(uiTabLabels->pushButtonDLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::EditDLFormula);
|
|
|
|
connect(uiTabLabels->pushButtonDLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::EditDLFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditDLWidthFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdateDetailLabelValues);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditDLHeightFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdateDetailLabelValues);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditDLAngleFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdateDetailLabelValues);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->pushButtonShowDLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::DeployDLWidth);
|
|
|
|
connect(uiTabLabels->pushButtonShowDLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::DeployDLHeight);
|
|
|
|
connect(uiTabLabels->pushButtonShowDLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::DeployDLAngle);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
EnabledDetailLabel();
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_PLWidthBaseHeight = uiTabLabels->lineEditPLWidthFormula->height();
|
|
|
|
m_PLHeightBaseHeight = uiTabLabels->lineEditPLHeightFormula->height();
|
|
|
|
m_PLAngleBaseHeight = uiTabLabels->lineEditPLAngleFormula->height();
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->groupBoxPatternLabel, &QGroupBox::toggled, this, &DialogSeamAllowance::EnabledPatternLabel);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLCenterPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLTopLeftPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLBottomRightPin);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->comboBoxPLTopLeftPin,
|
2017-03-11 14:25:21 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::PatternPinPointChanged);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->comboBoxPLBottomRightPin,
|
2017-03-11 14:25:21 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::PatternPinPointChanged);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->pushButtonPLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::EditPLFormula);
|
|
|
|
connect(uiTabLabels->pushButtonPLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::EditPLFormula);
|
|
|
|
connect(uiTabLabels->pushButtonPLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::EditPLFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditPLWidthFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdatePatternLabelValues);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditPLHeightFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdatePatternLabelValues);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->lineEditPLAngleFormula, &QPlainTextEdit::textChanged, this,
|
2017-03-11 14:25:21 +01:00
|
|
|
&DialogSeamAllowance::UpdatePatternLabelValues);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabLabels->pushButtonShowPLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLWidth);
|
|
|
|
connect(uiTabLabels->pushButtonShowPLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLHeight);
|
|
|
|
connect(uiTabLabels->pushButtonShowPLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLAngle);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
EnabledPatternLabel();
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitGrainlineTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabGrainline->groupBoxGrainline, &QGroupBox::toggled, this, &DialogSeamAllowance::EnabledGrainline);
|
|
|
|
connect(uiTabGrainline->pushButtonRot, &QPushButton::clicked, this, &DialogSeamAllowance::EditGrainlineFormula);
|
|
|
|
connect(uiTabGrainline->pushButtonLen, &QPushButton::clicked, this, &DialogSeamAllowance::EditGrainlineFormula);
|
|
|
|
connect(uiTabGrainline->lineEditLenFormula, &QPlainTextEdit::textChanged, this,
|
|
|
|
&DialogSeamAllowance::UpdateGrainlineValues);
|
|
|
|
connect(uiTabGrainline->lineEditRotFormula, &QPlainTextEdit::textChanged, this,
|
|
|
|
&DialogSeamAllowance::UpdateGrainlineValues);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabGrainline->pushButtonShowRot, &QPushButton::clicked, this,
|
|
|
|
&DialogSeamAllowance::DeployGrainlineRotation);
|
|
|
|
connect(uiTabGrainline->pushButtonShowLen, &QPushButton::clicked, this,
|
|
|
|
&DialogSeamAllowance::DeployGrainlineLength);
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
EnabledGrainline();
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabGrainline->comboBoxArrow->addItem(tr("Both"));
|
|
|
|
uiTabGrainline->comboBoxArrow->addItem(tr("Just front"));
|
|
|
|
uiTabGrainline->comboBoxArrow->addItem(tr("Just rear"));
|
2017-01-12 18:09:00 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
m_iRotBaseHeight = uiTabGrainline->lineEditRotFormula->height();
|
|
|
|
m_iLenBaseHeight = uiTabGrainline->lineEditLenFormula->height();
|
2017-02-15 14:32:48 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineCenterPin);
|
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineTopPin);
|
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineBottomPin);
|
2017-02-23 15:33:15 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabGrainline->comboBoxGrainlineTopPin,
|
2017-02-23 15:33:15 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::GrainlinePinPointChanged);
|
2017-03-17 15:38:18 +01:00
|
|
|
connect(uiTabGrainline->comboBoxGrainlineBottomPin,
|
2017-02-23 15:33:15 +01:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSeamAllowance::GrainlinePinPointChanged);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
|
|
|
|
2017-02-14 14:11:54 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitPinsTab()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPins->listWidgetPins->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(uiTabPins->listWidgetPins, &QListWidget::customContextMenuRequested, this,
|
2017-02-14 14:11:54 +01:00
|
|
|
&DialogSeamAllowance::ShowPinsContextMenu);
|
|
|
|
}
|
|
|
|
|
2017-02-15 14:32:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::InitAllPinComboboxes()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineCenterPin);
|
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineTopPin);
|
|
|
|
InitPinPoint(uiTabGrainline->comboBoxGrainlineBottomPin);
|
2017-02-15 14:32:48 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLCenterPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLTopLeftPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxDLBottomRightPin);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLCenterPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLTopLeftPin);
|
|
|
|
InitPinPoint(uiTabLabels->comboBoxPLBottomRightPin);
|
2017-02-15 14:32:48 +01:00
|
|
|
}
|
|
|
|
|
2017-01-21 14:24:40 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogSeamAllowance::GetFormulaSAWidth() const
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
QString width = uiTabPaths->plainTextEditFormulaWidth->toPlainText();
|
2017-01-21 14:24:40 +01:00
|
|
|
width.replace("\n", " ");
|
|
|
|
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
|
|
|
|
{
|
|
|
|
const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (width.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployWidthFormulaTextEdit();
|
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabPaths->plainTextEditFormulaWidth->setPlainText(width);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
|
|
|
VisToolPiece *path = qobject_cast<VisToolPiece *>(vis);
|
|
|
|
SCASSERT(path != nullptr)
|
|
|
|
const VPiece p = CreatePiece();
|
|
|
|
path->SetPiece(p);
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth);
|
2017-01-21 14:24:40 +01:00
|
|
|
}
|
|
|
|
|
2016-11-29 16:39:13 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-12-03 17:01:39 +01:00
|
|
|
void DialogSeamAllowance::UpdateCurrentCustomSARecord()
|
2016-11-29 16:39:13 +01:00
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetCustomSA->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetCustomSA->count() == 0 || row == -1)
|
2016-11-29 16:39:13 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *item = uiTabPaths->listWidgetCustomSA->item(row);
|
2016-11-29 16:39:13 +01:00
|
|
|
SCASSERT(item != nullptr);
|
|
|
|
const CustomSARecord record = qvariant_cast<CustomSARecord>(item->data(Qt::UserRole));
|
2016-12-03 17:01:39 +01:00
|
|
|
item->setText(GetPathName(record.path, record.reverse));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::UpdateCurrentInternalPathRecord()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
const int row = uiTabPaths->listWidgetInternalPaths->currentRow();
|
|
|
|
if (uiTabPaths->listWidgetInternalPaths->count() == 0 || row == -1)
|
2016-12-03 17:01:39 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
QListWidgetItem *item = uiTabPaths->listWidgetInternalPaths->item(row);
|
2016-12-03 17:01:39 +01:00
|
|
|
SCASSERT(item != nullptr);
|
|
|
|
const quint32 path = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
|
|
|
item->setText(GetPathName(path));
|
2016-11-29 16:39:13 +01:00
|
|
|
}
|
2017-01-12 18:09:00 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ClearFields()
|
|
|
|
{
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->comboBoxMaterial->setCurrentIndex(0);
|
|
|
|
uiTabLabels->spinBoxCutNumber->setValue(0);
|
|
|
|
uiTabLabels->comboBoxPlacement->setCurrentIndex(0);
|
2017-01-12 18:09:00 +01:00
|
|
|
}
|
2017-02-14 16:33:30 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
QVector<T> DialogSeamAllowance::GetPieceInternals(const QListWidget *list) const
|
|
|
|
{
|
|
|
|
SCASSERT(list != nullptr)
|
|
|
|
QVector<T> internals;
|
|
|
|
for (qint32 i = 0; i < list->count(); ++i)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = list->item(i);
|
|
|
|
internals.append(qvariant_cast<T>(item->data(Qt::UserRole)));
|
|
|
|
}
|
|
|
|
return internals;
|
|
|
|
}
|
2017-02-27 13:28:22 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula)
|
2017-02-27 13:28:22 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (angleFormula.isEmpty())
|
|
|
|
{
|
|
|
|
angleFormula = QString("0");
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
|
2017-02-27 13:28:22 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
2017-03-11 14:25:21 +01:00
|
|
|
this->DeployGrainlineRotation();
|
2017-02-27 13:28:22 +01:00
|
|
|
}
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabGrainline->lineEditRotFormula->setPlainText(formula);
|
2017-02-27 13:28:22 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabGrainline->lineEditRotFormula);
|
2017-02-27 13:28:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetGrainlineLength(QString lengthFormula)
|
2017-02-27 13:28:22 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (lengthFormula.isEmpty())
|
|
|
|
{
|
|
|
|
lengthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(lengthFormula, qApp->Settings()->GetOsSeparator());
|
2017-02-27 13:28:22 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
2017-03-11 14:25:21 +01:00
|
|
|
this->DeployGrainlineLength();
|
2017-02-27 13:28:22 +01:00
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabGrainline->lineEditLenFormula->setPlainText(formula);
|
2017-02-27 13:28:22 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabGrainline->lineEditLenFormula);
|
2017-02-27 13:28:22 +01:00
|
|
|
}
|
2017-03-11 14:25:21 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetDLWidth(QString widthFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (widthFormula.isEmpty())
|
|
|
|
{
|
|
|
|
widthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployDLWidth();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditDLWidthFormula->setPlainText(formula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditDLWidthFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetDLHeight(QString heightFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (heightFormula.isEmpty())
|
|
|
|
{
|
|
|
|
heightFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployDLHeight();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditDLHeightFormula->setPlainText(formula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditDLHeightFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetDLAngle(QString angleFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (angleFormula.isEmpty())
|
|
|
|
{
|
|
|
|
angleFormula = QString("0");
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployDLAngle();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditDLAngleFormula->setPlainText(formula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditDLAngleFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetPLWidth(QString widthFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (widthFormula.isEmpty())
|
|
|
|
{
|
|
|
|
widthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployPLWidth();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditPLWidthFormula->setPlainText(formula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditPLWidthFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetPLHeight(QString heightFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (heightFormula.isEmpty())
|
|
|
|
{
|
|
|
|
heightFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployPLHeight();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditPLHeightFormula->setPlainText(formula);
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditPLHeightFormula);
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-13 14:00:32 +01:00
|
|
|
void DialogSeamAllowance::SetPLAngle(QString angleFormula)
|
2017-03-11 14:25:21 +01:00
|
|
|
{
|
2017-03-13 14:00:32 +01:00
|
|
|
if (angleFormula.isEmpty())
|
|
|
|
{
|
|
|
|
angleFormula = QString("0");
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:25:21 +01:00
|
|
|
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formula.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployPLAngle();
|
|
|
|
}
|
2017-03-13 14:00:32 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
uiTabLabels->lineEditPLAngleFormula->setPlainText(formula);
|
|
|
|
|
|
|
|
MoveCursorToEnd(uiTabLabels->lineEditPLAngleFormula);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSeamAllowance::ShowPins()
|
|
|
|
{
|
|
|
|
if (m_visPins.isNull())
|
|
|
|
{
|
|
|
|
m_visPins = new VisPiecePins(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_visPins->SetPins(GetPieceInternals<quint32>(uiTabPins->listWidgetPins));
|
2017-03-11 14:25:21 +01:00
|
|
|
|
2017-03-17 15:38:18 +01:00
|
|
|
if (not qApp->getCurrentScene()->items().contains(m_visPins))
|
|
|
|
{
|
|
|
|
m_visPins->VisualMode(NULL_ID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_visPins->RefreshGeometry();
|
|
|
|
}
|
2017-03-11 14:25:21 +01:00
|
|
|
}
|