From e4cd325e878b596713d907cdc7924630a0a684af Mon Sep 17 00:00:00 2001 From: ValeryStk Date: Thu, 30 Jan 2025 18:06:40 +0300 Subject: [PATCH 1/2] wip --- gui/bin.json | 7 +++++++ gui/davis_gui.cpp | 7 +++++++ gui/davis_gui.h | 2 +- gui/res.qrc | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gui/bin.json diff --git a/gui/bin.json b/gui/bin.json new file mode 100644 index 0000000..142589e --- /dev/null +++ b/gui/bin.json @@ -0,0 +1,7 @@ +[ + { + "file_size_in_bytes": 4177936, + "data_type": "uint8", + "numbers_in_line": 2044 + } +] \ No newline at end of file diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index cae4a50..e4b9ea5 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -471,6 +471,11 @@ QStringList DavisGUI::getLinesFromFile(const QString& pathToFile) { return str_lines; } +bool DavisGUI::mayBeShowBIN(const QString &path) +{ + +} + void DavisGUI::setMaxStyleWindow(int animDuration) { m_isMinStyleWindow = false; hideElementsDuringResize(); @@ -956,6 +961,8 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) { return; } if (suffix == "bin") { + QJsonArray bins; + jsn::getJsonArrayFromFile(":/bin.json",bins); if (info.size() == 4177936) { std::vector> data = dvs::readBinaryFile(filePath.toLatin1().data(), 2044); dv::show(data); diff --git a/gui/davis_gui.h b/gui/davis_gui.h index 79bd744..23c0810 100644 --- a/gui/davis_gui.h +++ b/gui/davis_gui.h @@ -20,7 +20,6 @@ QT_END_NAMESPACE enum class Skins {DEFAULT, NEWYEAR}; - class DavisGUI : public QMainWindow { Q_OBJECT @@ -70,6 +69,7 @@ class DavisGUI : public QMainWindow { std::vector>& multicharts); QStringList getLinesFromFile(const QString& pathToFile); + bool mayBeShowBIN(const QString& path); private slots: void showAboutWindow(); diff --git a/gui/res.qrc b/gui/res.qrc index 230c477..909447d 100644 --- a/gui/res.qrc +++ b/gui/res.qrc @@ -14,5 +14,6 @@ user_keys_list.json res/icon/D-16x16.png res/newYear.gif + bin.json From 7eec2dd9d5b4a35f0e770bd7de0d56482912d94a Mon Sep 17 00:00:00 2001 From: ValeryStk Date: Fri, 31 Jan 2025 12:00:20 +0300 Subject: [PATCH 2/2] Update davis_gui.cpp --- gui/davis_gui.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index e4b9ea5..425bb64 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -471,9 +471,28 @@ QStringList DavisGUI::getLinesFromFile(const QString& pathToFile) { return str_lines; } -bool DavisGUI::mayBeShowBIN(const QString &path) -{ - +bool DavisGUI::mayBeShowBIN(const QString& path) { + QFileInfo info(path); + QJsonArray bins; + if (jsn::getJsonArrayFromFile("bin.json", bins) == false) { + jsn::getJsonArrayFromFile(":/bin.json", bins); + } + for (int i = 0; i < bins.size(); ++i) { + int file_size = bins[i].toObject().value("file_size_in_bytes").toInt(); + int numbers_in_line = bins[i].toObject().value("numbers_in_line").toInt(); + QString data_type = bins[i].toObject().value("data_type").toString(); + if (info.size() == file_size) { + if (data_type == "uint8") { + std::vector> data = dvs::readBinaryFile(path.toLatin1().data(), numbers_in_line); + dv::show(data); + } else if (data_type == "uint16") { + std::vector> data = dvs::readBinaryFile(path.toLatin1().data(), numbers_in_line); + dv::show(data); + } + return true; + } + } + return false; } void DavisGUI::setMaxStyleWindow(int animDuration) { @@ -961,13 +980,9 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) { return; } if (suffix == "bin") { - QJsonArray bins; - jsn::getJsonArrayFromFile(":/bin.json",bins); - if (info.size() == 4177936) { - std::vector> data = dvs::readBinaryFile(filePath.toLatin1().data(), 2044); - dv::show(data); - } - return; + if (mayBeShowBIN(filePath)) { + return; + }; } if (info.exists()) {