Dimension labels.
This commit is contained in:
parent
f072ee5888
commit
eaf6975331
223
src/app/tape/dialogs/dialogdimensionlabels.cpp
Normal file
223
src/app/tape/dialogs/dialogdimensionlabels.cpp
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogdimensionlabels.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 8 10, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#include "dialogdimensionlabels.h"
|
||||||
|
#include "ui_dialogdimensionlabels.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogDimensionLabels::DialogDimensionLabels(const QMap<MeasurementDimension, MeasurementDimension_p> &dimensions, bool fullCircumference,
|
||||||
|
QWidget *parent)
|
||||||
|
: QDialog(parent),
|
||||||
|
ui(new Ui::DialogDimensionLabels),
|
||||||
|
m_dimensions(dimensions),
|
||||||
|
m_fullCircumference(fullCircumference)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
InitLabels();
|
||||||
|
|
||||||
|
InitDimensions();
|
||||||
|
InitTable();
|
||||||
|
|
||||||
|
connect(ui->comboBoxDimensionLabels, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&DialogDimensionLabels::DimensionChanged);
|
||||||
|
connect(ui->tableWidget, &QTableWidget::itemChanged, this, &DialogDimensionLabels::LabelChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogDimensionLabels::~DialogDimensionLabels()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::LanguageChange)
|
||||||
|
{
|
||||||
|
// retranslate designer form (single inheritance approach)
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
|
MeasurementDimension type =
|
||||||
|
static_cast<MeasurementDimension>(ui->comboBoxDimensionLabels->currentData().toInt());
|
||||||
|
|
||||||
|
InitDimensions();
|
||||||
|
|
||||||
|
int index = ui->comboBoxDimensionLabels->findData(static_cast<int>(type));
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
ui->comboBoxDimensionLabels->blockSignals(true);
|
||||||
|
ui->comboBoxDimensionLabels->setCurrentIndex(index);
|
||||||
|
ui->comboBoxDimensionLabels->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int row = ui->tableWidget->currentRow();
|
||||||
|
InitTable();
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->selectRow(row);
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember to call base class implementation
|
||||||
|
QDialog::changeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::DimensionChanged()
|
||||||
|
{
|
||||||
|
InitTable();
|
||||||
|
ui->tableWidget->selectRow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::LabelChanged(QTableWidgetItem *item)
|
||||||
|
{
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
MeasurementDimension type =
|
||||||
|
static_cast<MeasurementDimension>(ui->comboBoxDimensionLabels->currentData().toInt());
|
||||||
|
int value = item->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
DimesionLabels labels = m_labels.value(type);
|
||||||
|
labels.insert(value, item->text());
|
||||||
|
|
||||||
|
m_labels.insert(type, labels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::InitLabels()
|
||||||
|
{
|
||||||
|
m_labels.clear();
|
||||||
|
|
||||||
|
const QList<MeasurementDimension_p> dimensions = m_dimensions.values();
|
||||||
|
|
||||||
|
for(auto &dimension : dimensions)
|
||||||
|
{
|
||||||
|
m_labels.insert(dimension->Type(), dimension->Labels());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::InitDimensions()
|
||||||
|
{
|
||||||
|
ui->comboBoxDimensionLabels->blockSignals(true);
|
||||||
|
ui->comboBoxDimensionLabels->clear();
|
||||||
|
|
||||||
|
for(auto &dimension : m_dimensions)
|
||||||
|
{
|
||||||
|
ui->comboBoxDimensionLabels->addItem(VAbstartMeasurementDimension::DimensionName(dimension->Type()),
|
||||||
|
static_cast<int>(dimension->Type()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->comboBoxDimensionLabels->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogDimensionLabels::InitTable()
|
||||||
|
{
|
||||||
|
ui->tableWidget->blockSignals(true);
|
||||||
|
ui->tableWidget->clearContents();
|
||||||
|
|
||||||
|
const MeasurementDimension type =
|
||||||
|
static_cast<MeasurementDimension>(ui->comboBoxDimensionLabels->currentData().toInt());
|
||||||
|
|
||||||
|
MeasurementDimension_p dimension;
|
||||||
|
|
||||||
|
if (m_dimensions.contains(type))
|
||||||
|
{
|
||||||
|
dimension = m_dimensions.value(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dimension.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<int> bases = dimension->ValidBases();
|
||||||
|
|
||||||
|
ui->tableWidget->setRowCount(bases.size());
|
||||||
|
|
||||||
|
const DimesionLabels labels = m_labels.value(type);
|
||||||
|
|
||||||
|
for(int row = 0; row < bases.size(); ++row)
|
||||||
|
{
|
||||||
|
const int base = bases.at(row);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto *itemValue = new QTableWidgetItem(DimensionValue(dimension, base));
|
||||||
|
itemValue->setData(Qt::UserRole, base);
|
||||||
|
itemValue->setTextAlignment(Qt::AlignHCenter | Qt::AlignCenter);
|
||||||
|
|
||||||
|
// set the item non-editable (view only), and non-selectable
|
||||||
|
Qt::ItemFlags flags = itemValue->flags();
|
||||||
|
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
|
||||||
|
itemValue->setFlags(flags);
|
||||||
|
|
||||||
|
ui->tableWidget->setItem(row, 0, itemValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto *itemLabel = new QTableWidgetItem(labels.value(base));
|
||||||
|
itemLabel->setData(Qt::UserRole, base);
|
||||||
|
itemLabel->setTextAlignment(Qt::AlignHCenter | Qt::AlignCenter);
|
||||||
|
|
||||||
|
ui->tableWidget->setItem(row, 1, itemLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
ui->tableWidget->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimension, int value)
|
||||||
|
{
|
||||||
|
QStringList labels;
|
||||||
|
|
||||||
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
|
{
|
||||||
|
return QString::number(value);
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
|
{
|
||||||
|
if (dimension->IsCircumference())
|
||||||
|
{
|
||||||
|
return QString::number(m_fullCircumference ? value*2 : value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString::number(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
|
{
|
||||||
|
return QString::number(m_fullCircumference ? value*2 : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString::number(value);
|
||||||
|
}
|
82
src/app/tape/dialogs/dialogdimensionlabels.h
Normal file
82
src/app/tape/dialogs/dialogdimensionlabels.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogdimensionlabels.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 8 10, 2020
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2020 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#ifndef DIALOGDIMENSIONLABELS_H
|
||||||
|
#define DIALOGDIMENSIONLABELS_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
#include "../vformat/vdimensions.h"
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class DialogDimensionLabels;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QTableWidgetItem;
|
||||||
|
|
||||||
|
class DialogDimensionLabels : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogDimensionLabels(const QMap<MeasurementDimension, MeasurementDimension_p > &dimensions,
|
||||||
|
bool fullCircumference, QWidget *parent = nullptr);
|
||||||
|
virtual ~DialogDimensionLabels();
|
||||||
|
|
||||||
|
QMap<MeasurementDimension, DimesionLabels> Labels() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void DimensionChanged();
|
||||||
|
void LabelChanged(QTableWidgetItem *item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogDimensionLabels)
|
||||||
|
Ui::DialogDimensionLabels *ui;
|
||||||
|
|
||||||
|
QMap<MeasurementDimension, MeasurementDimension_p > m_dimensions;
|
||||||
|
QMap<MeasurementDimension, DimesionLabels> m_labels{};
|
||||||
|
bool m_fullCircumference;
|
||||||
|
|
||||||
|
void InitLabels();
|
||||||
|
void InitDimensions();
|
||||||
|
void InitTable();
|
||||||
|
|
||||||
|
QString DimensionValue(const MeasurementDimension_p &dimension, int value);
|
||||||
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline QMap<MeasurementDimension, DimesionLabels> DialogDimensionLabels::Labels() const
|
||||||
|
{
|
||||||
|
return m_labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DIALOGDIMENSIONLABELS_H
|
136
src/app/tape/dialogs/dialogdimensionlabels.ui
Normal file
136
src/app/tape/dialogs/dialogdimensionlabels.ui
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogDimensionLabels</class>
|
||||||
|
<widget class="QDialog" name="DialogDimensionLabels">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>345</width>
|
||||||
|
<height>424</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dimension labels</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../share/resources/tapeicon.qrc">
|
||||||
|
<normaloff>:/tapeicon/64x64/logo.png</normaloff>:/tapeicon/64x64/logo.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<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="QLabel" name="labelDimension">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Dimension:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxDimensionLabels"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableWidget" name="tableWidget">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Value</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Label</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../share/resources/tapeicon.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>DialogDimensionLabels</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>DialogDimensionLabels</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -538,18 +538,32 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
|
||||||
{
|
{
|
||||||
SCASSERT(control != nullptr)
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
|
const DimesionLabels labels = dimension->Labels();
|
||||||
const QString units = UnitsToStr(dimension->Units(), true);
|
const QString units = UnitsToStr(dimension->Units(), true);
|
||||||
|
|
||||||
if (dimension->Type() == MeasurementDimension::X)
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(base).arg(units), base);
|
control->addItem(QString("%1 %2").arg(base).arg(units), base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::Y)
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (dimension->IsCircumference())
|
if (dimension->IsCircumference())
|
||||||
{
|
{
|
||||||
|
@ -561,13 +575,21 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -575,19 +597,33 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
|
||||||
{
|
{
|
||||||
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
|
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
|
||||||
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
|
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
|
||||||
|
const DimesionLabels dimensionLabels = dimension->Labels();
|
||||||
|
|
||||||
QStringList labels;
|
QStringList labels;
|
||||||
|
|
||||||
if (dimension->Type() == MeasurementDimension::X)
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
labels.append(dimensionLabels.value(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
labels.append(QString("%1 %2").arg(base).arg(units));
|
labels.append(QString("%1 %2").arg(base).arg(units));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::Y)
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
labels.append(dimensionLabels.value(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (dimension->IsCircumference())
|
if (dimension->IsCircumference())
|
||||||
{
|
{
|
||||||
|
@ -599,13 +635,21 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
labels.append(dimensionLabels.value(base));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# This need for corect working file translations.pro
|
# This need for corect working file translations.pro
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
$$PWD/dialogs/dialogdimensionlabels.cpp \
|
||||||
$$PWD/dialogs/dialogrestrictdimension.cpp \
|
$$PWD/dialogs/dialogrestrictdimension.cpp \
|
||||||
$$PWD/main.cpp \
|
$$PWD/main.cpp \
|
||||||
$$PWD/tmainwindow.cpp \
|
$$PWD/tmainwindow.cpp \
|
||||||
|
@ -18,6 +19,7 @@ SOURCES += \
|
||||||
*msvc*:SOURCES += $$PWD/stable.cpp
|
*msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
$$PWD/dialogs/dialogdimensionlabels.h \
|
||||||
$$PWD/dialogs/dialogrestrictdimension.h \
|
$$PWD/dialogs/dialogrestrictdimension.h \
|
||||||
$$PWD/tmainwindow.h \
|
$$PWD/tmainwindow.h \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
|
@ -33,6 +35,7 @@ HEADERS += \
|
||||||
$$PWD/dialogs/dialogsetupmultisize.h
|
$$PWD/dialogs/dialogsetupmultisize.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
$$PWD/dialogs/dialogdimensionlabels.ui \
|
||||||
$$PWD/dialogs/dialogrestrictdimension.ui \
|
$$PWD/dialogs/dialogrestrictdimension.ui \
|
||||||
$$PWD/tmainwindow.ui \
|
$$PWD/tmainwindow.ui \
|
||||||
$$PWD/dialogs/dialogabouttape.ui \
|
$$PWD/dialogs/dialogabouttape.ui \
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "dialogs/dialogtapepreferences.h"
|
#include "dialogs/dialogtapepreferences.h"
|
||||||
#include "dialogs/dialogsetupmultisize.h"
|
#include "dialogs/dialogsetupmultisize.h"
|
||||||
#include "dialogs/dialogrestrictdimension.h"
|
#include "dialogs/dialogrestrictdimension.h"
|
||||||
|
#include "dialogs/dialogdimensionlabels.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/calculator.h"
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "../vpatterndb/pmsystems.h"
|
#include "../vpatterndb/pmsystems.h"
|
||||||
|
@ -2229,6 +2230,25 @@ void TMainWindow::RestrictThirdDimesion()
|
||||||
DimensionABaseChanged(); // trigger refresh
|
DimensionABaseChanged(); // trigger refresh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::EditDimensionLabels()
|
||||||
|
{
|
||||||
|
const QMap<MeasurementDimension, MeasurementDimension_p > dimensions = m->Dimensions();
|
||||||
|
|
||||||
|
DialogDimensionLabels dialog(dimensions, m->IsFullCircumference(), this);
|
||||||
|
if (dialog.exec() == QDialog::Rejected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m->SetDimensionLabels(dialog.Labels());
|
||||||
|
|
||||||
|
MeasurementsWereSaved(false);
|
||||||
|
|
||||||
|
InitDimensionsBaseValue();
|
||||||
|
InitDimensionControls();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::SetupMenu()
|
void TMainWindow::SetupMenu()
|
||||||
{
|
{
|
||||||
|
@ -2516,10 +2536,6 @@ void TMainWindow::InitMenu()
|
||||||
ui->actionRestrictSecondDimension->setEnabled(true);
|
ui->actionRestrictSecondDimension->setEnabled(true);
|
||||||
connect(ui->actionRestrictSecondDimension, &QAction::triggered, this, &TMainWindow::RestrictSecondDimesion);
|
connect(ui->actionRestrictSecondDimension, &QAction::triggered, this, &TMainWindow::RestrictSecondDimesion);
|
||||||
|
|
||||||
separator = new QAction(this);
|
|
||||||
separator->setSeparator(true);
|
|
||||||
ui->menuMeasurements->insertAction(ui->actionRestrictSecondDimension, separator);
|
|
||||||
|
|
||||||
if (dimensions.size() > 2)
|
if (dimensions.size() > 2)
|
||||||
{
|
{
|
||||||
ui->actionRestrictThirdDimension->setVisible(true);
|
ui->actionRestrictThirdDimension->setVisible(true);
|
||||||
|
@ -2529,6 +2545,10 @@ void TMainWindow::InitMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->actionDimensionLabels->setVisible(true);
|
||||||
|
ui->actionDimensionLabels->setEnabled(true);
|
||||||
|
connect(ui->actionDimensionLabels, &QAction::triggered, this, &TMainWindow::EditDimensionLabels);
|
||||||
|
|
||||||
// File
|
// File
|
||||||
ui->actionExportToIndividual->setVisible(true);
|
ui->actionExportToIndividual->setVisible(true);
|
||||||
ui->actionExportToIndividual->setEnabled(true);
|
ui->actionExportToIndividual->setEnabled(true);
|
||||||
|
@ -2556,6 +2576,14 @@ void TMainWindow::InitDimensionsBaseValue()
|
||||||
dimension->IsCircumference(),
|
dimension->IsCircumference(),
|
||||||
m->IsFullCircumference()));
|
m->IsFullCircumference()));
|
||||||
|
|
||||||
|
DimesionLabels labels = dimension->Labels();
|
||||||
|
|
||||||
|
if (labels.contains(dimension->BaseValue()) && not labels.value(dimension->BaseValue()).isEmpty())
|
||||||
|
{
|
||||||
|
base->setText(labels.value(dimension->BaseValue()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
|
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
if (dimension->Type() != MeasurementDimension::X && fc)
|
if (dimension->Type() != MeasurementDimension::X && fc)
|
||||||
|
@ -2572,6 +2600,7 @@ void TMainWindow::InitDimensionsBaseValue()
|
||||||
base->setText(QString::number(dimension->BaseValue()));
|
base->setText(QString::number(dimension->BaseValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
||||||
|
@ -2597,17 +2626,31 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
control->clear();
|
control->clear();
|
||||||
|
|
||||||
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
||||||
|
const DimesionLabels labels = dimension->Labels();
|
||||||
|
|
||||||
if (dimension->Type() == MeasurementDimension::X)
|
if (dimension->Type() == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(base).arg(unit), base);
|
control->addItem(QString("%1 %2").arg(base).arg(unit), base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::Y)
|
else if (dimension->Type() == MeasurementDimension::Y)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (dimension->IsCircumference())
|
if (dimension->IsCircumference())
|
||||||
{
|
{
|
||||||
|
@ -2619,13 +2662,21 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
||||||
{
|
{
|
||||||
for(auto base : bases)
|
for(auto base : bases)
|
||||||
|
{
|
||||||
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
||||||
|
{
|
||||||
|
control->addItem(labels.value(base), base);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
|
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// after initialization the current index is 0. The signal for changing the index will not be triggered if not make
|
// after initialization the current index is 0. The signal for changing the index will not be triggered if not make
|
||||||
// it invalid first
|
// it invalid first
|
||||||
|
|
|
@ -142,6 +142,8 @@ private slots:
|
||||||
void RestrictSecondDimesion();
|
void RestrictSecondDimesion();
|
||||||
void RestrictThirdDimesion();
|
void RestrictThirdDimesion();
|
||||||
|
|
||||||
|
void EditDimensionLabels();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TMainWindow)
|
Q_DISABLE_COPY(TMainWindow)
|
||||||
Ui::TMainWindow *ui;
|
Ui::TMainWindow *ui;
|
||||||
|
|
|
@ -995,6 +995,7 @@
|
||||||
<addaction name="actionUseFullCircumference"/>
|
<addaction name="actionUseFullCircumference"/>
|
||||||
<addaction name="actionRestrictSecondDimension"/>
|
<addaction name="actionRestrictSecondDimension"/>
|
||||||
<addaction name="actionRestrictThirdDimension"/>
|
<addaction name="actionRestrictThirdDimension"/>
|
||||||
|
<addaction name="actionDimensionLabels"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuMeasurements"/>
|
<addaction name="menuMeasurements"/>
|
||||||
|
@ -1389,6 +1390,17 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionDimensionLabels">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Dimension labels</string>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
|
@ -13,6 +13,20 @@
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="dimension" minOccurs="0" maxOccurs="3">
|
<xs:element name="dimension" minOccurs="0" maxOccurs="3">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="labels" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="label" minOccurs="0" maxOccurs="unbounded">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name="value" type="dimesionValue" use="required"/>
|
||||||
|
<xs:attribute name="label" type="xs:string" use="required"/>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
<xs:attribute name="type" type="dimensionType" use="required"/>
|
<xs:attribute name="type" type="dimensionType" use="required"/>
|
||||||
<xs:attribute name="base" type="dimesionValue" use="required"/>
|
<xs:attribute name="base" type="dimesionValue" use="required"/>
|
||||||
<xs:attribute name="min" type="dimesionValue" use="required"/>
|
<xs:attribute name="min" type="dimesionValue" use="required"/>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define VDIMENSIONS_H
|
#define VDIMENSIONS_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ class VAbstartMeasurementDimension;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
|
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
|
||||||
|
using DimesionLabels = QMap<int, QString>;
|
||||||
|
|
||||||
class VAbstartMeasurementDimension
|
class VAbstartMeasurementDimension
|
||||||
{
|
{
|
||||||
|
@ -87,6 +89,9 @@ public:
|
||||||
static QString DimensionName(MeasurementDimension type);
|
static QString DimensionName(MeasurementDimension type);
|
||||||
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc);
|
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc);
|
||||||
|
|
||||||
|
DimesionLabels Labels() const;
|
||||||
|
void SetLabels(const DimesionLabels &labels);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Unit m_units{Unit::Cm};
|
Unit m_units{Unit::Cm};
|
||||||
int m_minValue{0};
|
int m_minValue{0};
|
||||||
|
@ -94,6 +99,7 @@ protected:
|
||||||
int m_step{-1};
|
int m_step{-1};
|
||||||
int m_baseValue{0};
|
int m_baseValue{0};
|
||||||
QString m_error{};
|
QString m_error{};
|
||||||
|
DimesionLabels m_labels{};
|
||||||
|
|
||||||
bool IsRangeValid();
|
bool IsRangeValid();
|
||||||
bool IsStepValid();
|
bool IsStepValid();
|
||||||
|
@ -167,6 +173,18 @@ inline bool VAbstartMeasurementDimension::IsCircumference() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline DimesionLabels VAbstartMeasurementDimension::Labels() const
|
||||||
|
{
|
||||||
|
return m_labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline void VAbstartMeasurementDimension::SetLabels(const DimesionLabels &labels)
|
||||||
|
{
|
||||||
|
m_labels = labels;
|
||||||
|
}
|
||||||
|
|
||||||
// VXMeasurementDimension
|
// VXMeasurementDimension
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
class VXMeasurementDimension : public VAbstartMeasurementDimension
|
class VXMeasurementDimension : public VAbstartMeasurementDimension
|
||||||
|
|
|
@ -74,6 +74,8 @@ const QString VMeasurements::TagRestrictions = QStringLiteral("restrictions"
|
||||||
const QString VMeasurements::TagRestriction = QStringLiteral("restriction");
|
const QString VMeasurements::TagRestriction = QStringLiteral("restriction");
|
||||||
const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
|
const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
|
||||||
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
|
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
|
||||||
|
const QString VMeasurements::TagLabels = QStringLiteral("labels");
|
||||||
|
const QString VMeasurements::TagLabel = QStringLiteral("label");
|
||||||
|
|
||||||
const QString VMeasurements::AttrBase = QStringLiteral("base");
|
const QString VMeasurements::AttrBase = QStringLiteral("base");
|
||||||
const QString VMeasurements::AttrValue = QStringLiteral("value");
|
const QString VMeasurements::AttrValue = QStringLiteral("value");
|
||||||
|
@ -91,6 +93,7 @@ const QString VMeasurements::AttrMax = QStringLiteral("max");
|
||||||
const QString VMeasurements::AttrStep = QStringLiteral("step");
|
const QString VMeasurements::AttrStep = QStringLiteral("step");
|
||||||
const QString VMeasurements::AttrCircumference = QStringLiteral("circumference");
|
const QString VMeasurements::AttrCircumference = QStringLiteral("circumference");
|
||||||
const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference");
|
const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference");
|
||||||
|
const QString VMeasurements::AttrLabel = QStringLiteral("label");
|
||||||
|
|
||||||
const QString VMeasurements::GenderMale = QStringLiteral("male");
|
const QString VMeasurements::GenderMale = QStringLiteral("male");
|
||||||
const QString VMeasurements::GenderFemale = QStringLiteral("female");
|
const QString VMeasurements::GenderFemale = QStringLiteral("female");
|
||||||
|
@ -822,10 +825,13 @@ QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions()
|
||||||
const int step = GetParametrInt(dom, AttrStep, QString("-1"));
|
const int step = GetParametrInt(dom, AttrStep, QString("-1"));
|
||||||
const int base = GetParametrInt(dom, AttrBase, QChar('0'));
|
const int base = GetParametrInt(dom, AttrBase, QChar('0'));
|
||||||
|
|
||||||
|
const DimesionLabels labels = ReadDimensionLabels(dom);
|
||||||
|
|
||||||
if (type == MeasurementDimension::X)
|
if (type == MeasurementDimension::X)
|
||||||
{
|
{
|
||||||
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
|
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
|
||||||
dimension->SetBaseValue(base);
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
dimensionsCached->insert(type, dimension);
|
dimensionsCached->insert(type, dimension);
|
||||||
}
|
}
|
||||||
else if (type == MeasurementDimension::Y)
|
else if (type == MeasurementDimension::Y)
|
||||||
|
@ -833,18 +839,21 @@ QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions()
|
||||||
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
|
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
|
||||||
dimension->SetBaseValue(base);
|
dimension->SetBaseValue(base);
|
||||||
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
|
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
|
||||||
|
dimension->SetLabels(labels);
|
||||||
dimensionsCached->insert(type, dimension);
|
dimensionsCached->insert(type, dimension);
|
||||||
}
|
}
|
||||||
else if (type == MeasurementDimension::W)
|
else if (type == MeasurementDimension::W)
|
||||||
{
|
{
|
||||||
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
|
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
|
||||||
dimension->SetBaseValue(base);
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
dimensionsCached->insert(type, dimension);
|
dimensionsCached->insert(type, dimension);
|
||||||
}
|
}
|
||||||
else if (type == MeasurementDimension::Z)
|
else if (type == MeasurementDimension::Z)
|
||||||
{
|
{
|
||||||
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
|
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
|
||||||
dimension->SetBaseValue(base);
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
dimensionsCached->insert(type, dimension);
|
dimensionsCached->insert(type, dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,6 +917,24 @@ QPair<int, int> VMeasurements::Restriction(int base, int base2) const
|
||||||
return restrictions.value(hash, QPair<int, int>(0, 0));
|
return restrictions.value(hash, QPair<int, int>(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMeasurements::SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels)
|
||||||
|
{
|
||||||
|
const QDomNodeList list = elementsByTagName(TagDimension);
|
||||||
|
for (int i=0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
|
||||||
|
|
||||||
|
if (labels.contains(type))
|
||||||
|
{
|
||||||
|
SaveDimesionLabels(dom, labels.value(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dimensionsCached->clear(); // Invalidate cache
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VMeasurements::GenderToStr(const GenderType &sex)
|
QString VMeasurements::GenderToStr(const GenderType &sex)
|
||||||
{
|
{
|
||||||
|
@ -1311,3 +1338,84 @@ void VMeasurements::WriteCorrections(QDomElement &mElement, const QMap<QString,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMeasurements::SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels)
|
||||||
|
{
|
||||||
|
if (dElement.isNull())
|
||||||
|
{
|
||||||
|
qDebug() << "Invalid dimension tag";
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement labelsTag = dElement.firstChildElement(TagLabels);
|
||||||
|
if (not labels.isEmpty())
|
||||||
|
{
|
||||||
|
if (not labelsTag.isNull())
|
||||||
|
{
|
||||||
|
RemoveAllChildren(labelsTag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
labelsTag = createElement(TagLabels);
|
||||||
|
dElement.appendChild(labelsTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
DimesionLabels::const_iterator i = labels.constBegin();
|
||||||
|
while (i != labels.constEnd())
|
||||||
|
{
|
||||||
|
if (not i.value().isEmpty())
|
||||||
|
{
|
||||||
|
QDomElement labelTag = createElement(TagLabel);
|
||||||
|
|
||||||
|
SetAttribute(labelTag, AttrValue, i.key());
|
||||||
|
SetAttribute(labelTag, AttrLabel, i.value());
|
||||||
|
|
||||||
|
labelsTag.appendChild(labelTag);
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (not labelsTag.isNull())
|
||||||
|
{
|
||||||
|
dElement.removeChild(labelsTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DimesionLabels VMeasurements::ReadDimensionLabels(const QDomElement &dElement) const
|
||||||
|
{
|
||||||
|
if (dElement.isNull())
|
||||||
|
{
|
||||||
|
return DimesionLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement labelsTag = dElement.firstChildElement(TagLabels);
|
||||||
|
if (labelsTag.isNull())
|
||||||
|
{
|
||||||
|
return DimesionLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
DimesionLabels labels;
|
||||||
|
|
||||||
|
QDomNode labelTag = labelsTag.firstChild();
|
||||||
|
while (not labelTag.isNull())
|
||||||
|
{
|
||||||
|
if (labelTag.isElement())
|
||||||
|
{
|
||||||
|
const QDomElement l = labelTag.toElement();
|
||||||
|
const int value = GetParametrInt(l, AttrValue, QChar('0'));
|
||||||
|
const QString label = GetParametrEmptyString(l, AttrLabel);
|
||||||
|
|
||||||
|
if (value > 0 && not label.isEmpty())
|
||||||
|
{
|
||||||
|
labels.insert(value, label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
labelTag = labelTag.nextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,8 @@ public:
|
||||||
|
|
||||||
QPair<int, int> Restriction(int base, int base2=0) const;
|
QPair<int, int> Restriction(int base, int base2=0) const;
|
||||||
|
|
||||||
|
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);
|
||||||
|
|
||||||
static const QString TagVST;
|
static const QString TagVST;
|
||||||
static const QString TagVIT;
|
static const QString TagVIT;
|
||||||
static const QString TagBodyMeasurements;
|
static const QString TagBodyMeasurements;
|
||||||
|
@ -139,6 +141,8 @@ public:
|
||||||
static const QString TagRestriction;
|
static const QString TagRestriction;
|
||||||
static const QString TagCorrections;
|
static const QString TagCorrections;
|
||||||
static const QString TagCorrection;
|
static const QString TagCorrection;
|
||||||
|
static const QString TagLabels;
|
||||||
|
static const QString TagLabel;
|
||||||
|
|
||||||
static const QString AttrBase;
|
static const QString AttrBase;
|
||||||
static const QString AttrValue;
|
static const QString AttrValue;
|
||||||
|
@ -156,6 +160,7 @@ public:
|
||||||
static const QString AttrStep;
|
static const QString AttrStep;
|
||||||
static const QString AttrCircumference;
|
static const QString AttrCircumference;
|
||||||
static const QString AttrFullCircumference;
|
static const QString AttrFullCircumference;
|
||||||
|
static const QString AttrLabel;
|
||||||
|
|
||||||
static const QString GenderMale;
|
static const QString GenderMale;
|
||||||
static const QString GenderFemale;
|
static const QString GenderFemale;
|
||||||
|
@ -206,6 +211,9 @@ private:
|
||||||
|
|
||||||
QMap<QString, qreal> ReadCorrections(const QDomElement &mElement) const;
|
QMap<QString, qreal> ReadCorrections(const QDomElement &mElement) const;
|
||||||
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
|
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
|
||||||
|
|
||||||
|
void SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels);
|
||||||
|
DimesionLabels ReadDimensionLabels(const QDomElement &dElement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VMEASUREMENTS_H
|
#endif // VMEASUREMENTS_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user