issue #712 new default allowance setting taken into account in seam allowance tool dialog. StrToUnits and UnitsToStr moved from VDomDocument to def

--HG--
branch : develop
This commit is contained in:
Ronan Le Tiec 2017-07-02 13:34:36 +02:00
parent 07556c6c46
commit f080b88cf7
47 changed files with 205 additions and 198 deletions

View File

@ -636,7 +636,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
if (units.contains(unitValue)) if (units.contains(unitValue))
{ {
flagUnit = true; flagUnit = true;
unit = VDomDocument::StrToUnits(unitValue); unit = StrToUnits(unitValue);
} }
else else
{ {

View File

@ -535,9 +535,9 @@ void TMainWindow::changeEvent(QEvent *event)
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + QLatin1String(" ") + ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + QLatin1String(" ") +
VDomDocument::UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QLatin1String(" ") + ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QLatin1String(" ") +
VDomDocument::UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
labelGradationHeights = new QLabel(tr("Height:")); labelGradationHeights = new QLabel(tr("Height:"));
labelGradationSizes = new QLabel(tr("Size:")); labelGradationSizes = new QLabel(tr("Size:"));
@ -1231,7 +1231,7 @@ void TMainWindow::Fx()
dialog->setWindowTitle(tr("Edit measurement")); dialog->setWindowTitle(tr("Edit measurement"));
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "), dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "),
true)); true));
const QString postfix = VDomDocument::UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch)
dialog->setPostfix(postfix); dialog->setPostfix(postfix);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
@ -1488,7 +1488,7 @@ void TMainWindow::ShowNewMData(bool fresh)
ui->doubleSpinBoxInSizes->blockSignals(true); ui->doubleSpinBoxInSizes->blockSignals(true);
ui->doubleSpinBoxInHeights->blockSignals(true); ui->doubleSpinBoxInHeights->blockSignals(true);
const QString postfix = VDomDocument::UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch)
const qreal value = UnitConvertor(data->GetTableValue(meash->GetName(), mType), mUnit, pUnit); const qreal value = UnitConvertor(data->GetTableValue(meash->GetName(), mType), mUnit, pUnit);
ui->labelCalculatedValue->setText(qApp->LocaleToString(value) + " " +postfix); ui->labelCalculatedValue->setText(qApp->LocaleToString(value) + " " +postfix);
@ -1670,14 +1670,14 @@ void TMainWindow::SaveMValue()
if (formulaField->text() == text) if (formulaField->text() == text)
{ {
QTableWidgetItem *result = ui->tableWidget->item(row, ColumnCalcValue); QTableWidgetItem *result = ui->tableWidget->item(row, ColumnCalcValue);
const QString postfix = VDomDocument::UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch)
ui->labelCalculatedValue->setText(result->text() + " " +postfix); ui->labelCalculatedValue->setText(result->text() + " " +postfix);
return; return;
} }
if (text.isEmpty()) if (text.isEmpty())
{ {
const QString postfix = VDomDocument::UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch)
ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
return; return;
} }
@ -1997,9 +1997,9 @@ void TMainWindow::InitWindow()
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + " " + ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + " " +
VDomDocument::UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " + ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " +
VDomDocument::UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct // Because Qt Designer doesn't know about our deleting we will create empty objects for correct
// working the retranslation UI // working the retranslation UI
@ -2184,9 +2184,9 @@ void TMainWindow::InitTable()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowUnits() void TMainWindow::ShowUnits()
{ {
const QString unit = VDomDocument::UnitsToStr(mUnit); const QString unit = UnitsToStr(mUnit);
ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, VDomDocument::UnitsToStr(pUnit));// calculated value ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(pUnit));// calculated value
ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit);// formula ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit);// formula
ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit);// base value ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit);// base value
ShowHeaderUnits(ui->tableWidget, ColumnInSizes, unit);// in sizes ShowHeaderUnits(ui->tableWidget, ColumnInSizes, unit);// in sizes
@ -2645,7 +2645,7 @@ QString TMainWindow::ClearCustomName(const QString &name) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label) bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
{ {
const QString postfix = VDomDocument::UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch)
if (formula.isEmpty()) if (formula.isEmpty())
{ {
label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
@ -3111,9 +3111,9 @@ void TMainWindow::InitUnits()
void TMainWindow::InitComboBoxUnits() void TMainWindow::InitComboBoxUnits()
{ {
SCASSERT(comboBoxUnits != nullptr) SCASSERT(comboBoxUnits != nullptr)
comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Cm, true), QVariant(static_cast<int>(Unit::Cm))); comboBoxUnits->addItem(UnitsToStr(Unit::Cm, true), QVariant(static_cast<int>(Unit::Cm)));
comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Mm, true), QVariant(static_cast<int>(Unit::Mm))); comboBoxUnits->addItem(UnitsToStr(Unit::Mm, true), QVariant(static_cast<int>(Unit::Mm)));
comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Inch, true), QVariant(static_cast<int>(Unit::Inch))); comboBoxUnits->addItem(UnitsToStr(Unit::Inch, true), QVariant(static_cast<int>(Unit::Inch)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -2237,7 +2237,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
VFormula length1(spl.GetC1LengthFormula(), i->getData()); VFormula length1(spl.GetC1LengthFormula(), i->getData());
length1.setCheckZero(false); length1.setCheckZero(false);
length1.setToolId(i->getId()); length1.setToolId(i->getId());
length1.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); length1.setPostfix(UnitsToStr(qApp->patternUnit()));
AddPropertyFormula(tr("C1: length:"), length1, AttrLength1); AddPropertyFormula(tr("C1: length:"), length1, AttrLength1);
VFormula angle2(spl.GetEndAngleFormula(), i->getData()); VFormula angle2(spl.GetEndAngleFormula(), i->getData());
@ -2249,7 +2249,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
VFormula length2(spl.GetC2LengthFormula(), i->getData()); VFormula length2(spl.GetC2LengthFormula(), i->getData());
length2.setCheckZero(false); length2.setCheckZero(false);
length2.setToolId(i->getId()); length2.setToolId(i->getId());
length2.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); length2.setPostfix(UnitsToStr(qApp->patternUnit()));
AddPropertyFormula(tr("C2: length:"), length2, AttrLength2); AddPropertyFormula(tr("C2: length:"), length2, AttrLength2);
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics()); AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
@ -2947,7 +2947,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
VFormula length1F(spl.GetC1LengthFormula(), i->getData()); VFormula length1F(spl.GetC1LengthFormula(), i->getData());
length1F.setCheckZero(false); length1F.setCheckZero(false);
length1F.setToolId(i->getId()); length1F.setToolId(i->getId());
length1F.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); length1F.setPostfix(UnitsToStr(qApp->patternUnit()));
QVariant length1; QVariant length1;
length1.setValue(length1F); length1.setValue(length1F);
idToProperty[AttrLength1]->setValue(length1); idToProperty[AttrLength1]->setValue(length1);
@ -2963,7 +2963,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
VFormula length2F(spl.GetC2LengthFormula(), i->getData()); VFormula length2F(spl.GetC2LengthFormula(), i->getData());
length2F.setCheckZero(false); length2F.setCheckZero(false);
length2F.setToolId(i->getId()); length2F.setToolId(i->getId());
length2F.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); length2F.setPostfix(UnitsToStr(qApp->patternUnit()));
QVariant length2; QVariant length2;
length2.setValue(length2F); length2.setValue(length2F);
idToProperty[AttrLength2]->setValue(length2); idToProperty[AttrLength2]->setValue(length2);

View File

@ -155,7 +155,7 @@
<number>3</number> <number>3</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<double>10.000000000000000</double> <double>100.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>

View File

@ -254,7 +254,7 @@ void DialogIncrements::FillAnglesCurves()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::ShowUnits() void DialogIncrements::ShowUnits()
{ {
const QString unit = VDomDocument::UnitsToStr(qApp->patternUnit()); const QString unit = UnitsToStr(qApp->patternUnit());
ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit);// calculated value ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit);// calculated value
ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit);// formula ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit);// formula
@ -328,7 +328,7 @@ QString DialogIncrements::ClearIncrementName(const QString &name) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label) bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
{ {
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch)
if (formula.isEmpty()) if (formula.isEmpty())
{ {
label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
@ -636,7 +636,7 @@ void DialogIncrements::SaveIncrFormula()
{ {
QTableWidgetItem *result = ui->tableWidgetIncrement->item(row, 1); QTableWidgetItem *result = ui->tableWidgetIncrement->item(row, 1);
//Show unit in dialog lable (cm, mm or inch) //Show unit in dialog lable (cm, mm or inch)
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit()); const QString postfix = UnitsToStr(qApp->patternUnit());
ui->labelCalculatedValue->setText(result->text() + " " +postfix); ui->labelCalculatedValue->setText(result->text() + " " +postfix);
return; return;
} }
@ -644,7 +644,7 @@ void DialogIncrements::SaveIncrFormula()
if (text.isEmpty()) if (text.isEmpty())
{ {
//Show unit in dialog lable (cm, mm or inch) //Show unit in dialog lable (cm, mm or inch)
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit()); const QString postfix = UnitsToStr(qApp->patternUnit());
ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
return; return;
} }
@ -725,7 +725,7 @@ void DialogIncrements::Fx()
dialog->setWindowTitle(tr("Edit increment")); dialog->setWindowTitle(tr("Edit increment"));
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "), dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "),
qApp->Settings()->GetOsSeparator())); qApp->Settings()->GetOsSeparator()));
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch) dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch)
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)

View File

@ -703,13 +703,13 @@ void DialogLayoutSettings::IgnoreAllFields(int state)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::InitPaperUnits() void DialogLayoutSettings::InitPaperUnits()
{ {
ui->comboBoxPaperSizeUnit->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); ui->comboBoxPaperSizeUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
ui->comboBoxPaperSizeUnit->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); ui->comboBoxPaperSizeUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
ui->comboBoxPaperSizeUnit->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); ui->comboBoxPaperSizeUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch)));
ui->comboBoxPaperSizeUnit->addItem(tr("Pixels"), QVariant(VDomDocument::UnitsToStr(Unit::Px))); ui->comboBoxPaperSizeUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px)));
// set default unit // set default unit
oldPaperUnit = VDomDocument::StrToUnits(qApp->ValentinaSettings()->GetUnit()); oldPaperUnit = StrToUnits(qApp->ValentinaSettings()->GetUnit());
const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(qApp->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(qApp->ValentinaSettings()->GetUnit());
if (indexUnit != -1) if (indexUnit != -1)
{ {
@ -720,12 +720,12 @@ void DialogLayoutSettings::InitPaperUnits()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::InitLayoutUnits() void DialogLayoutSettings::InitLayoutUnits()
{ {
ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch)));
// set default unit // set default unit
oldLayoutUnit = VDomDocument::StrToUnits(qApp->ValentinaSettings()->GetUnit()); oldLayoutUnit = StrToUnits(qApp->ValentinaSettings()->GetUnit());
const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit());
if (indexUnit != -1) if (indexUnit != -1)
{ {
@ -976,13 +976,13 @@ QMarginsF DialogLayoutSettings::GetDefPrinterFields() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit DialogLayoutSettings::PaperUnit() const Unit DialogLayoutSettings::PaperUnit() const
{ {
return VDomDocument::StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString()); return StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit DialogLayoutSettings::LayoutUnit() const Unit DialogLayoutSettings::LayoutUnit() const
{ {
return VDomDocument::StrToUnits(ui->comboBoxLayoutUnit->currentData().toString()); return StrToUnits(ui->comboBoxLayoutUnit->currentData().toString());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -31,7 +31,6 @@
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../vmisc/vsettings.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../ifc/xml/vdomdocument.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
@ -70,7 +69,7 @@ DialogNewPattern::~DialogNewPattern()
Unit DialogNewPattern::PatternUnit() const Unit DialogNewPattern::PatternUnit() const
{ {
const qint32 index = ui->comboBoxUnits->currentIndex(); const qint32 index = ui->comboBoxUnits->currentIndex();
return VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); return StrToUnits(ui->comboBoxUnits->itemData(index).toString());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -111,9 +110,9 @@ void DialogNewPattern::showEvent(QShowEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogNewPattern::InitUnits() void DialogNewPattern::InitUnits()
{ {
ui->comboBoxUnits->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); ui->comboBoxUnits->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
ui->comboBoxUnits->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); ui->comboBoxUnits->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch)));
// set default unit // set default unit
const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->ValentinaSettings()->GetUnit());

View File

@ -1631,7 +1631,7 @@ void MainWindow::ShowMeasurements()
arguments = QStringList() arguments = QStringList()
<< absoluteMPath << absoluteMPath
<< "-u" << "-u"
<< VDomDocument::UnitsToStr(qApp->patternUnit()) << UnitsToStr(qApp->patternUnit())
<< "-e" << "-e"
<< QString().setNum(static_cast<int>(UnitConvertor(VContainer::height(), doc->MUnit(), Unit::Cm))) << QString().setNum(static_cast<int>(UnitConvertor(VContainer::height(), doc->MUnit(), Unit::Cm)))
<< "-s" << "-s"
@ -1641,7 +1641,7 @@ void MainWindow::ShowMeasurements()
{ {
arguments = QStringList() << absoluteMPath arguments = QStringList() << absoluteMPath
<< "-u" << "-u"
<< VDomDocument::UnitsToStr(qApp->patternUnit()); << UnitsToStr(qApp->patternUnit());
} }
if (isNoScaling) if (isNoScaling)
@ -1790,7 +1790,7 @@ void MainWindow::ToolBarOption()
ui->toolBarOption->addSeparator(); ui->toolBarOption->addSeparator();
} }
mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(VDomDocument::UnitsToStr(qApp->patternUnit(), true))); mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
ui->toolBarOption->addWidget(mouseCoordinate); ui->toolBarOption->addWidget(mouseCoordinate);
} }
@ -1964,7 +1964,7 @@ void MainWindow::MouseMove(const QPointF &scenePos)
//: Coords in status line: "X, Y (units)" //: Coords in status line: "X, Y (units)"
mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x()))) mouseCoordinate->setText(QString("%1, %2 (%3)").arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y()))) .arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())))
.arg(VDomDocument::UnitsToStr(qApp->patternUnit(), true))); .arg(UnitsToStr(qApp->patternUnit(), true)));
} }
} }
@ -3123,7 +3123,7 @@ void MainWindow::New()
AddPP(patternPieceName); AddPP(patternPieceName);
mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(VDomDocument::UnitsToStr(qApp->patternUnit(), true))); mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(qApp->patternUnit(), true)));
ui->toolBarOption->addWidget(mouseCoordinate); ui->toolBarOption->addWidget(mouseCoordinate);
m_curFileFormatVersion = VPatternConverter::PatternMaxVer; m_curFileFormatVersion = VPatternConverter::PatternMaxVer;

View File

@ -484,7 +484,7 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit VDomDocument::MUnit() const Unit VDomDocument::MUnit() const
{ {
Unit unit = VDomDocument::StrToUnits(UniqueTagText(TagUnit, unitCM)); Unit unit = StrToUnits(UniqueTagText(TagUnit, unitCM));
if (unit == Unit::Px) if (unit == Unit::Px)
{ {
@ -648,61 +648,6 @@ void VDomDocument::setXMLContent(const QString &fileName)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
Unit VDomDocument::StrToUnits(const QString &unit)
{
const QStringList units = QStringList() << unitMM << unitCM << unitINCH << unitPX;
Unit result = Unit::Cm;
switch (units.indexOf(unit))
{
case 0:// mm
result = Unit::Mm;
break;
case 2:// inch
result = Unit::Inch;
break;
case 3:// px
result = Unit::Px;
break;
case 1:// cm
default:
result = Unit::Cm;
break;
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UnitsToStr translate unit to string.
*
* This method used when need write unit in xml file and for showing unit in dialogs.
* @param unit curent unit
* @param translate true if need show translated name. Default value false.
* @return string reprezantation for unit.
*/
QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate)
{
QString result;
switch (unit)
{
case Unit::Mm:
translate ? result = QObject::tr("mm") : result = unitMM;
break;
case Unit::Inch:
translate ? result = QObject::tr("inch") : result = unitINCH;
break;
case Unit::Px:
translate ? result = QObject::tr("px") : result = unitPX;
break;
case Unit::Cm:
default:
translate ? result = QObject::tr("cm") : result = unitCM;
break;
}
return result;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::UnitsHelpString() QString VDomDocument::UnitsHelpString()
{ {

View File

@ -109,8 +109,6 @@ public:
static void ValidateXML(const QString &schema, const QString &fileName); static void ValidateXML(const QString &schema, const QString &fileName);
virtual void setXMLContent(const QString &fileName); virtual void setXMLContent(const QString &fileName);
static Unit StrToUnits(const QString &unit);
static QString UnitsToStr(const Unit &unit, const bool translate = false);
static QString UnitsHelpString(); static QString UnitsHelpString();
virtual bool SaveDocument(const QString &fileName, QString &error); virtual bool SaveDocument(const QString &fileName, QString &error);

View File

@ -677,6 +677,62 @@ PassmarkAngleType StringToPassmarkAngleType(const QString &value)
return PassmarkAngleType::Straightforward; return PassmarkAngleType::Straightforward;
} }
//---------------------------------------------------------------------------------------------------------------------
Unit StrToUnits(const QString &unit)
{
const QStringList units = QStringList() << unitMM << unitCM << unitINCH << unitPX;
Unit result = Unit::Cm;
switch (units.indexOf(unit))
{
case 0:// mm
result = Unit::Mm;
break;
case 2:// inch
result = Unit::Inch;
break;
case 3:// px
result = Unit::Px;
break;
case 1:// cm
default:
result = Unit::Cm;
break;
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UnitsToStr translate unit to string.
*
* This method used when need write unit in xml file and for showing unit in dialogs.
* @param unit curent unit
* @param translate true if need show translated name. Default value false.
* @return string reprezantation for unit.
*/
QString UnitsToStr(const Unit &unit, const bool translate)
{
QString result;
switch (unit)
{
case Unit::Mm:
translate ? result = QObject::tr("mm") : result = unitMM;
break;
case Unit::Inch:
translate ? result = QObject::tr("inch") : result = unitINCH;
break;
case Unit::Px:
translate ? result = QObject::tr("px") : result = unitPX;
break;
case Unit::Cm:
default:
translate ? result = QObject::tr("cm") : result = unitCM;
break;
}
return result;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void InitLanguages(QComboBox *combobox) void InitLanguages(QComboBox *combobox)
{ {

View File

@ -94,6 +94,11 @@ enum class PassmarkAngleType : unsigned char
QString PassmarkAngleTypeToString(PassmarkAngleType type); QString PassmarkAngleTypeToString(PassmarkAngleType type);
PassmarkAngleType StringToPassmarkAngleType(const QString &value); PassmarkAngleType StringToPassmarkAngleType(const QString &value);
Unit StrToUnits(const QString &unit);
QString UnitsToStr(const Unit &unit, const bool translate = false);
enum class PiecePathIncludeType : unsigned char enum class PiecePathIncludeType : unsigned char
{ {
AsMainPath = 0, AsMainPath = 0,

View File

@ -774,8 +774,7 @@ double VCommonSettings::GetDefaultSeamAllowance()
{ {
double defaultValue; double defaultValue;
//Unit globalUnit = VDomDocument::StrToUnits(GetUnit()); Unit globalUnit = StrToUnits(GetUnit());
Unit globalUnit = Unit::Cm; // just for test purpuses
switch (globalUnit) switch (globalUnit)
{ {

View File

@ -40,8 +40,6 @@
#include "../vlayout/vbank.h" #include "../vlayout/vbank.h"
class VDomDocument;
class VCommonSettings : public QSettings class VCommonSettings : public QSettings
{ {
Q_OBJECT Q_OBJECT

View File

@ -174,28 +174,28 @@ void DialogEditWrongFormula::ValChanged(int row)
const QString name = qApp->TrVars()->VarFromUser(item->text()); const QString name = qApp->TrVars()->VarFromUser(item->text());
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name); const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
SetDescription(item->text(), data->GetTableValue(name, qApp->patternType()), SetDescription(item->text(), data->GetTableValue(name, qApp->patternType()),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), stable->GetGuiText()); UnitsToStr(qApp->patternUnit(), true), stable->GetGuiText());
return; return;
} }
if (ui->radioButtonIncrements->isChecked()) if (ui->radioButtonIncrements->isChecked())
{ {
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text()); const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
SetDescription(item->text(), data->GetTableValue(item->text(), qApp->patternType()), SetDescription(item->text(), data->GetTableValue(item->text(), qApp->patternType()),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), incr->GetDescription()); UnitsToStr(qApp->patternUnit(), true), incr->GetDescription());
return; return;
} }
if (ui->radioButtonLengthLine->isChecked()) if (ui->radioButtonLengthLine->isChecked())
{ {
SetDescription(item->text(), SetDescription(item->text(),
*data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(), *data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Line length")); UnitsToStr(qApp->patternUnit(), true), tr("Line length"));
return; return;
} }
if (ui->radioButtonLengthSpline->isChecked()) if (ui->radioButtonLengthSpline->isChecked())
{ {
SetDescription(item->text(), SetDescription(item->text(),
*data->GetVariable<VCurveLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(), *data->GetVariable<VCurveLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Curve length")); UnitsToStr(qApp->patternUnit(), true), tr("Curve length"));
return; return;
} }
if (ui->radioButtonAngleLine->isChecked()) if (ui->radioButtonAngleLine->isChecked())
@ -209,7 +209,7 @@ void DialogEditWrongFormula::ValChanged(int row)
{ {
SetDescription(item->text(), SetDescription(item->text(),
*data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(), *data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Arc radius")); UnitsToStr(qApp->patternUnit(), true), tr("Arc radius"));
return; return;
} }
if (ui->radioButtonAnglesCurves->isChecked()) if (ui->radioButtonAnglesCurves->isChecked())

View File

@ -132,7 +132,7 @@ void DialogAlongLine::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -292,7 +292,7 @@ void DialogArc::RadiusChanged()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
labelResultCalculation = ui->labelResultRadius; labelResultCalculation = ui->labelResultRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius, postfix); ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius, postfix);
} }
@ -324,7 +324,7 @@ void DialogArc::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius()); dialog->SetFormula(GetRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius(dialog->GetFormula()); SetRadius(dialog->GetFormula());
@ -379,7 +379,7 @@ void DialogArc::CheckState()
void DialogArc::EvalRadius() void DialogArc::EvalRadius()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix); const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
if (radius < 0) if (radius < 0)

View File

@ -251,7 +251,7 @@ void DialogArcWithLength::RadiusChanged()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
labelResultCalculation = ui->labelResultRadius; labelResultCalculation = ui->labelResultRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagRadius, ui->plainTextEditRadius, timerRadius, postfix); ValFormulaChanged(flagRadius, ui->plainTextEditRadius, timerRadius, postfix);
} }
@ -268,7 +268,7 @@ void DialogArcWithLength::LengthChanged()
{ {
labelEditFormula = ui->labelEditLength; labelEditFormula = ui->labelEditLength;
labelResultCalculation = ui->labelResultLength; labelResultCalculation = ui->labelResultLength;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, postfix); ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, postfix);
} }
@ -278,7 +278,7 @@ void DialogArcWithLength::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius()); dialog->SetFormula(GetRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius(dialog->GetFormula()); SetRadius(dialog->GetFormula());
@ -306,7 +306,7 @@ void DialogArcWithLength::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit the arc length")); dialog->setWindowTitle(tr("Edit the arc length"));
dialog->SetFormula(GetLength()); dialog->SetFormula(GetLength());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetLength(dialog->GetFormula()); SetLength(dialog->GetFormula());
@ -367,7 +367,7 @@ void DialogArcWithLength::closeEvent(QCloseEvent *event)
void DialogArcWithLength::Radius() void DialogArcWithLength::Radius()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagRadius, ui->labelResultRadius, postfix); const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
if (radius < 0) if (radius < 0)
@ -385,7 +385,7 @@ void DialogArcWithLength::Radius()
void DialogArcWithLength::Length() void DialogArcWithLength::Length()
{ {
labelEditFormula = ui->labelEditLength; labelEditFormula = ui->labelEditLength;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal length = Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix); const qreal length = Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
if (qFuzzyIsNull(length)) if (qFuzzyIsNull(length))

View File

@ -129,7 +129,7 @@ void DialogBisector::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -90,7 +90,7 @@ void DialogCutArc::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -189,7 +189,7 @@ void DialogCutSpline::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -189,7 +189,7 @@ void DialogCutSplinePath::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -367,7 +367,7 @@ void DialogEllipticalArc::SetColor(const QString &value)
void DialogEllipticalArc::EvalRadiuses() void DialogEllipticalArc::EvalRadiuses()
{ {
labelEditFormula = ui->labelEditRadius1; labelEditFormula = ui->labelEditRadius1;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius_1 = Eval(ui->plainTextEditRadius1->toPlainText(), flagRadius1, ui->labelResultRadius1, postfix); const qreal radius_1 = Eval(ui->plainTextEditRadius1->toPlainText(), flagRadius1, ui->labelResultRadius1, postfix);
if (radius_1 < 0) if (radius_1 < 0)
@ -442,7 +442,7 @@ void DialogEllipticalArc::FXRadius1()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius1")); dialog->setWindowTitle(tr("Edit radius1"));
dialog->SetFormula(GetRadius1()); dialog->SetFormula(GetRadius1());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius1(dialog->GetFormula()); SetRadius1(dialog->GetFormula());
@ -456,7 +456,7 @@ void DialogEllipticalArc::FXRadius2()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius2")); dialog->setWindowTitle(tr("Edit radius2"));
dialog->SetFormula(GetRadius2()); dialog->SetFormula(GetRadius2());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius2(dialog->GetFormula()); SetRadius2(dialog->GetFormula());
@ -514,7 +514,7 @@ void DialogEllipticalArc::Radius1Changed()
{ {
labelEditFormula = ui->labelEditRadius1; labelEditFormula = ui->labelEditRadius1;
labelResultCalculation = ui->labelResultRadius1; labelResultCalculation = ui->labelResultRadius1;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagRadius1, ui->plainTextEditRadius1, timerRadius1, postfix); ValFormulaChanged(flagRadius1, ui->plainTextEditRadius1, timerRadius1, postfix);
} }
@ -526,7 +526,7 @@ void DialogEllipticalArc::Radius2Changed()
{ {
labelEditFormula = ui->labelEditRadius2; labelEditFormula = ui->labelEditRadius2;
labelResultCalculation = ui->labelResultRadius2; labelResultCalculation = ui->labelResultRadius2;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagRadius2, ui->plainTextEditRadius2, timerRadius2, postfix); ValFormulaChanged(flagRadius2, ui->plainTextEditRadius2, timerRadius2, postfix);
} }

View File

@ -164,7 +164,7 @@ void DialogEndLine::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -313,7 +313,7 @@ void DialogMove::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetLength()); dialog->SetFormula(GetLength());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetLength(dialog->GetFormula()); SetLength(dialog->GetFormula());
@ -415,6 +415,6 @@ void DialogMove::EvalAngle()
void DialogMove::EvalLength() void DialogMove::EvalLength()
{ {
labelEditFormula = ui->labelEditLength; labelEditFormula = ui->labelEditLength;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix); Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
} }

View File

@ -123,7 +123,7 @@ void DialogNormal::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -255,7 +255,7 @@ void DialogPointFromCircleAndTangent::CircleRadiusChanged()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
labelResultCalculation = ui->labelResultCircleRadius; labelResultCalculation = ui->labelResultCircleRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagCircleRadius, ui->plainTextEditRadius, timerCircleRadius, postfix); ValFormulaChanged(flagCircleRadius, ui->plainTextEditRadius, timerCircleRadius, postfix);
} }
@ -265,7 +265,7 @@ void DialogPointFromCircleAndTangent::FXCircleRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetCircleRadius()); dialog->SetFormula(GetCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCircleRadius(dialog->GetFormula()); SetCircleRadius(dialog->GetFormula());
@ -277,7 +277,7 @@ void DialogPointFromCircleAndTangent::FXCircleRadius()
void DialogPointFromCircleAndTangent::EvalCircleRadius() void DialogPointFromCircleAndTangent::EvalCircleRadius()
{ {
labelEditFormula = ui->labelEditRadius; labelEditFormula = ui->labelEditRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagCircleRadius, const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagCircleRadius,
ui->labelResultCircleRadius, postfix); ui->labelResultCircleRadius, postfix);

View File

@ -133,7 +133,7 @@ void DialogPointOfContact::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(getRadius()); dialog->SetFormula(getRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
setRadius(dialog->GetFormula()); setRadius(dialog->GetFormula());

View File

@ -301,7 +301,7 @@ void DialogPointOfIntersectionCircles::Circle1RadiusChanged()
{ {
labelEditFormula = ui->labelEditCircle1Radius; labelEditFormula = ui->labelEditCircle1Radius;
labelResultCalculation = ui->labelResultCircle1Radius; labelResultCalculation = ui->labelResultCircle1Radius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagCircle1Radius, ui->plainTextEditCircle1Radius, timerCircle1Radius, postfix); ValFormulaChanged(flagCircle1Radius, ui->plainTextEditCircle1Radius, timerCircle1Radius, postfix);
} }
@ -310,7 +310,7 @@ void DialogPointOfIntersectionCircles::Circle2RadiusChanged()
{ {
labelEditFormula = ui->labelEditCircle2Radius; labelEditFormula = ui->labelEditCircle2Radius;
labelResultCalculation = ui->labelResultCircle2Radius; labelResultCalculation = ui->labelResultCircle2Radius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagCircle2Radius, ui->plainTextEditCircle2Radius, timerCircle2Radius, postfix); ValFormulaChanged(flagCircle2Radius, ui->plainTextEditCircle2Radius, timerCircle2Radius, postfix);
} }
@ -320,7 +320,7 @@ void DialogPointOfIntersectionCircles::FXCircle1Radius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit first circle radius")); dialog->setWindowTitle(tr("Edit first circle radius"));
dialog->SetFormula(GetFirstCircleRadius()); dialog->SetFormula(GetFirstCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFirstCircleRadius(dialog->GetFormula()); SetFirstCircleRadius(dialog->GetFormula());
@ -334,7 +334,7 @@ void DialogPointOfIntersectionCircles::FXCircle2Radius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit second circle radius")); dialog->setWindowTitle(tr("Edit second circle radius"));
dialog->SetFormula(GetSecondCircleRadius()); dialog->SetFormula(GetSecondCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetSecondCircleRadius(dialog->GetFormula()); SetSecondCircleRadius(dialog->GetFormula());
@ -346,7 +346,7 @@ void DialogPointOfIntersectionCircles::FXCircle2Radius()
void DialogPointOfIntersectionCircles::EvalCircle1Radius() void DialogPointOfIntersectionCircles::EvalCircle1Radius()
{ {
labelEditFormula = ui->labelEditCircle1Radius; labelEditFormula = ui->labelEditCircle1Radius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditCircle1Radius->toPlainText(), flagCircle1Radius, const qreal radius = Eval(ui->plainTextEditCircle1Radius->toPlainText(), flagCircle1Radius,
ui->labelResultCircle1Radius, postfix); ui->labelResultCircle1Radius, postfix);
@ -365,7 +365,7 @@ void DialogPointOfIntersectionCircles::EvalCircle1Radius()
void DialogPointOfIntersectionCircles::EvalCircle2Radius() void DialogPointOfIntersectionCircles::EvalCircle2Radius()
{ {
labelEditFormula = ui->labelEditCircle2Radius; labelEditFormula = ui->labelEditCircle2Radius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditCircle2Radius->toPlainText(), flagCircle2Radius, const qreal radius = Eval(ui->plainTextEditCircle2Radius->toPlainText(), flagCircle2Radius,
ui->labelResultCircle2Radius, postfix); ui->labelResultCircle2Radius, postfix);

View File

@ -131,7 +131,7 @@ void DialogShoulderPoint::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -268,7 +268,7 @@ void DialogSpline::Length1Changed()
{ {
labelEditFormula = ui->labelEditLength1; labelEditFormula = ui->labelEditLength1;
labelResultCalculation = ui->labelResultLength1; labelResultCalculation = ui->labelResultLength1;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagLength1, ui->plainTextEditLength1F, timerLength1, postfix); ValFormulaChanged(flagLength1, ui->plainTextEditLength1F, timerLength1, postfix);
} }
@ -277,7 +277,7 @@ void DialogSpline::Length2Changed()
{ {
labelEditFormula = ui->labelEditLength2; labelEditFormula = ui->labelEditLength2;
labelResultCalculation = ui->labelResultLength2; labelResultCalculation = ui->labelResultLength2;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagLength2, ui->plainTextEditLength2F, timerLength2, postfix); ValFormulaChanged(flagLength2, ui->plainTextEditLength2F, timerLength2, postfix);
} }
@ -335,7 +335,7 @@ void DialogSpline::FXLength1()
QString length1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), QString length1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(),
qApp->Settings()->GetOsSeparator()); qApp->Settings()->GetOsSeparator());
dialog->SetFormula(length1F); dialog->SetFormula(length1F);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
@ -358,7 +358,7 @@ void DialogSpline::FXLength2()
QString length2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), QString length2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(),
qApp->Settings()->GetOsSeparator()); qApp->Settings()->GetOsSeparator());
dialog->SetFormula(length2F); dialog->SetFormula(length2F);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
@ -403,7 +403,7 @@ void DialogSpline::EvalAngle2()
void DialogSpline::EvalLength1() void DialogSpline::EvalLength1()
{ {
labelEditFormula = ui->labelEditLength1; labelEditFormula = ui->labelEditLength1;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1, ui->labelResultLength1, postfix, const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1, ui->labelResultLength1, postfix,
false); false);
@ -422,7 +422,7 @@ void DialogSpline::EvalLength1()
void DialogSpline::EvalLength2() void DialogSpline::EvalLength2()
{ {
labelEditFormula = ui->labelEditLength2; labelEditFormula = ui->labelEditLength2;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2, ui->labelResultLength2, postfix, const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2, ui->labelResultLength2, postfix,
false); false);

View File

@ -523,7 +523,7 @@ void DialogSplinePath::FXLength1()
qApp->Settings()->GetOsSeparator()); qApp->Settings()->GetOsSeparator());
dialog->SetFormula(length1F); dialog->SetFormula(length1F);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
@ -548,7 +548,7 @@ void DialogSplinePath::FXLength2()
qApp->Settings()->GetOsSeparator()); qApp->Settings()->GetOsSeparator());
dialog->SetFormula(length2F); dialog->SetFormula(length2F);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator()); length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
@ -611,7 +611,7 @@ void DialogSplinePath::EvalLength1()
} }
labelEditFormula = ui->labelEditLength1; labelEditFormula = ui->labelEditLength1;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1[row], ui->labelResultLength1, const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1[row], ui->labelResultLength1,
postfix, false); postfix, false);
@ -642,7 +642,7 @@ void DialogSplinePath::EvalLength2()
} }
labelEditFormula = ui->labelEditLength2; labelEditFormula = ui->labelEditLength2;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2[row], ui->labelResultLength2, const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2[row], ui->labelResultLength2,
postfix, false); postfix, false);

View File

@ -1222,7 +1222,7 @@ void DialogTool::EvalFormula()
{ {
SCASSERT(plainTextEditFormula != nullptr) SCASSERT(plainTextEditFormula != nullptr)
SCASSERT(labelResultCalculation != nullptr) SCASSERT(labelResultCalculation != nullptr)
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch) const QString postfix = UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch)
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false); Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
} }

View File

@ -554,7 +554,7 @@ void DialogPiecePath::PassmarkAngleTypeChanged(int id)
void DialogPiecePath::EvalWidth() void DialogPiecePath::EvalWidth()
{ {
labelEditFormula = ui->labelEditWidth; labelEditFormula = ui->labelEditWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidth->toPlainText(); const QString formula = ui->plainTextEditFormulaWidth->toPlainText();
m_saWidth = Eval(formula, flagFormula, ui->labelResultWidth, postfix, false, true); m_saWidth = Eval(formula, flagFormula, ui->labelResultWidth, postfix, false, true);
@ -574,7 +574,7 @@ void DialogPiecePath::EvalWidth()
void DialogPiecePath::EvalWidthBefore() void DialogPiecePath::EvalWidthBefore()
{ {
labelEditFormula = ui->labelEditBefore; labelEditFormula = ui->labelEditBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText(); QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
bool flagFormula = false; // fake flag bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultBefore, postfix, false, true); Eval(formula, flagFormula, ui->labelResultBefore, postfix, false, true);
@ -592,7 +592,7 @@ void DialogPiecePath::EvalWidthBefore()
void DialogPiecePath::EvalWidthAfter() void DialogPiecePath::EvalWidthAfter()
{ {
labelEditFormula = ui->labelEditAfter; labelEditFormula = ui->labelEditAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText(); QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
bool flagFormula = false; // fake flag bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultAfter, postfix, false, true); Eval(formula, flagFormula, ui->labelResultAfter, postfix, false, true);
@ -613,7 +613,7 @@ void DialogPiecePath::FXWidth()
dialog->setWindowTitle(tr("Edit seam allowance width")); dialog->setWindowTitle(tr("Edit seam allowance width"));
dialog->SetFormula(GetFormulaSAWidth()); dialog->SetFormula(GetFormulaSAWidth());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormulaSAWidth(dialog->GetFormula()); SetFormulaSAWidth(dialog->GetFormula());
@ -628,7 +628,7 @@ void DialogPiecePath::FXWidthBefore()
dialog->setWindowTitle(tr("Edit seam allowance width before")); dialog->setWindowTitle(tr("Edit seam allowance width before"));
dialog->SetFormula(GetFormulaSAWidthBefore()); dialog->SetFormula(GetFormulaSAWidthBefore());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCurrentSABefore(dialog->GetFormula()); SetCurrentSABefore(dialog->GetFormula());
@ -643,7 +643,7 @@ void DialogPiecePath::FXWidthAfter()
dialog->setWindowTitle(tr("Edit seam allowance width after")); dialog->setWindowTitle(tr("Edit seam allowance width after"));
dialog->SetFormula(GetFormulaSAWidthAfter()); dialog->SetFormula(GetFormulaSAWidthAfter());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCurrentSAAfter(dialog->GetFormula()); SetCurrentSAAfter(dialog->GetFormula());
@ -656,7 +656,7 @@ void DialogPiecePath::WidthChanged()
{ {
labelEditFormula = ui->labelEditWidth; labelEditFormula = ui->labelEditWidth;
labelResultCalculation = ui->labelResultWidth; labelResultCalculation = ui->labelResultWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidth, m_timerWidth, postfix); ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidth, m_timerWidth, postfix);
} }
@ -665,7 +665,7 @@ void DialogPiecePath::WidthBeforeChanged()
{ {
labelEditFormula = ui->labelEditBefore; labelEditFormula = ui->labelEditBefore;
labelResultCalculation = ui->labelResultBefore; labelResultCalculation = ui->labelResultBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix); ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
} }
@ -675,7 +675,7 @@ void DialogPiecePath::WidthAfterChanged()
{ {
labelEditFormula = ui->labelEditAfter; labelEditFormula = ui->labelEditAfter;
labelResultCalculation = ui->labelResultAfter; labelResultCalculation = ui->labelResultAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix); ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
} }

View File

@ -1305,7 +1305,7 @@ void DialogSeamAllowance::UpdateGrainlineValues()
{ {
plbVal = uiTabGrainline->labelLen; plbVal = uiTabGrainline->labelLen;
plbText = uiTabGrainline->labelEditLen; plbText = uiTabGrainline->labelEditLen;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = QLatin1String(" ") + UnitsToStr(qApp->patternUnit());
} }
plbVal->setToolTip(tr("Value")); plbVal->setToolTip(tr("Value"));
@ -1375,13 +1375,13 @@ void DialogSeamAllowance::UpdateDetailLabelValues()
{ {
plbVal = uiTabLabels->labelDLWidth; plbVal = uiTabLabels->labelDLWidth;
plbText = uiTabLabels->labelEditDLWidth; plbText = uiTabLabels->labelEditDLWidth;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = QLatin1String(" ") + UnitsToStr(qApp->patternUnit());
} }
else if (i == 1) else if (i == 1)
{ {
plbVal = uiTabLabels->labelDLHeight; plbVal = uiTabLabels->labelDLHeight;
plbText = uiTabLabels->labelEditDLHeight; plbText = uiTabLabels->labelEditDLHeight;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = QLatin1String(" ") + UnitsToStr(qApp->patternUnit());
} }
else else
{ {
@ -1460,13 +1460,13 @@ void DialogSeamAllowance::UpdatePatternLabelValues()
{ {
plbVal = uiTabLabels->labelPLWidth; plbVal = uiTabLabels->labelPLWidth;
plbText = uiTabLabels->labelEditPLWidth; plbText = uiTabLabels->labelEditPLWidth;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = QLatin1String(" ") + UnitsToStr(qApp->patternUnit());
} }
else if (i == 1) else if (i == 1)
{ {
plbVal = uiTabLabels->labelPLHeight; plbVal = uiTabLabels->labelPLHeight;
plbText = uiTabLabels->labelEditPLHeight; plbText = uiTabLabels->labelEditPLHeight;
qsUnit = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = QLatin1String(" ") + UnitsToStr(qApp->patternUnit());
} }
else else
{ {
@ -1868,7 +1868,7 @@ void DialogSeamAllowance::ResetLabelsWarning()
void DialogSeamAllowance::EvalWidth() void DialogSeamAllowance::EvalWidth()
{ {
labelEditFormula = uiTabPaths->labelEditWidth; labelEditFormula = uiTabPaths->labelEditWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const QString formula = uiTabPaths->plainTextEditFormulaWidth->toPlainText(); const QString formula = uiTabPaths->plainTextEditFormulaWidth->toPlainText();
m_saWidth = Eval(formula, flagFormula, uiTabPaths->labelResultWidth, postfix, false, true); m_saWidth = Eval(formula, flagFormula, uiTabPaths->labelResultWidth, postfix, false, true);
@ -1888,7 +1888,7 @@ void DialogSeamAllowance::EvalWidth()
void DialogSeamAllowance::EvalWidthBefore() void DialogSeamAllowance::EvalWidthBefore()
{ {
labelEditFormula = uiTabPaths->labelEditBefore; labelEditFormula = uiTabPaths->labelEditBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const QString formula = uiTabPaths->plainTextEditFormulaWidthBefore->toPlainText(); const QString formula = uiTabPaths->plainTextEditFormulaWidthBefore->toPlainText();
bool flagFormula = false; // fake flag bool flagFormula = false; // fake flag
Eval(formula, flagFormula, uiTabPaths->labelResultBefore, postfix, false, true); Eval(formula, flagFormula, uiTabPaths->labelResultBefore, postfix, false, true);
@ -1902,7 +1902,7 @@ void DialogSeamAllowance::EvalWidthBefore()
void DialogSeamAllowance::EvalWidthAfter() void DialogSeamAllowance::EvalWidthAfter()
{ {
labelEditFormula = uiTabPaths->labelEditAfter; labelEditFormula = uiTabPaths->labelEditAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
const QString formula = uiTabPaths->plainTextEditFormulaWidthAfter->toPlainText(); const QString formula = uiTabPaths->plainTextEditFormulaWidthAfter->toPlainText();
bool flagFormula = false; // fake flag bool flagFormula = false; // fake flag
Eval(formula, flagFormula, uiTabPaths->labelResultAfter, postfix, false, true); Eval(formula, flagFormula, uiTabPaths->labelResultAfter, postfix, false, true);
@ -1919,7 +1919,7 @@ void DialogSeamAllowance::FXWidth()
dialog->setWindowTitle(tr("Edit seam allowance width")); dialog->setWindowTitle(tr("Edit seam allowance width"));
dialog->SetFormula(GetFormulaSAWidth()); dialog->SetFormula(GetFormulaSAWidth());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormulaSAWidth(dialog->GetFormula()); SetFormulaSAWidth(dialog->GetFormula());
@ -1934,7 +1934,7 @@ void DialogSeamAllowance::FXWidthBefore()
dialog->setWindowTitle(tr("Edit seam allowance width before")); dialog->setWindowTitle(tr("Edit seam allowance width before"));
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore)); dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore));
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCurrentSABefore(dialog->GetFormula()); SetCurrentSABefore(dialog->GetFormula());
@ -1949,7 +1949,7 @@ void DialogSeamAllowance::FXWidthAfter()
dialog->setWindowTitle(tr("Edit seam allowance width after")); dialog->setWindowTitle(tr("Edit seam allowance width after"));
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter)); dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter));
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCurrentSAAfter(dialog->GetFormula()); SetCurrentSAAfter(dialog->GetFormula());
@ -1962,7 +1962,7 @@ void DialogSeamAllowance::WidthChanged()
{ {
labelEditFormula = uiTabPaths->labelEditWidth; labelEditFormula = uiTabPaths->labelEditWidth;
labelResultCalculation = uiTabPaths->labelResultWidth; labelResultCalculation = uiTabPaths->labelResultWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidth, m_timerWidth, postfix); ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidth, m_timerWidth, postfix);
} }
@ -1971,7 +1971,7 @@ void DialogSeamAllowance::WidthBeforeChanged()
{ {
labelEditFormula = uiTabPaths->labelEditBefore; labelEditFormula = uiTabPaths->labelEditBefore;
labelResultCalculation = uiTabPaths->labelResultBefore; labelResultCalculation = uiTabPaths->labelResultBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; bool flagFormula = false;
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix); ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
} }
@ -1981,7 +1981,7 @@ void DialogSeamAllowance::WidthAfterChanged()
{ {
labelEditFormula = uiTabPaths->labelEditAfter; labelEditFormula = uiTabPaths->labelEditAfter;
labelResultCalculation = uiTabPaths->labelResultAfter; labelResultCalculation = uiTabPaths->labelResultAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; bool flagFormula = false;
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix); ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
} }
@ -2525,8 +2525,15 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance); connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough. // init the default seam allowance, convert the value if app unit is different than pattern unit
m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnit()); m_saWidth = qApp->Settings()->GetDefaultSeamAllowance();
Unit defaultUnit = StrToUnits(qApp->Settings()->GetUnit());
Unit patternUnit = qApp->patternUnit();
if(defaultUnit != patternUnit)
{
m_saWidth = UnitConvertor(m_saWidth, defaultUnit, patternUnit);
}
uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth)); uiTabPaths->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth));
InitNodesList(); InitNodesList();

View File

@ -36,7 +36,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabMainPath"> <widget class="QWidget" name="tabMainPath">
<attribute name="title"> <attribute name="title">

View File

@ -262,7 +262,7 @@ VFormula VToolMove::GetFormulaLength() const
VFormula fLength(formulaLength, getData()); VFormula fLength(formulaLength, getData());
fLength.setCheckZero(true); fLength.setCheckZero(true);
fLength.setToolId(id); fLength.setToolId(id);
fLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
return fLength; return fLength;
} }

View File

@ -227,7 +227,7 @@ VFormula VToolArc::GetFormulaRadius() const
VFormula radius(arc->GetFormulaRadius(), getData()); VFormula radius(arc->GetFormulaRadius(), getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }

View File

@ -196,7 +196,7 @@ VFormula VToolArcWithLength::GetFormulaRadius() const
VFormula radius(arc->GetFormulaRadius(), getData()); VFormula radius(arc->GetFormulaRadius(), getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }
@ -253,7 +253,7 @@ VFormula VToolArcWithLength::GetFormulaLength() const
VFormula radius(arc->GetFormulaLength(), getData()); VFormula radius(arc->GetFormulaLength(), getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }

View File

@ -240,7 +240,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius1() const
VFormula radius1(elArc->GetFormulaRadius1(), getData()); VFormula radius1(elArc->GetFormulaRadius1(), getData());
radius1.setCheckZero(true); radius1.setCheckZero(true);
radius1.setToolId(id); radius1.setToolId(id);
radius1.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius1.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius1; return radius1;
} }
@ -268,7 +268,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius2() const
VFormula radius2(elArc->GetFormulaRadius2(), getData()); VFormula radius2(elArc->GetFormulaRadius2(), getData());
radius2.setCheckZero(true); radius2.setCheckZero(true);
radius2.setToolId(id); radius2.setToolId(id);
radius2.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius2.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius2; return radius2;
} }

View File

@ -99,7 +99,7 @@ VFormula VToolCut::GetFormula() const
VFormula val(formula, getData()); VFormula val(formula, getData());
val.setCheckZero(true); val.setCheckZero(true);
val.setToolId(id); val.setToolId(id);
val.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); val.setPostfix(UnitsToStr(qApp->patternUnit()));
return val; return val;
} }

View File

@ -214,7 +214,7 @@ VFormula VToolLinePoint::GetFormulaLength() const
VFormula fLength(formulaLength, this->getData()); VFormula fLength(formulaLength, this->getData());
fLength.setCheckZero(true); fLength.setCheckZero(true);
fLength.setToolId(id); fLength.setToolId(id);
fLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
return fLength; return fLength;
} }

View File

@ -230,7 +230,7 @@ VFormula VToolPointFromCircleAndTangent::GetCircleRadius() const
VFormula radius(circleRadius, getData()); VFormula radius(circleRadius, getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }

View File

@ -409,7 +409,7 @@ VFormula VToolPointOfContact::getArcRadius() const
VFormula radius(arcRadius, this->getData()); VFormula radius(arcRadius, this->getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }

View File

@ -245,7 +245,7 @@ VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const
VFormula radius(firstCircleRadius, getData()); VFormula radius(firstCircleRadius, getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }
@ -269,7 +269,7 @@ VFormula VToolPointOfIntersectionCircles::GetSecondCircleRadius() const
VFormula radius(secondCircleRadius, getData()); VFormula radius(secondCircleRadius, getData());
radius.setCheckZero(true); radius.setCheckZero(true);
radius.setToolId(id); radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit())); radius.setPostfix(UnitsToStr(qApp->patternUnit()));
return radius; return radius;
} }

View File

@ -117,7 +117,7 @@ void VisToolMove::RefreshGeometry()
DrawLine(this, line, supportColor2, Qt::DashLine); DrawLine(this, line, supportColor2, Qt::DashLine);
DrawPoint(pointFinish, line.p2(), supportColor); DrawPoint(pointFinish, line.p2(), supportColor);
static const QString prefix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); static const QString prefix = UnitsToStr(qApp->patternUnit(), true);
Visualization::toolTip = tr("Length = %1%2, angle = %3°, <b>Shift</b> - sticking angle, " Visualization::toolTip = tr("Length = %1%2, angle = %3°, <b>Shift</b> - sticking angle, "
"<b>Mouse click</b> - finish creation") "<b>Mouse click</b> - finish creation")
.arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)), .arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)),

View File

@ -78,7 +78,7 @@ void VisToolEndLine::RefreshGeometry()
DrawPoint(point, line.p2(), mainColor); DrawPoint(point, line.p2(), mainColor);
} }
DrawLine(this, line, mainColor, lineStyle); DrawLine(this, line, mainColor, lineStyle);
static const QString prefix = VDomDocument::UnitsToStr(qApp->patternUnit(), true); static const QString prefix = UnitsToStr(qApp->patternUnit(), true);
Visualization::toolTip = tr("<b>Point at distance and angle</b>: angle = %1°, length = %2%3; " Visualization::toolTip = tr("<b>Point at distance and angle</b>: angle = %1°, length = %2%3; "
"<b>Shift</b> - sticking angle, <b>Enter</b> - finish creation") "<b>Shift</b> - sticking angle, <b>Enter</b> - finish creation")
.arg(this->line().angle()) .arg(this->line().angle())