diff --git a/include/colorlabel.h b/include/colorlabel.h index 23a60176fc18ad1465674eaa7018598a2659b53a..0d1a689670480898bafa0fcfb9d4031d6cfda449 100644 --- a/include/colorlabel.h +++ b/include/colorlabel.h @@ -34,6 +34,8 @@ private slots: void loadStateID(unsigned int); // La fonction idPath permet de parcourir la liste des états et d'avoir un affiche du nom et de la couleur sur l'interface void pickColor(); + void on_state_label_textEdited(const QString &arg1); + private: Ui::ColorLabel *ui; Alphabet a; diff --git a/include/interface.hpp b/include/interface.hpp index fbfe06f0f03d92cb86770cc008aabe38af72d280..8996a3cd9fcdc712b7015d0d61801b846c263197 100644 --- a/include/interface.hpp +++ b/include/interface.hpp @@ -108,6 +108,7 @@ private: //! \brief Charge la grille depuis une image. void load_from_image(); + //! \brief Charge un nouvel alphabet et met à jour l'UI. void ui_update_alphabet(const Alphabet& alph); //! \brief Sauvegarde la configuration actuelle. diff --git a/models/langston.json b/models/langston.json deleted file mode 100644 index b7e0cddb7a0faf2cac104a65d3ba5f774b3377f2..0000000000000000000000000000000000000000 --- a/models/langston.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "alphabet": [ - { - "color": [ - 255, - 255, - 255 - ], - "name": "Dead" - }, - { - "color": [ - 0, - 0, - 255 - ], - "name": "Alive" - } - ], - "author": "JM", - "date": "jeu. juin 3 2021", - "desc": "Langston's Loops.\n!!CORRIGER L'ALPHABET!!", - "neighborhood_data": { - "radius": 1 - }, - "neighborhood_name": "Von Neumann", - "title": "langston_loops", - "transition_data": { - "rule_string": "rotate4\n0,0,0,0,0->0\n0,0,0,0,1->2\n0,0,0,0,2->0\n0,0,0,0,3->0\n0,0,0,0,5->0\n0,0,0,0,6->3\n0,0,0,0,7->1\n0,0,0,1,1->2\n0,0,0,1,2->2\n0,0,0,1,3->2\n0,0,0,2,1->2\n0,0,0,2,2->0\n0,0,0,2,3->0\n0,0,0,2,6->2\n0,0,0,2,7->2\n0,0,0,3,2->0\n0,0,0,5,2->5\n0,0,0,6,2->2\n0,0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2\n3,0,1,0,2->1\n3,0,1,2,2->0\n3,0,2,5,1->1\n4,0,1,1,2->0\n4,0,1,2,2->0\n4,0,1,2,5->0\n4,0,2,1,2->0\n4,0,2,2,2->1\n4,0,2,3,2->6\n4,0,2,5,2->0\n4,0,3,2,2->1\n5,0,0,0,2->2\n5,0,0,2,1->5\n5,0,0,2,2->5\n5,0,0,2,3->2\n5,0,0,2,7->2\n5,0,0,5,2->0\n5,0,2,0,2->2\n5,0,2,1,2->2\n5,0,2,1,5->2\n5,0,2,2,2->0\n5,0,2,2,4->4\n5,0,2,7,2->2\n5,1,2,1,2->2\n5,1,2,2,2->0\n5,1,2,4,2->2\n5,1,2,7,2->2\n6,0,0,0,1->1\n6,0,0,0,2->1\n6,0,2,1,2->0\n6,1,2,1,2->5\n6,1,2,1,3->1\n6,1,2,2,2->5\n7,0,0,0,7->7\n7,0,1,1,2->0\n7,0,1,2,2->0\n7,0,1,2,5->0\n7,0,2,1,2->0\n7,0,2,2,2->1\n7,0,2,2,5->1\n7,0,2,3,2->1\n7,0,2,5,2->5\n7,0,2,7,2->0" - }, - "transition_name": "Non isotropic rulestring" -} diff --git a/models/langton.json b/models/langton.json new file mode 100644 index 0000000000000000000000000000000000000000..288c8eb57312ade3829a6d55fb2f7c6e7de0ee74 --- /dev/null +++ b/models/langton.json @@ -0,0 +1,80 @@ +{ + "alphabet": [ + { + "color": [ + 0, + 0, + 0 + ], + "name": "Background" + }, + { + "color": [ + 0, + 0, + 255 + ], + "name": "Core" + }, + { + "color": [ + 255, + 0, + 0 + ], + "name": "Sheath" + }, + { + "color": [ + 0, + 170, + 0 + ], + "name": "Green" + }, + { + "color": [ + 255, + 255, + 0 + ], + "name": "Yellow" + }, + { + "color": [ + 255, + 85, + 255 + ], + "name": "Pink" + }, + { + "color": [ + 255, + 255, + 255 + ], + "name": "White" + }, + { + "color": [ + 0, + 255, + 255 + ], + "name": "Cyan" + } + ], + "author": "JM", + "date": "dim. juin 6 2021", + "desc": "", + "neighborhood_data": { + "radius": 1 + }, + "neighborhood_name": "Von Neumann", + "title": "langton", + "transition_data": { + "rule_string": "rotate4\n0,0,0,0,0->0\n0,0,1,0,0->2\n0,0,2,0,0->0\n0,0,3,0,0->0\n0,0,5,0,0->0\n0,0,6,0,0->3\n0,0,7,0,0->1\n0,0,1,0,1->2\n0,0,2,0,1->2\n0,0,3,0,1->2\n0,0,1,0,2->2\n0,0,2,0,2->0\n0,0,3,0,2->0\n0,0,6,0,2->2\n0,0,7,0,2->2\n0,0,2,0,3->0\n0,0,2,0,5->5\n0,0,2,0,6->2\n0,0,2,0,7->2\n0,0,2,1,0->2\n0,0,2,1,1->0\n0,0,2,2,0->0\n0,0,3,2,0->0\n0,0,5,2,0->0\n0,0,2,2,1->5\n0,0,2,2,2->0\n0,0,2,2,3->2\n0,0,2,5,2->2\n0,1,2,2,3->1\n0,1,2,2,4->1\n0,1,2,2,5->5\n0,1,2,2,6->1\n0,1,2,2,7->1\n0,1,5,2,7->1\n0,1,2,4,2->1\n0,1,2,4,3->1\n0,1,2,4,4->1\n0,1,2,4,7->1\n0,1,5,6,2->1\n0,1,2,7,2->1\n0,1,5,7,2->5\n0,1,2,7,5->1\n0,1,2,7,6->1\n0,1,2,7,7->1\n0,2,7,5,2->1\n1,0,1,0,0->1\n1,0,6,0,0->1\n1,0,7,0,0->7\n1,0,1,0,1->1\n1,0,2,0,1->1\n1,0,1,0,2->1\n1,0,4,0,2->4\n1,0,7,0,2->7\n1,0,1,0,5->1\n1,0,1,1,0->1\n1,0,1,1,1->1\n1,0,4,1,2->4\n1,0,7,1,2->7\n1,0,2,2,0->6\n1,0,2,2,1->1\n1,0,1,2,2->1\n1,0,4,2,2->4\n1,0,6,2,2->3\n1,0,7,2,2->7\n1,0,2,2,3->7\n1,0,2,2,4->4\n1,0,2,2,6->6\n1,0,4,2,6->4\n1,0,7,2,6->7\n1,0,1,2,7->0\n1,0,2,2,7->7\n1,0,2,5,4->7\n1,1,2,1,1->1\n1,1,2,1,2->1\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->2\n2,0,2,7,7->2\n2,1,2,1,2->2\n2,1,6,1,2->1\n2,1,2,2,2->2\n2,1,4,2,2->2\n2,1,6,2,2->2\n2,1,7,2,2->2\n2,1,2,4,2->2\n2,1,2,5,2->2\n2,1,2,6,2->2\n2,1,2,7,2->2\n2,2,7,2,2->2\n2,2,4,2,4->2\n2,2,6,2,4->2\n2,2,6,2,7->2\n2,2,7,2,7->2\n3,0,1,0,0->3\n3,0,2,0,0->2\n3,0,4,0,0->1\n3,0,7,0,0->6\n3,0,2,0,1->3\n3,0,2,0,4->1\n3,0,2,0,6->2\n3,0,2,1,0->1\n3,0,2,1,2->0\n3,0,1,2,5->1\n4,0,2,1,1->0\n4,0,2,1,2->0\n4,0,5,1,2->0\n4,0,2,2,1->0\n4,0,2,2,2->1\n4,0,2,2,3->6\n4,0,2,2,5->0\n4,0,2,3,2->1\n5,0,2,0,0->2\n5,0,1,0,2->5\n5,0,2,0,2->5\n5,0,3,0,2->2\n5,0,7,0,2->2\n5,0,2,0,5->0\n5,0,2,2,0->2\n5,0,2,2,1->2\n5,0,5,2,1->2\n5,0,2,2,2->0\n5,0,4,2,2->4\n5,0,2,2,7->2\n5,1,2,2,1->2\n5,1,2,2,2->0\n5,1,2,2,4->2\n5,1,2,2,7->2\n6,0,1,0,0->1\n6,0,2,0,0->1\n6,0,2,2,1->0\n6,1,2,2,1->5\n6,1,3,2,1->1\n6,1,2,2,2->5\n7,0,7,0,0->7\n7,0,2,1,1->0\n7,0,2,1,2->0\n7,0,5,1,2->0\n7,0,2,2,1->0\n7,0,2,2,2->1\n7,0,5,2,2->1\n7,0,2,2,3->1\n7,0,2,2,5->5\n7,0,2,2,7->0" + }, + "transition_name": "Non isotropic rulestring" +} diff --git a/patterns/Langton/langton_loop.json b/patterns/Langton/langton_loop.json new file mode 100644 index 0000000000000000000000000000000000000000..86c6ca3ac528f7ffad5871310be1d8b3932a3385 --- /dev/null +++ b/patterns/Langton/langton_loop.json @@ -0,0 +1,438 @@ +{ + "author": "JM", + "cells": [ + { + "state": 2, + "x": 1, + "y": 0 + }, + { + "state": 2, + "x": 2, + "y": 0 + }, + { + "state": 2, + "x": 3, + "y": 0 + }, + { + "state": 2, + "x": 4, + "y": 0 + }, + { + "state": 2, + "x": 5, + "y": 0 + }, + { + "state": 2, + "x": 6, + "y": 0 + }, + { + "state": 2, + "x": 7, + "y": 0 + }, + { + "state": 2, + "x": 8, + "y": 0 + }, + { + "state": 2, + "x": 0, + "y": 1 + }, + { + "state": 1, + "x": 1, + "y": 1 + }, + { + "state": 7, + "x": 2, + "y": 1 + }, + { + "state": 1, + "x": 4, + "y": 1 + }, + { + "state": 4, + "x": 5, + "y": 1 + }, + { + "state": 1, + "x": 7, + "y": 1 + }, + { + "state": 4, + "x": 8, + "y": 1 + }, + { + "state": 2, + "x": 9, + "y": 1 + }, + { + "state": 2, + "x": 0, + "y": 2 + }, + { + "state": 2, + "x": 2, + "y": 2 + }, + { + "state": 2, + "x": 3, + "y": 2 + }, + { + "state": 2, + "x": 4, + "y": 2 + }, + { + "state": 2, + "x": 5, + "y": 2 + }, + { + "state": 2, + "x": 6, + "y": 2 + }, + { + "state": 2, + "x": 7, + "y": 2 + }, + { + "state": 2, + "x": 9, + "y": 2 + }, + { + "state": 2, + "x": 0, + "y": 3 + }, + { + "state": 7, + "x": 1, + "y": 3 + }, + { + "state": 2, + "x": 2, + "y": 3 + }, + { + "state": 2, + "x": 7, + "y": 3 + }, + { + "state": 1, + "x": 8, + "y": 3 + }, + { + "state": 2, + "x": 9, + "y": 3 + }, + { + "state": 2, + "x": 0, + "y": 4 + }, + { + "state": 1, + "x": 1, + "y": 4 + }, + { + "state": 2, + "x": 2, + "y": 4 + }, + { + "state": 2, + "x": 7, + "y": 4 + }, + { + "state": 1, + "x": 8, + "y": 4 + }, + { + "state": 2, + "x": 9, + "y": 4 + }, + { + "state": 2, + "x": 0, + "y": 5 + }, + { + "state": 2, + "x": 2, + "y": 5 + }, + { + "state": 2, + "x": 7, + "y": 5 + }, + { + "state": 1, + "x": 8, + "y": 5 + }, + { + "state": 2, + "x": 9, + "y": 5 + }, + { + "state": 2, + "x": 0, + "y": 6 + }, + { + "state": 7, + "x": 1, + "y": 6 + }, + { + "state": 2, + "x": 2, + "y": 6 + }, + { + "state": 2, + "x": 7, + "y": 6 + }, + { + "state": 1, + "x": 8, + "y": 6 + }, + { + "state": 2, + "x": 9, + "y": 6 + }, + { + "state": 2, + "x": 0, + "y": 7 + }, + { + "state": 1, + "x": 1, + "y": 7 + }, + { + "state": 2, + "x": 2, + "y": 7 + }, + { + "state": 2, + "x": 3, + "y": 7 + }, + { + "state": 2, + "x": 4, + "y": 7 + }, + { + "state": 2, + "x": 5, + "y": 7 + }, + { + "state": 2, + "x": 6, + "y": 7 + }, + { + "state": 2, + "x": 7, + "y": 7 + }, + { + "state": 1, + "x": 8, + "y": 7 + }, + { + "state": 2, + "x": 9, + "y": 7 + }, + { + "state": 2, + "x": 10, + "y": 7 + }, + { + "state": 2, + "x": 11, + "y": 7 + }, + { + "state": 2, + "x": 12, + "y": 7 + }, + { + "state": 2, + "x": 13, + "y": 7 + }, + { + "state": 2, + "x": 0, + "y": 8 + }, + { + "state": 7, + "x": 2, + "y": 8 + }, + { + "state": 1, + "x": 3, + "y": 8 + }, + { + "state": 7, + "x": 5, + "y": 8 + }, + { + "state": 1, + "x": 6, + "y": 8 + }, + { + "state": 7, + "x": 8, + "y": 8 + }, + { + "state": 1, + "x": 9, + "y": 8 + }, + { + "state": 1, + "x": 10, + "y": 8 + }, + { + "state": 1, + "x": 11, + "y": 8 + }, + { + "state": 1, + "x": 12, + "y": 8 + }, + { + "state": 1, + "x": 13, + "y": 8 + }, + { + "state": 2, + "x": 14, + "y": 8 + }, + { + "state": 2, + "x": 1, + "y": 9 + }, + { + "state": 2, + "x": 2, + "y": 9 + }, + { + "state": 2, + "x": 3, + "y": 9 + }, + { + "state": 2, + "x": 4, + "y": 9 + }, + { + "state": 2, + "x": 5, + "y": 9 + }, + { + "state": 2, + "x": 6, + "y": 9 + }, + { + "state": 2, + "x": 7, + "y": 9 + }, + { + "state": 2, + "x": 8, + "y": 9 + }, + { + "state": 2, + "x": 9, + "y": 9 + }, + { + "state": 2, + "x": 10, + "y": 9 + }, + { + "state": 2, + "x": 11, + "y": 9 + }, + { + "state": 2, + "x": 12, + "y": 9 + }, + { + "state": 2, + "x": 13, + "y": 9 + } + ], + "date": "dim. juin 6 2021", + "desc": "", + "title": "langton" +} diff --git a/src/colorlabel.cpp b/src/colorlabel.cpp index b77792cee23a45af549dbb45c714d593ba47f9f6..5590c8a13d3d4deca975ae98818416c48ab78f6c 100644 --- a/src/colorlabel.cpp +++ b/src/colorlabel.cpp @@ -140,3 +140,10 @@ void ColorLabel::pickColor() pal.setColor(QPalette::Window, color); ui->color_label->setPalette(pal); } + +void ColorLabel::on_state_label_textEdited(const QString &arg1) +{ + state s = a.getState(current_id); + a.setState(current_id, state(s.getColor(), arg1.toStdString())); + ui->state_list->item(current_id)->setText(arg1); +} diff --git a/src/gridview.cpp b/src/gridview.cpp index 321ab499c50b3571b617c1bae8961640ab1ced6d..f6cb22b9f889b9551d453fbbfd6e83521a7160f4 100644 --- a/src/gridview.cpp +++ b/src/gridview.cpp @@ -219,7 +219,7 @@ void GridGraphicsView::drawForeground(QPainter *painter, const QRectF &) if (lod < 10) return; // trop zoomé, on ne dessine rien - painter->setPen(QPen(Qt::black, 0)); // cosmetic 1-pixel pen + painter->setPen(QPen(Qt::gray, 0)); // cosmetic 1-pixel pen QVector<QLine> lines; // horizontal lines diff --git a/src/interface.cpp b/src/interface.cpp index 099a176cbaf925d199add5d2b024c55d6468503b..146a5cae519f901d810e1223064ab99ec5ea04b0 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -43,8 +43,7 @@ MainWindow::MainWindow(QWidget *parent) ColorLabel* dialog = new ColorLabel(simulation.getAlphabet(), this); if (dialog->exec()) { - simulation.setAlphabet(dialog->getAlphabet()); - ui->grid_view->set_alphabet(dialog->getAlphabet()); + ui_update_alphabet(dialog->getAlphabet()); } }); connect(ui->transition_list, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int) @@ -327,6 +326,7 @@ void MainWindow::update_neighborhood_settings() void MainWindow::enable_rule_customization() { //ui->simulation_tab->setEnabled(false); + ui->savePatternButton->setEnabled(false); ui->customize_button->setText("Cancel customization"); ui->rule_settings->setEnabled(true); m_customizing = true; @@ -335,6 +335,7 @@ void MainWindow::enable_rule_customization() void MainWindow::disable_rule_customization() { //ui->simulation_tab->setEnabled(true); + ui->savePatternButton->setEnabled(true); ui->customize_button->setEnabled(true); ui->rule_settings->setEnabled(false); ui->customize_button->setText("Customize..."); @@ -405,8 +406,7 @@ void MainWindow::load_model(const QJsonObject &obj) // On transfère la propriété de ces pointeurs vers Simulation, qui en est désormais propriétaire pour l'exécution de l'automate simulation.setNeighborhoodRule(m_neighborhood_rule); simulation.setTransitionRule(m_transition_rule); - simulation.setAlphabet(alpha); - ui->grid_view->set_alphabet(alpha); + ui_update_alphabet(alpha); m_loaded_model = obj; } @@ -516,12 +516,13 @@ void MainWindow::load_from_image() void MainWindow::ui_update_alphabet(const Alphabet &alpha) { + simulation.setAlphabet(alpha); ui->grid_view->set_alphabet(alpha); ui->nbrStateComboBox->clear(); - std::cout << alpha.taille() << endl; - fflush(stdout); for (unsigned i = 0; i < alpha.taille(); ++i) + { ui->nbrStateComboBox->addItem(QString::number(i)); + } } void MainWindow::save_grid_configuration() diff --git a/src/neighborhood_rules/vonNeumannNeighborhoodRule.cpp b/src/neighborhood_rules/vonNeumannNeighborhoodRule.cpp index 59ce07087a79c59b172d59fd1fcc2577fb992875..a3cb5077562b0c007fa8be419c55cc89eeac0399 100644 --- a/src/neighborhood_rules/vonNeumannNeighborhoodRule.cpp +++ b/src/neighborhood_rules/vonNeumannNeighborhoodRule.cpp @@ -14,7 +14,7 @@ vonNeumannNeighborhoodRule::vonNeumannNeighborhoodRule(int _radius) Coord newCord; for(int i = -_radius; i <= _radius; i++){ for(int j = -_radius; j <= _radius; j++){ - if( abs(i+j) <= _radius) { + if((abs(i) + abs(j)) <= _radius) { newCord.x = i; newCord.y = j; if(!(newCord.x == 0 && newCord.y == 0)) {