Commit b03fd11b authored by Yann Boucher's avatar Yann Boucher
Browse files

Résolution d'un bug dans Automaton, qui inversait colonnes et lignes

parent bd9afa91
Pipeline #79531 passed with stages
in 17 seconds
......@@ -159,6 +159,28 @@ public:
std::string str;
};
/**
\class HelpProperty
\brief Représente un bouton permettant l'affichage d'un manuel.
**/
struct HelpProperty : public PropertyImpl<StringProperty>
{
public:
//! \brief Constructeur par défaut.
HelpProperty() = default;
/** \brief Constructeur avec valeur initiale.
\param initval Valeur initiale.
**/
HelpProperty(const std::string& initval)
: str(initval)
{}
public:
//! \brief La chaîne de caractères contenant l'aide.
std::string str;
};
/**
\class IntegerProperty
......
......@@ -59,6 +59,7 @@ private:
void visit(IntegerProperty& prop);
void visit(CoordinateProperty& prop);
void visit(PropertyList& list);
void visit(HelpProperty&);
private:
std::stack<QWidget*> m_widget_hierarchy;
......@@ -88,6 +89,7 @@ private:
void visit(IntegerProperty& prop);
void visit(CoordinateProperty& prop);
void visit(PropertyList& list);
void visit(HelpProperty&) {}
private:
std::stack<QVariant> m_current_hierarchy;
......@@ -114,6 +116,8 @@ private:
void visit(IntegerProperty& prop);
void visit(CoordinateProperty& prop);
void visit(PropertyList& prop);
void visit(HelpProperty&) {}
private:
std::stack<QJsonValue> m_current_hierarchy;
};
......
......@@ -130,6 +130,7 @@ private:
private:
mutable std::vector<TotalisticRuleEntry> m_entries;
DEFINE_CONFIGURABLE_PROPERTY(StringProperty, rule_string, "Rule String");
DEFINE_CONFIGURABLE_PROPERTY(HelpProperty, help_string, "All your base are belong to us");
};
#endif // TOTALISTICTRANSITIONRULE_HPP
......@@ -9,8 +9,8 @@ Automaton::~Automaton() {
void Automaton::setAlphabet(const Alphabet& A) {
alphabet = A;
for(int i=0; i<static_cast<int>(grid.get_rows()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_col()); ++j) {
for(int i=0; i<static_cast<int>(grid.get_col()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_rows()); ++j) {
grid.set_cell({i,j}, 0);
}
}
......@@ -45,8 +45,8 @@ const Grid& Automaton::getGrid() const {
void Automaton::setGrid(const Grid& G) {
grid = G;
unsigned int state;
for(int i=0; i<static_cast<int>(grid.get_rows()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_col()); ++j) {
for(int i=0; i<static_cast<int>(grid.get_col()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_rows()); ++j) {
state = grid.get_state({i,j});
if(state >= alphabet.taille()) {
grid.set_cell({i,j}, state%alphabet.taille());
......@@ -57,8 +57,8 @@ void Automaton::setGrid(const Grid& G) {
void Automaton::runOnce() {
Grid tempGrid(grid);
for(int i=0; i<static_cast<int>(grid.get_rows()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_col()); ++j) {
for(int i=0; i<static_cast<int>(grid.get_col()); ++i) {
for(int j=0; j<static_cast<int>(grid.get_rows()); ++j) {
tempGrid.set_cell({i, j}, transitionRule->getState(grid.get_state({i,j}),neighbourhoodRule->getNeighborhood(grid, {i, j}))%alphabet.taille());
}
}
......
......@@ -130,6 +130,17 @@ void UIBuilderVisitor::visit(CoordinateProperty &prop)
[&prop](int i) { prop.c.y = i; });
}
void UIBuilderVisitor::visit(HelpProperty& prop)
{
QPushButton* button = new QPushButton("Help", current_widget());
add_widget("", button);
QObject::connect(button, &QPushButton::clicked,
[&prop]() {
QMessageBox::information(NULL, "Help", QString::fromStdString(prop.str));
});
}
void UIBuilderVisitor::visit(PropertyList &list)
{
push_array_widget(list);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment