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