Clean code.
This commit is contained in:
parent
1b2343e537
commit
3133ae1609
|
@ -65,8 +65,6 @@ Q_LOGGING_CATEGORY(vCon, "v.container")
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
QMap<QString, quint32> VContainer::_id = QMap<QString, quint32>();
|
QMap<QString, quint32> VContainer::_id = QMap<QString, quint32>();
|
||||||
QMap<QString, qreal> VContainer::_size = QMap<QString, qreal>();
|
|
||||||
QMap<QString, qreal> VContainer::_height = QMap<QString, qreal>();
|
|
||||||
QMap<QString, QSet<QString>> VContainer::uniqueNames = QMap<QString, QSet<QString>>();
|
QMap<QString, QSet<QString>> VContainer::uniqueNames = QMap<QString, QSet<QString>>();
|
||||||
QMap<QString, quint32> VContainer::copyCounter = QMap<QString, quint32>();
|
QMap<QString, quint32> VContainer::copyCounter = QMap<QString, quint32>();
|
||||||
|
|
||||||
|
@ -92,16 +90,6 @@ VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit, co
|
||||||
_id[d->nspace] = NULL_ID;
|
_id[d->nspace] = NULL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not _size.contains(d->nspace))
|
|
||||||
{
|
|
||||||
_size[d->nspace] = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not _height.contains(d->nspace))
|
|
||||||
{
|
|
||||||
_height[d->nspace] = 176;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not uniqueNames.contains(d->nspace))
|
if (not uniqueNames.contains(d->nspace))
|
||||||
{
|
{
|
||||||
uniqueNames[d->nspace] = QSet<QString>();
|
uniqueNames[d->nspace] = QSet<QString>();
|
||||||
|
@ -167,7 +155,7 @@ QString VContainer::UniqueNamespace()
|
||||||
{
|
{
|
||||||
candidate = QUuid::createUuid().toString();
|
candidate = QUuid::createUuid().toString();
|
||||||
}
|
}
|
||||||
while(_size.contains(candidate));
|
while(_id.contains(candidate));
|
||||||
|
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +164,6 @@ QString VContainer::UniqueNamespace()
|
||||||
void VContainer::ClearNamespace(const QString &nspace)
|
void VContainer::ClearNamespace(const QString &nspace)
|
||||||
{
|
{
|
||||||
_id.remove(nspace);
|
_id.remove(nspace);
|
||||||
_size.remove(nspace);
|
|
||||||
_height.remove(nspace);
|
|
||||||
uniqueNames.remove(nspace);
|
uniqueNames.remove(nspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,72 +720,6 @@ void VContainer::ClearExceptUniqueIncrementNames() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetSize set value of size
|
|
||||||
* @param size value of size
|
|
||||||
*/
|
|
||||||
void VContainer::SetSize(qreal size) const
|
|
||||||
{
|
|
||||||
_size[d->nspace] = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetGrowth set value of growth
|
|
||||||
* @param height value of height
|
|
||||||
*/
|
|
||||||
void VContainer::SetHeight(qreal height) const
|
|
||||||
{
|
|
||||||
_height[d->nspace] = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief size return size
|
|
||||||
* @return size in mm
|
|
||||||
*/
|
|
||||||
qreal VContainer::size() const
|
|
||||||
{
|
|
||||||
return VContainer::size(d->nspace);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
qreal VContainer::size(const QString &nspace)
|
|
||||||
{
|
|
||||||
if (_size.contains(nspace))
|
|
||||||
{
|
|
||||||
return _size.value(nspace);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw VException(QStringLiteral("Unknown namespace"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief height return height
|
|
||||||
* @return height in pattern units
|
|
||||||
*/
|
|
||||||
qreal VContainer::height() const
|
|
||||||
{
|
|
||||||
return VContainer::height(d->nspace);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
qreal VContainer::height(const QString &nspace)
|
|
||||||
{
|
|
||||||
if (_height.contains(nspace))
|
|
||||||
{
|
|
||||||
return _height.value(nspace);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw VException(QStringLiteral("Unknown namespace"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief data container with datagObjects return container of gObjects
|
* @brief data container with datagObjects return container of gObjects
|
||||||
|
|
|
@ -190,13 +190,6 @@ public:
|
||||||
void ClearUniqueIncrementNames() const;
|
void ClearUniqueIncrementNames() const;
|
||||||
void ClearExceptUniqueIncrementNames() const;
|
void ClearExceptUniqueIncrementNames() const;
|
||||||
|
|
||||||
void SetSize(qreal size) const;
|
|
||||||
void SetHeight(qreal height) const;
|
|
||||||
qreal size() const;
|
|
||||||
static qreal size(const QString &nspace);
|
|
||||||
qreal height() const;
|
|
||||||
static qreal height(const QString &nspace);
|
|
||||||
|
|
||||||
void RemoveIncrement(const QString& name);
|
void RemoveIncrement(const QString& name);
|
||||||
|
|
||||||
const QHash<quint32, QSharedPointer<VGObject> > *CalculationGObjects() const;
|
const QHash<quint32, QSharedPointer<VGObject> > *CalculationGObjects() const;
|
||||||
|
@ -227,8 +220,6 @@ private:
|
||||||
* @brief _id current id. New object will have value +1. For empty class equal 0.
|
* @brief _id current id. New object will have value +1. For empty class equal 0.
|
||||||
*/
|
*/
|
||||||
static QMap<QString, quint32> _id;
|
static QMap<QString, quint32> _id;
|
||||||
static QMap<QString, qreal> _size;
|
|
||||||
static QMap<QString, qreal> _height;
|
|
||||||
static QMap<QString, QSet<QString>> uniqueNames;
|
static QMap<QString, QSet<QString>> uniqueNames;
|
||||||
static QMap<QString, quint32> copyCounter;
|
static QMap<QString, quint32> copyCounter;
|
||||||
|
|
||||||
|
|
|
@ -48,16 +48,20 @@ TST_VMeasurements::TST_VMeasurements(QObject *parent) :
|
||||||
void TST_VMeasurements::CreateEmptyMultisizeFile()
|
void TST_VMeasurements::CreateEmptyMultisizeFile()
|
||||||
{
|
{
|
||||||
Unit mUnit = Unit::Cm;
|
Unit mUnit = Unit::Cm;
|
||||||
const int height = 176;
|
|
||||||
const int size = 50;
|
|
||||||
|
|
||||||
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
||||||
VContainer::UniqueNamespace()));
|
VContainer::UniqueNamespace()));
|
||||||
data->SetHeight(height);
|
auto m_xDimension = QSharedPointer<VXMeasurementDimension>::create(mUnit, 50, 200, 6);
|
||||||
data->SetSize(size);
|
m_xDimension->SetBaseValue(176);
|
||||||
|
|
||||||
|
auto m_yDimension = QSharedPointer<VYMeasurementDimension>::create(mUnit, 2, 22, 72);
|
||||||
|
m_yDimension->SetBaseValue(50);
|
||||||
|
m_yDimension->SetCircumference(true);
|
||||||
|
|
||||||
|
QVector<MeasurementDimension_p > dimensions{m_xDimension, m_yDimension};
|
||||||
|
|
||||||
QSharedPointer<VMeasurements> m =
|
QSharedPointer<VMeasurements> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, /*size, height,*/ data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, dimensions, data.data()));
|
||||||
|
|
||||||
QTemporaryFile file;
|
QTemporaryFile file;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
@ -138,16 +142,21 @@ void TST_VMeasurements::CreateEmptyIndividualFile()
|
||||||
void TST_VMeasurements::ValidPMCodesMultisizeFile()
|
void TST_VMeasurements::ValidPMCodesMultisizeFile()
|
||||||
{
|
{
|
||||||
Unit mUnit = Unit::Cm;
|
Unit mUnit = Unit::Cm;
|
||||||
const int height = 176;
|
|
||||||
const int size = 50;
|
|
||||||
|
|
||||||
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
||||||
VContainer::UniqueNamespace()));
|
VContainer::UniqueNamespace()));
|
||||||
data->SetHeight(height);
|
|
||||||
data->SetSize(size);
|
auto m_xDimension = QSharedPointer<VXMeasurementDimension>::create(mUnit, 50, 200, 6);
|
||||||
|
m_xDimension->SetBaseValue(176);
|
||||||
|
|
||||||
|
auto m_yDimension = QSharedPointer<VYMeasurementDimension>::create(mUnit, 2, 22, 72);
|
||||||
|
m_yDimension->SetBaseValue(50);
|
||||||
|
m_yDimension->SetCircumference(true);
|
||||||
|
|
||||||
|
QVector<MeasurementDimension_p > dimensions{m_xDimension, m_yDimension};
|
||||||
|
|
||||||
QSharedPointer<VMeasurements> m =
|
QSharedPointer<VMeasurements> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, /*size, height,*/ data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, dimensions, data.data()));
|
||||||
|
|
||||||
const QStringList listSystems = ListPMSystems();
|
const QStringList listSystems = ListPMSystems();
|
||||||
for (int i = 0; i < listSystems.size(); ++i)
|
for (int i = 0; i < listSystems.size(); ++i)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user