VToolSeamAllowance add grainline and labels. Only the dialog.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-12 19:09:00 +02:00
parent e7adac78ba
commit 297b73a951
3 changed files with 1218 additions and 63 deletions

View file

@ -30,86 +30,48 @@
#include "ui_dialogseamallowance.h"
#include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpiecepath.h"
#include "../vpatterndb/calculator.h"
#include "visualization/path/vistoolpiece.h"
#include "dialogpiecepath.h"
#include "../../undocommands/savepiecepathoptions.h"
#include "../support/dialogeditwrongformula.h"
#include <QMenu>
#include <QtNumeric>
//---------------------------------------------------------------------------------------------------------------------
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogSeamAllowance),
applyAllowed(false),// By default disabled
m_bAddMode(true),
m_mx(0),
m_my(0),
m_dialog()
m_dialog(),
m_qslMaterials(),
m_qslPlacements(),
m_conMCP(),
m_oldData(),
m_oldGeom(),
m_oldGrainline(),
m_iRotBaseHeight(0),
m_iLenBaseHeight(0)
{
ui->setupUi(this);
InitOkCancelApply(ui);
EnableApply(applyAllowed);
InitMainPathTab();
InitSeamAllowanceTab();
InitInternalPathsTab();
InitPatternPieceDataTab();
InitGrainlineTab();
flagName = true;//We have default name of piece.
flagError = MainPathIsValid();
CheckState();
ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
const QString suffix = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ui->doubleSpinBoxSeams->setSuffix(suffix);
ui->doubleSpinBoxSABefore->setSuffix(suffix);
ui->doubleSpinBoxSAAfter->setSuffix(suffix);
if(qApp->patternUnit() == Unit::Inch)
{
ui->doubleSpinBoxSeams->setDecimals(5);
ui->doubleSpinBoxSABefore->setDecimals(5);
ui->doubleSpinBoxSAAfter->setDecimals(5);
}
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
ui->doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit()));
InitNodesList();
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeChanged);
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefBefore);
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefAfter);
connect(ui->doubleSpinBoxSeams, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this](){NodeChanged(ui->comboBoxNodes->currentIndex());});
connect(ui->doubleSpinBoxSABefore, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSABefore);
connect(ui->doubleSpinBoxSAAfter, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSAAfter);
ui->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetMainPath, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowMainPathContextMenu);
connect(ui->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
connect(ui->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
InitNodeAngles(ui->comboBoxAngle);
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeAngleChanged);
ui->listWidgetCustomSA->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowCustomSAContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::currentRowChanged, this, &DialogSeamAllowance::CustomSAChanged);
connect(ui->comboBoxStartPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAStartPointChanged);
connect(ui->comboBoxEndPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAEndPointChanged);
connect(ui->comboBoxIncludeType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAIncludeTypeChanged);
ui->listWidgetInternalPaths->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetInternalPaths, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowInternalPathsContextMenu);
if (not applyAllowed)
{
vis = new VisToolPiece(data);
@ -132,6 +94,8 @@ void DialogSeamAllowance::EnableApply(bool enable)
applyAllowed = enable;
ui->tabSeamAllowance->setEnabled(applyAllowed);
ui->tabInternalPaths->setEnabled(applyAllowed);
ui->tabPatternPieceData->setEnabled(applyAllowed);
ui->tabGrainline->setEnabled(applyAllowed);
}
//---------------------------------------------------------------------------------------------------------------------
@ -178,11 +142,34 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
ui->doubleSpinBoxSeams->setValue(piece.GetSAWidth());
ui->checkBoxSeams->setChecked(piece.IsSeamAllowance());
ui->lineEditName->setText(piece.GetName());
m_mx = piece.GetMx();
m_my = piece.GetMy();
ui->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
ui->checkBoxDetail->setChecked(piece.GetPatternPieceData().IsVisible());
ui->checkBoxPattern->setChecked(piece.GetPatternInfo().IsVisible());
m_conMCP.clear();
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
{
m_conMCP << piece.GetPatternPieceData().GetMCP(i);
}
UpdateList();
ui->checkBoxGrainline->setChecked(piece.GetGrainlineGeometry().IsVisible());
ui->lineEditRotFormula->setPlainText(piece.GetGrainlineGeometry().GetRotation());
ui->lineEditLenFormula->setPlainText(piece.GetGrainlineGeometry().GetLength());
ui->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
m_oldData = piece.GetPatternPieceData();
m_oldGeom = piece.GetPatternInfo();
m_oldGrainline = piece.GetGrainlineGeometry();
ValidObjects(MainPathIsValid());
EnableGrainlineRotation();
ListChanged();
}
@ -303,6 +290,140 @@ void DialogSeamAllowance::CheckState()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateList()
{
ui->listWidgetMCP->clear();
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("");
}
ui->listWidgetMCP->addItem(qsText);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::AddUpdate()
{
MaterialCutPlacement mcp;
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
int i = ui->comboBoxMaterial->itemData(ui->comboBoxMaterial->currentIndex()).toInt();
#else
int i = ui->comboBoxMaterial->currentData().toInt();
#endif
QString qsMat = ui->comboBoxMaterial->currentText();
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();
ui->comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
}
}
mcp.m_iCutNumber = ui->spinBoxCutNumber->value();
mcp.m_ePlacement = PlacementType(ui->comboBoxPlacement->currentIndex());
if (m_bAddMode == true)
{
m_conMCP << mcp;
}
else
{
int iR = ui->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP[iR] = mcp;
SetAddMode();
}
UpdateList();
ClearFields();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Cancel()
{
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Remove()
{
int iR = ui->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP.removeAt(iR);
UpdateList();
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NameDetailChanged()
{
SCASSERT(labelEditNamePoint != nullptr)
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
if (edit->text().isEmpty())
{
flagName = false;
ChangeColor(labelEditNamePoint, Qt::red);
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
ui->tabWidget->setTabIcon(1, icon);
}
else
{
flagName = true;
ChangeColor(labelEditNamePoint, okColor);
QIcon icon;
ui->tabWidget->setTabIcon(1, icon);
}
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::MaterialChanged()
{
ui->pushButtonAdd->setEnabled(ui->comboBoxMaterial->currentText().isEmpty() == false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
{
@ -738,6 +859,208 @@ void DialogSeamAllowance::PathDialogClosed(int result)
delete m_dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateValues()
{
QPlainTextEdit* apleSender[2];
apleSender[0] = ui->lineEditRotFormula;
apleSender[1] = ui->lineEditLenFormula;
bool bFormulasOK = true;
for (int i = 0; i < 2; ++i)
{
QLabel* plbVal;
QLabel* plbText;
QString qsUnit;
if (i == 0)
{
plbVal = ui->labelRot;
plbText = ui->labelEditRot;
QChar ch(0x00b0);
qsUnit = ch;
}
else
{
plbVal = ui->labelLen;
plbText = ui->labelEditLen;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit());
}
plbVal->setToolTip(tr("Value"));
QString qsFormula = apleSender[i]->toPlainText().simplified();
Calculator cal;
QString qsVal;
try
{
qsFormula.replace("\n", " ");
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
qreal dVal;
dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
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)
{
qsVal.clear();
ChangeColor(plbText, Qt::red);
bFormulasOK = false;
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
}
if (qsVal.isEmpty() == false)
{
qsVal += qsUnit;
}
plbVal->setText(qsVal);
}
bOk->setEnabled(bFormulasOK);
if (bFormulasOK == false)
{
QIcon icon(":/icons/win.icon.theme/16x16/status/dialog-warning.png");
ui->tabWidget->setTabIcon(ui->tabWidget->indexOf(ui->tabGrainline), icon);
}
else
{
ResetWarning();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetAddMode()
{
ui->pushButtonAdd->setText(tr("Add"));
ui->pushButtonCancel->hide();
ui->pushButtonRemove->hide();
ui->listWidgetMCP->setCurrentRow(-1);
m_bAddMode = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetEditMode()
{
int iR = ui->listWidgetMCP->currentRow();
// 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;
}
ui->pushButtonAdd->setText(tr("Update"));
ui->pushButtonCancel->show();
ui->pushButtonRemove->show();
MaterialCutPlacement mcp = m_conMCP.at(iR);
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
if (iRow >= 0)
{
ui->comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
}
else
{
ui->comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
}
}
else
{
ui->comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
}
ui->spinBoxCutNumber->setValue(mcp.m_iCutNumber);
ui->comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
m_bAddMode = false;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnableGrainlineRotation()
{
ui->lineEditRotFormula->setEnabled(ui->checkBoxGrainline->isChecked());
ui->lineEditLenFormula->setEnabled(ui->checkBoxGrainline->isChecked());
ui->pushButtonRot->setEnabled(ui->checkBoxGrainline->isChecked());
ui->pushButtonLen->setEnabled(ui->checkBoxGrainline->isChecked());
ui->pushButtonShowLen->setEnabled(ui->checkBoxGrainline->isChecked());
ui->pushButtonShowRot->setEnabled(ui->checkBoxGrainline->isChecked());
if (ui->checkBoxGrainline->isChecked() == true)
{
UpdateValues();
}
else
{
ChangeColor(ui->labelEditLen, okColor);
ChangeColor(ui->labelEditRot, okColor);
bOk->setEnabled(true);
ResetWarning();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EditFormula()
{
QPlainTextEdit* pleFormula;
bool bCheckZero;
if (sender() == ui->pushButtonLen)
{
pleFormula = ui->lineEditLenFormula;
bCheckZero = true;
}
else if (sender() == ui->pushButtonRot)
{
pleFormula = ui->lineEditRotFormula;
bCheckZero = false;
}
else
{
// should not get here!
return;
}
DialogEditWrongFormula dlg(data, NULL_ID, this);
dlg.SetFormula(pleFormula->toPlainText());
dlg.setCheckZero(bCheckZero);
if (dlg.exec() == QDialog::Accepted)
{
QString qsFormula = dlg.GetFormula();
qsFormula.replace("\n", " ");
pleFormula->setPlainText(qsFormula);
UpdateValues();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployRotation()
{
DeployFormula(ui->lineEditRotFormula, ui->pushButtonShowRot, m_iRotBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployLength()
{
DeployFormula(ui->lineEditLenFormula, ui->pushButtonShowLen, m_iLenBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ResetWarning()
{
QIcon icon;
ui->tabWidget->setTabIcon(ui->tabWidget->indexOf(ui->tabGrainline), icon);
}
//---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::CreatePiece() const
{
@ -767,9 +1090,33 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
piece.SetSeamAllowance(ui->checkBoxSeams->isChecked());
piece.SetSAWidth(ui->doubleSpinBoxSeams->value());
piece.SetName(ui->lineEditName->text());
piece.SetMx(m_mx);
piece.SetMy(m_my);
piece.GetPatternPieceData().SetLetter(ui->lineEditLetter->text());
for (int i = 0; i < m_conMCP.count(); ++i)
{
piece.GetPatternPieceData().Append(m_conMCP[i]);
}
piece.GetPatternPieceData().SetPos(m_oldData.GetPos());
piece.GetPatternPieceData().SetLabelWidth(m_oldData.GetLabelWidth());
piece.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight());
piece.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
piece.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
piece.GetPatternPieceData().SetVisible(ui->checkBoxDetail->isChecked());
piece.GetPatternInfo() = m_oldGeom;
piece.GetPatternInfo().SetVisible(ui->checkBoxPattern->isChecked());
piece.GetGrainlineGeometry() = m_oldGrainline;
piece.GetGrainlineGeometry().SetVisible(ui->checkBoxGrainline->isChecked());
piece.GetGrainlineGeometry().SetRotation(ui->lineEditRotFormula->toPlainText());
piece.GetGrainlineGeometry().SetLength(ui->lineEditLenFormula->toPlainText());
piece.GetGrainlineGeometry().SetArrowType(VGrainlineGeometry::ArrowType(ui->comboBoxArrow->currentIndex()));
return piece;
}
@ -1006,6 +1353,67 @@ void DialogSeamAllowance::SetCurrentSAAfter(qreal value)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitMainPathTab()
{
ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
ui->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetMainPath, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowMainPathContextMenu);
connect(ui->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitSeamAllowanceTab()
{
connect(ui->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
const QString suffix = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ui->doubleSpinBoxSeams->setSuffix(suffix);
ui->doubleSpinBoxSABefore->setSuffix(suffix);
ui->doubleSpinBoxSAAfter->setSuffix(suffix);
if(qApp->patternUnit() == Unit::Inch)
{
ui->doubleSpinBoxSeams->setDecimals(5);
ui->doubleSpinBoxSABefore->setDecimals(5);
ui->doubleSpinBoxSAAfter->setDecimals(5);
}
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
ui->doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit()));
InitNodesList();
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeChanged);
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefBefore);
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefAfter);
connect(ui->doubleSpinBoxSeams, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this](){NodeChanged(ui->comboBoxNodes->currentIndex());});
connect(ui->doubleSpinBoxSABefore, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSABefore);
connect(ui->doubleSpinBoxSAAfter, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSAAfter);
InitNodeAngles(ui->comboBoxAngle);
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeAngleChanged);
ui->listWidgetCustomSA->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowCustomSAContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::currentRowChanged, this, &DialogSeamAllowance::CustomSAChanged);
connect(ui->comboBoxStartPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAStartPointChanged);
connect(ui->comboBoxEndPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAEndPointChanged);
connect(ui->comboBoxIncludeType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAIncludeTypeChanged);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
{
@ -1036,6 +1444,75 @@ void DialogSeamAllowance::InitSAIncludeType()
static_cast<unsigned char>(PiecePathIncludeType::AsCustomSA));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitInternalPathsTab()
{
ui->listWidgetInternalPaths->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetInternalPaths, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowInternalPathsContextMenu);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPatternPieceDataTab()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditLetter->setClearButtonEnabled(true);
#endif
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
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)
{
ui->comboBoxMaterial->addItem(m_qslMaterials[i], i);
}
const QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
for (int i = 0; i < qsl.count(); ++i)
{
ui->comboBoxMaterial->addItem(qsl.at(i), int(MaterialType::mtUserDefined));
}
m_qslPlacements << tr("None") << tr("Cut on fold");
ui->comboBoxPlacement->addItems(m_qslPlacements);
ui->pushButtonRot->setIcon(QIcon("://icon/16x16/fx.png"));
ui->pushButtonLen->setIcon(QIcon("://icon/16x16/fx.png"));
connect(ui->pushButtonAdd, &QPushButton::clicked, this, &DialogSeamAllowance::AddUpdate);
connect(ui->pushButtonCancel, &QPushButton::clicked, this, &DialogSeamAllowance::Cancel);
connect(ui->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove);
connect(ui->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode);
connect(ui->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitGrainlineTab()
{
connect(ui->checkBoxGrainline, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableGrainlineRotation);
connect(ui->pushButtonRot, &QPushButton::clicked, this, &DialogSeamAllowance::EditFormula);
connect(ui->pushButtonLen, &QPushButton::clicked, this, &DialogSeamAllowance::EditFormula);
connect(ui->lineEditLenFormula, &QPlainTextEdit::textChanged, this, &DialogSeamAllowance::UpdateValues);
connect(ui->lineEditRotFormula, &QPlainTextEdit::textChanged, this, &DialogSeamAllowance::UpdateValues);
connect(ui->pushButtonShowRot, &QPushButton::clicked, this, &DialogSeamAllowance::DeployRotation);
connect(ui->pushButtonShowLen, &QPushButton::clicked, this, &DialogSeamAllowance::DeployLength);
SetAddMode();
EnableGrainlineRotation();
ui->comboBoxArrow->addItem(tr("Both"));
ui->comboBoxArrow->addItem(tr("Just front"));
ui->comboBoxArrow->addItem(tr("Just rear"));
m_iRotBaseHeight = ui->lineEditRotFormula->height();
m_iLenBaseHeight = ui->lineEditLenFormula->height();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateCurrentCustomSARecord()
{
@ -1065,3 +1542,11 @@ void DialogSeamAllowance::UpdateCurrentInternalPathRecord()
const quint32 path = qvariant_cast<quint32>(item->data(Qt::UserRole));
item->setText(GetPathName(path));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ClearFields()
{
ui->comboBoxMaterial->setCurrentIndex(0);
ui->spinBoxCutNumber->setValue(0);
ui->comboBoxPlacement->setCurrentIndex(0);
}

View file

@ -31,6 +31,9 @@
#include "dialogtool.h"
#include "../vpatterndb/vpiece.h"
#include "../vpatterndb/vpatterninfogeometry.h"
#include "../vpatterndb/vpatternpiecedata.h"
#include "../vpatterndb/vgrainlinegeometry.h"
namespace Ui
{
@ -59,7 +62,15 @@ protected:
virtual void SaveData() Q_DECL_OVERRIDE;
virtual void CheckState() Q_DECL_OVERRIDE;
protected slots:
void UpdateList();
void AddUpdate();
void Cancel();
void Remove();
private slots:
void NameDetailChanged();
void MaterialChanged();
void ShowMainPathContextMenu(const QPoint &pos);
void ShowCustomSAContextMenu(const QPoint &pos);
void ShowInternalPathsContextMenu(const QPoint &pos);
@ -78,16 +89,37 @@ private slots:
void CustomSAChanged(int row);
void PathDialogClosed(int result);
void UpdateValues();
void SetAddMode();
void SetEditMode();
void EnableGrainlineRotation();
void EditFormula();
void DeployRotation();
void DeployLength();
void ResetWarning();
private:
Q_DISABLE_COPY(DialogSeamAllowance)
Ui::DialogSeamAllowance *ui;
bool applyAllowed;
bool m_bAddMode;
qreal m_mx;
qreal m_my;
QPointer<DialogTool> m_dialog;
QStringList m_qslMaterials;
QStringList m_qslPlacements;
// temporary container for Material/Cut/Placement 3-tuples
MCPContainer m_conMCP;
VPatternPieceData m_oldData;
VPatternInfoGeometry m_oldGeom;
VGrainlineGeometry m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
VPiece CreatePiece() const;
void NewMainPathItem(const VPieceNode &node);
@ -97,11 +129,9 @@ private:
bool MainPathIsValid() const;
void ValidObjects(bool value);
bool MainPathIsClockwise() const;
void InitNodesList();
void InitCSAPoint(QComboBox *box);
void InitSAIncludeType();
void UpdateCurrentCustomSARecord();
void UpdateCurrentInternalPathRecord();
void ClearFields();
QListWidgetItem *GetItemById(quint32 id);
@ -109,6 +139,15 @@ private:
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
void InitMainPathTab();
void InitSeamAllowanceTab();
void InitNodesList();
void InitCSAPoint(QComboBox *box);
void InitSAIncludeType();
void InitInternalPathsTab();
void InitPatternPieceDataTab();
void InitGrainlineTab();
};
#endif // DIALOGSEAMALLOWANCE_H

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>504</height>
<width>521</width>
<height>493</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="tabMainPath">
<attribute name="title">
@ -399,6 +399,637 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPatternPieceData">
<attribute name="title">
<string>Pattern piece data</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Letter:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditLetter">
<property name="maxLength">
<number>3</number>
</property>
<property name="placeholderText">
<string>Letter of pattern piece</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelEditName">
<property name="text">
<string>Name of detail:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditName">
<property name="text">
<string>Detail</string>
</property>
<property name="maxLength">
<number>30</number>
</property>
<property name="placeholderText">
<string>Name can't be empty</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Material/Cut number/Placement</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Cut number:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Material type:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxMaterial">
<property name="toolTip">
<string>You can choose one of the predefined materials or enter a new one</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinBoxCutNumber">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxPlacement"/>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QPushButton" name="pushButtonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButtonRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="checkBoxDetail">
<property name="text">
<string>Detail label visible</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxPattern">
<property name="text">
<string>Pattern label visible</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QListWidget" name="listWidgetMCP">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabGrainline">
<attribute name="title">
<string>Grainline</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="checkBoxGrainline">
<property name="text">
<string>Grainline visible</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditRot">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Rotation:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="pushButtonRot">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelEqual">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelRot">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="lineEditRotFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="plainText">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonShowRot">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditLen">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="pushButtonLen">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelEqual_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelLen">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPlainTextEdit" name="lineEditLenFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="plainText">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonShowLen">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="labelEditLen_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Arrows:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxArrow"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>