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
03f5f426
Commit
03f5f426
authored
May 24, 2021
by
Yann Boucher
Browse files
Implemented dialog for loading a model, and behavior for customizing it
parent
0cb352ba
Changes
8
Hide whitespace changes
Inline
Side-by-side
forms/interface.ui
View file @
03f5f426
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
<rect>
<rect>
<x>
0
</x>
<x>
0
</x>
<y>
0
</y>
<y>
0
</y>
<width>
1
101
</width>
<width>
1
092
</width>
<height>
7
06
</height>
<height>
7
54
</height>
</rect>
</rect>
</property>
</property>
<property
name=
"windowTitle"
>
<property
name=
"windowTitle"
>
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
</widget>
</widget>
</item>
</item>
<item>
<item>
<widget
class=
"QGroupBox"
name=
"
groupBox
"
>
<widget
class=
"QGroupBox"
name=
"
simulation_tab
"
>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Fixed"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<horstretch>
0
</horstretch>
...
@@ -395,153 +395,196 @@ pattern recorded :</string>
...
@@ -395,153 +395,196 @@ pattern recorded :</string>
<property
name=
"title"
>
<property
name=
"title"
>
<string>
Rules
</string>
<string>
Rules
</string>
</property>
</property>
<layout
class=
"Q
VBox
Layout"
name=
"
vertical
Layout_
4
"
>
<layout
class=
"Q
Grid
Layout"
name=
"
grid
Layout_
3
"
>
<item>
<item
row=
"4"
column=
"0"
colspan=
"3"
>
<widget
class=
"Q
PushButton"
name=
"openRuleButton
"
>
<widget
class=
"Q
GroupBox"
name=
"rule_settings
"
>
<property
name=
"
text
"
>
<property
name=
"
enabled
"
>
<
string>
(file) Open rule
</string
>
<
bool>
false
</bool
>
</property>
</property>
</widget>
<property
name=
"title"
>
</item>
<string>
Settings
</string>
<item>
</property>
<layout
class=
"QGridLayout"
name=
"statesNeighborhoodLayout_3"
>
<layout
class=
"QFormLayout"
name=
"formLayout"
>
<item
row=
"1"
column=
"0"
>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"neighborhoodLabel"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<property
name=
"text"
>
<item>
<string>
Neighborhood :
</string>
<widget
class=
"QLabel"
name=
"transitionFunctionLabel"
>
</property>
<property
name=
"text"
>
<property
name=
"buddy"
>
<string>
Transition function :
</string>
<cstring>
neighborhood_list
</cstring>
</property>
</property>
</widget>
</widget>
</item>
</item>
</layout>
<item
row=
"1"
column=
"1"
>
</item>
<widget
class=
"QComboBox"
name=
"neighborhood_list"
>
<item
row=
"0"
column=
"0"
colspan=
"2"
>
<property
name=
"currentIndex"
>
<layout
class=
"QGridLayout"
name=
"statesNeighborhoodLayout_3"
>
<number>
-1
</number>
<item
row=
"1"
column=
"0"
>
</property>
<widget
class=
"QLabel"
name=
"neighborhoodLabel"
>
</widget>
<property
name=
"text"
>
</item>
<string>
Neighborhood :
</string>
<item
row=
"0"
column=
"2"
>
</property>
<widget
class=
"QPushButton"
name=
"statesSettingsButton"
>
<property
name=
"buddy"
>
<property
name=
"text"
>
<cstring>
neighborhood_list
</cstring>
<string>
States settings (color...)
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"1"
column=
"1"
>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QComboBox"
name=
"neighborhood_list"
>
<widget
class=
"QPushButton"
name=
"cusumNeighborhoodButton"
>
<property
name=
"currentIndex"
>
<property
name=
"enabled"
>
<number>
-1
</number>
<bool>
false
</bool>
</property>
</property>
</widget>
<property
name=
"text"
>
</item>
<string>
Custom neighborhood
</string>
<item
row=
"0"
column=
"2"
>
</property>
<widget
class=
"QPushButton"
name=
"statesSettingsButton"
>
</widget>
<property
name=
"text"
>
</item>
<string>
States settings (color...)
</string>
<item
row=
"0"
column=
"1"
>
</property>
<widget
class=
"QComboBox"
name=
"nbrStatesComboBox"
>
</widget>
<item>
</item>
<property
name=
"text"
>
<item
row=
"1"
column=
"2"
>
<string>
2
</string>
<widget
class=
"QPushButton"
name=
"cusumNeighborhoodButton"
>
</property>
<property
name=
"enabled"
>
</item>
<bool>
false
</bool>
<item>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
3
</string>
<string>
Custom neighborhood
</string>
</property>
</property>
</item>
</widget>
<item>
</item>
<property
name=
"text"
>
<item
row=
"0"
column=
"1"
>
<string>
4
</string>
<widget
class=
"QComboBox"
name=
"nbrStatesComboBox"
>
</property>
<item>
</item>
<property
name=
"text"
>
<item>
<string>
2
</string>
<property
name=
"text"
>
</property>
<string>
5
</string>
</item>
</property>
<item>
</item>
<property
name=
"text"
>
<item>
<string>
3
</string>
<property
name=
"text"
>
</property>
<string>
6
</string>
</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>
<property
name=
"buddy"
>
<cstring>
nbrStatesComboBox
</cstring>
</property>
</widget>
</item>
<item
row=
"2"
column=
"1"
>
<widget
class=
"QLabel"
name=
"radiusLabel"
>
<property
name=
"text"
>
<string>
Radius r :
</string>
</property>
<property
name=
"buddy"
>
<cstring>
radiusSpinBox
</cstring>
</property>
</widget>
</item>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QSpinBox"
name=
"radiusSpinBox"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
</widget>
</item>
</layout>
</item>
<item
row=
"2"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"transition_list"
/>
</item>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QGroupBox"
name=
"rule_settings_area"
>
<property
name=
"title"
>
<string>
Transition rule settings
</string>
</property>
</property>
</item>
</widget>
<item>
</item>
<item
row=
"4"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"informationLabel"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
7
</string>
<string>
New rule must be saved before running simulation
</string>
</property>
</property>
</item>
</widget>
<item>
</item>
<item
row=
"5"
column=
"0"
colspan=
"2"
>
<widget
class=
"QPushButton"
name=
"saveRuleButton"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
8
</string>
<string>
Save rule
</string>
</property>
</property>
</item>
</widget>
</widget>
</item>
</item>
</layout>
</widget>
</item>
<item
row=
"0"
column=
"0"
colspan=
"3"
>
<widget
class=
"QPushButton"
name=
"openRuleButton"
>
<property
name=
"text"
>
<string>
Load rule
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"2"
>
<widget
class=
"QPushButton"
name=
"customize_button"
>
<property
name=
"text"
>
<string>
Customize...
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
colspan=
"2"
>
<layout
class=
"QFormLayout"
name=
"formLayout_2"
>
<property
name=
"labelAlignment"
>
<set>
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
</set>
</property>
<property
name=
"formAlignment"
>
<set>
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
</set>
</property>
<item
row=
"0"
column=
"0"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"
nbrStatesL
abel"
>
<widget
class=
"QLabel"
name=
"
l
abel"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Number of states :
</string>
<string>
Name :
</string>
</property>
<property
name=
"buddy"
>
<cstring>
nbrStatesComboBox
</cstring>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"2"
column=
"1"
>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLabel"
name=
"radiusLabel"
>
<widget
class=
"QLabel"
name=
"rule_name"
>
<property
name=
"text"
>
<string>
Radius r :
</string>
</property>
<property
name=
"buddy"
>
<cstring>
radiusSpinBox
</cstring>
</property>
</widget>
</item>
<item
row=
"2"
column=
"2"
>
<widget
class=
"QSpinBox"
name=
"radiusSpinBox"
>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QLabel"
name=
"transitionFunctionLabel"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Transition function :
</string>
<string>
RuleName
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item>
<widget
class=
"QComboBox"
name=
"transition_list"
/>
</item>
</layout>
</layout>
</item>
</item>
<item>
<widget
class=
"QGroupBox"
name=
"rule_settings_area"
>
<property
name=
"title"
>
<string>
Transition rule settings
</string>
</property>
</widget>
</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>
</layout>
</widget>
</widget>
</item>
</item>
...
@@ -577,7 +620,7 @@ pattern recorded :</string>
...
@@ -577,7 +620,7 @@ pattern recorded :</string>
<rect>
<rect>
<x>
0
</x>
<x>
0
</x>
<y>
0
</y>
<y>
0
</y>
<width>
1
101
</width>
<width>
1
092
</width>
<height>
25
</height>
<height>
25
</height>
</rect>
</rect>
</property>
</property>
...
...
forms/modelloadingdialog.ui
0 → 100644
View file @
03f5f426
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
ModelLoadingDialog
</class>
<widget
class=
"QDialog"
name=
"ModelLoadingDialog"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
385
</width>
<height>
639
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Dialog
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QTreeWidget"
name=
"tree"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
5
</verstretch>
</sizepolicy>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string
notr=
"true"
>
1
</string>
</property>
</column>
</widget>
</item>
<item>
<widget
class=
"QFrame"
name=
"frame"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
3
</verstretch>
</sizepolicy>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Raised
</enum>
</property>
<layout
class=
"QFormLayout"
name=
"formLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Title :
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLabel"
name=
"title"
>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_struct_author"
>
<property
name=
"text"
>
<string>
Author :
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QLabel"
name=
"author"
>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Date :
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"1"
>
<widget
class=
"QLabel"
name=
"date"
>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Description :
</string>
</property>
<property
name=
"buddy"
>
<cstring>
desc
</cstring>
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QPlainTextEdit"
name=
"desc"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"readOnly"
>
<bool>
true
</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget
class=
"QDialogButtonBox"
name=
"buttonBox"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"standardButtons"
>
<set>
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>
buttonBox
</sender>
<signal>
accepted()
</signal>
<receiver>
ModelLoadingDialog
</receiver>
<slot>
accept()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
229
</x>
<y>
617
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
157
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
buttonBox
</sender>
<signal>
rejected()
</signal>
<receiver>
ModelLoadingDialog
</receiver>
<slot>
reject()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
297
</x>
<y>
623
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
286
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
include/interface.hpp
View file @
03f5f426
...
@@ -66,6 +66,8 @@ private slots:
...
@@ -66,6 +66,8 @@ private slots:
void
on_saveRuleButton_clicked
();
void
on_saveRuleButton_clicked
();
void
on_customize_button_clicked
();
private:
private:
//! \brief Initialiser la liste des transitions et voisinages disponibles
//! \brief Initialiser la liste des transitions et voisinages disponibles
void
init_transition_neighborhood_list
();
void
init_transition_neighborhood_list
();
...
@@ -73,6 +75,20 @@ private:
...
@@ -73,6 +75,20 @@ private:
//! \brief Mets à jour le widget contenant les paramètres pour la règle de transition choisie
//! \brief Mets à jour le widget contenant les paramètres pour la règle de transition choisie
void
update_transition_settings
();
void
update_transition_settings
();
//! \brief Configure pour activer la customisation d'une règle actuelle
void
enable_rule_customization
();
//! \brief Configure pour désactiver la customisation d'une règle actuelle
void
disable_rule_customization
();
//! \brief Charge un modèle d'automate à partir d'un objet JSON
void
load_model
(
const
QJsonObject
&
obj
);
//! \brief Déclenche la confirmation et la sauvegarde du modèle édité actuel
void
save_model
();
//! \brief Retourne le modèle par défaut à charger
QJsonObject
default_model
()
const
;
private:
private:
Ui
::
MainWindow
*
ui
;
Ui
::
MainWindow
*
ui
;
};
};
...
...
include/modelloadingdialog.hpp
0 → 100644
View file @
03f5f426
#ifndef MODELLOADINGDIALOG_HPP
#define MODELLOADINGDIALOG_HPP
#include
<QDialog>
#include
<QDir>
#include
<QTreeWidgetItem>
#include
<QFileSystemWatcher>
#include
<QJsonObject>
namespace
Ui
{
class
ModelLoadingDialog
;
}
class
ModelLoadingException
:
public
std
::
exception
{
std
::
string
_msg
;
public:
ModelLoadingException
(
const
std
::
string
&
msg
)
:
_msg
(
msg
){}
virtual
const
char
*
what
()
const
noexcept
override
{
return
_msg
.
c_str
();
}
};
class
ModelLoadingDialog
:
public
QDialog
{
Q_OBJECT
public:
explicit
ModelLoadingDialog
(
QWidget
*
parent
=
nullptr
);
~
ModelLoadingDialog
();
//! \brief Retoure le modèle choisi en tant qu'objet JSON.
QJsonObject
model
()
const
;
protected:
void
done
(
int
r
);
private:
void
load_models
();
QTreeWidgetItem
*
add_directory_contents
(
const
QDir
&
dir
);
private
slots
:
void
update_info
(
QTreeWidgetItem
*
item
,
int
column
);
private:
Ui
::
ModelLoadingDialog
*
ui
;
QFileSystemWatcher
m_watcher
;
QJsonObject
m_current_model
;
};
#endif // MODELLOADINGDIALOG_HPP