Load measurements.
--HG-- branch : feature
This commit is contained in:
parent
498aaa4ea2
commit
0acf149be7
|
@ -232,6 +232,62 @@ void MainWindow::InitScenes()
|
||||||
qApp->setSceneView(ui->view);
|
qApp->setSceneView(ui->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::LoadMeasurements(const QString &path)
|
||||||
|
{
|
||||||
|
if (path.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VMeasurements *m = nullptr;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m = new VMeasurements(pattern);
|
||||||
|
m->setXMLContent(path);
|
||||||
|
|
||||||
|
if (m->Type() == MeasurementsType::Unknown)
|
||||||
|
{
|
||||||
|
VException e("Measurement file has unknown format.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m->Type() == MeasurementsType::Standard)
|
||||||
|
{
|
||||||
|
VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList mList = m->ListAll();
|
||||||
|
const QStringList pList = doc->ListMeasurements();
|
||||||
|
|
||||||
|
const QSet<QString> match = pList.toSet().subtract(mList.toSet());
|
||||||
|
if (not match.isEmpty())
|
||||||
|
{
|
||||||
|
VException e("Measurement file doesn't include all required measurements.");
|
||||||
|
e.AddMoreInformation(QString("Please, additionaly provide: %1")
|
||||||
|
.arg(QStringList(match.toList()).join(", ")));
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern->ClearVariables(VarType::Measurement);
|
||||||
|
m->ReadMeasurements();
|
||||||
|
delete m;
|
||||||
|
doc->SetPath(path);
|
||||||
|
PatternWasModified(false);
|
||||||
|
doc->LiteParseTree(Document::LiteParse);
|
||||||
|
}
|
||||||
|
catch (VException &e)
|
||||||
|
{
|
||||||
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
|
delete m;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief OptionDraw help change name of pattern piece.
|
* @brief OptionDraw help change name of pattern piece.
|
||||||
|
@ -902,6 +958,34 @@ void MainWindow::PrepareSceneList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::LoadIndividual()
|
||||||
|
{
|
||||||
|
const QString filter = tr("Individual measurements (*.vit);;Standard measurements (*.vst)");
|
||||||
|
//Use standard path to standard measurements
|
||||||
|
const QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements();
|
||||||
|
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
|
||||||
|
|
||||||
|
if (not mPath.isEmpty())
|
||||||
|
{
|
||||||
|
LoadMeasurements(mPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::LoadStandard()
|
||||||
|
{
|
||||||
|
const QString filter = tr("Individual measurements (*.vit);;Standard measurements (*.vst)");
|
||||||
|
//Use standard path to individual measurements
|
||||||
|
const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements();
|
||||||
|
const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
|
||||||
|
|
||||||
|
if (not mPath.isEmpty())
|
||||||
|
{
|
||||||
|
LoadMeasurements(mPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ToolBarOption enable option toolbar.
|
* @brief ToolBarOption enable option toolbar.
|
||||||
|
@ -1716,6 +1800,8 @@ void MainWindow::Clear()
|
||||||
ui->actionEdit_pattern_code->setEnabled(false);
|
ui->actionEdit_pattern_code->setEnabled(false);
|
||||||
ui->actionLast_tool->setEnabled(false);
|
ui->actionLast_tool->setEnabled(false);
|
||||||
ui->actionShowCurveDetails->setEnabled(false);
|
ui->actionShowCurveDetails->setEnabled(false);
|
||||||
|
ui->actionLoadIndividual->setEnabled(false);
|
||||||
|
ui->actionLoadStandard->setEnabled(false);
|
||||||
SetEnableTool(false);
|
SetEnableTool(false);
|
||||||
qApp->setPatternUnit(Unit::Cm);
|
qApp->setPatternUnit(Unit::Cm);
|
||||||
qApp->setPatternType(MeasurementsType::Individual);
|
qApp->setPatternType(MeasurementsType::Individual);
|
||||||
|
@ -1924,6 +2010,8 @@ void MainWindow::SetEnableWidgets(bool enable)
|
||||||
ui->actionZoomFitBest->setEnabled(enable);
|
ui->actionZoomFitBest->setEnabled(enable);
|
||||||
ui->actionZoomOriginal->setEnabled(enable);
|
ui->actionZoomOriginal->setEnabled(enable);
|
||||||
ui->actionShowCurveDetails->setEnabled(enable);
|
ui->actionShowCurveDetails->setEnabled(enable);
|
||||||
|
ui->actionLoadIndividual->setEnabled(enable);
|
||||||
|
ui->actionLoadStandard->setEnabled(enable);
|
||||||
|
|
||||||
//Now we don't want allow user call context menu
|
//Now we don't want allow user call context menu
|
||||||
sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP());
|
sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP());
|
||||||
|
@ -2661,6 +2749,8 @@ void MainWindow::CreateActions()
|
||||||
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode);
|
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode);
|
||||||
connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow);
|
connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow);
|
||||||
connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionCurveDetailsMode);
|
connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionCurveDetailsMode);
|
||||||
|
connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual);
|
||||||
|
connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard);
|
||||||
|
|
||||||
connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs);
|
connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs);
|
||||||
connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin);
|
connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin);
|
||||||
|
|
|
@ -159,6 +159,9 @@ protected:
|
||||||
|
|
||||||
virtual void CleanLayout() Q_DECL_OVERRIDE;
|
virtual void CleanLayout() Q_DECL_OVERRIDE;
|
||||||
virtual void PrepareSceneList() Q_DECL_OVERRIDE;
|
virtual void PrepareSceneList() Q_DECL_OVERRIDE;
|
||||||
|
private slots:
|
||||||
|
void LoadIndividual();
|
||||||
|
void LoadStandard();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(MainWindow)
|
Q_DISABLE_COPY(MainWindow)
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
|
@ -282,6 +285,8 @@ private:
|
||||||
void AddPP(const QString &PPName);
|
void AddPP(const QString &PPName);
|
||||||
|
|
||||||
void InitScenes();
|
void InitScenes();
|
||||||
|
|
||||||
|
void LoadMeasurements(const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -1085,6 +1085,8 @@
|
||||||
<string>Measurements</string>
|
<string>Measurements</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionTable"/>
|
<addaction name="actionTable"/>
|
||||||
|
<addaction name="actionLoadIndividual"/>
|
||||||
|
<addaction name="actionLoadStandard"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuWindow">
|
<widget class="QMenu" name="menuWindow">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -1854,6 +1856,22 @@
|
||||||
<string>Export original layout</string>
|
<string>Export original layout</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionLoadIndividual">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Load Individual ...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionLoadStandard">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Load Standard ...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -1867,8 +1885,8 @@
|
||||||
<tabstop>toolButtonSplinePath</tabstop>
|
<tabstop>toolButtonSplinePath</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="share/resources/toolicon.qrc"/>
|
|
||||||
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
||||||
|
<include location="share/resources/toolicon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user