Skip to content

Mr bin #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gui/bin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"file_size_in_bytes": 4177936,
"data_type": "uint8",
"numbers_in_line": 2044
}
]
32 changes: 27 additions & 5 deletions gui/davis_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,30 @@ QStringList DavisGUI::getLinesFromFile(const QString& pathToFile) {
return str_lines;
}

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<std::vector<uint8_t>> data = dvs::readBinaryFile<uint8_t>(path.toLatin1().data(), numbers_in_line);
dv::show(data);
} else if (data_type == "uint16") {
std::vector<std::vector<uint16_t>> data = dvs::readBinaryFile<uint16_t>(path.toLatin1().data(), numbers_in_line);
dv::show(data);
}
return true;
}
}
return false;
}

void DavisGUI::setMaxStyleWindow(int animDuration) {
m_isMinStyleWindow = false;
hideElementsDuringResize();
Expand Down Expand Up @@ -956,11 +980,9 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) {
return;
}
if (suffix == "bin") {
if (info.size() == 4177936) {
std::vector<std::vector<uint8_t>> data = dvs::readBinaryFile<uint8_t>(filePath.toLatin1().data(), 2044);
dv::show(data);
}
return;
if (mayBeShowBIN(filePath)) {
return;
};
}

if (info.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion gui/davis_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ QT_END_NAMESPACE
enum class Skins {DEFAULT, NEWYEAR};



class DavisGUI : public QMainWindow {
Q_OBJECT

Expand Down Expand Up @@ -70,6 +69,7 @@ class DavisGUI : public QMainWindow {
std::vector<std::vector<double>>& multicharts);

QStringList getLinesFromFile(const QString& pathToFile);
bool mayBeShowBIN(const QString& path);

private slots:
void showAboutWindow();
Expand Down
1 change: 1 addition & 0 deletions gui/res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<file>user_keys_list.json</file>
<file>res/icon/D-16x16.png</file>
<file>res/newYear.gif</file>
<file>bin.json</file>
</qresource>
</RCC>