Fixed issue #882. VContainer class doesn't support multi document mode.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2018-09-18 16:38:16 +03:00
parent 49506c0bf2
commit 60b323cf8e
36 changed files with 322 additions and 228 deletions

View File

@ -103,6 +103,7 @@
- [#823] SVG Export - seam and cutting line of one piece missing.
- Added submenu to quick access to piece node point angle type.
- [#880] Fix broken seam allowance angle type.
- [#882] VContainer class doesn't support multi document mode.
# Version 0.5.0 May 9, 2017
- [#581] User can now filter input lists by keyword in function wizard.

View File

@ -250,11 +250,9 @@ bool TMainWindow::LoadFile(const QString &path)
try
{
data = new VContainer(qApp->TrVars(), &mUnit);
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
m = new VMeasurements(data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m->setXMLContent(path);
mType = m->Type();
@ -335,8 +333,7 @@ bool TMainWindow::LoadFile(const QString &path)
}
else
{
qApp->NewMainWindow();
return qApp->MainWindow()->LoadFile(path);
return qApp->NewMainWindow()->LoadFile(path);
}
return true;
@ -364,15 +361,13 @@ void TMainWindow::FileNew()
pUnit = mUnit;
mType = measurements.Type();
data = new VContainer(qApp->TrVars(), &mUnit);
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
currentHeight = measurements.BaseHeight();
currentSize = measurements.BaseSize();
if (mType == MeasurementsType::Multisize)
{
m = new VMeasurements(mUnit, measurements.BaseSize(), measurements.BaseHeight(), data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
}
@ -397,8 +392,7 @@ void TMainWindow::FileNew()
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->FileNew();
qApp->NewMainWindow()->FileNew();
}
}
@ -2093,13 +2087,13 @@ void TMainWindow::InitWindow()
labelGradationHeights = new QLabel(tr("Height:"));
gradationHeights = SetGradationList(labelGradationHeights, listHeights);
SetDefaultHeight(static_cast<int>(VContainer::height()));
SetDefaultHeight(static_cast<int>(data->height()));
connect(gradationHeights, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedHeight);
labelGradationSizes = new QLabel(tr("Size:"));
gradationSizes = SetGradationList(labelGradationSizes, listSizes);
SetDefaultSize(static_cast<int>(VContainer::size()));
SetDefaultSize(static_cast<int>(data->size()));
connect(gradationSizes, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedSize);
@ -2433,7 +2427,7 @@ void TMainWindow::SetDefaultSize(int value)
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RefreshData(bool freshCall)
{
VContainer::ClearUniqueNames();
data->ClearUniqueNames();
data->ClearVariables(VarType::Measurement);
m->ReadMeasurements();
@ -2894,11 +2888,9 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
try
{
data = new VContainer(qApp->TrVars(), &mUnit);
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
m = new VMeasurements(data);
m->SetSize(&currentSize);
m->SetHeight(&currentHeight);
m->setXMLContent(path);
mType = m->Type();
@ -2975,8 +2967,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
}
else
{
qApp->NewMainWindow();
return qApp->MainWindow()->LoadFile(path);
return qApp->NewMainWindow()->LoadFile(path);
}
return true;
@ -3014,8 +3005,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
QAction *action = menu->addAction(tr("&New Window"));
connect(action, &QAction::triggered, this, []()
{
qApp->NewMainWindow();
qApp->MainWindow()->activateWindow();
qApp->NewMainWindow()->activateWindow();
});
action->setMenuRole(QAction::NoRole);
menu->addSeparator();

View File

@ -677,7 +677,8 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
}
QRegularExpression rx(NameRegExp());
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false
|| rx.match(name).hasMatch() == false)
{
idToProperty[AttrName]->setValue(i->name());
}
@ -704,7 +705,8 @@ void VToolOptionsPropertyBrowser::SetPointName1(const QString &name)
}
QRegularExpression rx(NameRegExp());
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false
|| rx.match(name).hasMatch() == false)
{
idToProperty[AttrName1]->setValue(i->nameP1());
}
@ -731,7 +733,8 @@ void VToolOptionsPropertyBrowser::SetPointName2(const QString &name)
}
QRegularExpression rx(NameRegExp());
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false
|| rx.match(name).hasMatch() == false)
{
idToProperty[AttrName2]->setValue(i->nameP2());
}
@ -764,11 +767,11 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix)
}
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = VContainer::AllUniqueNames(valentinaNamespace);
for (auto &uniqueName : uniqueNames)
{
const QString name = uniqueName + suffix;
if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name))
if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name, valentinaNamespace))
{
idToProperty[AttrSuffix]->setValue(item->Suffix());
return;

View File

@ -667,7 +667,7 @@ void DialogPatternProperties::SetDefaultHeight(const QString &def)
}
else
{
const int height = static_cast<int>(VContainer::height());
const int height = static_cast<int>(pattern->height());
index = ui->comboBoxHeight->findText(QString().setNum(height));
if (index != -1)
{
@ -688,7 +688,7 @@ void DialogPatternProperties::SetDefaultSize(const QString &def)
}
else
{
const int size = static_cast<int>(VContainer::size());
const int size = static_cast<int>(pattern->size());
index = ui->comboBoxSize->findText(QString().setNum(size));
if (index != -1)
{

View File

@ -112,7 +112,9 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (selectedAction == actionRename)
{
DialogGroup *dialog = new DialogGroup(new VContainer(qApp->TrVars(), qApp->patternUnitP()), NULL_ID, this);
DialogGroup *dialog = new DialogGroup(new VContainer(qApp->TrVars(), qApp->patternUnitP(),
VContainer::UniqueNamespace()),
NULL_ID, this);
dialog->SetName(doc->GetGroupName(id));
const int result = dialog->exec();

View File

@ -444,8 +444,8 @@ bool MainWindow::LoadMeasurements(const QString &path)
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
VContainer::SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
pattern->SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
pattern->SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
doc->SetPatternWasChanged(true);
emit doc->UpdatePatternLabel();
@ -500,8 +500,8 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(size);
VContainer::SetHeight(height);
pattern->SetSize(size);
pattern->SetHeight(height);
doc->SetPatternWasChanged(true);
emit doc->UpdatePatternLabel();
@ -1143,7 +1143,7 @@ void MainWindow::ClosedDialogGroup(int result)
{
const QPointer<DialogGroup> dialog = qobject_cast<DialogGroup *>(dialogTool);
SCASSERT(not dialog.isNull())
const QDomElement group = doc->CreateGroup(VContainer::getNextId(), dialog->GetName(), dialog->GetGroup());
const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup());
if (not group.isNull())
{
AddGroup *addGroup = new AddGroup(group, doc);
@ -1733,9 +1733,9 @@ void MainWindow::ShowMeasurements()
<< "-u"
<< UnitsToStr(qApp->patternUnit())
<< "-e"
<< QString().setNum(static_cast<int>(UnitConvertor(VContainer::height(), doc->MUnit(), Unit::Cm)))
<< QString().setNum(static_cast<int>(UnitConvertor(pattern->height(), doc->MUnit(), Unit::Cm)))
<< "-s"
<< QString().setNum(static_cast<int>(UnitConvertor(VContainer::size(), doc->MUnit(), Unit::Cm)));
<< QString().setNum(static_cast<int>(UnitConvertor(pattern->size(), doc->MUnit(), Unit::Cm)));
}
else
{
@ -1796,7 +1796,7 @@ void MainWindow::SyncMeasurements()
if (mChanges)
{
const QString path = AbsoluteMPath(qApp->GetPatternPath(), doc->MPath());
if(UpdateMeasurements(path, static_cast<int>(VContainer::size()), static_cast<int>(VContainer::height())))
if(UpdateMeasurements(path, static_cast<int>(pattern->size()), static_cast<int>(pattern->height())))
{
if (not watcher->files().contains(path))
{
@ -3378,9 +3378,9 @@ void MainWindow::PatternChangesWereSaved(bool saved)
*/
void MainWindow::ChangedSize(const QString & text)
{
const int size = static_cast<int>(VContainer::size());
const int size = static_cast<int>(pattern->size());
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), text.toInt(),
static_cast<int>(VContainer::height())))
static_cast<int>(pattern->height())))
{
doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
@ -3408,8 +3408,8 @@ void MainWindow::ChangedSize(const QString & text)
*/
void MainWindow::ChangedHeight(const QString &text)
{
const int height = static_cast<int>(VContainer::height());
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), static_cast<int>(VContainer::size()),
const int height = static_cast<int>(pattern->height());
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), static_cast<int>(pattern->size()),
text.toInt()))
{
doc->LiteParseTree(Document::LiteParse);
@ -3456,13 +3456,13 @@ void MainWindow::SetDefaultHeight()
}
else
{
index = gradationHeights->findText(QString().setNum(VContainer::height()));
index = gradationHeights->findText(QString().setNum(pattern->height()));
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
}
VContainer::SetHeight(gradationHeights->currentText().toInt());
pattern->SetHeight(gradationHeights->currentText().toInt());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3476,13 +3476,13 @@ void MainWindow::SetDefaultSize()
}
else
{
index = gradationSizes->findText(QString().setNum(VContainer::size()));
index = gradationSizes->findText(QString().setNum(pattern->size()));
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
}
VContainer::SetSize(gradationSizes->currentText().toInt());
pattern->SetSize(gradationSizes->currentText().toInt());
}
//---------------------------------------------------------------------------------------------------------------------
@ -4423,8 +4423,6 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
// Here comes undocumented Valentina's feature.
// Because app bundle in Mac OS X doesn't allow setup assosiation for Tape we must do this through Valentina
VMeasurements m(pattern);
m.SetSize(VContainer::rsize());
m.SetHeight(VContainer::rheight());
m.setXMLContent(fileName);
if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual)
@ -4960,8 +4958,6 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
else
{
QScopedPointer<VMeasurements> m(new VMeasurements(pattern));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
m->setXMLContent(mPath);
patternType = m->Type();

View File

@ -112,7 +112,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
listDetails(),
currentScene(nullptr),
tempSceneLayout(nullptr),
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())),
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP(), valentinaNamespace)),
doc(nullptr),
papers(),
shadows(),
@ -1665,20 +1665,20 @@ void MainWindowsNoGUI::SetSizeHeightForIndividualM() const
if (vars->contains(size_M))
{
VContainer::SetSize(*vars->value(size_M)->GetValue());
pattern->SetSize(*vars->value(size_M)->GetValue());
}
else
{
VContainer::SetSize(0);
pattern->SetSize(0);
}
if (vars->contains(height_M))
{
VContainer::SetHeight(*vars->value(height_M)->GetValue());
pattern->SetHeight(*vars->value(height_M)->GetValue());
}
else
{
VContainer::SetHeight(0);
pattern->SetHeight(0);
}
doc->SetPatternWasChanged(true);
@ -1776,8 +1776,6 @@ QSharedPointer<VMeasurements> MainWindowsNoGUI::OpenMeasurementFile(const QStrin
try
{
m = QSharedPointer<VMeasurements>(new VMeasurements(pattern));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
m->setXMLContent(path);
if (m->Type() == MeasurementsType::Unknown)

View File

@ -337,14 +337,14 @@ VContainer VPattern::GetCompleteData() const
const int countPP = CountPP();
if (countPP <= 0 || history.isEmpty() || tools.isEmpty())
{
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
const quint32 id = (countPP == 1 ? history.last().getId() : LastToolId());
if (id == NULL_ID)
{
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
try
@ -354,7 +354,7 @@ VContainer VPattern::GetCompleteData() const
catch (VExceptionBadId &e)
{
Q_UNUSED(e)
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
}
const VDataTool *vTool = tools.value(id);
@ -455,7 +455,7 @@ void VPattern::LiteParseIncrements()
{
emit SetEnabledGUI(true);
VContainer::ClearUniqueIncrementNames();
data->ClearUniqueIncrementNames();
data->ClearVariables(VarType::Increment);
QDomNodeList tags = elementsByTagName(TagIncrements);
@ -3998,7 +3998,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa
QString VPattern::GenerateSuffix() const
{
const QString suffixBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP())).toLower();
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = data->AllUniqueNames();
qint32 num = 1;
QString suffix;
for (;;)
@ -4258,7 +4258,7 @@ void VPattern::PrepareForParse(const Document &parse)
}
else if (parse == Document::LiteParse)
{
VContainer::ClearUniqueNames();
data->ClearUniqueNames();
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
data->ClearVariables(QVector<VarType>({VarType::Increment,
VarType::LineAngle,

View File

@ -447,7 +447,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{
if (domElement.tagName() == TagGroup)
{
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR));
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace);
const QPair<bool, QMap<quint32, quint32> > groupData = ParseItemElement(domElement);
const QMap<quint32, quint32> group = groupData.second;

View File

@ -99,9 +99,7 @@ QString FileComment()
VMeasurements::VMeasurements(VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Unknown),
m_currentSize(nullptr),
m_currentHeight(nullptr)
type(MeasurementsType::Unknown)
{
SCASSERT(data != nullptr)
}
@ -110,9 +108,7 @@ VMeasurements::VMeasurements(VContainer *data)
VMeasurements::VMeasurements(Unit unit, VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Individual),
m_currentSize(nullptr),
m_currentHeight(nullptr)
type(MeasurementsType::Individual)
{
SCASSERT(data != nullptr)
@ -123,9 +119,7 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data)
:VDomDocument(),
data(data),
type(MeasurementsType::Multisize),
m_currentSize(nullptr),
m_currentHeight(nullptr)
type(MeasurementsType::Multisize)
{
SCASSERT(data != nullptr)
@ -262,7 +256,8 @@ void VMeasurements::ReadMeasurements() const
// That's why we need two containers: one for converted values, second for real data.
// Container for values in measurement file's unit
QScopedPointer<VContainer> tempData(new VContainer(data->GetTrVars(), data->GetPatternUnit()));
QScopedPointer<VContainer> tempData(new VContainer(data->GetTrVars(), data->GetPatternUnit(),
VContainer::UniqueNamespace()));
const QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i)
@ -283,8 +278,6 @@ void VMeasurements::ReadMeasurements() const
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, BaseSize(),
BaseHeight(), base, ksize, kheight));
tempMeash->SetSize(m_currentSize);
tempMeash->SetHeight(m_currentHeight);
tempMeash->SetUnit(data->GetPatternUnit());
base = UnitConvertor(base, MUnit(), *data->GetPatternUnit());
@ -296,8 +289,6 @@ void VMeasurements::ReadMeasurements() const
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
base, ksize, kheight, fullName, description));
meash->SetSize(m_currentSize);
meash->SetHeight(m_currentHeight);
meash->SetUnit(data->GetPatternUnit());
}
else
@ -477,18 +468,6 @@ void VMeasurements::SetReadOnly(bool ro)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetSize(qreal *size)
{
m_currentSize = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetHeight(qreal *height)
{
m_currentHeight = height;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMName(const QString &name, const QString &text)
{

View File

@ -90,9 +90,6 @@ public:
bool IsReadOnly() const;
void SetReadOnly(bool ro);
void SetSize(qreal *size);
void SetHeight(qreal *height);
void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text);
void SetMBaseValue(const QString &name, double value);
@ -145,9 +142,6 @@ private:
VContainer *data;
MeasurementsType type;
qreal *m_currentSize;
qreal *m_currentHeight;
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight);
void CreateEmptyIndividualFile(Unit unit);

View File

@ -96,14 +96,14 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
QString mExt;
if (qApp->patternType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vst";
}
else if (qApp->patternType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vit";
}

View File

@ -202,6 +202,8 @@ const QString unitCM = QStringLiteral("cm");
const QString unitINCH = QStringLiteral("inch");
const QString unitPX = QStringLiteral("px");
const QString valentinaNamespace = QStringLiteral("valentina");
//---------------------------------------------------------------------------------------------------------------------
QPixmap QPixmapFromCache(const QString &pixmapPath)
{

View File

@ -417,6 +417,8 @@ extern const QString unitCM;
extern const QString unitINCH;
extern const QString unitPX;
extern const QString valentinaNamespace;
QPixmap QPixmapFromCache(const QString &pixmapPath);
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);

View File

@ -104,7 +104,7 @@ bool VIncrement::IsFormulaOk() const
//---------------------------------------------------------------------------------------------------------------------
VContainer *VIncrement::GetData()
{
return &d->data;
return d->data.data();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -48,7 +48,7 @@ public:
formula(QString()),
formulaOk(false),
previewCalculation(false),
data(VContainer(nullptr, nullptr))
data()
{}
VIncrementData(VContainer *data, quint32 index, const QString &formula, bool ok)
@ -56,17 +56,17 @@ public:
formula(formula),
formulaOk(ok),
previewCalculation(false),
data(*data)
data(QSharedPointer<VContainer>(new VContainer(*data)))
{
// When we create an increment in the dialog it will get neccesary data. Such data must be removed because will
// confuse a user. Increment should not know nothing about internal variables.
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
this->data.ClearVariables(QVector<VarType>({VarType::LineAngle,
VarType::LineLength,
VarType::CurveLength,
VarType::CurveCLength,
VarType::ArcRadius,
VarType::CurveAngle}));
this->data->ClearVariables(QVector<VarType>({VarType::LineAngle,
VarType::LineLength,
VarType::CurveLength,
VarType::CurveCLength,
VarType::ArcRadius,
VarType::CurveAngle}));
}
VIncrementData(const VIncrementData &incr)
@ -85,7 +85,7 @@ public:
QString formula;
bool formulaOk;
bool previewCalculation;
VContainer data;
QSharedPointer<VContainer> data;
private:
VIncrementData &operator=(const VIncrementData &) Q_DECL_EQ_DELETE;

View File

@ -307,19 +307,7 @@ qreal *VMeasurement::GetValue()
//---------------------------------------------------------------------------------------------------------------------
VContainer *VMeasurement::GetData()
{
return &d->data;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetSize(qreal *size)
{
d->currentSize = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetHeight(qreal *height)
{
d->currentHeight = height;
return d->data.data();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -87,8 +87,6 @@ public:
VContainer *GetData();
void SetSize(qreal *size);
void SetHeight(qreal *height);
void SetUnit(const Unit *unit);
qreal GetBase() const;

View File

@ -44,7 +44,7 @@ public:
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName, qreal baseSize, qreal baseHeight,
qreal base, qreal ksize, qreal kheight )
: data(VContainer(nullptr, nullptr)),
: data(),
index(index),
formula(),
gui_text(gui_text),
@ -62,7 +62,7 @@ public:
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, const QString &gui_text,
const QString &tagName, qreal base)
: data(*data),
: data(QSharedPointer<VContainer>(new VContainer(*data))),
index(index),
formula(formula),
gui_text(gui_text),
@ -98,7 +98,7 @@ public:
virtual ~VMeasurementData();
VContainer data;
QSharedPointer<VContainer> data;
quint32 index;
QString formula;
QString gui_text;

View File

@ -31,6 +31,7 @@
#include <limits.h>
#include <QVector>
#include <QtDebug>
#include <QUuid>
#include "../ifc/exception/vexception.h"
#include "../vgeometry/vabstractcubicbezierpath.h"
@ -63,18 +64,54 @@ Q_LOGGING_CATEGORY(vCon, "v.container")
QT_WARNING_POP
quint32 VContainer::_id = NULL_ID;
qreal VContainer::_size = 50;
qreal VContainer::_height = 176;
QSet<QString> VContainer::uniqueNames = QSet<QString>();
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, quint32> VContainer::copyCounter = QMap<QString, quint32>();
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VContainer create empty container
*/
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit)
:d(new VContainerData(trVars, patternUnit))
{}
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
:d(new VContainerData(trVars, patternUnit, nspace))
{
if (nspace.isEmpty())
{
qFatal("Namesapce is empty.");
}
if (VContainer::_id.contains(nspace))
{
qFatal("Namespace is not unique.");
}
if (not _id.contains(d->nspace))
{
_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))
{
uniqueNames[d->nspace] = QSet<QString>();
}
if (not copyCounter.contains(d->nspace))
{
copyCounter[d->nspace] = 1;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
@ -89,6 +126,7 @@ VContainer &VContainer::operator =(const VContainer &data)
return *this;
}
d = data.d;
++copyCounter[d->nspace];
return *this;
}
@ -99,12 +137,36 @@ VContainer &VContainer::operator =(const VContainer &data)
*/
VContainer::VContainer(const VContainer &data)
:d(data.d)
{}
{
++copyCounter[d->nspace];
}
//---------------------------------------------------------------------------------------------------------------------
VContainer::~VContainer()
{}
//---------------------------------------------------------------------------------------------------------------------
QString VContainer::UniqueNamespace()
{
QString candidate;
do
{
candidate = QUuid::createUuid().toString();
}
while(_size.contains(candidate));
return candidate;
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearNamespace(const QString &nspace)
{
_id.remove(nspace);
_size.remove(nspace);
_height.remove(nspace);
uniqueNames.remove(nspace);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetGObject returns a point by id
@ -203,7 +265,7 @@ quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
return NULL_ID;
}
uniqueNames.insert(obj->name());
uniqueNames[d->nspace].insert(obj->name());
const quint32 id = getNextId();
obj->setId(id);
@ -236,9 +298,9 @@ quint32 VContainer::AddPiecePath(const VPiecePath &path)
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VContainer::getId()
quint32 VContainer::getId() const
{
return _id;
return _id.value(d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
@ -246,17 +308,33 @@ quint32 VContainer::getId()
* @brief getNextId generate next unique id
* @return next unique id
*/
quint32 VContainer::getNextId()
quint32 VContainer::getNextId() const
{
//TODO. Current count of ids are very big and allow us save time before someone will reach its max value.
//Better way, of cource, is to seek free ids inside the set of values and reuse them.
//But for now better to keep it as it is now.
if (_id == UINT_MAX)
if (_id.value(d->nspace) == UINT_MAX)
{
qCritical()<<(tr("Number of free id exhausted."));
}
_id++;
return _id;
_id[d->nspace]++;
return _id.value(d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::UpdateId(quint32 newId, const QString &nspace)
{
if (_id.contains(nspace))
{
if (newId > _id.value(nspace))
{
_id[nspace] = newId;
}
}
else
{
throw VException(QStringLiteral("Unknown namespace"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -264,12 +342,9 @@ quint32 VContainer::getNextId()
* @brief UpdateId update id. If new id bigger when current save new like current.
* @param newId id
*/
void VContainer::UpdateId(quint32 newId)
void VContainer::UpdateId(quint32 newId) const
{
if (newId > _id)
{
_id = newId;
}
VContainer::UpdateId(newId, d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
@ -279,7 +354,7 @@ void VContainer::UpdateId(quint32 newId)
void VContainer::Clear()
{
qCDebug(vCon, "Clearing container data.");
_id = NULL_ID;
_id[d->nspace] = NULL_ID;
d->pieces->clear();
d->piecePaths->clear();
@ -292,7 +367,7 @@ void VContainer::Clear()
void VContainer::ClearForFullParse()
{
qCDebug(vCon, "Clearing container data for full parse.");
_id = NULL_ID;
_id[d->nspace] = NULL_ID;
d->pieces->clear();
d->piecePaths->clear();
@ -552,17 +627,43 @@ const QMap<QString, QSharedPointer<VCurveAngle> > VContainer::DataAnglesCurves()
}
//---------------------------------------------------------------------------------------------------------------------
bool VContainer::IsUnique(const QString &name)
bool VContainer::IsUnique(const QString &name) const
{
return (!uniqueNames.contains(name) && !builInFunctions.contains(name));
return VContainer::IsUnique(name, d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VContainer::AllUniqueNames()
bool VContainer::IsUnique(const QString &name, const QString &nspace)
{
QStringList names = builInFunctions;
names.append(uniqueNames.toList());
return names;
if (uniqueNames.contains(nspace))
{
return (!uniqueNames.value(nspace).contains(name) && !builInFunctions.contains(name));
}
else
{
throw VException(QStringLiteral("Unknown namespace"));
}
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VContainer::AllUniqueNames() const
{
return AllUniqueNames(d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VContainer::AllUniqueNames(const QString &nspace)
{
if (uniqueNames.contains(nspace))
{
QStringList names = builInFunctions;
names.append(uniqueNames.value(nspace).toList());
return names;
}
else
{
throw VException(QStringLiteral("Unknown namespace"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -596,22 +697,22 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearUniqueNames()
void VContainer::ClearUniqueNames() const
{
uniqueNames.clear();
uniqueNames[d->nspace].clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearUniqueIncrementNames()
void VContainer::ClearUniqueIncrementNames() const
{
const QList<QString> list = uniqueNames.toList();
const QList<QString> list = uniqueNames.value(d->nspace).toList();
ClearUniqueNames();
for(auto &name : list)
{
if (not name.startsWith('#'))
{
uniqueNames.insert(name);
uniqueNames[d->nspace].insert(name);
}
}
}
@ -621,9 +722,9 @@ void VContainer::ClearUniqueIncrementNames()
* @brief SetSize set value of size
* @param size value of size
*/
void VContainer::SetSize(qreal size)
void VContainer::SetSize(qreal size) const
{
_size = size;
_size[d->nspace] = size;
}
//---------------------------------------------------------------------------------------------------------------------
@ -631,9 +732,9 @@ void VContainer::SetSize(qreal size)
* @brief SetGrowth set value of growth
* @param height value of height
*/
void VContainer::SetHeight(qreal height)
void VContainer::SetHeight(qreal height) const
{
_height = height;
_height[d->nspace] = height;
}
//---------------------------------------------------------------------------------------------------------------------
@ -641,15 +742,22 @@ void VContainer::SetHeight(qreal height)
* @brief size return size
* @return size in mm
*/
qreal VContainer::size()
qreal VContainer::size() const
{
return _size;
return VContainer::size(d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
qreal *VContainer::rsize()
qreal VContainer::size(const QString &nspace)
{
return &_size;
if (_size.contains(nspace))
{
return _size.value(nspace);
}
else
{
throw VException(QStringLiteral("Unknown namespace"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -657,15 +765,22 @@ qreal *VContainer::rsize()
* @brief height return height
* @return height in pattern units
*/
qreal VContainer::height()
qreal VContainer::height() const
{
return _height;
return VContainer::height(d->nspace);
}
//---------------------------------------------------------------------------------------------------------------------
qreal *VContainer::rheight()
qreal VContainer::height(const QString &nspace)
{
return &_height;
if (_height.contains(nspace))
{
return _height.value(nspace);
}
else
{
throw VException(QStringLiteral("Unknown namespace"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -692,4 +807,14 @@ const QHash<QString, QSharedPointer<VInternalVariable> > *VContainer::DataVariab
//---------------------------------------------------------------------------------------------------------------------
VContainerData::~VContainerData()
{}
{
if (ref == 0)
{
--VContainer::copyCounter[nspace];
}
if (VContainer::copyCounter.value(nspace) == 0)
{
VContainer::ClearNamespace(nspace);
}
}

View File

@ -68,14 +68,15 @@ class VContainerData : public QSharedData //-V690
{
public:
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
: calculationObjects(QHash<quint32, QSharedPointer<VGObject> >()),
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
trVars(trVars),
patternUnit(patternUnit)
patternUnit(patternUnit),
nspace(nspace)
{}
VContainerData(const VContainerData &data)
@ -86,7 +87,8 @@ public:
pieces(data.pieces),
piecePaths(data.piecePaths),
trVars(data.trVars),
patternUnit(data.patternUnit)
patternUnit(data.patternUnit),
nspace(data.nspace)
{}
virtual ~VContainerData();
@ -105,6 +107,9 @@ public:
const VTranslateVars *trVars;
const Unit *patternUnit;
/** @brief nspace namespace for static variables */
QString nspace;
private:
VContainerData &operator=(const VContainerData &) Q_DECL_EQ_DELETE;
};
@ -118,10 +123,12 @@ class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer)
public:
VContainer(const VTranslateVars *trVars, const Unit *patternUnit);
VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace);
VContainer(const VContainer &data);
~VContainer();
friend class VContainerData;
VContainer &operator=(const VContainer &data);
#ifdef Q_COMPILER_RVALUE_REFS
VContainer &operator=(VContainer &&data) Q_DECL_NOTHROW { Swap(data); return *this; }
@ -130,6 +137,8 @@ public:
inline void Swap(VContainer &data) Q_DECL_NOTHROW
{ std::swap(d, data.d); }
static QString UniqueNamespace();
template <typename T>
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
@ -139,9 +148,10 @@ public:
quint32 GetPieceForPiecePath(quint32 id) const;
template <typename T>
QSharedPointer<T> GetVariable(QString name) const;
static quint32 getId();
static quint32 getNextId();
static void UpdateId(quint32 newId);
quint32 getId() const;
quint32 getNextId() const;
void UpdateId(quint32 newId) const;
static void UpdateId(quint32 newId, const QString &nspace);
quint32 AddGObject(VGObject *obj);
quint32 AddGObject(const QSharedPointer<VGObject> &obj);
@ -174,15 +184,15 @@ public:
void ClearCalculationGObjects();
void ClearVariables(const VarType &type = VarType::Unknown);
void ClearVariables(const QVector<VarType> &types);
static void ClearUniqueNames();
static void ClearUniqueIncrementNames();
void ClearUniqueNames() const;
void ClearUniqueIncrementNames() const;
static void SetSize(qreal size);
static void SetHeight(qreal height);
static qreal size();
static qreal *rsize();
static qreal height();
static qreal *rheight();
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);
@ -199,8 +209,11 @@ public:
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
static bool IsUnique(const QString &name);
static QStringList AllUniqueNames();
bool IsUnique(const QString &name) const;
static bool IsUnique(const QString &name, const QString &nspace);
QStringList AllUniqueNames() const;
static QStringList AllUniqueNames(const QString &nspace);
const Unit *GetPatternUnit() const;
const VTranslateVars *GetTrVars() const;
@ -209,10 +222,11 @@ private:
/**
* @brief _id current id. New object will have value +1. For empty class equal 0.
*/
static quint32 _id;
static qreal _size;
static qreal _height;
static QSet<QString> uniqueNames;
static QMap<QString, quint32> _id;
static QMap<QString, qreal> _size;
static QMap<QString, qreal> _height;
static QMap<QString, QSet<QString>> uniqueNames;
static QMap<QString, quint32> copyCounter;
QSharedDataPointer<VContainerData> d;
@ -226,6 +240,8 @@ private:
template <typename T>
const QMap<QString, QSharedPointer<T> > DataVar(const VarType &type) const;
static void ClearNamespace(const QString &nspace);
};
Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE);
@ -324,7 +340,7 @@ void VContainer::AddVariable(const QString& name, const QSharedPointer<T> &var)
d->variables.insert(name, var);
}
uniqueNames.insert(name);
uniqueNames[d->nspace].insert(name);
}
//---------------------------------------------------------------------------------------------------------------------
@ -353,7 +369,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
{
SCASSERT(not obj.isNull())
UpdateObject(id, obj);
uniqueNames.insert(obj->name());
uniqueNames[d->nspace].insert(obj->name());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -521,14 +521,14 @@ void DialogEditLabel::InitPlaceholders()
QString mExt;
if (qApp->patternType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vst";
}
else if (qApp->patternType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vit";
}

View File

@ -253,7 +253,7 @@ void DialogFlippingByAxis::SuffixChanged()
if (m_suffix != suffix)
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = data->AllUniqueNames();
for (auto &uniqueName : uniqueNames)
{
const QString name = uniqueName + suffix;

View File

@ -280,7 +280,7 @@ void DialogFlippingByLine::SuffixChanged()
if (m_suffix != suffix)
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = data->AllUniqueNames();
for (auto &uniqueName : uniqueNames)
{
const QString name = uniqueName + suffix;

View File

@ -473,7 +473,7 @@ void DialogMove::SuffixChanged()
if (m_suffix != suffix)
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = data->AllUniqueNames();
for (auto &uniqueName : uniqueNames)
{
const QString name = uniqueName + suffix;

View File

@ -335,7 +335,7 @@ void DialogRotation::SuffixChanged()
if (m_suffix != suffix)
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = VContainer::AllUniqueNames();
const QStringList uniqueNames = data->AllUniqueNames();
for (auto &uniqueName : uniqueNames)
{
const QString name = uniqueName + suffix;

View File

@ -53,7 +53,7 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData,
{
initData.destination.clear();// Try to avoid mistake, value must be empty
initData.id = VContainer::getNextId();//Just reserve id for tool
initData.id = initData.data->getNextId();//Just reserve id for tool
for (auto idObject : qAsConst(initData.source))
{

View File

@ -197,7 +197,7 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
{
initData.destination.clear();// Try to avoid mistake, value must be empty
initData.id = VContainer::getNextId();//Just reserve id for tool
initData.id = initData.data->getNextId();//Just reserve id for tool
for (auto idObject : qAsConst(initData.source))
{

View File

@ -142,7 +142,7 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
{
initData.destination.clear();// Try to avoid mistake, value must be empty
initData.id = VContainer::getNextId();//Just reserve id for tool
initData.id = initData.data->getNextId();//Just reserve id for tool
for (auto idObject : qAsConst(initData.source))
{

View File

@ -162,7 +162,7 @@ VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
if (initData.typeCreation == Source::FromGui)
{
initData.id = VContainer::getNextId();//Just reserve id for tool
initData.id = initData.data->getNextId();//Just reserve id for tool
initData.p1id = initData.data->AddGObject(p1);
initData.p2id = initData.data->AddGObject(p2);
}

View File

@ -139,8 +139,8 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
if (initData.typeCreation == Source::FromGui)
{
initData.id = initData.data->AddGObject(p);
a1->setId(VContainer::getNextId());
a2->setId(VContainer::getNextId());
a1->setId(initData.data->getNextId());
a2->setId(initData.data->getNextId());
initData.data->AddArc(a1, a1->id(), initData.id);
initData.data->AddArc(a2, a2->id(), initData.id);
}

View File

@ -155,8 +155,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
initData.id = initData.data->AddGObject(p);
initData.data->AddLine(initData.basePointId, initData.id);
VContainer::getNextId();
VContainer::getNextId();
initData.data->getNextId();
initData.data->getNextId();
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
}
else

View File

@ -140,12 +140,12 @@ VToolLine * VToolLine::Create(VToolLineInitData initData)
SCASSERT(initData.data != nullptr)
if (initData.typeCreation == Source::FromGui)
{
initData.id = VContainer::getNextId();
initData.id = initData.data->getNextId();
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
}
else
{
VContainer::UpdateId(initData.id);
initData.data->UpdateId(initData.id);
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
if (initData.parse != Document::FullParse)
{

View File

@ -1763,7 +1763,7 @@ VToolUnionDetails* VToolUnionDetails::Create(VToolUnionDetailsInitData initData)
VToolUnionDetails *unionDetails = nullptr;
if (initData.typeCreation == Source::FromGui)
{
initData.id = VContainer::getNextId();
initData.id = initData.data->getNextId();
}
else
{

View File

@ -50,14 +50,13 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
const int height = 176;
const int size = 50;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
VContainer::SetHeight(height);
VContainer::SetSize(size);
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
VContainer::UniqueNamespace()));
data->SetHeight(height);
data->SetSize(size);
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
QTemporaryFile file;
QString fileName;
@ -97,7 +96,8 @@ void TST_VMeasurements::CreateEmptyIndividualFile()
{
Unit mUnit = Unit::Cm;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
VContainer::UniqueNamespace()));
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
@ -140,14 +140,13 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
const int height = 176;
const int size = 50;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
VContainer::SetHeight(height);
VContainer::SetSize(size);
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
VContainer::UniqueNamespace()));
data->SetHeight(height);
data->SetSize(size);
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
m->SetSize(VContainer::rsize());
m->SetHeight(VContainer::rheight());
const QStringList listSystems = ListPMSystems();
for (int i = 0; i < listSystems.size(); ++i)
@ -195,7 +194,8 @@ void TST_VMeasurements::ValidPMCodesIndividualFile()
{
Unit mUnit = Unit::Cm;
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
VContainer::UniqueNamespace()));
QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));

View File

@ -49,7 +49,7 @@ void TST_VPiece::ClearLoop()
// See file <root>/src/app/share/collection/jacketМ6_30-110.val
// Check correct seam allowance
const Unit unit = Unit::Mm;
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit));
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace()));
qApp->setPatternUnit(unit);
data->UpdateGObject(304, new VPointF(61.866708661417327, 446.92270866141735, "Ф1", 5.0000125984251973,
@ -221,7 +221,7 @@ void TST_VPiece::Issue620()
// See file <root>/src/app/share/collection/bugs/Issue_#620.vit
// Check main path
const Unit unit = Unit::Cm;
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit));
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace()));
qApp->setPatternUnit(unit);
data->UpdateGObject(1, new VPointF(30, 39.999874015748034, "A", 5.0000125984251973, 9.9999874015748045));