Fixed issue #249. Size Base and Height Base (Calculations Error and Display

Wish List).

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-02-25 21:50:13 +02:00
parent 924af81eae
commit 72324c0942
4 changed files with 21 additions and 16 deletions

View File

@ -861,12 +861,12 @@ void MainWindow::ToolBarOption()
const QStringList listSizes = VMeasurement::ListSizes(doc->GetGradationSizes());
gradationHeights = SetGradationList(tr("Height: "), listHeights);
SetDefaultHeight(static_cast<int>(GHeights::H176));
SetDefaultHeight(static_cast<int>(pattern->height()));
connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedHeight);
gradationSizes = SetGradationList(tr("Size: "), listSizes);
SetDefaultSize(static_cast<int>(GSizes::S50));
SetDefaultSize(static_cast<int>(pattern->size()));
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedSize);
@ -890,12 +890,13 @@ QComboBox *MainWindow::SetGradationList(const QString &label, const QStringList
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetDefaultHeight set base height in combobox.
* @param value [in] height value in pattern units.
*/
void MainWindow::SetDefaultHeight(int value)
{
qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit());
QString strVal = QString("%1").arg(val);
qint32 index = gradationHeights->findText(strVal);
const qint32 index = gradationHeights->findText(QString("%1").arg(value));
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
@ -907,12 +908,13 @@ void MainWindow::SetDefaultHeight(int value)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetDefaultSize set base size in combobox.
* @param value [in] size value in pattern units.
*/
void MainWindow::SetDefaultSize(int value)
{
qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit());
QString strVal = QString("%1").arg(val);
qint32 index = gradationSizes->findText(strVal);
const qint32 index = gradationSizes->findText(QString("%1").arg(value));
if (index != -1)
{
gradationSizes->setCurrentIndex(index);

View File

@ -34,8 +34,10 @@ const QString VStandardMeasurements::TagDescription = QStringLiteral("descr
const QString VStandardMeasurements::TagId = QStringLiteral("id");
const QString VStandardMeasurements::TagSize = QStringLiteral("size");
const QString VStandardMeasurements::TagHeight = QStringLiteral("height");
const QString VStandardMeasurements::AttrSize_increase = QStringLiteral("size_increase");
const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase");
const QString VStandardMeasurements::AttrBase = QStringLiteral("base");
//---------------------------------------------------------------------------------------------------------------------
VStandardMeasurements::VStandardMeasurements(VContainer *data)
@ -93,7 +95,7 @@ void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const
//---------------------------------------------------------------------------------------------------------------------
qreal VStandardMeasurements::TakeParametr(const QString &tag, qreal defValue) const
qreal VStandardMeasurements::TakeParametr(const QString &tag, const QString &attr, qreal defValue) const
{
const qreal defVal = UnitConvertor(defValue, Unit::Cm, qApp->patternUnit());
@ -110,7 +112,7 @@ qreal VStandardMeasurements::TakeParametr(const QString &tag, qreal defValue) co
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
qreal value = GetParametrDouble(domElement, AttrValue, QString("%1").arg(defVal));
qreal value = GetParametrDouble(domElement, attr, QString("%1").arg(defVal));
value = UnitConvertor(value, MUnit(), qApp->patternUnit());
return value;
}
@ -122,7 +124,7 @@ qreal VStandardMeasurements::TakeParametr(const QString &tag, qreal defValue) co
//---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::SetSize()
{
const qreal value = TakeParametr(TagSize, 50);
const qreal value = TakeParametr(TagSize, AttrBase, 50);
data->SetSize(value);
data->SetSizeName(size_M);
}
@ -130,7 +132,7 @@ void VStandardMeasurements::SetSize()
//---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::SetHeight()
{
const qreal value = TakeParametr(TagHeight, 176);
const qreal value = TakeParametr(TagHeight, AttrBase, 176);
data->SetHeight(value);
data->SetHeightName(height_M);
}

View File

@ -53,13 +53,15 @@ public:
static const QString TagId;
static const QString TagSize;
static const QString TagHeight;
static const QString AttrSize_increase;
static const QString AttrHeight_increase;
static const QString AttrBase;
protected:
virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag);
private:
Q_DISABLE_COPY(VStandardMeasurements)
qreal TakeParametr(const QString &tag, qreal defValue) const;
qreal TakeParametr(const QString &tag, const QString &attr, qreal defValue) const;
};
#endif // VSTANDARDMEASUREMENTS_H

View File

@ -15,7 +15,6 @@
<xs:element name="height">
<xs:complexType>
<xs:attribute name="base" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="body-measurements">