Better way check values in dialog arc. Issue 193.
--HG-- branch : develop
This commit is contained in:
parent
22f52e4101
commit
cf36ec0b09
|
@ -38,7 +38,7 @@
|
||||||
* I took idea from this article http://ololoepepe.blogspot.com/2013/08/qt.html.
|
* I took idea from this article http://ololoepepe.blogspot.com/2013/08/qt.html.
|
||||||
* As you know, if wrap string to a function translate, it will be marked for translation. No matter what namespace
|
* As you know, if wrap string to a function translate, it will be marked for translation. No matter what namespace
|
||||||
* contains this function. In class Translation used this circumstance.
|
* contains this function. In class Translation used this circumstance.
|
||||||
* It is mean never change name of method translate!!!!!.
|
* This mean never change name of method translate!!!!!.
|
||||||
* Instead of using QT_TRANSLATE_NOOP3 macros we can store strings in QMap.
|
* Instead of using QT_TRANSLATE_NOOP3 macros we can store strings in QMap.
|
||||||
* Example:
|
* Example:
|
||||||
* create map and fill up its
|
* create map and fill up its
|
||||||
|
|
|
@ -86,8 +86,8 @@ void ConfigurationPage::Apply()
|
||||||
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
|
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
|
||||||
qApp->getSettings()->setValue("configuration/locale", locale);
|
qApp->getSettings()->setValue("configuration/locale", locale);
|
||||||
langChanged = false;
|
langChanged = false;
|
||||||
QString text = QString(tr("Setup user interface language updated and will be used the next time start") + " " +
|
QString text = tr("Setup user interface language updated and will be used the next time start") + " " +
|
||||||
QApplication::applicationName());
|
QApplication::applicationName();
|
||||||
QMessageBox::information(this, QApplication::applicationName(), text);
|
QMessageBox::information(this, QApplication::applicationName(), text);
|
||||||
}
|
}
|
||||||
if (this->unitChanged)
|
if (this->unitChanged)
|
||||||
|
@ -95,7 +95,7 @@ void ConfigurationPage::Apply()
|
||||||
QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
|
QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
|
||||||
qApp->getSettings()->setValue("configuration/unit", unit);
|
qApp->getSettings()->setValue("configuration/unit", unit);
|
||||||
this->unitChanged = false;
|
this->unitChanged = false;
|
||||||
QString text = QString(tr("Default unit updated and will be used the next pattern creation"));
|
QString text = tr("Default unit updated and will be used the next pattern creation");
|
||||||
QMessageBox::information(this, QApplication::applicationName(), text);
|
QMessageBox::information(this, QApplication::applicationName(), text);
|
||||||
}
|
}
|
||||||
if (labelLangChanged)
|
if (labelLangChanged)
|
||||||
|
|
|
@ -201,7 +201,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
||||||
if (domElem.isElement() == false)
|
if (domElem.isElement() == false)
|
||||||
{
|
{
|
||||||
qDebug()<<"Can't find element by id"<<Q_FUNC_INFO;
|
qDebug()<<"Can't find element by id"<<Q_FUNC_INFO;
|
||||||
return QString(tr("Can't create record."));
|
return tr("Can't create record.");
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -291,7 +291,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
|
qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
|
||||||
return QString(tr("Can't create record."));
|
return tr("Can't create record.");
|
||||||
}
|
}
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
@ -397,14 +397,14 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"Got wrong tool type. Ignore.";
|
qDebug()<<"Got wrong tool type. Ignore.";
|
||||||
return QString(tr("Can't create record."));
|
return tr("Can't create record.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
qDebug()<<e.ErrorMessage()<<Q_FUNC_INFO;
|
qDebug()<<e.ErrorMessage()<<Q_FUNC_INFO;
|
||||||
return QString(tr("Can't create record."));
|
return tr("Can't create record.");
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,7 +458,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
Changes += currentChange->element->GettreeNodeName();
|
Changes += currentChange->element->GettreeNodeName();
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||||
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
currentChange->element->GettreeNodeValue(): tr("<no value>");
|
||||||
Changes += "\n";
|
Changes += "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -466,9 +466,9 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
||||||
{
|
{
|
||||||
Changes += QString("Modified type %1 : ").arg(nodetype);
|
Changes += QString("Modified type %1 : ").arg(nodetype);
|
||||||
Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged"));
|
Changes += (currentChange->changedText) ? *currentChange->newText : tr("Unchanged");
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged"));
|
Changes += (currentChange->changedValue) ? *currentChange->newValue: tr("Unchanged");
|
||||||
Changes += "\n";
|
Changes += "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -479,7 +479,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
||||||
Changes += currentChange->element->GettreeNodeName();
|
Changes += currentChange->element->GettreeNodeName();
|
||||||
Changes += "/";
|
Changes += "/";
|
||||||
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||||
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
currentChange->element->GettreeNodeValue(): tr("<no value>");
|
||||||
Changes += "\n";
|
Changes += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
|
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
|
||||||
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()),
|
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()),
|
||||||
f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr),
|
f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr),
|
||||||
angleF1(0), angleF2(0)
|
angleF1(INT_MIN), angleF2(INT_MIN)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -352,7 +352,17 @@ void DialogArc::EvalRadius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRadius;
|
labelEditFormula = ui->labelEditRadius;
|
||||||
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
||||||
Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
|
const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
|
||||||
|
|
||||||
|
if (radius < 0)
|
||||||
|
{
|
||||||
|
flagRadius = false;
|
||||||
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
|
ui->labelResultRadius->setText(tr("Error"));
|
||||||
|
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
|
||||||
|
DialogArc::CheckState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -394,14 +404,21 @@ void DialogArc::ShowLineAngles()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::CheckAngles()
|
void DialogArc::CheckAngles()
|
||||||
{
|
{
|
||||||
|
if (angleF1 == INT_MIN || angleF2 == INT_MIN)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (qFuzzyCompare(angleF1 + 1, angleF2 + 1))
|
if (qFuzzyCompare(angleF1 + 1, angleF2 + 1))
|
||||||
{
|
{
|
||||||
flagF1 = false;
|
flagF1 = false;
|
||||||
ChangeColor(ui->labelEditF1, Qt::red);
|
ChangeColor(ui->labelEditF1, Qt::red);
|
||||||
|
ui->labelResultF1->setText(tr("Error"));
|
||||||
ui->labelResultF1->setToolTip(tr("Angles equal"));
|
ui->labelResultF1->setToolTip(tr("Angles equal"));
|
||||||
|
|
||||||
flagF2 = false;
|
flagF2 = false;
|
||||||
ChangeColor(ui->labelEditF2, Qt::red);
|
ChangeColor(ui->labelEditF2, Qt::red);
|
||||||
|
ui->labelResultF2->setText(tr("Error"));
|
||||||
ui->labelResultF2->setToolTip(tr("Angles equal"));
|
ui->labelResultF2->setToolTip(tr("Angles equal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
||||||
CheckState();
|
CheckState();
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
labelResultCalculation->setText(tr("Error"));
|
labelResultCalculation->setText(tr("Error"));
|
||||||
|
labelResultCalculation->setToolTip(tr("Empty field"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer->start(1000);
|
timer->start(1000);
|
||||||
|
@ -458,6 +459,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
|
||||||
CheckState();
|
CheckState();
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(labelEditFormula, Qt::red);
|
||||||
labelResultCalculation->setText(tr("Error"));
|
labelResultCalculation->setText(tr("Error"));
|
||||||
|
labelResultCalculation->setToolTip(tr("Empty field"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
|
@ -478,7 +480,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
|
||||||
SCASSERT(label != nullptr);
|
SCASSERT(label != nullptr);
|
||||||
SCASSERT(labelEditFormula != nullptr);
|
SCASSERT(labelEditFormula != nullptr);
|
||||||
|
|
||||||
qreal result = 0;
|
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
||||||
|
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -908,7 +910,7 @@ void DialogTool::EvalFormula()
|
||||||
SCASSERT(plainTextEditFormula != nullptr);
|
SCASSERT(plainTextEditFormula != nullptr);
|
||||||
SCASSERT(labelResultCalculation != nullptr);
|
SCASSERT(labelResultCalculation != nullptr);
|
||||||
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());
|
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());
|
||||||
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix);
|
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -214,10 +214,13 @@ void VToolArc::setFormulaRadius(const VFormula &value)
|
||||||
{
|
{
|
||||||
if (value.error() == false)
|
if (value.error() == false)
|
||||||
{
|
{
|
||||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
{
|
||||||
arc->SetFormulaRadius(value);
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||||
SaveOption(obj);
|
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||||
|
arc->SetFormulaRadius(value);
|
||||||
|
SaveOption(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +244,12 @@ void VToolArc::setFormulaF1(const VFormula &value)
|
||||||
{
|
{
|
||||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||||
arc->SetFormulaF1(value);
|
|
||||||
SaveOption(obj);
|
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF2() + 1)==false)// Angles can't be equal
|
||||||
|
{
|
||||||
|
arc->SetFormulaF1(value);
|
||||||
|
SaveOption(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,8 +273,11 @@ void VToolArc::setFormulaF2(const VFormula &value)
|
||||||
{
|
{
|
||||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||||
arc->SetFormulaF2(value);
|
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF1() + 1)==false)// Angles can't be equal
|
||||||
SaveOption(obj);
|
{
|
||||||
|
arc->SetFormulaF2(value);
|
||||||
|
SaveOption(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,12 +84,12 @@ void VisToolSplinePath::RefreshGeometry()
|
||||||
}
|
}
|
||||||
if (path.CountPoint() < 3)
|
if (path.CountPoint() < 3)
|
||||||
{
|
{
|
||||||
Visualization::toolTip = QString(tr("<b>Curve path</b>: select three or more points"));
|
Visualization::toolTip = tr("<b>Curve path</b>: select three or more points");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Visualization::toolTip = QString(tr("<b>Curve path</b>: select three or more points, "
|
Visualization::toolTip = tr("<b>Curve path</b>: select three or more points, "
|
||||||
"<b>Enter</b> - finish creation"));
|
"<b>Enter</b> - finish creation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user