diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index 8d66bf784..3800f0275 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -2837,6 +2837,7 @@ void MainWindow::Clear()
ui->actionHistory->setEnabled(false);
ui->actionTable->setEnabled(false);
ui->actionExportIncrementsToCSV->setEnabled(false);
+ ui->actionExportFinalMeasurementsToCSV->setEnabled(false);
ui->actionFinalMeasurements->setEnabled(false);
ui->actionLast_tool->setEnabled(false);
ui->actionShowCurveDetails->setEnabled(false);
@@ -3084,6 +3085,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionLayout->setEnabled(enable);
ui->actionTable->setEnabled(enable && drawStage);
ui->actionExportIncrementsToCSV->setEnabled(enable);
+ ui->actionExportFinalMeasurementsToCSV->setEnabled(enable);
ui->actionFinalMeasurements->setEnabled(enable);
ui->actionZoomFitBest->setEnabled(enable);
ui->actionZoomFitBestCurrent->setEnabled(enable && drawStage);
@@ -3978,6 +3980,7 @@ void MainWindow::CreateActions()
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open);
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::New);
connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV);
+ connect(ui->actionExportFinalMeasurementsToCSV, &QAction::triggered, this, &MainWindow::ExportFMeasurementsToCSV);
connect(ui->actionTable, &QAction::triggered, this, [this](bool checked)
{
diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui
index dad8e7a57..9da3d2538 100644
--- a/src/app/valentina/mainwindow.ui
+++ b/src/app/valentina/mainwindow.ui
@@ -1709,6 +1709,7 @@
+
@@ -2703,8 +2712,8 @@
-
+
diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp
index 39047e802..2dd5ac119 100644
--- a/src/app/valentina/mainwindowsnogui.cpp
+++ b/src/app/valentina/mainwindowsnogui.cpp
@@ -33,6 +33,8 @@
#include "../vdxf/vdxfpaintdevice.h"
#include "dialogs/dialoglayoutsettings.h"
#include "../vwidgets/vmaingraphicsscene.h"
+#include "../vmisc/dialogs/dialogexporttocsv.h"
+#include "../vmisc/qxtcsvmodel.h"
#include "../vlayout/vlayoutgenerator.h"
#include "dialogs/dialoglayoutprogress.h"
#include "dialogs/dialogsavelayout.h"
@@ -41,6 +43,7 @@
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
#include "../vpatterndb/measurements.h"
+#include "../vpatterndb/calculator.h"
#include "../vtools/tools/vabstracttool.h"
#include "../vtools/tools/vtoolseamallowance.h"
@@ -224,6 +227,31 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
qApp->exit(V_EX_DATAERR);
}
+//---------------------------------------------------------------------------------------------------------------------
+void MainWindowsNoGUI::ExportFMeasurementsToCSV()
+{
+ QString fileName = CSVFilePath();
+
+ if (fileName.isEmpty())
+ {
+ return;
+ }
+
+ DialogExportToCSV dialog(this);
+ dialog.SetWithHeader(qApp->Settings()->GetCSVWithHeader());
+ dialog.SetSelectedMib(qApp->Settings()->GetCSVCodec());
+ dialog.SetSeparator(qApp->Settings()->GetCSVSeparator());
+
+ if (dialog.exec() == QDialog::Accepted)
+ {
+ ExportFMeasurementsToCSVData(fileName, dialog.IsWithHeader(), dialog.GetSelectedMib(), dialog.GetSeparator());
+
+ qApp->Settings()->SetCSVSeparator(dialog.GetSeparator());
+ qApp->Settings()->SetCSVCodec(dialog.GetSelectedMib());
+ qApp->Settings()->SetCSVWithHeader(dialog.IsWithHeader());
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportData(const QVector &listDetails, const DialogSaveLayout &dialog)
{
@@ -1543,6 +1571,59 @@ void MainWindowsNoGUI::SetSizeHeightForIndividualM() const
emit doc->UpdatePatternLabel();
}
+//---------------------------------------------------------------------------------------------------------------------
+void MainWindowsNoGUI::ExportFMeasurementsToCSVData(const QString &fileName, bool withHeader, int mib,
+ const QChar &separator) const
+{
+ QxtCsvModel csv;
+
+ csv.insertColumn(0);
+ csv.insertColumn(1);
+
+ if (withHeader)
+ {
+ csv.setHeaderText(0, tr("Name"));
+ csv.setHeaderText(1, tr("Value"));
+ }
+
+ const QVector measurements = doc->GetFinalMeasurements();
+ const VContainer completeData = doc->GetCompleteData();
+
+ for (int i=0; i < measurements.size(); ++i)
+ {
+ const VFinalMeasurement &m = measurements.at(i);
+
+ csv.insertRow(i);
+ csv.setText(i, 0, m.name); // name
+
+ qreal result = 0;
+ if (not m.formula.isEmpty())
+ {
+ try
+ {
+ QString f = m.formula;
+ // Replace line return character with spaces for calc if exist
+ f.replace("\n", " ");
+ QScopedPointer cal(new Calculator());
+ result = cal->EvalFormula(completeData.DataVariables(), f);
+
+ if (qIsInf(result) || qIsNaN(result))
+ {
+ result = 0;
+ }
+ }
+ catch (qmu::QmuParserError &)
+ {
+ result = 0;
+ }
+ }
+
+ csv.setText(i, 1, qApp->LocaleToString(result)); // value
+ }
+
+ csv.toCSV(fileName, withHeader, separator, QTextCodec::codecForMib(mib));
+}
+
//---------------------------------------------------------------------------------------------------------------------
int MainWindowsNoGUI::ContinueIfLayoutStale()
{
diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h
index 1af1651ef..4df454544 100644
--- a/src/app/valentina/mainwindowsnogui.h
+++ b/src/app/valentina/mainwindowsnogui.h
@@ -56,6 +56,8 @@ public slots:
void PrintOrigin();
void PrintTiled();
void RefreshDetailsLabel();
+protected slots:
+ void ExportFMeasurementsToCSV();
protected:
QVector listDetails;
@@ -100,6 +102,9 @@ protected:
int ContinueIfLayoutStale();
QString FileName() const;
void SetSizeHeightForIndividualM() const;
+
+ void ExportFMeasurementsToCSVData(const QString &fileName,
+ bool withHeader, int mib, const QChar &separator) const;
private slots:
void PrintPages (QPrinter *printer);
void ErrorConsoleMode(const LayoutErrors &state);
diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp
index 58dfec4b7..e4820d95c 100644
--- a/src/libs/vwidgets/vabstractmainwindow.cpp
+++ b/src/libs/vwidgets/vabstractmainwindow.cpp
@@ -30,6 +30,7 @@
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vmisc/vabstractapplication.h"
#include "dialogs/dialogexporttocsv.h"
+#include "../ifc/xml/vabstractpattern.h"
#include
#include
diff --git a/src/libs/vwidgets/vabstractmainwindow.h b/src/libs/vwidgets/vabstractmainwindow.h
index 588d978ae..b1a2f1365 100644
--- a/src/libs/vwidgets/vabstractmainwindow.h
+++ b/src/libs/vwidgets/vabstractmainwindow.h
@@ -35,7 +35,7 @@
#include
#include
-class DialogExportToCSV;
+class VFinalMeasurement;
class VAbstractMainWindow : public QMainWindow
{
@@ -58,11 +58,12 @@ protected:
bool ContinueFormatRewrite(const QString ¤tFormatVersion, const QString &maxFormatVersion);
void ToolBarStyle(QToolBar *bar);
+ QString CSVFilePath();
+
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator)=0;
+
private:
Q_DISABLE_COPY(VAbstractMainWindow)
-
- QString CSVFilePath();
};
#endif // VABSTRACTMAINWINDOW_H