]> git.mar77i.info Git - bigintmandel/commitdiff
compress output files, and use an extension other than .json
authormar77i <mar77i@protonmail.ch>
Mon, 22 Apr 2024 00:30:11 +0000 (02:30 +0200)
committermar77i <mar77i@protonmail.ch>
Mon, 22 Apr 2024 00:30:11 +0000 (02:30 +0200)
bigintwidget.cpp
bigintwidget.h
mandel.cpp
mandel.h

index 30c7ff2cc3c582e4feaef60b485383414bf7f5ce..916c141f90e5866a4be4748f442559942d3de738 100644 (file)
@@ -24,13 +24,13 @@ static inline QMenuBar *setup_menu_bar(BigintWidget *parent) {
         menu->addAction("&Load"),
         &QAction::triggered,
         parent,
-        &BigintWidget::load_json
+        &BigintWidget::load_data
     );
     QObject::connect(
         menu->addAction("&Save"),
         &QAction::triggered,
         parent,
-        &BigintWidget::save_json
+        &BigintWidget::save_data
     );
     menu->addSeparator();
     QObject::connect(
@@ -202,20 +202,20 @@ void BigintWidget::settings_widget_accepted() {
     update_img();
 }
 
-void BigintWidget::load_json() {
+void BigintWidget::load_data() {
     QString file_name = QFileDialog::getOpenFileName(
-        this, "Load JSON", "", "JSON Documents (*.json)"
+        this, "Load Data", "", "BigintMandel Data (*.bim)"
     );
     if (!file_name.isEmpty()) {
-        settings.load_json(file_name);
+        settings.load_data(file_name);
         update_img();
     }
 }
 
-void BigintWidget::save_json() {
+void BigintWidget::save_data() {
     QString file_name = QFileDialog::getSaveFileName(
-        this, "Save JSON", "", "JSON Documents (*.json)"
+        this, "Save Data", "", "BigintMandel Data (*.bim)"
     );
     if (!file_name.isEmpty())
-        settings.save_json(file_name);
+        settings.save_data(file_name);
 }
index 705be1814245dd59b611d6bc3d8f21382d8900a5..327c92ca3130b47e5e2e5a7e18129d811d78318c 100644 (file)
@@ -43,8 +43,8 @@ public Q_SLOT:
     void settings_widget_accepted();
     void finished_cell(int num);
     void finished();
-    void load_json();
-    void save_json();
+    void load_data();
+    void save_data();
 };
 
 #endif // BIGINTWIDGET_H
index f68b5ffd1aaf51df5949df534074ee39f91ea7d5..cdeae911f3bc69b6694b4a7af91c782e7f80fbb2 100644 (file)
@@ -108,11 +108,12 @@ void MandelSettings::zoom(const QSize size, const QPoint pos) {
 }
 
 void MandelSettings::finished_cell(int num, const MandelResultCell &result) {
-    size_t iter = result.get_iter();
     cells[num].set_result(result);
     if (!img)
         return;
     img->setPixelColor(cells[num].get_pos(), cells[num].get_color());
+    return;
+    (void)colors;
 }
 
 void MandelSettings::save_img(QString file_name) {
@@ -137,7 +138,7 @@ void MandelSettings::reset(size_t max_iter, const QSize size) {
     setup_cells(cells, &params);
 }
 
-void MandelSettings::load_json(QString file_name) {
+void MandelSettings::load_data(QString file_name) {
     QFile file(file_name);
     QJsonObject json;
     QJsonArray json_array;
@@ -146,7 +147,7 @@ void MandelSettings::load_json(QString file_name) {
         qWarning("Couldn't open save file.");
         return;
     }
-    json = QJsonDocument::fromJson(file.readAll()).object();
+    json = QJsonDocument::fromJson(qUncompress(file.readAll())).object();
     params = MandelParams::from_json(json["params"].toObject());
     json_array = json["cells"].toArray();
     cells.resize(json_array.size(), MandelCell(&params));
@@ -156,7 +157,7 @@ void MandelSettings::load_json(QString file_name) {
     file.close();
 }
 
-void MandelSettings::save_json(QString file_name) {
+void MandelSettings::save_data(QString file_name) {
     QVector<MandelCell>::iterator i;
     QFile file(file_name);
     QJsonObject json;
@@ -169,7 +170,7 @@ void MandelSettings::save_json(QString file_name) {
         qWarning("Couldn't open save file.");
         return;
     }
-    file.write(QJsonDocument(json).toJson());
+    file.write(qCompress(QJsonDocument(json).toJson(), 9));
     file.close();
 }
 
index dba45e3d8b1b6472a6e696f811a9febec94a9df4..8910f978901445489cba6bab6d668867aa80e690 100644 (file)
--- a/mandel.h
+++ b/mandel.h
@@ -74,8 +74,8 @@ public:
     void finished_cell(int num, const MandelResultCell &cell);
     void save_img(QString file_name);
     void reset(size_t max_iter, QSize size);
-    void load_json(QString file_name);
-    void save_json(QString file_name);
+    void load_data(QString file_name);
+    void save_data(QString file_name);
 };
 
 extern QVector<QColor> colors;