Skip to content
GitLab
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
ec3c13e6
Commit
ec3c13e6
authored
May 31, 2021
by
Arthur Detree
Browse files
Implémentation Widget ColorLabel + Version 1 Mode Daltonien
parent
78ea73a0
Pipeline
#78810
passed with stages
in 17 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
forms/colorlabel.cpp
0 → 100644
View file @
ec3c13e6
#include
"colorlabel.h"
#include
"ui_colorlabel.h"
#include
"state.hpp"
#include
"stateColor.hpp"
#include
"alphabet.hpp"
#include
<stdlib.h>
#include
<string>
#include
<QListWidget>
ColorLabel
::
ColorLabel
(
QWidget
*
parent
)
:
QWidget
(
parent
),
ui
(
new
Ui
::
ColorLabel
)
{
ui
->
setupUi
(
this
);
connect
(
ui
->
generate_button
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
generateState
(
a
,
state_label
->
text
(),
red_slider
->
value
(),
green_slider
->
value
(),
blue_slider
->
value
())));
connect
(
ui
->
random_button
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
randomGenerator
(
a
,
state_label
->
text
())));
connect
(
ui
->
daltonian_button
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
daltonianMode
(
a
,
nbStates
)));
}
ColorLabel
::~
ColorLabel
()
{
delete
ui
;
}
void
ColorLabel
::
generateState
(
Alphabet
a
,
QString
name_state
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
){
std
::
string
string_name_state
=
name_state
.
toStdString
();
// On passe notre QString en string pour pouvoir utiliser le constructeur
state
*
newstate
=
new
state
(
stateColor
(
r
,
g
,
b
),
string_name_state
);
// Création de notre nouvel état
a
.
newEtat
(
*
newstate
);
// Ajout du nouvel état dans l'alphabet
ui
->
state_list
->
addItem
(
name_state
);
// Ajout du nouvel état dans la liste
}
void
ColorLabel
::
randomGenerator
(
Alphabet
a
,
QString
name_state
){
std
::
string
string_name_state
=
name_state
.
toStdString
();
unsigned
int
r
=
rand
()
%
255
;
// On génère aléatoirement nos couleurs
unsigned
int
g
=
rand
()
%
255
;
unsigned
int
b
=
rand
()
%
255
;
state
*
newstate
=
new
state
(
stateColor
(
r
,
g
,
b
),
string_name_state
);
// Création de notre nouvel état
a
.
newEtat
(
*
newstate
);
// Ajout du nouvel état dans l'alphabet
ui
->
state_list
->
addItem
(
name_state
);
// Ajout du nouvel état dans la liste
}
void
ColorLabel
::
daltonianMode
(
Alphabet
a
,
unsigned
int
nbStates
){
ui
->
state_list
->
clear
();
// On vide toujours la liste quand on active le mode Daltonien
// Création des états à partir du constructeur
state
*
black
=
new
state
(
stateColor
(
0
,
0
,
0
),
"Black"
);
state
*
white
=
new
state
(
stateColor
(
255
,
255
,
255
),
"White"
);
state
*
blue
=
new
state
(
stateColor
(
0
,
0
,
255
),
"Blue"
);
state
*
pink
=
new
state
(
stateColor
(
255
,
0
,
255
),
"Pink"
);
state
*
red
=
new
state
(
stateColor
(
255
,
0
,
0
),
"Red"
);
state
*
green
=
new
state
(
stateColor
(
0
,
255
,
0
),
"Green"
);
state
*
orange
=
new
state
(
stateColor
(
255
,
127
,
0
),
"Orange"
);
state
*
grey
=
new
state
(
stateColor
(
127
,
127
,
127
),
"Grey"
);
// Ajout des états dans la liste
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
black
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
white
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
blue
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
pink
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
red
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
green
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
orange
->
getStateLabel
()));
ui
->
state_list
->
addItem
(
QString
::
fromStdString
(
grey
->
getStateLabel
()));
// Ajout des états dans l'Alphabet
a
.
newEtat
(
*
black
);
a
.
newEtat
(
*
white
);
a
.
newEtat
(
*
blue
);
a
.
newEtat
(
*
pink
);
a
.
newEtat
(
*
red
);
a
.
newEtat
(
*
green
);
a
.
newEtat
(
*
orange
);
a
.
newEtat
(
*
grey
);
}
forms/colorlabel.h
0 → 100644
View file @
ec3c13e6
#ifndef COLORLABEL_H
#define COLORLABEL_H
#include
<QWidget>
#include
"state.hpp"
#include
"stateColor.hpp"
#include
"alphabet.hpp"
#include
<QListWidget>
namespace
Ui
{
class
ColorLabel
;
}
class
ColorLabel
:
public
QWidget
{
Q_OBJECT
public:
explicit
ColorLabel
(
QWidget
*
parent
=
nullptr
);
~
ColorLabel
();
public
slots
:
void
generateState
(
Alphabet
a
,
QString
list
,
unsigned
int
r
,
unsigned
int
g
,
unsigned
int
b
);
// Génère notre état en cliquant sur le bouton "Generate"
void
randomGenerator
(
Alphabet
a
,
QString
name_state
);
// Génère un état aléatoire
void
daltonianMode
(
Alphabet
a
,
unsigned
int
nbStates
);
// La fonction est pour le moment implémentée pour 8 états fixe, à améliorer avec un nbStates désiré
private:
Ui
::
ColorLabel
*
ui
;
};
#endif // COLORLABEL_H
forms/colorlabel.ui
0 → 100644
View file @
ec3c13e6
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
ColorLabel
</class>
<widget
class=
"QWidget"
name=
"ColorLabel"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
470
</width>
<height>
232
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<widget
class=
"QWidget"
name=
""
>
<property
name=
"geometry"
>
<rect>
<x>
10
</x>
<y>
10
</y>
<width>
444
</width>
<height>
194
</height>
</rect>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_7"
>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
State name :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"state_label"
>
<property
name=
"text"
>
<string>
Empty_name
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Color repartition :
</string>
</property>
</widget>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Red
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"red_slider"
>
<property
name=
"maximum"
>
<number>
255
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"red_value"
>
<property
name=
"text"
>
<string>
0
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_3"
>
<item>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"text"
>
<string>
Green
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"green_slider"
>
<property
name=
"maximum"
>
<number>
255
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"green_value"
>
<property
name=
"text"
>
<string>
0
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
>
<item>
<widget
class=
"QLabel"
name=
"label_5"
>
<property
name=
"text"
>
<string>
Blue
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"blue_slider"
>
<property
name=
"maximum"
>
<number>
255
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"blue_value"
>
<property
name=
"text"
>
<string>
0
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_5"
>
<item>
<widget
class=
"QPushButton"
name=
"generate_button"
>
<property
name=
"text"
>
<string>
Generate
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"random_button"
>
<property
name=
"text"
>
<string>
Random
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_6"
>
<item>
<widget
class=
"QPushButton"
name=
"daltonian_button"
>
<property
name=
"text"
>
<string>
Daltonian Mode
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"quit_button"
>
<property
name=
"text"
>
<string>
Quit
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget
class=
"QListWidget"
name=
"state_list"
>
<item>
<property
name=
"text"
>
<string>
Nouvel élément
</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>
red_slider
</sender>
<signal>
sliderMoved(int)
</signal>
<receiver>
red_value
</receiver>
<slot>
setNum(int)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
84
</x>
<y>
82
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
185
</x>
<y>
82
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
green_slider
</sender>
<signal>
sliderMoved(int)
</signal>
<receiver>
green_value
</receiver>
<slot>
setNum(int)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
155
</x>
<y>
104
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
187
</x>
<y>
107
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
blue_slider
</sender>
<signal>
sliderMoved(int)
</signal>
<receiver>
blue_value
</receiver>
<slot>
setNum(int)
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
169
</x>
<y>
134
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
182
</x>
<y>
132
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
quit_button
</sender>
<signal>
clicked()
</signal>
<receiver>
ColorLabel
</receiver>
<slot>
close()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
150
</x>
<y>
186
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
193
</x>
<y>
209
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
include/state.hpp
View file @
ec3c13e6
...
...
@@ -12,7 +12,6 @@ Représente les données graphiques associées à un état d'un alphabet.
#define STATE_H
#include
<string>
#include
"stateColor.hpp"
//! \brief Représente les données cosmétiques associées à un état.
...
...
src/src.pro
View file @
ec3c13e6
...
...
@@ -12,6 +12,7 @@ TEMPLATE = app
INCLUDEPATH
+=
..
/
include
..
/
include
/
transition_rules
..
/
include
/
neighborhood_rules
SOURCES
+=
\
..
/
forms
/
colorlabel
.
cpp
\
alphabet
.
cpp
\
mathexpr
.
cpp
\
neighborhood_rules
/
arbitraryneighborhoodrule
.
cpp
\
...
...
@@ -38,6 +39,7 @@ SOURCES += \
HEADERS
+=
\
..
/
forms
/
colorlabel
.
h
\
..
/
include
/
automaton
.
hpp
\
..
/
include
/
coord
.
hpp
\
..
/
include
/
savingdialog
.
hpp
\
...
...
@@ -69,6 +71,7 @@ HEADERS += \
..
/
include
/
neighborhoodWidget
.
hpp
FORMS
+=
\
..
/
forms
/
colorlabel
.
ui
\
..
/
forms
/
interface
.
ui
\
..
/
forms
/
savingdialog
.
ui
\
..
/
forms
/
structurelibraryview
.
ui
\
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment