Fixed issue #882. VContainer class doesn't support multi document mode.
--HG-- branch : release
This commit is contained in:
parent
49506c0bf2
commit
60b323cf8e
|
@ -103,6 +103,7 @@
|
||||||
- [#823] SVG Export - seam and cutting line of one piece missing.
|
- [#823] SVG Export - seam and cutting line of one piece missing.
|
||||||
- Added submenu to quick access to piece node point angle type.
|
- Added submenu to quick access to piece node point angle type.
|
||||||
- [#880] Fix broken seam allowance 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
|
# Version 0.5.0 May 9, 2017
|
||||||
- [#581] User can now filter input lists by keyword in function wizard.
|
- [#581] User can now filter input lists by keyword in function wizard.
|
||||||
|
|
|
@ -250,11 +250,9 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
data = new VContainer(qApp->TrVars(), &mUnit);
|
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
|
||||||
|
|
||||||
m = new VMeasurements(data);
|
m = new VMeasurements(data);
|
||||||
m->SetSize(¤tSize);
|
|
||||||
m->SetHeight(¤tHeight);
|
|
||||||
m->setXMLContent(path);
|
m->setXMLContent(path);
|
||||||
|
|
||||||
mType = m->Type();
|
mType = m->Type();
|
||||||
|
@ -335,8 +333,7 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qApp->NewMainWindow();
|
return qApp->NewMainWindow()->LoadFile(path);
|
||||||
return qApp->MainWindow()->LoadFile(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -364,15 +361,13 @@ void TMainWindow::FileNew()
|
||||||
pUnit = mUnit;
|
pUnit = mUnit;
|
||||||
mType = measurements.Type();
|
mType = measurements.Type();
|
||||||
|
|
||||||
data = new VContainer(qApp->TrVars(), &mUnit);
|
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
|
||||||
currentHeight = measurements.BaseHeight();
|
currentHeight = measurements.BaseHeight();
|
||||||
currentSize = measurements.BaseSize();
|
currentSize = measurements.BaseSize();
|
||||||
|
|
||||||
if (mType == MeasurementsType::Multisize)
|
if (mType == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
m = new VMeasurements(mUnit, measurements.BaseSize(), measurements.BaseHeight(), data);
|
m = new VMeasurements(mUnit, measurements.BaseSize(), measurements.BaseHeight(), data);
|
||||||
m->SetSize(¤tSize);
|
|
||||||
m->SetHeight(¤tHeight);
|
|
||||||
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
|
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
|
||||||
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
|
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
|
||||||
}
|
}
|
||||||
|
@ -397,8 +392,7 @@ void TMainWindow::FileNew()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qApp->NewMainWindow();
|
qApp->NewMainWindow()->FileNew();
|
||||||
qApp->MainWindow()->FileNew();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2093,13 +2087,13 @@ void TMainWindow::InitWindow()
|
||||||
|
|
||||||
labelGradationHeights = new QLabel(tr("Height:"));
|
labelGradationHeights = new QLabel(tr("Height:"));
|
||||||
gradationHeights = SetGradationList(labelGradationHeights, listHeights);
|
gradationHeights = SetGradationList(labelGradationHeights, listHeights);
|
||||||
SetDefaultHeight(static_cast<int>(VContainer::height()));
|
SetDefaultHeight(static_cast<int>(data->height()));
|
||||||
connect(gradationHeights, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(gradationHeights, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &TMainWindow::ChangedHeight);
|
this, &TMainWindow::ChangedHeight);
|
||||||
|
|
||||||
labelGradationSizes = new QLabel(tr("Size:"));
|
labelGradationSizes = new QLabel(tr("Size:"));
|
||||||
gradationSizes = SetGradationList(labelGradationSizes, listSizes);
|
gradationSizes = SetGradationList(labelGradationSizes, listSizes);
|
||||||
SetDefaultSize(static_cast<int>(VContainer::size()));
|
SetDefaultSize(static_cast<int>(data->size()));
|
||||||
connect(gradationSizes, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(gradationSizes, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &TMainWindow::ChangedSize);
|
this, &TMainWindow::ChangedSize);
|
||||||
|
|
||||||
|
@ -2433,7 +2427,7 @@ void TMainWindow::SetDefaultSize(int value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::RefreshData(bool freshCall)
|
void TMainWindow::RefreshData(bool freshCall)
|
||||||
{
|
{
|
||||||
VContainer::ClearUniqueNames();
|
data->ClearUniqueNames();
|
||||||
data->ClearVariables(VarType::Measurement);
|
data->ClearVariables(VarType::Measurement);
|
||||||
m->ReadMeasurements();
|
m->ReadMeasurements();
|
||||||
|
|
||||||
|
@ -2894,11 +2888,9 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
data = new VContainer(qApp->TrVars(), &mUnit);
|
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
|
||||||
|
|
||||||
m = new VMeasurements(data);
|
m = new VMeasurements(data);
|
||||||
m->SetSize(¤tSize);
|
|
||||||
m->SetHeight(¤tHeight);
|
|
||||||
m->setXMLContent(path);
|
m->setXMLContent(path);
|
||||||
|
|
||||||
mType = m->Type();
|
mType = m->Type();
|
||||||
|
@ -2975,8 +2967,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qApp->NewMainWindow();
|
return qApp->NewMainWindow()->LoadFile(path);
|
||||||
return qApp->MainWindow()->LoadFile(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3014,8 +3005,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
||||||
QAction *action = menu->addAction(tr("&New Window"));
|
QAction *action = menu->addAction(tr("&New Window"));
|
||||||
connect(action, &QAction::triggered, this, []()
|
connect(action, &QAction::triggered, this, []()
|
||||||
{
|
{
|
||||||
qApp->NewMainWindow();
|
qApp->NewMainWindow()->activateWindow();
|
||||||
qApp->MainWindow()->activateWindow();
|
|
||||||
});
|
});
|
||||||
action->setMenuRole(QAction::NoRole);
|
action->setMenuRole(QAction::NoRole);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
|
@ -677,7 +677,8 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression rx(NameRegExp());
|
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());
|
idToProperty[AttrName]->setValue(i->name());
|
||||||
}
|
}
|
||||||
|
@ -704,7 +705,8 @@ void VToolOptionsPropertyBrowser::SetPointName1(const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression rx(NameRegExp());
|
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());
|
idToProperty[AttrName1]->setValue(i->nameP1());
|
||||||
}
|
}
|
||||||
|
@ -731,7 +733,8 @@ void VToolOptionsPropertyBrowser::SetPointName2(const QString &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression rx(NameRegExp());
|
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());
|
idToProperty[AttrName2]->setValue(i->nameP2());
|
||||||
}
|
}
|
||||||
|
@ -764,11 +767,11 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpression rx(NameRegExp());
|
QRegularExpression rx(NameRegExp());
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = VContainer::AllUniqueNames(valentinaNamespace);
|
||||||
for (auto &uniqueName : uniqueNames)
|
for (auto &uniqueName : uniqueNames)
|
||||||
{
|
{
|
||||||
const QString name = uniqueName + suffix;
|
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());
|
idToProperty[AttrSuffix]->setValue(item->Suffix());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -667,7 +667,7 @@ void DialogPatternProperties::SetDefaultHeight(const QString &def)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int height = static_cast<int>(VContainer::height());
|
const int height = static_cast<int>(pattern->height());
|
||||||
index = ui->comboBoxHeight->findText(QString().setNum(height));
|
index = ui->comboBoxHeight->findText(QString().setNum(height));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
|
@ -688,7 +688,7 @@ void DialogPatternProperties::SetDefaultSize(const QString &def)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int size = static_cast<int>(VContainer::size());
|
const int size = static_cast<int>(pattern->size());
|
||||||
index = ui->comboBoxSize->findText(QString().setNum(size));
|
index = ui->comboBoxSize->findText(QString().setNum(size));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,9 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
|
||||||
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||||
if (selectedAction == actionRename)
|
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));
|
dialog->SetName(doc->GetGroupName(id));
|
||||||
const int result = dialog->exec();
|
const int result = dialog->exec();
|
||||||
|
|
||||||
|
|
|
@ -444,8 +444,8 @@ bool MainWindow::LoadMeasurements(const QString &path)
|
||||||
|
|
||||||
if (m->Type() == MeasurementsType::Multisize)
|
if (m->Type() == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
VContainer::SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
|
pattern->SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
|
||||||
VContainer::SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
|
pattern->SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
|
||||||
|
|
||||||
doc->SetPatternWasChanged(true);
|
doc->SetPatternWasChanged(true);
|
||||||
emit doc->UpdatePatternLabel();
|
emit doc->UpdatePatternLabel();
|
||||||
|
@ -500,8 +500,8 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
|
||||||
|
|
||||||
if (m->Type() == MeasurementsType::Multisize)
|
if (m->Type() == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
VContainer::SetSize(size);
|
pattern->SetSize(size);
|
||||||
VContainer::SetHeight(height);
|
pattern->SetHeight(height);
|
||||||
|
|
||||||
doc->SetPatternWasChanged(true);
|
doc->SetPatternWasChanged(true);
|
||||||
emit doc->UpdatePatternLabel();
|
emit doc->UpdatePatternLabel();
|
||||||
|
@ -1143,7 +1143,7 @@ void MainWindow::ClosedDialogGroup(int result)
|
||||||
{
|
{
|
||||||
const QPointer<DialogGroup> dialog = qobject_cast<DialogGroup *>(dialogTool);
|
const QPointer<DialogGroup> dialog = qobject_cast<DialogGroup *>(dialogTool);
|
||||||
SCASSERT(not dialog.isNull())
|
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())
|
if (not group.isNull())
|
||||||
{
|
{
|
||||||
AddGroup *addGroup = new AddGroup(group, doc);
|
AddGroup *addGroup = new AddGroup(group, doc);
|
||||||
|
@ -1733,9 +1733,9 @@ void MainWindow::ShowMeasurements()
|
||||||
<< "-u"
|
<< "-u"
|
||||||
<< UnitsToStr(qApp->patternUnit())
|
<< UnitsToStr(qApp->patternUnit())
|
||||||
<< "-e"
|
<< "-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"
|
<< "-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
|
else
|
||||||
{
|
{
|
||||||
|
@ -1796,7 +1796,7 @@ void MainWindow::SyncMeasurements()
|
||||||
if (mChanges)
|
if (mChanges)
|
||||||
{
|
{
|
||||||
const QString path = AbsoluteMPath(qApp->GetPatternPath(), doc->MPath());
|
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))
|
if (not watcher->files().contains(path))
|
||||||
{
|
{
|
||||||
|
@ -3378,9 +3378,9 @@ void MainWindow::PatternChangesWereSaved(bool saved)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ChangedSize(const QString & text)
|
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(),
|
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), text.toInt(),
|
||||||
static_cast<int>(VContainer::height())))
|
static_cast<int>(pattern->height())))
|
||||||
{
|
{
|
||||||
doc->LiteParseTree(Document::LiteParse);
|
doc->LiteParseTree(Document::LiteParse);
|
||||||
emit sceneDetails->DimensionsChanged();
|
emit sceneDetails->DimensionsChanged();
|
||||||
|
@ -3408,8 +3408,8 @@ void MainWindow::ChangedSize(const QString & text)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ChangedHeight(const QString &text)
|
void MainWindow::ChangedHeight(const QString &text)
|
||||||
{
|
{
|
||||||
const int height = static_cast<int>(VContainer::height());
|
const int height = static_cast<int>(pattern->height());
|
||||||
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), static_cast<int>(VContainer::size()),
|
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPatternPath(), doc->MPath()), static_cast<int>(pattern->size()),
|
||||||
text.toInt()))
|
text.toInt()))
|
||||||
{
|
{
|
||||||
doc->LiteParseTree(Document::LiteParse);
|
doc->LiteParseTree(Document::LiteParse);
|
||||||
|
@ -3456,13 +3456,13 @@ void MainWindow::SetDefaultHeight()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index = gradationHeights->findText(QString().setNum(VContainer::height()));
|
index = gradationHeights->findText(QString().setNum(pattern->height()));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
gradationHeights->setCurrentIndex(index);
|
gradationHeights->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VContainer::SetHeight(gradationHeights->currentText().toInt());
|
pattern->SetHeight(gradationHeights->currentText().toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -3476,13 +3476,13 @@ void MainWindow::SetDefaultSize()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index = gradationSizes->findText(QString().setNum(VContainer::size()));
|
index = gradationSizes->findText(QString().setNum(pattern->size()));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
gradationSizes->setCurrentIndex(index);
|
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.
|
// 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
|
// Because app bundle in Mac OS X doesn't allow setup assosiation for Tape we must do this through Valentina
|
||||||
VMeasurements m(pattern);
|
VMeasurements m(pattern);
|
||||||
m.SetSize(VContainer::rsize());
|
|
||||||
m.SetHeight(VContainer::rheight());
|
|
||||||
m.setXMLContent(fileName);
|
m.setXMLContent(fileName);
|
||||||
|
|
||||||
if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual)
|
if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual)
|
||||||
|
@ -4960,8 +4958,6 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QScopedPointer<VMeasurements> m(new VMeasurements(pattern));
|
QScopedPointer<VMeasurements> m(new VMeasurements(pattern));
|
||||||
m->SetSize(VContainer::rsize());
|
|
||||||
m->SetHeight(VContainer::rheight());
|
|
||||||
m->setXMLContent(mPath);
|
m->setXMLContent(mPath);
|
||||||
|
|
||||||
patternType = m->Type();
|
patternType = m->Type();
|
||||||
|
|
|
@ -112,7 +112,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||||
listDetails(),
|
listDetails(),
|
||||||
currentScene(nullptr),
|
currentScene(nullptr),
|
||||||
tempSceneLayout(nullptr),
|
tempSceneLayout(nullptr),
|
||||||
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())),
|
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP(), valentinaNamespace)),
|
||||||
doc(nullptr),
|
doc(nullptr),
|
||||||
papers(),
|
papers(),
|
||||||
shadows(),
|
shadows(),
|
||||||
|
@ -1665,20 +1665,20 @@ void MainWindowsNoGUI::SetSizeHeightForIndividualM() const
|
||||||
|
|
||||||
if (vars->contains(size_M))
|
if (vars->contains(size_M))
|
||||||
{
|
{
|
||||||
VContainer::SetSize(*vars->value(size_M)->GetValue());
|
pattern->SetSize(*vars->value(size_M)->GetValue());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VContainer::SetSize(0);
|
pattern->SetSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vars->contains(height_M))
|
if (vars->contains(height_M))
|
||||||
{
|
{
|
||||||
VContainer::SetHeight(*vars->value(height_M)->GetValue());
|
pattern->SetHeight(*vars->value(height_M)->GetValue());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VContainer::SetHeight(0);
|
pattern->SetHeight(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc->SetPatternWasChanged(true);
|
doc->SetPatternWasChanged(true);
|
||||||
|
@ -1776,8 +1776,6 @@ QSharedPointer<VMeasurements> MainWindowsNoGUI::OpenMeasurementFile(const QStrin
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m = QSharedPointer<VMeasurements>(new VMeasurements(pattern));
|
m = QSharedPointer<VMeasurements>(new VMeasurements(pattern));
|
||||||
m->SetSize(VContainer::rsize());
|
|
||||||
m->SetHeight(VContainer::rheight());
|
|
||||||
m->setXMLContent(path);
|
m->setXMLContent(path);
|
||||||
|
|
||||||
if (m->Type() == MeasurementsType::Unknown)
|
if (m->Type() == MeasurementsType::Unknown)
|
||||||
|
|
|
@ -337,14 +337,14 @@ VContainer VPattern::GetCompleteData() const
|
||||||
const int countPP = CountPP();
|
const int countPP = CountPP();
|
||||||
if (countPP <= 0 || history.isEmpty() || tools.isEmpty())
|
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());
|
const quint32 id = (countPP == 1 ? history.last().getId() : LastToolId());
|
||||||
|
|
||||||
if (id == NULL_ID)
|
if (id == NULL_ID)
|
||||||
{
|
{
|
||||||
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
|
return (data != nullptr ? *data : VContainer(nullptr, nullptr, VContainer::UniqueNamespace()));
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -354,7 +354,7 @@ VContainer VPattern::GetCompleteData() const
|
||||||
catch (VExceptionBadId &e)
|
catch (VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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);
|
const VDataTool *vTool = tools.value(id);
|
||||||
|
@ -455,7 +455,7 @@ void VPattern::LiteParseIncrements()
|
||||||
{
|
{
|
||||||
emit SetEnabledGUI(true);
|
emit SetEnabledGUI(true);
|
||||||
|
|
||||||
VContainer::ClearUniqueIncrementNames();
|
data->ClearUniqueIncrementNames();
|
||||||
data->ClearVariables(VarType::Increment);
|
data->ClearVariables(VarType::Increment);
|
||||||
|
|
||||||
QDomNodeList tags = elementsByTagName(TagIncrements);
|
QDomNodeList tags = elementsByTagName(TagIncrements);
|
||||||
|
@ -3998,7 +3998,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa
|
||||||
QString VPattern::GenerateSuffix() const
|
QString VPattern::GenerateSuffix() const
|
||||||
{
|
{
|
||||||
const QString suffixBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP())).toLower();
|
const QString suffixBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP())).toLower();
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = data->AllUniqueNames();
|
||||||
qint32 num = 1;
|
qint32 num = 1;
|
||||||
QString suffix;
|
QString suffix;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -4258,7 +4258,7 @@ void VPattern::PrepareForParse(const Document &parse)
|
||||||
}
|
}
|
||||||
else if (parse == Document::LiteParse)
|
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");
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||||
data->ClearVariables(QVector<VarType>({VarType::Increment,
|
data->ClearVariables(QVector<VarType>({VarType::Increment,
|
||||||
VarType::LineAngle,
|
VarType::LineAngle,
|
||||||
|
|
|
@ -447,7 +447,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
|
||||||
{
|
{
|
||||||
if (domElement.tagName() == TagGroup)
|
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 QPair<bool, QMap<quint32, quint32> > groupData = ParseItemElement(domElement);
|
||||||
const QMap<quint32, quint32> group = groupData.second;
|
const QMap<quint32, quint32> group = groupData.second;
|
||||||
|
|
|
@ -99,9 +99,7 @@ QString FileComment()
|
||||||
VMeasurements::VMeasurements(VContainer *data)
|
VMeasurements::VMeasurements(VContainer *data)
|
||||||
:VDomDocument(),
|
:VDomDocument(),
|
||||||
data(data),
|
data(data),
|
||||||
type(MeasurementsType::Unknown),
|
type(MeasurementsType::Unknown)
|
||||||
m_currentSize(nullptr),
|
|
||||||
m_currentHeight(nullptr)
|
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
}
|
}
|
||||||
|
@ -110,9 +108,7 @@ VMeasurements::VMeasurements(VContainer *data)
|
||||||
VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
||||||
:VDomDocument(),
|
:VDomDocument(),
|
||||||
data(data),
|
data(data),
|
||||||
type(MeasurementsType::Individual),
|
type(MeasurementsType::Individual)
|
||||||
m_currentSize(nullptr),
|
|
||||||
m_currentHeight(nullptr)
|
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
|
||||||
|
@ -123,9 +119,7 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
||||||
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data)
|
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data)
|
||||||
:VDomDocument(),
|
:VDomDocument(),
|
||||||
data(data),
|
data(data),
|
||||||
type(MeasurementsType::Multisize),
|
type(MeasurementsType::Multisize)
|
||||||
m_currentSize(nullptr),
|
|
||||||
m_currentHeight(nullptr)
|
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
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.
|
// That's why we need two containers: one for converted values, second for real data.
|
||||||
|
|
||||||
// Container for values in measurement file's unit
|
// 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);
|
const QDomNodeList list = elementsByTagName(TagMeasurement);
|
||||||
for (int i=0; i < list.size(); ++i)
|
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(),
|
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, BaseSize(),
|
||||||
BaseHeight(), base, ksize, kheight));
|
BaseHeight(), base, ksize, kheight));
|
||||||
tempMeash->SetSize(m_currentSize);
|
|
||||||
tempMeash->SetHeight(m_currentHeight);
|
|
||||||
tempMeash->SetUnit(data->GetPatternUnit());
|
tempMeash->SetUnit(data->GetPatternUnit());
|
||||||
|
|
||||||
base = UnitConvertor(base, MUnit(), *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,
|
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
|
||||||
base, ksize, kheight, fullName, description));
|
base, ksize, kheight, fullName, description));
|
||||||
meash->SetSize(m_currentSize);
|
|
||||||
meash->SetHeight(m_currentHeight);
|
|
||||||
meash->SetUnit(data->GetPatternUnit());
|
meash->SetUnit(data->GetPatternUnit());
|
||||||
}
|
}
|
||||||
else
|
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)
|
void VMeasurements::SetMName(const QString &name, const QString &text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,9 +90,6 @@ public:
|
||||||
bool IsReadOnly() const;
|
bool IsReadOnly() const;
|
||||||
void SetReadOnly(bool ro);
|
void SetReadOnly(bool ro);
|
||||||
|
|
||||||
void SetSize(qreal *size);
|
|
||||||
void SetHeight(qreal *height);
|
|
||||||
|
|
||||||
void SetMName(const QString &name, const QString &text);
|
void SetMName(const QString &name, const QString &text);
|
||||||
void SetMValue(const QString &name, const QString &text);
|
void SetMValue(const QString &name, const QString &text);
|
||||||
void SetMBaseValue(const QString &name, double value);
|
void SetMBaseValue(const QString &name, double value);
|
||||||
|
@ -145,9 +142,6 @@ private:
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
MeasurementsType type;
|
MeasurementsType type;
|
||||||
|
|
||||||
qreal *m_currentSize;
|
|
||||||
qreal *m_currentHeight;
|
|
||||||
|
|
||||||
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight);
|
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight);
|
||||||
void CreateEmptyIndividualFile(Unit unit);
|
void CreateEmptyIndividualFile(Unit unit);
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,14 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
|
||||||
QString mExt;
|
QString mExt;
|
||||||
if (qApp->patternType() == MeasurementsType::Multisize)
|
if (qApp->patternType() == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
curSize = QString::number(VContainer::size());
|
curSize = QString::number(VContainer::size(valentinaNamespace));
|
||||||
curHeight = QString::number(VContainer::height());
|
curHeight = QString::number(VContainer::height(valentinaNamespace));
|
||||||
mExt = "vst";
|
mExt = "vst";
|
||||||
}
|
}
|
||||||
else if (qApp->patternType() == MeasurementsType::Individual)
|
else if (qApp->patternType() == MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
curSize = QString::number(VContainer::size());
|
curSize = QString::number(VContainer::size(valentinaNamespace));
|
||||||
curHeight = QString::number(VContainer::height());
|
curHeight = QString::number(VContainer::height(valentinaNamespace));
|
||||||
mExt = "vit";
|
mExt = "vit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,8 @@ const QString unitCM = QStringLiteral("cm");
|
||||||
const QString unitINCH = QStringLiteral("inch");
|
const QString unitINCH = QStringLiteral("inch");
|
||||||
const QString unitPX = QStringLiteral("px");
|
const QString unitPX = QStringLiteral("px");
|
||||||
|
|
||||||
|
const QString valentinaNamespace = QStringLiteral("valentina");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPixmap QPixmapFromCache(const QString &pixmapPath)
|
QPixmap QPixmapFromCache(const QString &pixmapPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -417,6 +417,8 @@ extern const QString unitCM;
|
||||||
extern const QString unitINCH;
|
extern const QString unitINCH;
|
||||||
extern const QString unitPX;
|
extern const QString unitPX;
|
||||||
|
|
||||||
|
extern const QString valentinaNamespace;
|
||||||
|
|
||||||
QPixmap QPixmapFromCache(const QString &pixmapPath);
|
QPixmap QPixmapFromCache(const QString &pixmapPath);
|
||||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool VIncrement::IsFormulaOk() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VContainer *VIncrement::GetData()
|
VContainer *VIncrement::GetData()
|
||||||
{
|
{
|
||||||
return &d->data;
|
return d->data.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
formula(QString()),
|
formula(QString()),
|
||||||
formulaOk(false),
|
formulaOk(false),
|
||||||
previewCalculation(false),
|
previewCalculation(false),
|
||||||
data(VContainer(nullptr, nullptr))
|
data()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VIncrementData(VContainer *data, quint32 index, const QString &formula, bool ok)
|
VIncrementData(VContainer *data, quint32 index, const QString &formula, bool ok)
|
||||||
|
@ -56,17 +56,17 @@ public:
|
||||||
formula(formula),
|
formula(formula),
|
||||||
formulaOk(ok),
|
formulaOk(ok),
|
||||||
previewCalculation(false),
|
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
|
// 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.
|
// 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");
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||||
this->data.ClearVariables(QVector<VarType>({VarType::LineAngle,
|
this->data->ClearVariables(QVector<VarType>({VarType::LineAngle,
|
||||||
VarType::LineLength,
|
VarType::LineLength,
|
||||||
VarType::CurveLength,
|
VarType::CurveLength,
|
||||||
VarType::CurveCLength,
|
VarType::CurveCLength,
|
||||||
VarType::ArcRadius,
|
VarType::ArcRadius,
|
||||||
VarType::CurveAngle}));
|
VarType::CurveAngle}));
|
||||||
}
|
}
|
||||||
|
|
||||||
VIncrementData(const VIncrementData &incr)
|
VIncrementData(const VIncrementData &incr)
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
QString formula;
|
QString formula;
|
||||||
bool formulaOk;
|
bool formulaOk;
|
||||||
bool previewCalculation;
|
bool previewCalculation;
|
||||||
VContainer data;
|
QSharedPointer<VContainer> data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VIncrementData &operator=(const VIncrementData &) Q_DECL_EQ_DELETE;
|
VIncrementData &operator=(const VIncrementData &) Q_DECL_EQ_DELETE;
|
||||||
|
|
|
@ -307,19 +307,7 @@ qreal *VMeasurement::GetValue()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VContainer *VMeasurement::GetData()
|
VContainer *VMeasurement::GetData()
|
||||||
{
|
{
|
||||||
return &d->data;
|
return d->data.data();
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VMeasurement::SetSize(qreal *size)
|
|
||||||
{
|
|
||||||
d->currentSize = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VMeasurement::SetHeight(qreal *height)
|
|
||||||
{
|
|
||||||
d->currentHeight = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -87,8 +87,6 @@ public:
|
||||||
|
|
||||||
VContainer *GetData();
|
VContainer *GetData();
|
||||||
|
|
||||||
void SetSize(qreal *size);
|
|
||||||
void SetHeight(qreal *height);
|
|
||||||
void SetUnit(const Unit *unit);
|
void SetUnit(const Unit *unit);
|
||||||
|
|
||||||
qreal GetBase() const;
|
qreal GetBase() const;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
|
|
||||||
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName, qreal baseSize, qreal baseHeight,
|
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName, qreal baseSize, qreal baseHeight,
|
||||||
qreal base, qreal ksize, qreal kheight )
|
qreal base, qreal ksize, qreal kheight )
|
||||||
: data(VContainer(nullptr, nullptr)),
|
: data(),
|
||||||
index(index),
|
index(index),
|
||||||
formula(),
|
formula(),
|
||||||
gui_text(gui_text),
|
gui_text(gui_text),
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, const QString &gui_text,
|
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, const QString &gui_text,
|
||||||
const QString &tagName, qreal base)
|
const QString &tagName, qreal base)
|
||||||
: data(*data),
|
: data(QSharedPointer<VContainer>(new VContainer(*data))),
|
||||||
index(index),
|
index(index),
|
||||||
formula(formula),
|
formula(formula),
|
||||||
gui_text(gui_text),
|
gui_text(gui_text),
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
|
|
||||||
virtual ~VMeasurementData();
|
virtual ~VMeasurementData();
|
||||||
|
|
||||||
VContainer data;
|
QSharedPointer<VContainer> data;
|
||||||
quint32 index;
|
quint32 index;
|
||||||
QString formula;
|
QString formula;
|
||||||
QString gui_text;
|
QString gui_text;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "../vgeometry/vabstractcubicbezierpath.h"
|
#include "../vgeometry/vabstractcubicbezierpath.h"
|
||||||
|
@ -63,18 +64,54 @@ Q_LOGGING_CATEGORY(vCon, "v.container")
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
quint32 VContainer::_id = NULL_ID;
|
QMap<QString, quint32> VContainer::_id = QMap<QString, quint32>();
|
||||||
qreal VContainer::_size = 50;
|
QMap<QString, qreal> VContainer::_size = QMap<QString, qreal>();
|
||||||
qreal VContainer::_height = 176;
|
QMap<QString, qreal> VContainer::_height = QMap<QString, qreal>();
|
||||||
QSet<QString> VContainer::uniqueNames = QSet<QString>();
|
QMap<QString, QSet<QString>> VContainer::uniqueNames = QMap<QString, QSet<QString>>();
|
||||||
|
QMap<QString, quint32> VContainer::copyCounter = QMap<QString, quint32>();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VContainer create empty container
|
* @brief VContainer create empty container
|
||||||
*/
|
*/
|
||||||
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit)
|
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
|
||||||
:d(new VContainerData(trVars, patternUnit))
|
: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;
|
return *this;
|
||||||
}
|
}
|
||||||
d = data.d;
|
d = data.d;
|
||||||
|
++copyCounter[d->nspace];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +137,36 @@ VContainer &VContainer::operator =(const VContainer &data)
|
||||||
*/
|
*/
|
||||||
VContainer::VContainer(const VContainer &data)
|
VContainer::VContainer(const VContainer &data)
|
||||||
:d(data.d)
|
:d(data.d)
|
||||||
{}
|
{
|
||||||
|
++copyCounter[d->nspace];
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VContainer::~VContainer()
|
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
|
* @brief GetGObject returns a point by id
|
||||||
|
@ -203,7 +265,7 @@ quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
|
||||||
return NULL_ID;
|
return NULL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueNames.insert(obj->name());
|
uniqueNames[d->nspace].insert(obj->name());
|
||||||
const quint32 id = getNextId();
|
const quint32 id = getNextId();
|
||||||
obj->setId(id);
|
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
|
* @brief getNextId generate next unique id
|
||||||
* @return 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.
|
//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.
|
//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.
|
//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."));
|
qCritical()<<(tr("Number of free id exhausted."));
|
||||||
}
|
}
|
||||||
_id++;
|
_id[d->nspace]++;
|
||||||
return _id;
|
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.
|
* @brief UpdateId update id. If new id bigger when current save new like current.
|
||||||
* @param newId id
|
* @param newId id
|
||||||
*/
|
*/
|
||||||
void VContainer::UpdateId(quint32 newId)
|
void VContainer::UpdateId(quint32 newId) const
|
||||||
{
|
{
|
||||||
if (newId > _id)
|
VContainer::UpdateId(newId, d->nspace);
|
||||||
{
|
|
||||||
_id = newId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -279,7 +354,7 @@ void VContainer::UpdateId(quint32 newId)
|
||||||
void VContainer::Clear()
|
void VContainer::Clear()
|
||||||
{
|
{
|
||||||
qCDebug(vCon, "Clearing container data.");
|
qCDebug(vCon, "Clearing container data.");
|
||||||
_id = NULL_ID;
|
_id[d->nspace] = NULL_ID;
|
||||||
|
|
||||||
d->pieces->clear();
|
d->pieces->clear();
|
||||||
d->piecePaths->clear();
|
d->piecePaths->clear();
|
||||||
|
@ -292,7 +367,7 @@ void VContainer::Clear()
|
||||||
void VContainer::ClearForFullParse()
|
void VContainer::ClearForFullParse()
|
||||||
{
|
{
|
||||||
qCDebug(vCon, "Clearing container data for full parse.");
|
qCDebug(vCon, "Clearing container data for full parse.");
|
||||||
_id = NULL_ID;
|
_id[d->nspace] = NULL_ID;
|
||||||
|
|
||||||
d->pieces->clear();
|
d->pieces->clear();
|
||||||
d->piecePaths->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;
|
if (uniqueNames.contains(nspace))
|
||||||
names.append(uniqueNames.toList());
|
{
|
||||||
return names;
|
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();
|
ClearUniqueNames();
|
||||||
|
|
||||||
for(auto &name : list)
|
for(auto &name : list)
|
||||||
{
|
{
|
||||||
if (not name.startsWith('#'))
|
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
|
* @brief SetSize set value of size
|
||||||
* @param size 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
|
* @brief SetGrowth set value of growth
|
||||||
* @param height value of height
|
* @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
|
* @brief size return size
|
||||||
* @return size in mm
|
* @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
|
* @brief height return height
|
||||||
* @return height in pattern units
|
* @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()
|
VContainerData::~VContainerData()
|
||||||
{}
|
{
|
||||||
|
if (ref == 0)
|
||||||
|
{
|
||||||
|
--VContainer::copyCounter[nspace];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VContainer::copyCounter.value(nspace) == 0)
|
||||||
|
{
|
||||||
|
VContainer::ClearNamespace(nspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -68,14 +68,15 @@ class VContainerData : public QSharedData //-V690
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
|
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
|
||||||
: calculationObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
: calculationObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
||||||
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
|
||||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
|
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
|
||||||
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
|
||||||
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
|
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
|
||||||
trVars(trVars),
|
trVars(trVars),
|
||||||
patternUnit(patternUnit)
|
patternUnit(patternUnit),
|
||||||
|
nspace(nspace)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VContainerData(const VContainerData &data)
|
VContainerData(const VContainerData &data)
|
||||||
|
@ -86,7 +87,8 @@ public:
|
||||||
pieces(data.pieces),
|
pieces(data.pieces),
|
||||||
piecePaths(data.piecePaths),
|
piecePaths(data.piecePaths),
|
||||||
trVars(data.trVars),
|
trVars(data.trVars),
|
||||||
patternUnit(data.patternUnit)
|
patternUnit(data.patternUnit),
|
||||||
|
nspace(data.nspace)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~VContainerData();
|
virtual ~VContainerData();
|
||||||
|
@ -105,6 +107,9 @@ public:
|
||||||
const VTranslateVars *trVars;
|
const VTranslateVars *trVars;
|
||||||
const Unit *patternUnit;
|
const Unit *patternUnit;
|
||||||
|
|
||||||
|
/** @brief nspace namespace for static variables */
|
||||||
|
QString nspace;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VContainerData &operator=(const VContainerData &) Q_DECL_EQ_DELETE;
|
VContainerData &operator=(const VContainerData &) Q_DECL_EQ_DELETE;
|
||||||
};
|
};
|
||||||
|
@ -118,10 +123,12 @@ class VContainer
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VContainer)
|
Q_DECLARE_TR_FUNCTIONS(VContainer)
|
||||||
public:
|
public:
|
||||||
VContainer(const VTranslateVars *trVars, const Unit *patternUnit);
|
VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace);
|
||||||
VContainer(const VContainer &data);
|
VContainer(const VContainer &data);
|
||||||
~VContainer();
|
~VContainer();
|
||||||
|
|
||||||
|
friend class VContainerData;
|
||||||
|
|
||||||
VContainer &operator=(const VContainer &data);
|
VContainer &operator=(const VContainer &data);
|
||||||
#ifdef Q_COMPILER_RVALUE_REFS
|
#ifdef Q_COMPILER_RVALUE_REFS
|
||||||
VContainer &operator=(VContainer &&data) Q_DECL_NOTHROW { Swap(data); return *this; }
|
VContainer &operator=(VContainer &&data) Q_DECL_NOTHROW { Swap(data); return *this; }
|
||||||
|
@ -130,6 +137,8 @@ public:
|
||||||
inline void Swap(VContainer &data) Q_DECL_NOTHROW
|
inline void Swap(VContainer &data) Q_DECL_NOTHROW
|
||||||
{ std::swap(d, data.d); }
|
{ std::swap(d, data.d); }
|
||||||
|
|
||||||
|
static QString UniqueNamespace();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
|
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
|
||||||
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
|
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
|
||||||
|
@ -139,9 +148,10 @@ public:
|
||||||
quint32 GetPieceForPiecePath(quint32 id) const;
|
quint32 GetPieceForPiecePath(quint32 id) const;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QSharedPointer<T> GetVariable(QString name) const;
|
QSharedPointer<T> GetVariable(QString name) const;
|
||||||
static quint32 getId();
|
quint32 getId() const;
|
||||||
static quint32 getNextId();
|
quint32 getNextId() const;
|
||||||
static void UpdateId(quint32 newId);
|
void UpdateId(quint32 newId) const;
|
||||||
|
static void UpdateId(quint32 newId, const QString &nspace);
|
||||||
|
|
||||||
quint32 AddGObject(VGObject *obj);
|
quint32 AddGObject(VGObject *obj);
|
||||||
quint32 AddGObject(const QSharedPointer<VGObject> &obj);
|
quint32 AddGObject(const QSharedPointer<VGObject> &obj);
|
||||||
|
@ -174,15 +184,15 @@ public:
|
||||||
void ClearCalculationGObjects();
|
void ClearCalculationGObjects();
|
||||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||||
void ClearVariables(const QVector<VarType> &types);
|
void ClearVariables(const QVector<VarType> &types);
|
||||||
static void ClearUniqueNames();
|
void ClearUniqueNames() const;
|
||||||
static void ClearUniqueIncrementNames();
|
void ClearUniqueIncrementNames() const;
|
||||||
|
|
||||||
static void SetSize(qreal size);
|
void SetSize(qreal size) const;
|
||||||
static void SetHeight(qreal height);
|
void SetHeight(qreal height) const;
|
||||||
static qreal size();
|
qreal size() const;
|
||||||
static qreal *rsize();
|
static qreal size(const QString &nspace);
|
||||||
static qreal height();
|
qreal height() const;
|
||||||
static qreal *rheight();
|
static qreal height(const QString &nspace);
|
||||||
|
|
||||||
void RemoveIncrement(const QString& name);
|
void RemoveIncrement(const QString& name);
|
||||||
|
|
||||||
|
@ -199,8 +209,11 @@ public:
|
||||||
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
|
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
|
||||||
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
|
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
|
||||||
|
|
||||||
static bool IsUnique(const QString &name);
|
bool IsUnique(const QString &name) const;
|
||||||
static QStringList AllUniqueNames();
|
static bool IsUnique(const QString &name, const QString &nspace);
|
||||||
|
|
||||||
|
QStringList AllUniqueNames() const;
|
||||||
|
static QStringList AllUniqueNames(const QString &nspace);
|
||||||
|
|
||||||
const Unit *GetPatternUnit() const;
|
const Unit *GetPatternUnit() const;
|
||||||
const VTranslateVars *GetTrVars() 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.
|
* @brief _id current id. New object will have value +1. For empty class equal 0.
|
||||||
*/
|
*/
|
||||||
static quint32 _id;
|
static QMap<QString, quint32> _id;
|
||||||
static qreal _size;
|
static QMap<QString, qreal> _size;
|
||||||
static qreal _height;
|
static QMap<QString, qreal> _height;
|
||||||
static QSet<QString> uniqueNames;
|
static QMap<QString, QSet<QString>> uniqueNames;
|
||||||
|
static QMap<QString, quint32> copyCounter;
|
||||||
|
|
||||||
QSharedDataPointer<VContainerData> d;
|
QSharedDataPointer<VContainerData> d;
|
||||||
|
|
||||||
|
@ -226,6 +240,8 @@ private:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const QMap<QString, QSharedPointer<T> > DataVar(const VarType &type) const;
|
const QMap<QString, QSharedPointer<T> > DataVar(const VarType &type) const;
|
||||||
|
|
||||||
|
static void ClearNamespace(const QString &nspace);
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE);
|
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);
|
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())
|
SCASSERT(not obj.isNull())
|
||||||
UpdateObject(id, obj);
|
UpdateObject(id, obj);
|
||||||
uniqueNames.insert(obj->name());
|
uniqueNames[d->nspace].insert(obj->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -521,14 +521,14 @@ void DialogEditLabel::InitPlaceholders()
|
||||||
QString mExt;
|
QString mExt;
|
||||||
if (qApp->patternType() == MeasurementsType::Multisize)
|
if (qApp->patternType() == MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
curSize = QString::number(VContainer::size());
|
curSize = QString::number(VContainer::size(valentinaNamespace));
|
||||||
curHeight = QString::number(VContainer::height());
|
curHeight = QString::number(VContainer::height(valentinaNamespace));
|
||||||
mExt = "vst";
|
mExt = "vst";
|
||||||
}
|
}
|
||||||
else if (qApp->patternType() == MeasurementsType::Individual)
|
else if (qApp->patternType() == MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
curSize = QString::number(VContainer::size());
|
curSize = QString::number(VContainer::size(valentinaNamespace));
|
||||||
curHeight = QString::number(VContainer::height());
|
curHeight = QString::number(VContainer::height(valentinaNamespace));
|
||||||
mExt = "vit";
|
mExt = "vit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ void DialogFlippingByAxis::SuffixChanged()
|
||||||
if (m_suffix != suffix)
|
if (m_suffix != suffix)
|
||||||
{
|
{
|
||||||
QRegularExpression rx(NameRegExp());
|
QRegularExpression rx(NameRegExp());
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = data->AllUniqueNames();
|
||||||
for (auto &uniqueName : uniqueNames)
|
for (auto &uniqueName : uniqueNames)
|
||||||
{
|
{
|
||||||
const QString name = uniqueName + suffix;
|
const QString name = uniqueName + suffix;
|
||||||
|
|
|
@ -280,7 +280,7 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
if (m_suffix != suffix)
|
if (m_suffix != suffix)
|
||||||
{
|
{
|
||||||
QRegularExpression rx(NameRegExp());
|
QRegularExpression rx(NameRegExp());
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = data->AllUniqueNames();
|
||||||
for (auto &uniqueName : uniqueNames)
|
for (auto &uniqueName : uniqueNames)
|
||||||
{
|
{
|
||||||
const QString name = uniqueName + suffix;
|
const QString name = uniqueName + suffix;
|
||||||
|
|
|
@ -473,7 +473,7 @@ void DialogMove::SuffixChanged()
|
||||||
if (m_suffix != suffix)
|
if (m_suffix != suffix)
|
||||||
{
|
{
|
||||||
QRegularExpression rx(NameRegExp());
|
QRegularExpression rx(NameRegExp());
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = data->AllUniqueNames();
|
||||||
for (auto &uniqueName : uniqueNames)
|
for (auto &uniqueName : uniqueNames)
|
||||||
{
|
{
|
||||||
const QString name = uniqueName + suffix;
|
const QString name = uniqueName + suffix;
|
||||||
|
|
|
@ -335,7 +335,7 @@ void DialogRotation::SuffixChanged()
|
||||||
if (m_suffix != suffix)
|
if (m_suffix != suffix)
|
||||||
{
|
{
|
||||||
QRegularExpression rx(NameRegExp());
|
QRegularExpression rx(NameRegExp());
|
||||||
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
const QStringList uniqueNames = data->AllUniqueNames();
|
||||||
for (auto &uniqueName : uniqueNames)
|
for (auto &uniqueName : uniqueNames)
|
||||||
{
|
{
|
||||||
const QString name = uniqueName + suffix;
|
const QString name = uniqueName + suffix;
|
||||||
|
|
|
@ -53,7 +53,7 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData,
|
||||||
{
|
{
|
||||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
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))
|
for (auto idObject : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
|
|
|
@ -197,7 +197,7 @@ VToolMove *VToolMove::Create(VToolMoveInitData &initData)
|
||||||
{
|
{
|
||||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
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))
|
for (auto idObject : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,7 +142,7 @@ VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
|
||||||
{
|
{
|
||||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
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))
|
for (auto idObject : qAsConst(initData.source))
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,7 +162,7 @@ VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
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.p1id = initData.data->AddGObject(p1);
|
||||||
initData.p2id = initData.data->AddGObject(p2);
|
initData.p2id = initData.data->AddGObject(p2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,8 +139,8 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
initData.id = initData.data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
a1->setId(VContainer::getNextId());
|
a1->setId(initData.data->getNextId());
|
||||||
a2->setId(VContainer::getNextId());
|
a2->setId(initData.data->getNextId());
|
||||||
initData.data->AddArc(a1, a1->id(), initData.id);
|
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||||
initData.data->AddArc(a2, a2->id(), initData.id);
|
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
||||||
initData.id = initData.data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
initData.data->AddLine(initData.basePointId, initData.id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
|
|
||||||
VContainer::getNextId();
|
initData.data->getNextId();
|
||||||
VContainer::getNextId();
|
initData.data->getNextId();
|
||||||
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -140,12 +140,12 @@ VToolLine * VToolLine::Create(VToolLineInitData initData)
|
||||||
SCASSERT(initData.data != nullptr)
|
SCASSERT(initData.data != nullptr)
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
initData.id = VContainer::getNextId();
|
initData.id = initData.data->getNextId();
|
||||||
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VContainer::UpdateId(initData.id);
|
initData.data->UpdateId(initData.id);
|
||||||
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||||
if (initData.parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1763,7 +1763,7 @@ VToolUnionDetails* VToolUnionDetails::Create(VToolUnionDetailsInitData initData)
|
||||||
VToolUnionDetails *unionDetails = nullptr;
|
VToolUnionDetails *unionDetails = nullptr;
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
initData.id = VContainer::getNextId();
|
initData.id = initData.data->getNextId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,14 +50,13 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
|
||||||
const int height = 176;
|
const int height = 176;
|
||||||
const int size = 50;
|
const int size = 50;
|
||||||
|
|
||||||
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
|
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
||||||
VContainer::SetHeight(height);
|
VContainer::UniqueNamespace()));
|
||||||
VContainer::SetSize(size);
|
data->SetHeight(height);
|
||||||
|
data->SetSize(size);
|
||||||
|
|
||||||
QSharedPointer<VMeasurements> m =
|
QSharedPointer<VMeasurements> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
|
||||||
m->SetSize(VContainer::rsize());
|
|
||||||
m->SetHeight(VContainer::rheight());
|
|
||||||
|
|
||||||
QTemporaryFile file;
|
QTemporaryFile file;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
@ -97,7 +96,8 @@ void TST_VMeasurements::CreateEmptyIndividualFile()
|
||||||
{
|
{
|
||||||
Unit mUnit = Unit::Cm;
|
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> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
|
||||||
|
@ -140,14 +140,13 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
|
||||||
const int height = 176;
|
const int height = 176;
|
||||||
const int size = 50;
|
const int size = 50;
|
||||||
|
|
||||||
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit));
|
QSharedPointer<VContainer> data = QSharedPointer<VContainer>(new VContainer(nullptr, &mUnit,
|
||||||
VContainer::SetHeight(height);
|
VContainer::UniqueNamespace()));
|
||||||
VContainer::SetSize(size);
|
data->SetHeight(height);
|
||||||
|
data->SetSize(size);
|
||||||
|
|
||||||
QSharedPointer<VMeasurements> m =
|
QSharedPointer<VMeasurements> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
|
||||||
m->SetSize(VContainer::rsize());
|
|
||||||
m->SetHeight(VContainer::rheight());
|
|
||||||
|
|
||||||
const QStringList listSystems = ListPMSystems();
|
const QStringList listSystems = ListPMSystems();
|
||||||
for (int i = 0; i < listSystems.size(); ++i)
|
for (int i = 0; i < listSystems.size(); ++i)
|
||||||
|
@ -195,7 +194,8 @@ void TST_VMeasurements::ValidPMCodesIndividualFile()
|
||||||
{
|
{
|
||||||
Unit mUnit = Unit::Cm;
|
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> m =
|
||||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
|
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, data.data()));
|
||||||
|
|
|
@ -49,7 +49,7 @@ void TST_VPiece::ClearLoop()
|
||||||
// See file <root>/src/app/share/collection/jacketМ6_30-110.val
|
// See file <root>/src/app/share/collection/jacketМ6_30-110.val
|
||||||
// Check correct seam allowance
|
// Check correct seam allowance
|
||||||
const Unit unit = Unit::Mm;
|
const Unit unit = Unit::Mm;
|
||||||
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit));
|
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace()));
|
||||||
qApp->setPatternUnit(unit);
|
qApp->setPatternUnit(unit);
|
||||||
|
|
||||||
data->UpdateGObject(304, new VPointF(61.866708661417327, 446.92270866141735, "Ф1", 5.0000125984251973,
|
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
|
// See file <root>/src/app/share/collection/bugs/Issue_#620.vit
|
||||||
// Check main path
|
// Check main path
|
||||||
const Unit unit = Unit::Cm;
|
const Unit unit = Unit::Cm;
|
||||||
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit));
|
QScopedPointer<VContainer> data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace()));
|
||||||
qApp->setPatternUnit(unit);
|
qApp->setPatternUnit(unit);
|
||||||
|
|
||||||
data->UpdateGObject(1, new VPointF(30, 39.999874015748034, "A", 5.0000125984251973, 9.9999874015748045));
|
data->UpdateGObject(1, new VPointF(30, 39.999874015748034, "A", 5.0000125984251973, 9.9999874015748045));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user