From 73786ed2df1318d9c17c81258d51197683e2f057 Mon Sep 17 00:00:00 2001 From: Valery Date: Tue, 12 Nov 2024 16:30:44 +0300 Subject: [PATCH 1/3] Messages (#132) --- davis_one/davis.cpp | 12 ++--- gui/CMakeLists.txt | 2 + gui/davis_gui.cpp | 84 +++++++++++++++++++++-------------- gui/davis_gui.h | 4 ++ gui/davis_gui.ui | 6 +++ plotly_maker/plotly_maker.cpp | 12 ++--- 6 files changed, 75 insertions(+), 45 deletions(-) diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index 05d5c9f..c93e74d 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -968,24 +968,24 @@ void showReportPage(const string& title, void showReportFileNotFounded() { - showReportPage("Ошибка открытия файла.", + showReportPage("Open file error.", kWarningIcon, - "Файл не найден. Пожалуйста, проверьте правильность пути."); + "File is not founded. Please, check the path to the file."); } void showReportFileEmpty() { - showReportPage("Файл пустой.", + showReportPage("File is empty.", kWarningIcon, - "Файл не содержит информации для отображения."); + "No data to show."); } void showMatrixSizesAreNotTheSame() { - showReportPage("Разный размер строк", + showReportPage("Rows sizes are not the same", kWarningIcon, - "Строки в матрице имеют разный размер"); + "Rows have different sizes in matrix"); } diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 66baa7c..8e3172a 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -10,6 +10,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") +set(CMAKE_WIN32_EXECUTABLE ON) # QtCreator supports the following variables for Android, which are identical to qmake Android variables. # Check https://doc.qt.io/qt/deployment-android.html for more information. diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index 6b1bcd1..f53606a 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -3,6 +3,7 @@ #include "../davis_one/davis.h" +#include #include "QDragEnterEvent" #include "QMimeData" #include "QDebug" @@ -14,12 +15,15 @@ #include "QPainterPath" #include "QFileDialog" #include "QTextStream" +#include DavisGUI::DavisGUI(QWidget* parent) : QMainWindow(parent) - , ui(new Ui::DavisGUI) { + , ui(new Ui::DavisGUI), + m_copy_paste_action(new QAction("Вставить из буфера обмена")){ isAboutWindowShowed = false; ui->setupUi(this); + ui->centralwidget->addAction(m_copy_paste_action); this->setAcceptDrops(true); QHBoxLayout* hbl = ui->horizontalLayout_menu; QMenuBar* mb = new QMenuBar; @@ -57,6 +61,8 @@ DavisGUI::DavisGUI(QWidget* parent) qpbExit->setText("✕"); hbl->addWidget(qpbExit); this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + + connect(m_copy_paste_action,SIGNAL(triggered()),SLOT(pasteTextAdded())); } DavisGUI::~DavisGUI() { @@ -73,41 +79,20 @@ void DavisGUI::showAboutWindow() { isAboutWindowShowed = true; } -void DavisGUI::dragEnterEvent(QDragEnterEvent* event) { - if (event->mimeData()->hasUrls()) { - event->acceptProposedAction(); - } else { - qDebug() << "not drop"; - } +void DavisGUI::pasteTextAdded() +{ + QClipboard *clipboard = QApplication::clipboard(); + QString clipboardText = clipboard->text(); + qDebug()<mimeData()->urls().first().toLocalFile(); - - QFileInfo info(filePath); - qDebug() << "---file path--->" << filePath; - if (info.exists()) { - qDebug() << "exist"; +void DavisGUI::readPlotText(QStringList &str_lines) +{ std::vectorlines; std::vector> data; char separator; - QFile file(filePath); - QTextStream ts(&file); - ts.setCodec("UTF-8"); - if (file.open(QIODevice::ReadWrite) == false) { - dvs::showReportFileNotFounded(); - return; - }; - QString line; - QStringList str_lines; - while (ts.readLineInto(&line)) { - str_lines.append(line); - } - if (str_lines.empty()) { - dvs::showReportFileEmpty(); - return; - } - for (int i = 0; i < str_lines.size(); ++i) { std::vectorvalues; auto res = dvs::find_separator(str_lines[i].toStdString(), separator); @@ -134,9 +119,8 @@ void DavisGUI::dropEvent(QDropEvent* event) { } data.emplace_back(values); } - file.close(); - if (data.empty()) { // Empty file case + if (data.empty()) { qDebug() << "Empty file"; return; } @@ -166,6 +150,40 @@ void DavisGUI::dropEvent(QDropEvent* event) { config.typeVisual = dv::VISUALTYPE_CHART; dv::show(showVector, "chart", config); } +} + +void DavisGUI::dragEnterEvent(QDragEnterEvent* event) { + if (event->mimeData()->hasUrls()) { + event->acceptProposedAction(); + } else { + qDebug() << "not drop"; + } +} + +void DavisGUI::dropEvent(QDropEvent* event) { + QString filePath = event->mimeData()->urls().first().toLocalFile(); + QFileInfo info(filePath); + qDebug() << "---file path--->" << filePath; + if (info.exists()) { + qDebug() << "exist"; + QFile file(filePath); + QTextStream ts(&file); + ts.setCodec("UTF-8"); + if (file.open(QIODevice::ReadWrite) == false) { + dvs::showReportFileNotFounded(); + return; + }; + QString line; + QStringList str_lines; + while (ts.readLineInto(&line)) { + str_lines.append(line); + } + if (str_lines.empty()) { + dvs::showReportFileEmpty(); + return; + } + file.close(); + readPlotText(str_lines); } else { qDebug() << "not exist"; dvs::showReportFileNotFounded(); diff --git a/gui/davis_gui.h b/gui/davis_gui.h index 39742a1..2d636d6 100644 --- a/gui/davis_gui.h +++ b/gui/davis_gui.h @@ -3,6 +3,7 @@ #include #include "about_window.h" +#include "QAction" QT_BEGIN_NAMESPACE namespace Ui { class DavisGUI; } @@ -17,6 +18,7 @@ class DavisGUI : public QMainWindow { private slots: void showAboutWindow(); + void pasteTextAdded(); private: Ui::DavisGUI* ui; @@ -25,6 +27,8 @@ class DavisGUI : public QMainWindow { QAction* action_heatmap; About_window* aboutWindow; bool isAboutWindowShowed; + QAction* m_copy_paste_action; + void readPlotText(QStringList& str_lines); // QWidget interface protected: diff --git a/gui/davis_gui.ui b/gui/davis_gui.ui index 4572594..34d0752 100644 --- a/gui/davis_gui.ui +++ b/gui/davis_gui.ui @@ -16,10 +16,16 @@ 0 + + Qt::ActionsContextMenu + davis + + Qt::ActionsContextMenu + false diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index a8783c7..0efa0d4 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -318,24 +318,24 @@ void showReportPage(const string& title, void showReportFileNotFounded() { - showReportPage("Ошибка открытия файла.", + showReportPage("Open file error.", kWarningIcon, - "Файл не найден. Пожалуйста, проверьте правильность пути."); + "File is not founded. Please, check the path to the file."); } void showReportFileEmpty() { - showReportPage("Файл пустой.", + showReportPage("File is empty.", kWarningIcon, - "Файл не содержит информации для отображения."); + "No data to show."); } void showMatrixSizesAreNotTheSame() { - showReportPage("Разный размер строк", + showReportPage("Rows sizes are not the same", kWarningIcon, - "Строки в матрице имеют разный размер"); + "Rows have different sizes in matrix"); } //#STOP_GRAB_TO_DVS_NAMESPACE From cb94c57845371be93d81620f608caaadc6b700e1 Mon Sep 17 00:00:00 2001 From: ValeryStk Date: Wed, 13 Nov 2024 11:02:10 +0300 Subject: [PATCH 2/3] fix E --- common_utils/common_utils.cpp | 2 +- davis_one/davis.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common_utils/common_utils.cpp b/common_utils/common_utils.cpp index 502a970..3afbf32 100644 --- a/common_utils/common_utils.cpp +++ b/common_utils/common_utils.cpp @@ -236,7 +236,7 @@ bool make_string(const string& src, int find_separator(const std::string& src, char& separator) { - std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ','}; + std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'}; std::set unique_chars; bool is_service_char = false; bool is_dot_present = false; diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index c93e74d..8c4d2b3 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -584,7 +584,7 @@ bool make_string(const string& src, int find_separator(const std::string& src, char& separator) { - std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ','}; + std::vector ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'}; std::set unique_chars; bool is_service_char = false; bool is_dot_present = false; From bbf31a4cec14b85ed09083e23fe4449684e604d1 Mon Sep 17 00:00:00 2001 From: Valery Date: Fri, 15 Nov 2024 12:36:43 +0300 Subject: [PATCH 3/3] Show date time variant (#133) --- davis_one/davis.cpp | 66 +++++++++++ davis_one/davis.h | 14 +++ gui/CMakeLists.txt | 2 + gui/date_time_formats.json | 6 + gui/davis_gui.cpp | 200 +++++++++++++++++++++++----------- gui/davis_gui.h | 1 + gui/json_utils.cpp | 82 ++++++++++++++ gui/json_utils.h | 32 ++++++ gui/res.qrc | 1 + plotly_maker/html_parts.cpp | 35 ++++++ plotly_maker/html_parts.h | 11 ++ plotly_maker/plotly_maker.cpp | 31 ++++++ plotly_maker/plotly_maker.h | 3 + 13 files changed, 421 insertions(+), 63 deletions(-) create mode 100644 gui/date_time_formats.json create mode 100644 gui/json_utils.cpp create mode 100644 gui/json_utils.h diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index 8c4d2b3..c5cad9e 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -355,6 +355,41 @@ const char kNoFileFoundedPage[] = R"( extern const char kWarningIcon[] = R"davis_delimeter()davis_delimeter"; + + +extern const char kHtmlDateTimeModel[] = R"davis_delimeter( + + + +
+ + + +)davis_delimeter"; + + + // *INDENT-ON* } // namespace dvs end @@ -988,6 +1023,37 @@ void showMatrixSizesAreNotTheSame() { "Rows have different sizes in matrix"); } +void showDateTimeChart(const string& date_time_values, + const vector& yValues) { + + string out; + string davis_dir; +#ifdef _WIN32 + davis_dir = "\\davis_htmls"; +#elif __linux__ + davis_dir = "/davis_htmls"; +#endif + vectorargs {ARGS_DATE_TIME_PAGE_SIZE, ""}; + args[ARG_JS_NAME] = kPlotlyJsName; + args[ARG_DATE_TIME_VALUES] = date_time_values; + + std::string values; + for (size_t i = 0; i < yValues.size(); ++i) { + std::string value = std::to_string(yValues[i]); + values.append(value); + if (i != yValues.size() - 1) { + values.append(","); + } + } + + args[ARG_Y_DATE_TIME_VALUES] = values; + make_string(kHtmlDateTimeModel, args, out); + saveStringToFile(kReportPagePath, out); + openFileBySystem(kReportPagePath); + + +} + } // namespace dvs end diff --git a/davis_one/davis.h b/davis_one/davis.h index d32c3ce..3d9f7dd 100644 --- a/davis_one/davis.h +++ b/davis_one/davis.h @@ -139,6 +139,14 @@ enum ARGS_REPORT_PAGE_INDEX { ARGS_REPORT_PAGE_SIZE }; +enum ARGS_DATE_TIME_PAGE_INDEX { + ARG_JS_NAME, //%1 + ARG_DATE_TIME_VALUES, //%2 + ARG_Y_DATE_TIME_VALUES, //%3 + // ADD NEW ENUM BEFORE THIS COMMENT + ARGS_DATE_TIME_PAGE_SIZE +}; + extern const char kHtmlModel[]; extern const char kColorMapDefaultPart[]; @@ -160,6 +168,9 @@ extern const char kNoFileFoundedPage[]; extern const char kWarningIcon[]; +extern const char kHtmlDateTimeModel[]; + + } // namespace dvs end namespace dvs { @@ -332,6 +343,9 @@ void showReportFileEmpty(); void showMatrixSizesAreNotTheSame(); +void showDateTimeChart(const string& date_time_values, + const vector& yValues); + } // namespace dvs end diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 8e3172a..b488f8b 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -45,6 +45,8 @@ set(PROJECT_SOURCES about_window.cpp davis_gui.ui about_window.ui + json_utils.h + json_utils.cpp ) qt5_add_resources(PROJECT_SOURCES res.qrc) diff --git a/gui/date_time_formats.json b/gui/date_time_formats.json new file mode 100644 index 0000000..1a749c2 --- /dev/null +++ b/gui/date_time_formats.json @@ -0,0 +1,6 @@ +[ + "dd/MM/yyyy hh:mm", + "yyyy/MM/dd hh:mm:ss", + "yyyy.MM.dd_hh:mm:ss", + "yyyy/MM/dd hh_mm_ss" +] diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index f53606a..3e00999 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -16,11 +16,15 @@ #include "QFileDialog" #include "QTextStream" #include +#include +#include "json_utils.h" +#include "QDateTime" +#include DavisGUI::DavisGUI(QWidget* parent) : QMainWindow(parent) , ui(new Ui::DavisGUI), - m_copy_paste_action(new QAction("Вставить из буфера обмена")){ + m_copy_paste_action(new QAction("Вставить из буфера обмена")) { isAboutWindowShowed = false; ui->setupUi(this); ui->centralwidget->addAction(m_copy_paste_action); @@ -62,7 +66,7 @@ DavisGUI::DavisGUI(QWidget* parent) hbl->addWidget(qpbExit); this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - connect(m_copy_paste_action,SIGNAL(triggered()),SLOT(pasteTextAdded())); + connect(m_copy_paste_action, SIGNAL(triggered()), SLOT(pasteTextAdded())); } DavisGUI::~DavisGUI() { @@ -79,77 +83,131 @@ void DavisGUI::showAboutWindow() { isAboutWindowShowed = true; } -void DavisGUI::pasteTextAdded() -{ - QClipboard *clipboard = QApplication::clipboard(); - QString clipboardText = clipboard->text(); - qDebug()<text(); + qDebug() << clipboardText; + QStringList lines = clipboardText.split(QRegExp("[\r\n]+")); + if (checkDateTimeVariant(lines) == false) { readPlotText(lines); + }; } -void DavisGUI::readPlotText(QStringList &str_lines) -{ - std::vectorlines; - std::vector> data; - char separator; - for (int i = 0; i < str_lines.size(); ++i) { - std::vectorvalues; - auto res = dvs::find_separator(str_lines[i].toStdString(), separator); - //qDebug() << "sep result: " << separator << "--->" << res; - bool is_one_value = false; - std::replace(str_lines[i].begin(), str_lines[i].end(), ',', '.'); - if (res != dvs::GOOD_SEPARATOR) { - if (dvs::is_string_convertable_to_digit(str_lines[i].toStdString()) == false) { - continue; - } else { - is_one_value = true; - } +void DavisGUI::readPlotText(QStringList& str_lines) { + std::vectorlines; + std::vector> data; + char separator; + for (int i = 0; i < str_lines.size(); ++i) { + std::vectorvalues; + auto res = dvs::find_separator(str_lines[i].toStdString(), separator); + //qDebug() << "sep result: " << separator << "--->" << res; + bool is_one_value = false; + std::replace(str_lines[i].begin(), str_lines[i].end(), ',', '.'); + if (res != dvs::GOOD_SEPARATOR) { + if (dvs::is_string_convertable_to_digit(str_lines[i].toStdString()) == false) { + continue; + } else { + is_one_value = true; } - if (is_one_value == false) { - QStringList str_values = str_lines[i].split(separator); - for (int j = 0; j < str_values.size(); ++j) { - if (dvs::is_string_convertable_to_digit(str_values[j].toStdString()) == false) { - continue; - } - values.emplace_back(std::stod(str_values[j].toStdString())); + } + if (is_one_value == false) { + QStringList str_values = str_lines[i].split(separator); + for (int j = 0; j < str_values.size(); ++j) { + if (dvs::is_string_convertable_to_digit(str_values[j].toStdString()) == false) { + continue; } - } else { - values.emplace_back(std::stod(str_lines[i].toStdString())); + values.emplace_back(std::stod(str_values[j].toStdString())); } - data.emplace_back(values); + } else { + values.emplace_back(std::stod(str_lines[i].toStdString())); } + data.emplace_back(values); + } - if (data.empty()) { - qDebug() << "Empty file"; - return; - } + if (data.empty()) { + dvs::showReportFileEmpty(); + return; + } - if (data.size() == 2 || data[0].size() == 2) { //chartXY - dv::show(data, "chartXY"); - } else if (data.size() > 1 && data[0].size() > 1) { - if (action_heatmap->isChecked()) { - dv::show(data); - } else if (action_surface->isChecked()) { - dv::Config config; - config.typeVisual = dv::VISUALTYPE_SURFACE; - dv::show(data, "surface", config); + if (data.size() == 2 || data[0].size() == 2) { //chartXY + dv::show(data, "chartXY"); + } else if (data.size() > 1 && data[0].size() > 1) { + if (action_heatmap->isChecked()) { + dv::show(data); + } else if (action_surface->isChecked()) { + dv::Config config; + config.typeVisual = dv::VISUALTYPE_SURFACE; + dv::show(data, "surface", config); + } + } else { + std::vector showVector; + if (data.size() > 1 && data[0].size() == 1) { + std::vector new_data(data.size()); + for (size_t i = 0; i < new_data.size(); ++i) { + new_data[i] = data[i][0]; } + showVector = new_data; } else { - std::vector showVector; - if (data.size() > 1 && data[0].size() == 1) { - std::vector new_data(data.size()); - for (size_t i = 0; i < new_data.size(); ++i) { - new_data[i] = data[i][0]; + showVector = data[0]; + } + dv::Config config; + config.typeVisual = dv::VISUALTYPE_CHART; + dv::show(showVector, "chart", config); + } +} + +bool DavisGUI::checkDateTimeVariant(const QStringList& lines) { + + QJsonArray jarr; + if(jsn::getJsonArrayFromFile("date_time_formats.json", jarr)==false){ + jsn::getJsonArrayFromFile(":/date_time_formats.json", jarr); + } + qDebug() << jarr; + QString dates; + std::vector values; + + for (int i = 0; i < lines.size(); ++i) { + QString test = lines[i]; + for (int j = 0; j < jarr.size(); ++j) { + int template_time_stamp_size = jarr[j].toString().size(); + QString template_time_stamp = jarr[j].toString(); + if (test.size() < template_time_stamp_size + 1) { + continue; + } + QString separator = QString(test[template_time_stamp_size]); + QString substr = test.mid(0, template_time_stamp_size); + QDateTime dt = QDateTime::fromString(substr, template_time_stamp); + if (dt.isValid()) { + //2013-10-04 22:23:00 + qDebug() << dt.toString("yyyy-MM-dd hh:mm:ss"); + dates.append("'"); + dates.append(dt.toString("yyyy-MM-dd hh:mm:ss")); + dates.append("'"); + if (i < lines.size() - 1) { + dates.append(","); } - showVector = new_data; - } else { - showVector = data[0]; + + auto values_list = test.split(separator); + if (values_list.size() != 2) { + continue; + } + double value = values_list[1].toDouble(); + qDebug()<mimeData()->urls().first().toLocalFile(); + QList file_list = event->mimeData()->urls(); + if(file_list.size()>1){ + qDebug()<<"file list size: "<" << filePath; if (info.exists()) { - qDebug() << "exist"; QFile file(filePath); QTextStream ts(&file); ts.setCodec("UTF-8"); @@ -173,6 +234,17 @@ void DavisGUI::dropEvent(QDropEvent* event) { dvs::showReportFileNotFounded(); return; }; + + QString suffix = info.suffix(); + QStringList suffixes = {"jpg","bmp","png","svg","mp4","json"}; + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include + + +namespace jsn { + +bool getJsonObjectFromFile(const QString& path, + QJsonObject& object) { + QFile file(path); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "File can't be opened!" << path; + return false; + }; + QByteArray data = file.readAll(); + QJsonParseError errorPtr; + object = QJsonDocument::fromJson(data, &errorPtr).object(); + if (object.isEmpty()) { + qDebug() << "JSON IS EMPTY: " << errorPtr.errorString(); + return false; + } + file.close(); + + return true; +} + +bool getJsonArrayFromFile(const QString& path, + QJsonArray& object) { + QFile file(path); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "File can't be opened!" << path; + return false; + }; + QByteArray data = file.readAll(); + QJsonParseError errorPtr; + object = QJsonDocument::fromJson(data, &errorPtr).array(); + if (object.isEmpty()) { + qDebug() << "JSON IS EMPTY: " << errorPtr.errorString(); + return false; + } + file.close(); + return true; +} + +bool saveJsonObjectToFile(const QString& path, + const QJsonObject& json_object, + QJsonDocument::JsonFormat format) { + QFile file(path); + if (!file.open(QIODevice::WriteOnly)) + return false; + auto json_doc = QJsonDocument(json_object).toJson(format); + auto result = file.write(json_doc); + file.close(); + if (result == -1) + return false; + else + return true; +} + +bool saveJsonArrayToFile(const QString& path, + const QJsonArray& json_object, + QJsonDocument::JsonFormat format) { + QFile file(path); + if (!file.open(QIODevice::WriteOnly)) + return false; + auto json_doc = QJsonDocument(json_object).toJson(format); + auto result = file.write(json_doc); + file.close(); + if (result == -1) + return false; + else + return true; +} + +} // end jsn namespace diff --git a/gui/json_utils.h b/gui/json_utils.h new file mode 100644 index 0000000..64a074c --- /dev/null +++ b/gui/json_utils.h @@ -0,0 +1,32 @@ +#ifndef JSON_UTILS_H +#define JSON_UTILS_H + +#include "QVector" +#include "QJsonDocument" + +class QString; +class QJsonArray; +class QJsonObject; + + +namespace jsn { + + +bool getJsonObjectFromFile(const QString& path, + QJsonObject& object); + +bool getJsonArrayFromFile(const QString& path, + QJsonArray& object); + + +bool saveJsonObjectToFile(const QString& path, + const QJsonObject& json_object, + QJsonDocument::JsonFormat format); + +bool saveJsonArrayToFile(const QString& path, + const QJsonArray& json_object, + QJsonDocument::JsonFormat format); + +} // end namespace jsn + +#endif // JSON_UTILS_H diff --git a/gui/res.qrc b/gui/res.qrc index 3a7169f..e618b9a 100644 --- a/gui/res.qrc +++ b/gui/res.qrc @@ -9,5 +9,6 @@ res/davis.mp3 res/content_copy_200dp_969696_FILL0_wght300_GRAD0_opsz48.png res/check_200dp_969696_FILL0_wght300_GRAD0_opsz48.png + date_time_formats.json diff --git a/plotly_maker/html_parts.cpp b/plotly_maker/html_parts.cpp index ed6e2cf..e77b418 100644 --- a/plotly_maker/html_parts.cpp +++ b/plotly_maker/html_parts.cpp @@ -328,6 +328,41 @@ const char kNoFileFoundedPage[] = R"( extern const char kWarningIcon[] = R"davis_delimeter()davis_delimeter"; + + +extern const char kHtmlDateTimeModel[] = R"davis_delimeter( + + + +
+ + + +)davis_delimeter"; + + + // *INDENT-ON* //#STOP_GRAB_TO_DVS_NAMESPACE } // namespace dvs diff --git a/plotly_maker/html_parts.h b/plotly_maker/html_parts.h index 5b44c41..dba6061 100644 --- a/plotly_maker/html_parts.h +++ b/plotly_maker/html_parts.h @@ -32,6 +32,14 @@ enum ARGS_REPORT_PAGE_INDEX { ARGS_REPORT_PAGE_SIZE }; +enum ARGS_DATE_TIME_PAGE_INDEX { + ARG_JS_NAME, //%1 + ARG_DATE_TIME_VALUES, //%2 + ARG_Y_DATE_TIME_VALUES, //%3 + // ADD NEW ENUM BEFORE THIS COMMENT + ARGS_DATE_TIME_PAGE_SIZE +}; + extern const char kHtmlModel[]; extern const char kColorMapDefaultPart[]; @@ -52,6 +60,9 @@ extern const char kWarningJSLibAbsentPage[]; extern const char kNoFileFoundedPage[]; extern const char kWarningIcon[]; + +extern const char kHtmlDateTimeModel[]; + //#STOP_GRAB_TO_DVS_NAMESPACE } diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index 0efa0d4..24340b2 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -338,6 +338,37 @@ void showMatrixSizesAreNotTheSame() { "Rows have different sizes in matrix"); } +void showDateTimeChart(const string& date_time_values, + const vector& yValues) { + + string out; + string davis_dir; +#ifdef _WIN32 + davis_dir = "\\davis_htmls"; +#elif __linux__ + davis_dir = "/davis_htmls"; +#endif + vectorargs {ARGS_DATE_TIME_PAGE_SIZE, ""}; + args[ARG_JS_NAME] = kPlotlyJsName; + args[ARG_DATE_TIME_VALUES] = date_time_values; + + std::string values; + for (size_t i = 0; i < yValues.size(); ++i) { + std::string value = std::to_string(yValues[i]); + values.append(value); + if (i != yValues.size() - 1) { + values.append(","); + } + } + + args[ARG_Y_DATE_TIME_VALUES] = values; + make_string(kHtmlDateTimeModel, args, out); + saveStringToFile(kReportPagePath, out); + openFileBySystem(kReportPagePath); + + +} + //#STOP_GRAB_TO_DVS_NAMESPACE }; // namespace dvs diff --git a/plotly_maker/plotly_maker.h b/plotly_maker/plotly_maker.h index d3db86c..cbda0d9 100644 --- a/plotly_maker/plotly_maker.h +++ b/plotly_maker/plotly_maker.h @@ -47,6 +47,9 @@ void showReportFileEmpty(); void showMatrixSizesAreNotTheSame(); +void showDateTimeChart(const string& date_time_values, + const vector& yValues); + //#STOP_GRAB_TO_DVS_NAMESPACE }; // namespace dvs