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() 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) DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true), :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); 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.checkBoxGrainline, &QCheckBox::toggled, this, &DialogDetail::EnableGrainlineRotation);
connect(ui.pushButtonRot, &QPushButton::clicked, this, &DialogDetail::EditFormula); connect(ui.pushButtonRot, &QPushButton::clicked, this, &DialogDetail::EditFormula);
connect(ui.pushButtonLen, &QPushButton::clicked, this, &DialogDetail::EditFormula); connect(ui.pushButtonLen, &QPushButton::clicked, this, &DialogDetail::EditFormula);
connect(ui.lineEditLenFormula, &QLineEdit::textChanged, this, &DialogDetail::UpdateValue); connect(ui.lineEditLenFormula, &QPlainTextEdit::textChanged, this, &DialogDetail::UpdateValue);
connect(ui.lineEditRotFormula, &QLineEdit::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(); SetAddMode();
EnableGrainlineRotation(); EnableGrainlineRotation();
ui.tabWidget->setCurrentIndex(0); 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()); detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked());
if (ui.checkBoxGrainline->isChecked() == true) if (ui.checkBoxGrainline->isChecked() == true)
{ {
detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->text()); detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->toPlainText());
detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->text()); detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->toPlainText());
} }
return detail; return detail;
} }
@ -553,8 +560,8 @@ void DialogDetail::setDetail(const VDetail &value)
UpdateList(); UpdateList();
ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible()); ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible());
ui.lineEditRotFormula->setText(detail.GetGrainlineGeometry().GetRotation()); ui.lineEditRotFormula->setPlainText(detail.GetGrainlineGeometry().GetRotation());
ui.lineEditLenFormula->setText(detail.GetGrainlineGeometry().GetLength()); ui.lineEditLenFormula->setPlainText(detail.GetGrainlineGeometry().GetLength());
m_oldData = detail.GetPatternPieceData(); m_oldData = detail.GetPatternPieceData();
m_oldGeom = detail.GetPatternInfo(); m_oldGeom = detail.GetPatternInfo();
@ -830,10 +837,10 @@ void DialogDetail::ClearFields()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDetail::SetValue(QObject *pobjSender) void DialogDetail::SetValue(QObject *pobjSender)
{ {
QLineEdit* pleSender = qobject_cast<QLineEdit*>(pobjSender); QPlainTextEdit* pleSender = qobject_cast<QPlainTextEdit*>(pobjSender);
SCASSERT(pleSender != 0); SCASSERT(pleSender != 0);
QString qsFormula = pleSender->text().simplified(); QString qsFormula = pleSender->toPlainText().simplified();
Calculator cal; Calculator cal;
QString qsVal; QString qsVal;
try try
@ -856,18 +863,15 @@ void DialogDetail::SetValue(QObject *pobjSender)
qsVal.clear(); qsVal.clear();
} }
QLineEdit* pleVal;
QLabel* plbVal; QLabel* plbVal;
QString qsUnit; QString qsUnit;
if (pobjSender == ui.lineEditLenFormula) if (pobjSender == ui.lineEditLenFormula)
{ {
pleVal = ui.lineEditLenValue;
plbVal = ui.labelLen; plbVal = ui.labelLen;
qsUnit = " " + VDomDocument::UnitsToStr(qApp->patternUnit()); qsUnit = " " + VDomDocument::UnitsToStr(qApp->patternUnit());
} }
else if (pobjSender == ui.lineEditRotFormula) else if (pobjSender == ui.lineEditRotFormula)
{ {
pleVal = ui.lineEditRotValue;
plbVal = ui.labelRot; plbVal = ui.labelRot;
QChar ch(0x00b0); QChar ch(0x00b0);
qsUnit = ch; qsUnit = ch;
@ -882,7 +886,6 @@ void DialogDetail::SetValue(QObject *pobjSender)
{ {
qsVal += qsUnit; qsVal += qsUnit;
} }
pleVal->setText(qsVal);
plbVal->setText(qsVal); plbVal->setText(qsVal);
} }
@ -936,18 +939,18 @@ void DialogDetail::SetEditMode()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDetail::EnableGrainlineRotation() void DialogDetail::EnableGrainlineRotation()
{ {
ui.lineEditRotValue->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditRotFormula->setEnabled(ui.checkBoxGrainline->isChecked()); ui.lineEditRotFormula->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditLenValue->setEnabled(ui.checkBoxGrainline->isChecked());
ui.lineEditLenFormula->setEnabled(ui.checkBoxGrainline->isChecked()); ui.lineEditLenFormula->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked()); ui.pushButtonRot->setEnabled(ui.checkBoxGrainline->isChecked());
ui.pushButtonLen->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() void DialogDetail::EditFormula()
{ {
QLineEdit* pleFormula; QPlainTextEdit* pleFormula;
bool bCheckZero; bool bCheckZero;
if (sender() == ui.pushButtonLen) if (sender() == ui.pushButtonLen)
@ -967,20 +970,33 @@ void DialogDetail::EditFormula()
} }
DialogEditWrongFormula dlg(data, NULL_ID, this); DialogEditWrongFormula dlg(data, NULL_ID, this);
dlg.SetFormula(pleFormula->text()); dlg.SetFormula(pleFormula->toPlainText());
dlg.setCheckZero(bCheckZero); dlg.setCheckZero(bCheckZero);
if (dlg.exec() == true) if (dlg.exec() == true)
{ {
QString qsFormula = dlg.GetFormula(); QString qsFormula = dlg.GetFormula();
qsFormula.replace("\n", " "); qsFormula.replace("\n", " ");
pleFormula->setText(qsFormula); pleFormula->setPlainText(qsFormula);
SetValue(pleFormula); SetValue(pleFormula);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDetail::UpdateValue(const QString& qsText) void DialogDetail::UpdateValue()
{ {
Q_UNUSED(qsText);
SetValue(sender()); 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; VPatternPieceData m_oldData;
VPatternInfoGeometry m_oldGeom; VPatternInfoGeometry m_oldGeom;
VGrainlineGeometry m_oldGrainline; VGrainlineGeometry m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
bool DetailIsValid() const; bool DetailIsValid() const;
@ -132,7 +134,9 @@ private slots:
void SetEditMode(); void SetEditMode();
void EnableGrainlineRotation(); void EnableGrainlineRotation();
void EditFormula(); void EditFormula();
void UpdateValue(const QString& qsText); void UpdateValue();
void DeployRotation();
void DeployLength();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -535,65 +535,40 @@
<attribute name="title"> <attribute name="title">
<string>Grainline</string> <string>Grainline</string>
</attribute> </attribute>
<widget class="QWidget" name="formLayoutWidget"> <widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>20</x>
<y>10</y> <y>20</y>
<width>361</width> <width>351</width>
<height>201</height> <height>41</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0" columnminimumwidth="0,0,25"> <layout class="QHBoxLayout" name="horizontalLayout">
<item row="0" column="0" colspan="2"> <item>
<widget class="QCheckBox" name="checkBoxGrainline"> <widget class="QCheckBox" name="checkBoxGrainline">
<property name="text"> <property name="text">
<string>Grainline visible</string> <string>Grainline visible</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> </layout>
<widget class="QLabel" name="label_12"> </widget>
<property name="font"> <widget class="QWidget" name="horizontalLayoutWidget_2">
<font> <property name="geometry">
<family>Liberation Sans</family> <rect>
<pointsize>10</pointsize> <x>20</x>
<weight>75</weight> <y>70</y>
<bold>true</bold> <width>351</width>
</font> <height>41</height>
</property> </rect>
<property name="text"> </property>
<string>Length</string> <layout class="QHBoxLayout" name="horizontalLayout_5">
</property> <item>
</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">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="font"> <property name="font">
<font> <font>
<family>Liberation Sans</family> <pointsize>11</pointsize>
<pointsize>10</pointsize>
<weight>75</weight> <weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
@ -603,78 +578,201 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item>
<widget class="QLabel" name="label_13"> <spacer name="horizontalSpacer_2">
<property name="text"> <property name="orientation">
<string>Formula</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="1" column="1"> <width>40</width>
<widget class="QLabel" name="labelRot"> <height>20</height>
<property name="text"> </size>
<string/>
</property> </property>
</widget> </spacer>
</item> </item>
<item row="6" column="0"> <item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonRot"> <widget class="QPushButton" name="pushButtonRot">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed"> <string/>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="icon">
</sizepolicy> <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>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QPushButton" name="pushButtonLen">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed"> <string/>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="icon">
</sizepolicy> <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>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> </layout>
<widget class="QLineEdit" name="lineEditRotValue"> </widget>
<property name="readOnly"> <widget class="QWidget" name="horizontalLayoutWidget_5">
<bool>true</bool> <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> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item>
<widget class="QLineEdit" name="lineEditRotFormula"> <widget class="QPushButton" name="pushButtonShowLen">
<property name="clearButtonEnabled"> <property name="text">
<bool>true</bool> <string/>
</property> </property>
</widget> <property name="icon">
</item> <iconset theme="go-down">
<item row="5" column="1"> <normaloff/>
<widget class="QLineEdit" name="lineEditLenValue"> </iconset>
<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> </property>
</widget> </widget>
</item> </item>
@ -717,7 +815,6 @@
<tabstop>checkBoxDetail</tabstop> <tabstop>checkBoxDetail</tabstop>
<tabstop>checkBoxPattern</tabstop> <tabstop>checkBoxPattern</tabstop>
<tabstop>lineEditLetter</tabstop> <tabstop>lineEditLetter</tabstop>
<tabstop>checkBoxGrainline</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../../../vmisc/share/resources/icon.qrc"/> <include location="../../../vmisc/share/resources/icon.qrc"/>