Finished the grainline parameters editing in detail dialog
--HG-- branch : feature
This commit is contained in:
parent
853c6852a8
commit
906dafebe8
|
@ -60,10 +60,12 @@
|
||||||
|
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "vnodedetail.h"
|
#include "vnodedetail.h"
|
||||||
|
#include "../support/dialogeditwrongformula.h"
|
||||||
|
|
||||||
class QPointF;
|
class QPointF;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
@ -144,6 +146,8 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
|
|
||||||
m_qslPlacements << tr("None") << tr("Cut on fold");
|
m_qslPlacements << tr("None") << tr("Cut on fold");
|
||||||
ui.comboBoxPlacement->addItems(m_qslPlacements);
|
ui.comboBoxPlacement->addItems(m_qslPlacements);
|
||||||
|
ui.pushButtonRot->setIcon(QIcon("://icon/16x16/fx.png"));
|
||||||
|
ui.pushButtonLen->setIcon(QIcon("://icon/16x16/fx.png"));
|
||||||
|
|
||||||
connect(ui.pushButtonAdd, &QPushButton::clicked, this, &DialogDetail::AddUpdate);
|
connect(ui.pushButtonAdd, &QPushButton::clicked, this, &DialogDetail::AddUpdate);
|
||||||
connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel);
|
connect(ui.pushButtonCancel, &QPushButton::clicked, this, &DialogDetail::Cancel);
|
||||||
|
@ -151,6 +155,11 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode);
|
connect(ui.listWidgetMCP, &QListWidget::itemClicked, this, &DialogDetail::SetEditMode);
|
||||||
connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged);
|
connect(ui.comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogDetail::MaterialChanged);
|
||||||
connect(ui.checkBoxGrainline, &QCheckBox::toggled, this, &DialogDetail::EnableGrainlineRotation);
|
connect(ui.checkBoxGrainline, &QCheckBox::toggled, this, &DialogDetail::EnableGrainlineRotation);
|
||||||
|
connect(ui.pushButtonRot, &QPushButton::clicked, this, &DialogDetail::EditFormula);
|
||||||
|
connect(ui.pushButtonLen, &QPushButton::clicked, this, &DialogDetail::EditFormula);
|
||||||
|
connect(ui.lineEditLenFormula, &QLineEdit::textChanged, this, &DialogDetail::UpdateValue);
|
||||||
|
connect(ui.lineEditRotFormula, &QLineEdit::textChanged, this, &DialogDetail::UpdateValue);
|
||||||
|
|
||||||
SetAddMode();
|
SetAddMode();
|
||||||
EnableGrainlineRotation();
|
EnableGrainlineRotation();
|
||||||
|
|
||||||
|
@ -817,6 +826,65 @@ void DialogDetail::ClearFields()
|
||||||
ui.comboBoxPlacement->setCurrentIndex(0);
|
ui.comboBoxPlacement->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDetail::SetValue(QObject *pobjSender)
|
||||||
|
{
|
||||||
|
QLineEdit* pleSender = dynamic_cast<QLineEdit*>(pobjSender);
|
||||||
|
SCASSERT(pleSender != 0);
|
||||||
|
|
||||||
|
QString qsFormula = pleSender->text().simplified();
|
||||||
|
Calculator cal;
|
||||||
|
QString qsVal;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
qsFormula.replace("\n", " ");
|
||||||
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
||||||
|
qreal dVal;
|
||||||
|
dVal = cal.EvalFormula(data->PlainVariables(), qsFormula);
|
||||||
|
if (qIsInf(dVal) == true || qIsNaN(dVal) == true)
|
||||||
|
{
|
||||||
|
qsVal.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsVal.setNum(dVal, 'f', 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
qsVal.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineEdit* pleVal;
|
||||||
|
QLabel* plbVal;
|
||||||
|
QString qsUnit;
|
||||||
|
if (pobjSender == ui.lineEditLenFormula)
|
||||||
|
{
|
||||||
|
pleVal = ui.lineEditLenValue;
|
||||||
|
plbVal = ui.labelLen;
|
||||||
|
qsUnit = " " + VDomDocument::UnitsToStr(qApp->patternUnit());
|
||||||
|
}
|
||||||
|
else if (pobjSender == ui.lineEditRotFormula)
|
||||||
|
{
|
||||||
|
pleVal = ui.lineEditRotValue;
|
||||||
|
plbVal = ui.labelRot;
|
||||||
|
QChar ch(0x00b0);
|
||||||
|
qsUnit = ch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// should not get here
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qsVal.isEmpty() == false)
|
||||||
|
{
|
||||||
|
qsVal += qsUnit;
|
||||||
|
}
|
||||||
|
pleVal->setText(qsVal);
|
||||||
|
plbVal->setText(qsVal);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogDetail::SetAddMode()
|
void DialogDetail::SetAddMode()
|
||||||
{
|
{
|
||||||
|
@ -874,3 +942,43 @@ void DialogDetail::EnableGrainlineRotation()
|
||||||
ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked());
|
ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked());
|
||||||
ui.pushButtonLen->setEnabled(ui.checkBoxGrainline->isChecked());
|
ui.pushButtonLen->setEnabled(ui.checkBoxGrainline->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDetail::EditFormula()
|
||||||
|
{
|
||||||
|
QLineEdit* pleFormula;
|
||||||
|
bool bCheckZero;
|
||||||
|
|
||||||
|
if (sender() == ui.pushButtonLen)
|
||||||
|
{
|
||||||
|
pleFormula = ui.lineEditLenFormula;
|
||||||
|
bCheckZero = true;
|
||||||
|
}
|
||||||
|
else if (sender() == ui.pushButtonRot)
|
||||||
|
{
|
||||||
|
pleFormula = ui.lineEditRotFormula;
|
||||||
|
bCheckZero = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// should get here!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogEditWrongFormula dlg(data, NULL_ID, this);
|
||||||
|
dlg.SetFormula(pleFormula->text());
|
||||||
|
dlg.setCheckZero(bCheckZero);
|
||||||
|
if (dlg.exec() == true)
|
||||||
|
{
|
||||||
|
QString qsFormula = dlg.GetFormula();
|
||||||
|
qsFormula.replace("\n", " ");
|
||||||
|
pleFormula->setText(qsFormula);
|
||||||
|
SetValue(pleFormula);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDetail::UpdateValue(const QString&)
|
||||||
|
{
|
||||||
|
SetValue(sender());
|
||||||
|
}
|
||||||
|
|
|
@ -125,10 +125,14 @@ private:
|
||||||
|
|
||||||
quint32 RowId(int i) const;
|
quint32 RowId(int i) const;
|
||||||
|
|
||||||
|
void SetValue(QObject* pobjSender);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SetAddMode();
|
void SetAddMode();
|
||||||
void SetEditMode();
|
void SetEditMode();
|
||||||
void EnableGrainlineRotation();
|
void EnableGrainlineRotation();
|
||||||
|
void EditFormula();
|
||||||
|
void UpdateValue(const QString &);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -544,7 +544,7 @@
|
||||||
<height>201</height>
|
<height>201</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0" columnminimumwidth="0,0,30">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0" columnminimumwidth="0,0,25">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="checkBoxGrainline">
|
<widget class="QCheckBox" name="checkBoxGrainline">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -633,7 +633,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>f(x)</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -646,7 +646,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>f(x)</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -469,8 +469,11 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
|
||||||
*/
|
*/
|
||||||
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero)
|
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Eval started";
|
||||||
SCASSERT(label != nullptr);
|
SCASSERT(label != nullptr);
|
||||||
|
qDebug() << "Label ok";
|
||||||
SCASSERT(labelEditFormula != nullptr);
|
SCASSERT(labelEditFormula != nullptr);
|
||||||
|
qDebug() << "lef ok";
|
||||||
|
|
||||||
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user