Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
cf58a96e
Commit
cf58a96e
authored
Apr 28, 2021
by
Yann Boucher
Browse files
Merged work by Merwane; implemented the foundations of the GridView class
parent
4617dc50
Pipeline
#77195
passed with stages
in 20 seconds
Changes
11
Pipelines
1
Show whitespace changes
Inline
Side-by-side
forms/interface.ui
0 → 100644
View file @
cf58a96e
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
MainWindow
</class>
<widget
class=
"QMainWindow"
name=
"MainWindow"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
1075
</width>
<height>
616
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
MainWindow
</string>
</property>
<widget
class=
"QWidget"
name=
"centralwidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"0"
column=
"0"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<layout
class=
"QVBoxLayout"
name=
"simulationLayout"
stretch=
"0,0"
>
<item>
<widget
class=
"QWidget"
name=
"grid"
native=
"true"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
100
</width>
<height>
100
</height>
</size>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout_2"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"GridView"
name=
"frame"
>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Raised
</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QGroupBox"
name=
"groupBox"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"layoutDirection"
>
<enum>
Qt::LeftToRight
</enum>
</property>
<property
name=
"title"
>
<string>
Simulation
</string>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
stretch=
"0,0,0,0"
>
<property
name=
"sizeConstraint"
>
<enum>
QLayout::SetDefaultConstraint
</enum>
</property>
<property
name=
"bottomMargin"
>
<number>
9
</number>
</property>
<item>
<layout
class=
"QVBoxLayout"
name=
"playPauseLayout_5"
>
<item>
<widget
class=
"QPushButton"
name=
"playPauseButton"
>
<property
name=
"text"
>
<string>
Play/Pause
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"resetButton"
>
<property
name=
"text"
>
<string>
Reset
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"simSpeedLayout_3"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"simSpeedLabLayout_2"
>
<item>
<widget
class=
"QLabel"
name=
"simSpeedLabel"
>
<property
name=
"text"
>
<string>
Simulation speed :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"stepByStepCheckBox"
>
<property
name=
"text"
>
<string>
Step by step mode
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"sliderLayout_6"
>
<item>
<widget
class=
"QSlider"
name=
"simSpeedSlider"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QSpinBox"
name=
"simSpeedSpinbox"
/>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"nextPrevLayout_6"
stretch=
"0,0"
>
<property
name=
"spacing"
>
<number>
6
</number>
</property>
<item>
<widget
class=
"QPushButton"
name=
"nextButton"
>
<property
name=
"text"
>
<string>
Next step
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"prevButton"
>
<property
name=
"text"
>
<string>
Prev step
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"periodRecordLayout_7"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"periodLayout_5"
>
<item>
<widget
class=
"QLabel"
name=
"periodLabel"
>
<property
name=
"text"
>
<string>
Period :
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
</set>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"stepsPeriodLabel"
>
<property
name=
"text"
>
<string>
0 steps
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"recordLayout_3"
>
<item>
<widget
class=
"QLabel"
name=
"recordLabel"
>
<property
name=
"text"
>
<string>
Number of previous
pattern recorded :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"recordLineEdit"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
40
</width>
<height>
16777215
</height>
</size>
</property>
<property
name=
"text"
>
<string>
50
</string>
</property>
<property
name=
"maxLength"
>
<number>
10
</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"settingsLayout"
>
<item>
<widget
class=
"QGroupBox"
name=
"gridPatternGroupBox"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"title"
>
<string>
Grid and patterns
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<item>
<widget
class=
"QLabel"
name=
"gridDimLabel"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Minimum"
vsizetype=
"Minimum"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"text"
>
<string>
Grid dimension
</string>
</property>
</widget>
</item>
<item>
<layout
class=
"QFormLayout"
name=
"gridDimLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"widthLabel"
>
<property
name=
"text"
>
<string>
Width :
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"widthLineEdit"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"text"
>
<string>
5
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"heightLabel"
>
<property
name=
"text"
>
<string>
Height :
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"heightLineEdit"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"text"
>
<string>
5
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QGridLayout"
name=
"patternSettingsLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QPushButton"
name=
"randomPatternButton"
>
<property
name=
"text"
>
<string>
Random starting pattern
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QPushButton"
name=
"savePatternButton"
>
<property
name=
"text"
>
<string>
Save current pattern
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QPushButton"
name=
"openPatternButton"
>
<property
name=
"text"
>
<string>
(file) Open pattern
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<layout
class=
"QHBoxLayout"
name=
"drawCellLayout"
>
<item>
<widget
class=
"QPushButton"
name=
"drawCellButton"
>
<property
name=
"text"
>
<string>
Draw cell
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"nbrStateComboBox"
>
<item>
<property
name=
"text"
>
<string>
0
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
1
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
2
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
3
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
4
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
5
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
6
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
7
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
8
</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QGroupBox"
name=
"rulesGroupBox"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"title"
>
<string>
Rules
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_4"
>
<item>
<widget
class=
"QPushButton"
name=
"openRuleButton"
>
<property
name=
"text"
>
<string>
(file) Open rule
</string>
</property>
</widget>
</item>
<item>
<layout
class=
"QGridLayout"
name=
"statesNeighborhoodLayout_3"
>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"neighborhoodLabel"
>
<property
name=
"text"
>
<string>
Neighborhood :
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"neighborhoodComboBox"
>
<item>
<property
name=
"text"
>
<string>
Von Neumann
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Moore
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Custom
</string>
</property>
</item>
</widget>
</item>
<item
row=
"0"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"statesSettingsButton"
>
<property
name=
"text"
>
<string>
States settings (color...)
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"cusumNeighborhoodButton"
>
<property
name=
"text"
>
<string>
Custom neighborhood
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"nbrStatesComboBox"
>
<item>
<property
name=
"text"
>
<string>
0
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
1
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
2
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
3
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
4
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
5
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
6
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
7
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
8
</string>
</property>
</item>
</widget>
</item>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"nbrStatesLabel"
>
<property
name=
"text"
>
<string>
Number of states :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"1"
>
<widget
class=
"QLabel"
name=
"radiusLabel"
>
<property
name=
"text"
>
<string>
Radius r :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QLineEdit"
name=
"radiusLineEdit"
/>
</item>
</layout>
</item>
<item>
<widget
class=
"QLabel"
name=
"transitionFunctionLabel"
>
<property
name=
"text"
>
<string>
Transition function :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPlainTextEdit"
name=
"transitionFunctionTextEdit"
/>
</item>
<item>
<widget
class=
"QLabel"
name=
"informationLabel"
>
<property
name=
"text"
>
<string>
New rule must be saved before running simulation
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"saveRuleButton"
>
<property
name=
"text"
>
<string>
Save rule
</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget
class=
"QMenuBar"
name=
"menubar"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
1075
</width>
<height>
25
</height>
</rect>
</property>
</widget>
<widget
class=
"QStatusBar"
name=
"statusbar"
/>
</widget>
<customwidgets>
<customwidget>
<class>
GridView
</class>
<extends>
QFrame
</extends>
<header>
gridview.hpp
</header>
<container>
1
</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
include/grid.h
0 → 100644
View file @
cf58a96e
/**
\file grid.h
\date 24/04/2021
\author Merwane Bouri
\version 1
\brief Grid
Cette classe représente un réseau de cellules.
**/
#ifndef GRID_H
#define GRID_H
#include <iostream>
#include <vector>
#include "coord.hpp"
using
namespace
std
;
class
Grid
{
int
nb_rows
;
int
nb_col
;
std
::
vector
<
unsigned
int
>
matrix
;
public:
Grid
(
size_t
l
,
size_t
c
);
Grid
(
const
Grid
&
g
);
size_t
get_rows
()
const
{
return
nb_rows
;}
size_t
get_col
()
const
{
return
nb_col
;}
void
set_cell
(
int
i
,
int
j
,
unsigned
int
state
)
{
matrix
[((
i
%
nb_rows
+
nb_rows
)
%
nb_rows
)
*
nb_col
+
((
j
%
nb_col
+
nb_col
)
%
nb_col
)]
=
state
;
}
unsigned
int
get_state
(
int
i
,
int
j
)
const
{
return
matrix
[((
i
%
nb_rows
+
nb_rows
)
%
nb_rows
)
*
nb_col
+
((
j
%
nb_col
+
nb_col
)
%
nb_col
)];
}
Grid
&
operator
=
(
const
Grid
&
g
);
};
ostream
&
operator
<<
(
ostream
&
f
,
const
Grid
&
g
);
#endif // GRID_H
include/gridview.hpp
0 → 100644
View file @
cf58a96e
/**
\file gridview.hpp
\date 28/04/2021
\author Yann Boucher
\version 1
\brief GridView
Cette classe représente le widget utilisé pour l'affichage et l'interaction avec la grille actuelle.
**/
#ifndef GRIDVIEW_HPP