Fixed the grainline formulas editing

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-10-04 02:13:35 +02:00
commit b28538fefb
4 changed files with 237 additions and 120 deletions

View File

@ -33,7 +33,7 @@
//---------------------------------------------------------------------------------------------------------------------
VGrainlineGeometry::VGrainlineGeometry()
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(true)
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false)
{}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -79,7 +79,8 @@ class QWidget;
*/
DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true),
m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom(), m_oldGrainline()
m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom(), m_oldGrainline(),
m_iRotBaseHeight(0), m_iLenBaseHeight(0)
{
ui.setupUi(this);
@ -158,13 +159,19 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
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);
connect(ui.lineEditLenFormula, &QPlainTextEdit::textChanged, this, &DialogDetail::UpdateValue);
connect(ui.lineEditRotFormula, &QPlainTextEdit::textChanged, this, &DialogDetail::UpdateValue);
connect(ui.pushButtonShowRot, &QPushButton::clicked, this, &DialogDetail::DeployRotation);
connect(ui.pushButtonShowLen, &QPushButton::clicked, this, &DialogDetail::DeployLength);
SetAddMode();
EnableGrainlineRotation();
ui.tabWidget->setCurrentIndex(0);
m_iRotBaseHeight = ui.lineEditRotFormula->height();
m_iLenBaseHeight = ui.lineEditLenFormula->height();
}
//---------------------------------------------------------------------------------------------------------------------
@ -479,8 +486,8 @@ VDetail DialogDetail::CreateDetail() const
detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked());
if (ui.checkBoxGrainline->isChecked() == true)
{
detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->text());
detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->text());
detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->toPlainText());
detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->toPlainText());
}
return detail;
}
@ -553,8 +560,8 @@ void DialogDetail::setDetail(const VDetail &value)
UpdateList();
ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible());
ui.lineEditRotFormula->setText(detail.GetGrainlineGeometry().GetRotation());
ui.lineEditLenFormula->setText(detail.GetGrainlineGeometry().GetLength());
ui.lineEditRotFormula->setPlainText(detail.GetGrainlineGeometry().GetRotation());
ui.lineEditLenFormula->setPlainText(detail.GetGrainlineGeometry().GetLength());
m_oldData = detail.GetPatternPieceData();
m_oldGeom = detail.GetPatternInfo();
@ -830,10 +837,10 @@ void DialogDetail::ClearFields()
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::SetValue(QObject *pobjSender)
{
QLineEdit* pleSender = qobject_cast<QLineEdit*>(pobjSender);
QPlainTextEdit* pleSender = qobject_cast<QPlainTextEdit*>(pobjSender);
SCASSERT(pleSender != 0);
QString qsFormula = pleSender->text().simplified();
QString qsFormula = pleSender->toPlainText().simplified();
Calculator cal;
QString qsVal;
try
@ -856,18 +863,15 @@ void DialogDetail::SetValue(QObject *pobjSender)
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;
@ -882,7 +886,6 @@ void DialogDetail::SetValue(QObject *pobjSender)
{
qsVal += qsUnit;
}
pleVal->setText(qsVal);
plbVal->setText(qsVal);
}
@ -936,18 +939,18 @@ void DialogDetail::SetEditMode()
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::EnableGrainlineRotation()
{
ui.lineEditRotValue->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditRotFormula->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditLenValue->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditLenFormula->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonLen->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonShowLen->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonShowRot->setEnabled(ui.checkBoxGrainline->isChecked());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::EditFormula()
{
QLineEdit* pleFormula;
QPlainTextEdit* pleFormula;
bool bCheckZero;
if (sender() == ui.pushButtonLen)
@ -967,20 +970,33 @@ void DialogDetail::EditFormula()
}
DialogEditWrongFormula dlg(data, NULL_ID, this);
dlg.SetFormula(pleFormula->text());
dlg.SetFormula(pleFormula->toPlainText());
dlg.setCheckZero(bCheckZero);
if (dlg.exec() == true)
{
QString qsFormula = dlg.GetFormula();
qsFormula.replace("\n", " ");
pleFormula->setText(qsFormula);
pleFormula->setPlainText(qsFormula);
SetValue(pleFormula);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::UpdateValue(const QString& qsText)
void DialogDetail::UpdateValue()
{
Q_UNUSED(qsText);
SetValue(sender());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::DeployRotation()
{
DeployFormula(ui.lineEditRotFormula, ui.pushButtonShowRot, m_iRotBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDetail::DeployLength()
{
DeployFormula(ui.lineEditLenFormula, ui.pushButtonShowLen, m_iLenBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -109,6 +109,8 @@ private:
VPatternPieceData m_oldData;
VPatternInfoGeometry m_oldGeom;
VGrainlineGeometry m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
bool DetailIsValid() const;
@ -132,7 +134,9 @@ private slots:
void SetEditMode();
void EnableGrainlineRotation();
void EditFormula();
void UpdateValue(const QString& qsText);
void UpdateValue();
void DeployRotation();
void DeployLength();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -535,65 +535,40 @@
<attribute name="title">
<string>Grainline</string>
</attribute>
<widget class="QWidget" name="formLayoutWidget">
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>361</width>
<height>201</height>
<x>20</x>
<y>20</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0" columnminimumwidth="0,0,25">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBoxGrainline">
<property name="text">
<string>Grainline visible</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelLen">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Value</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Value</string>
</property>
</widget>
</item>
<item row="1" column="0">
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>10</pointsize>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
@ -603,78 +578,201 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Formula</string>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelRot">
<property name="text">
<string/>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item>
<widget class="QPushButton" name="pushButtonRot">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelRot">
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="2">
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>20</x>
<y>120</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="lineEditRotFormula">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonShowRot">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="go-down"/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_4">
<property name="geometry">
<rect>
<x>20</x>
<y>180</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonLen">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelLen">
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditRotValue">
<property name="readOnly">
<bool>true</bool>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_5">
<property name="geometry">
<rect>
<x>20</x>
<y>230</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="lineEditLenFormula">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditRotFormula">
<property name="clearButtonEnabled">
<bool>true</bool>
<item>
<widget class="QPushButton" name="pushButtonShowLen">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditLenValue">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditLenFormula">
<property name="clearButtonEnabled">
<bool>true</bool>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
</widget>
</item>
@ -717,7 +815,6 @@
<tabstop>checkBoxDetail</tabstop>
<tabstop>checkBoxPattern</tabstop>
<tabstop>lineEditLetter</tabstop>
<tabstop>checkBoxGrainline</tabstop>
</tabstops>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>