Skip to content

Commit d9e6175

Browse files
authored
Mr bin (#157)
1 parent c56c599 commit d9e6175

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

gui/bin.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"file_size_in_bytes": 4177936,
4+
"data_type": "uint8",
5+
"numbers_in_line": 2044
6+
}
7+
]

gui/davis_gui.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,30 @@ QStringList DavisGUI::getLinesFromFile(const QString& pathToFile) {
471471
return str_lines;
472472
}
473473

474+
bool DavisGUI::mayBeShowBIN(const QString& path) {
475+
QFileInfo info(path);
476+
QJsonArray bins;
477+
if (jsn::getJsonArrayFromFile("bin.json", bins) == false) {
478+
jsn::getJsonArrayFromFile(":/bin.json", bins);
479+
}
480+
for (int i = 0; i < bins.size(); ++i) {
481+
int file_size = bins[i].toObject().value("file_size_in_bytes").toInt();
482+
int numbers_in_line = bins[i].toObject().value("numbers_in_line").toInt();
483+
QString data_type = bins[i].toObject().value("data_type").toString();
484+
if (info.size() == file_size) {
485+
if (data_type == "uint8") {
486+
std::vector<std::vector<uint8_t>> data = dvs::readBinaryFile<uint8_t>(path.toLatin1().data(), numbers_in_line);
487+
dv::show(data);
488+
} else if (data_type == "uint16") {
489+
std::vector<std::vector<uint16_t>> data = dvs::readBinaryFile<uint16_t>(path.toLatin1().data(), numbers_in_line);
490+
dv::show(data);
491+
}
492+
return true;
493+
}
494+
}
495+
return false;
496+
}
497+
474498
void DavisGUI::setMaxStyleWindow(int animDuration) {
475499
m_isMinStyleWindow = false;
476500
hideElementsDuringResize();
@@ -956,11 +980,9 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) {
956980
return;
957981
}
958982
if (suffix == "bin") {
959-
if (info.size() == 4177936) {
960-
std::vector<std::vector<uint8_t>> data = dvs::readBinaryFile<uint8_t>(filePath.toLatin1().data(), 2044);
961-
dv::show(data);
962-
}
963-
return;
983+
if (mayBeShowBIN(filePath)) {
984+
return;
985+
};
964986
}
965987

966988
if (info.exists()) {

gui/davis_gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ QT_END_NAMESPACE
2020
enum class Skins {DEFAULT, NEWYEAR};
2121

2222

23-
2423
class DavisGUI : public QMainWindow {
2524
Q_OBJECT
2625

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

7271
QStringList getLinesFromFile(const QString& pathToFile);
72+
bool mayBeShowBIN(const QString& path);
7373

7474
private slots:
7575
void showAboutWindow();

gui/res.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<file>user_keys_list.json</file>
1515
<file>res/icon/D-16x16.png</file>
1616
<file>res/newYear.gif</file>
17+
<file>bin.json</file>
1718
</qresource>
1819
</RCC>

0 commit comments

Comments
 (0)