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.
|
||||
* 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.
|
||||
* 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.
|
||||
* Example:
|
||||
* create map and fill up its
|
||||
|
|
|
@ -86,8 +86,8 @@ void ConfigurationPage::Apply()
|
|||
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
|
||||
qApp->getSettings()->setValue("configuration/locale", locale);
|
||||
langChanged = false;
|
||||
QString text = QString(tr("Setup user interface language updated and will be used the next time start") + " " +
|
||||
QApplication::applicationName());
|
||||
QString text = tr("Setup user interface language updated and will be used the next time start") + " " +
|
||||
QApplication::applicationName();
|
||||
QMessageBox::information(this, QApplication::applicationName(), text);
|
||||
}
|
||||
if (this->unitChanged)
|
||||
|
@ -95,7 +95,7 @@ void ConfigurationPage::Apply()
|
|||
QString unit = qvariant_cast<QString>(this->unitCombo->itemData(this->unitCombo->currentIndex()));
|
||||
qApp->getSettings()->setValue("configuration/unit", unit);
|
||||
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);
|
||||
}
|
||||
if (labelLangChanged)
|
||||
|
|
|
@ -201,7 +201,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
if (domElem.isElement() == false)
|
||||
{
|
||||
qDebug()<<"Can't find element by id"<<Q_FUNC_INFO;
|
||||
return QString(tr("Can't create record."));
|
||||
return tr("Can't create record.");
|
||||
}
|
||||
try
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
else
|
||||
{
|
||||
qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
|
||||
return QString(tr("Can't create record."));
|
||||
return tr("Can't create record.");
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
@ -397,14 +397,14 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
break;
|
||||
default:
|
||||
qDebug()<<"Got wrong tool type. Ignore.";
|
||||
return QString(tr("Can't create record."));
|
||||
return tr("Can't create record.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
qDebug()<<e.ErrorMessage()<<Q_FUNC_INFO;
|
||||
return QString(tr("Can't create record."));
|
||||
return tr("Can't create record.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
|||
Changes += currentChange->element->GettreeNodeName();
|
||||
Changes += "/";
|
||||
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
||||
currentChange->element->GettreeNodeValue(): tr("<no value>");
|
||||
Changes += "\n";
|
||||
}
|
||||
else
|
||||
|
@ -466,9 +466,9 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
|||
if (currentChange->type == DialogPatternXmlEdit::ChangeTypeModify)
|
||||
{
|
||||
Changes += QString("Modified type %1 : ").arg(nodetype);
|
||||
Changes += (currentChange->changedText) ? *currentChange->newText : QString(tr("Unchanged"));
|
||||
Changes += (currentChange->changedText) ? *currentChange->newText : tr("Unchanged");
|
||||
Changes += "/";
|
||||
Changes += (currentChange->changedValue) ? *currentChange->newValue: QString(tr("Unchanged"));
|
||||
Changes += (currentChange->changedValue) ? *currentChange->newValue: tr("Unchanged");
|
||||
Changes += "\n";
|
||||
}
|
||||
else
|
||||
|
@ -479,7 +479,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked()
|
|||
Changes += currentChange->element->GettreeNodeName();
|
||||
Changes += "/";
|
||||
Changes += (currentChange->element->GettreeNodeValueSet()) ?
|
||||
currentChange->element->GettreeNodeValue(): QString(tr("<no value>"));
|
||||
currentChange->element->GettreeNodeValue(): tr("<no value>");
|
||||
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),
|
||||
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()),
|
||||
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);
|
||||
|
||||
|
@ -352,7 +352,17 @@ void DialogArc::EvalRadius()
|
|||
{
|
||||
labelEditFormula = ui->labelEditRadius;
|
||||
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()
|
||||
{
|
||||
if (angleF1 == INT_MIN || angleF2 == INT_MIN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (qFuzzyCompare(angleF1 + 1, angleF2 + 1))
|
||||
{
|
||||
flagF1 = false;
|
||||
ChangeColor(ui->labelEditF1, Qt::red);
|
||||
ui->labelResultF1->setText(tr("Error"));
|
||||
ui->labelResultF1->setToolTip(tr("Angles equal"));
|
||||
|
||||
flagF2 = false;
|
||||
ChangeColor(ui->labelEditF2, Qt::red);
|
||||
ui->labelResultF2->setText(tr("Error"));
|
||||
ui->labelResultF2->setToolTip(tr("Angles equal"));
|
||||
}
|
||||
|
||||
|
|
|
@ -441,6 +441,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
|||
CheckState();
|
||||
ChangeColor(labelEditFormula, Qt::red);
|
||||
labelResultCalculation->setText(tr("Error"));
|
||||
labelResultCalculation->setToolTip(tr("Empty field"));
|
||||
return;
|
||||
}
|
||||
timer->start(1000);
|
||||
|
@ -458,6 +459,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
|
|||
CheckState();
|
||||
ChangeColor(labelEditFormula, Qt::red);
|
||||
labelResultCalculation->setText(tr("Error"));
|
||||
labelResultCalculation->setToolTip(tr("Empty field"));
|
||||
return;
|
||||
}
|
||||
timer->setSingleShot(true);
|
||||
|
@ -478,7 +480,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
|
|||
SCASSERT(label != nullptr);
|
||||
SCASSERT(labelEditFormula != nullptr);
|
||||
|
||||
qreal result = 0;
|
||||
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
||||
|
||||
if (text.isEmpty())
|
||||
{
|
||||
|
@ -908,7 +910,7 @@ void DialogTool::EvalFormula()
|
|||
SCASSERT(plainTextEditFormula != nullptr);
|
||||
SCASSERT(labelResultCalculation != nullptr);
|
||||
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit());
|
||||
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix);
|
||||
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -213,6 +213,8 @@ VFormula VToolArc::getFormulaRadius() const
|
|||
void VToolArc::setFormulaRadius(const VFormula &value)
|
||||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
@ -220,6 +222,7 @@ void VToolArc::setFormulaRadius(const VFormula &value)
|
|||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArc::getFormulaF1() const
|
||||
|
@ -241,10 +244,14 @@ void VToolArc::setFormulaF1(const VFormula &value)
|
|||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
||||
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF2() + 1)==false)// Angles can't be equal
|
||||
{
|
||||
arc->SetFormulaF1(value);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArc::getFormulaF2() const
|
||||
|
@ -266,10 +273,13 @@ void VToolArc::setFormulaF2(const VFormula &value)
|
|||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetF1() + 1)==false)// Angles can't be equal
|
||||
{
|
||||
arc->SetFormulaF2(value);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolArc::ShowVisualization(bool show)
|
||||
|
|
|
@ -84,12 +84,12 @@ void VisToolSplinePath::RefreshGeometry()
|
|||
}
|
||||
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
|
||||
{
|
||||
Visualization::toolTip = QString(tr("<b>Curve path</b>: select three or more points, "
|
||||
"<b>Enter</b> - finish creation"));
|
||||
Visualization::toolTip = tr("<b>Curve path</b>: select three or more points, "
|
||||
"<b>Enter</b> - finish creation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user