Skip to content

Commit

Permalink
Revert "Merge branch 'main' into messages"
Browse files Browse the repository at this point in the history
This reverts commit 8898ba1, reversing
changes made to f5eba63.
  • Loading branch information
AntonMrt committed Nov 16, 2024
1 parent 8898ba1 commit b2c130c
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 374 deletions.
2 changes: 1 addition & 1 deletion common_utils/common_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ bool make_string(const string& src,

int find_separator(const std::string& src,
char& separator) {
std::vector<char> ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'};
std::vector<char> ignored_chars = {'+', '-', 'e', '.', '\r', ','};
std::set<char> unique_chars;
bool is_service_char = false;
bool is_dot_present = false;
Expand Down
76 changes: 6 additions & 70 deletions davis_one/davis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,41 +355,6 @@ const char kNoFileFoundedPage[] = R"(<!DOCTYPE html>

extern const char kWarningIcon[] = R"davis_delimeter(<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 156.262 144.407"><path d="M-109.166 7.227a2 2 0 0 0-.406.046c-3.195.03-6.176 1.695-7.785 4.483l-31.25 54.127-31.25 54.127h.002c-3.42 5.922 1.017 13.609 7.855 13.61h125.002c6.839-.001 11.277-7.688 7.857-13.61l-31.25-54.127-31.252-54.127c-1.465-2.539-4.079-4.164-6.978-4.45a2 2 0 0 0-.445-.077h-.004a2.006 2.006 0 0 0-.094-.002z" color="#000" style="solid-color:#000" transform="translate(186.615 2.437) scale(.99073)"/><path fill="#fff" d="M-109.165 9.227a7.081 7.081 0 0 0-6.46 3.529l-31.25 54.127-31.25 54.127c-2.674 4.631.777 10.609 6.126 10.61h125.002c5.348-.001 8.8-5.979 6.125-10.61l-31.25-54.127-31.252-54.127a7.079 7.079 0 0 0-5.79-3.53h-.001z" color="#000" style="solid-color:#000" transform="translate(186.615 2.437) scale(.99073)"/><path d="M-109.26 11.225a5.073 5.073 0 0 0-4.632 2.53l-31.25 54.128-31.25 54.127c-1.953 3.381.488 7.609 4.393 7.61h125.002c3.905-.001 6.345-4.229 4.392-7.61l-31.25-54.127-31.252-54.127a5.073 5.073 0 0 0-4.152-2.531z" color="#000" style="solid-color:#000" transform="translate(186.615 2.437) scale(.99073)"/><path fill="#fc0" d="M140.053 125.83H16.209L47.17 72.204l30.961-53.626 30.961 53.626z"/><g transform="translate(.295 2.437) scale(.99073)"><circle cx="78.564" cy="111.117" r="8.817"/><path d="M78.564 42.955a8.817 8.817 0 0 0-8.818 8.816l3.156 37.461a5.662 5.662 0 0 0 11.325 0l3.154-37.46a8.817 8.817 0 0 0-8.817-8.817z"/></g></svg>)davis_delimeter";



extern const char kHtmlDateTimeModel[] = R"davis_delimeter(
<head>
<script src="%1" charset="utf-8"></script>
</head>
<body><div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="height:95%; aspect-ratio: 1/1;"
id="gd"></div></div>
<script>
var data = [
{
x: [%2],
y: [%3],
type: 'scatter'
}
];
var config = {
editable: true,
showLink: true,
plotlyServerURL: "https://chart-studio.plotly.com"
};
Plotly.newPlot('gd', data);
</script>
</body>
)davis_delimeter";



// *INDENT-ON*

} // namespace dvs end
Expand Down Expand Up @@ -619,7 +584,7 @@ bool make_string(const string& src,

int find_separator(const std::string& src,
char& separator) {
std::vector<char> ignored_chars = {'+', '-', 'e', '.', '\r', ',', 'E'};
std::vector<char> ignored_chars = {'+', '-', 'e', '.', '\r', ','};
std::set<char> unique_chars;
bool is_service_char = false;
bool is_dot_present = false;
Expand Down Expand Up @@ -713,7 +678,7 @@ bool checkThatSizesAreTheSame(const vector<vector<double>>& values) {
for (size_t i = 0; i < values.size(); ++i) {

if (values[i].size() != size) {
showMatrixSizesAreNotTheSame();
showMatrixSizesAreNotTheSame(i);
return false;
}
}
Expand Down Expand Up @@ -1016,42 +981,13 @@ void showReportFileEmpty() {
}


void showMatrixSizesAreNotTheSame() {
void showMatrixSizesAreNotTheSame(int badRow) {

string text;
text.append("Rows have different sizes in matrix. Check the row № ").append(std::to_string(badRow + 1));
showReportPage("Rows sizes are not the same",
kWarningIcon,
"Rows have different sizes in matrix");
}

void showDateTimeChart(const string& date_time_values,
const vector<double>& yValues) {

string out;
string davis_dir;
#ifdef _WIN32
davis_dir = "\\davis_htmls";
#elif __linux__
davis_dir = "/davis_htmls";
#endif
vector<string>args {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);


text);
}


Expand Down
14 changes: 0 additions & 14 deletions davis_one/davis.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,6 @@ 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[];
Expand All @@ -168,9 +160,6 @@ extern const char kNoFileFoundedPage[];

extern const char kWarningIcon[];

extern const char kHtmlDateTimeModel[];


} // namespace dvs end

namespace dvs {
Expand Down Expand Up @@ -343,9 +332,6 @@ void showReportFileEmpty();

void showMatrixSizesAreNotTheSame(int badRow);

void showDateTimeChart(const string& date_time_values,
const vector<double>& yValues);


} // namespace dvs end

Expand Down
2 changes: 0 additions & 2 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ 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)
Expand Down
6 changes: 0 additions & 6 deletions gui/date_time_formats.json

This file was deleted.

88 changes: 6 additions & 82 deletions gui/davis_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include "QFileDialog"
#include "QTextStream"
#include <QClipboard>
#include <QJsonArray>
#include "json_utils.h"
#include "QDateTime"
#include <QProcess>

DavisGUI::DavisGUI(QWidget* parent)
: QMainWindow(parent)
Expand Down Expand Up @@ -88,9 +84,7 @@ void DavisGUI::pasteTextAdded() {
QString clipboardText = clipboard->text();
qDebug() << clipboardText;
QStringList lines = clipboardText.split(QRegExp("[\r\n]+"));
if (checkDateTimeVariant(lines) == false) {
readPlotText(lines);
};
readPlotText(lines);
}

void DavisGUI::readPlotText(QStringList& str_lines) {
Expand Down Expand Up @@ -125,7 +119,7 @@ void DavisGUI::readPlotText(QStringList& str_lines) {
}

if (data.empty()) {
dvs::showReportFileEmpty();
qDebug() << "Empty file";
return;
}

Expand Down Expand Up @@ -156,60 +150,6 @@ void DavisGUI::readPlotText(QStringList& str_lines) {
}
}

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<double> 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(",");
}

auto values_list = test.split(separator);
if (values_list.size() != 2) {
continue;
}
double value = values_list[1].toDouble();
qDebug()<<value;
values.emplace_back(value);

}
}
}
if (values.size() == 0)
return false;
qDebug() << "check sizes: " << lines.size() << values.size();
if (lines.size() != values.size()) {
return false;
}
dvs::showDateTimeChart(dates.toStdString(), values);
return true;


}

void DavisGUI::dragEnterEvent(QDragEnterEvent* event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
Expand All @@ -219,32 +159,18 @@ void DavisGUI::dragEnterEvent(QDragEnterEvent* event) {
}

void DavisGUI::dropEvent(QDropEvent* event) {
QList<QUrl> file_list = event->mimeData()->urls();
if(file_list.size()>1){
qDebug()<<"file list size: "<<file_list.size();
return;
}
QString filePath = file_list.first().toLocalFile();
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 suffix = info.suffix();
QStringList suffixes = {"jpg","bmp","png","svg","mp4","json"};
for(int i=0;i<suffixes.size();++i){
if(suffix == suffixes[i]){
QProcess process;
process.startDetached("cmd.exe", QStringList() << "/C" << filePath);
return;
}
}

QString line;
QStringList str_lines;
while (ts.readLineInto(&line)) {
Expand All @@ -255,9 +181,7 @@ void DavisGUI::dropEvent(QDropEvent* event) {
return;
}
file.close();
if (checkDateTimeVariant(str_lines) == false) {
readPlotText(str_lines);
};
readPlotText(str_lines);
} else {
qDebug() << "not exist";
dvs::showReportFileNotFounded();
Expand Down
1 change: 0 additions & 1 deletion gui/davis_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class DavisGUI : public QMainWindow {
bool isAboutWindowShowed;
QAction* m_copy_paste_action;
void readPlotText(QStringList& str_lines);
bool checkDateTimeVariant(const QStringList& lines);

// QWidget interface
protected:
Expand Down
82 changes: 0 additions & 82 deletions gui/json_utils.cpp

This file was deleted.

Loading

0 comments on commit b2c130c

Please sign in to comment.