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
ce449e49
Commit
ce449e49
authored
Jun 02, 2021
by
Eugene Pin
Browse files
Avancement du widget neighborhood (c'est pas si simple)
parent
adf359a6
Pipeline
#78947
passed with stages
in 17 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/neighborhoodWidget.hpp
View file @
ce449e49
...
...
@@ -3,6 +3,7 @@
#include
<QDialog>
#include
"neighborhood.hpp"
#include
"gridview.hpp"
namespace
Ui
{
class
NeighborhoodWidget
;
...
...
@@ -13,6 +14,7 @@ class NeighborhoodWidget : public QWidget
{
Q_OBJECT
Coord
currentPoint
;
public:
explicit
NeighborhoodWidget
(
QWidget
*
parent
=
nullptr
);
~
NeighborhoodWidget
();
...
...
@@ -20,7 +22,12 @@ public:
//! \brief Retourne le voisinage
Neighborhood
*
getVoisinage
()
const
;
QPushButton
*
getValidateButton
();
QPushButton
*
getValidateButton
()
const
;
GridView
&
getGridView
()
const
;
public
slots
:
Neighborhood
&
getNeighborhood
()
const
;
private
slots
:
...
...
src/neighborhoodWidget.cpp
View file @
ce449e49
...
...
@@ -25,9 +25,9 @@ NeighborhoodWidget::NeighborhoodWidget(QWidget *parent) :
QSize
size
=
gv
.
grid_size
();
Coord
mileu
=
{
size
.
width
()
/
2
,
size
.
height
()
/
2
};
currentPoint
=
{
size
.
width
()
/
2
,
size
.
height
()
/
2
};
Grid
newGrid
(
gv
.
get_grid
());
newGrid
.
set_cell
(
mileu
,
2
);
newGrid
.
set_cell
(
currentPoint
,
2
);
gv
.
copy_grid
(
newGrid
);
gv
.
enable_toggle_mode
(
1
,
0
);
// TODO le clic sur la cellule centrale
...
...
@@ -43,6 +43,30 @@ Neighborhood* NeighborhoodWidget::getVoisinage() const
return
nullptr
;
}
QPushButton
*
NeighborhoodWidget
::
getValidateButton
()
{
QPushButton
*
NeighborhoodWidget
::
getValidateButton
()
const
{
return
ui
->
validationButton
;
}
GridView
&
NeighborhoodWidget
::
getGridView
()
const
{
return
*
(
ui
->
grid_view
);
}
Neighborhood
&
NeighborhoodWidget
::
getNeighborhood
()
const
{
Neighborhood
*
newNeighborhood
=
new
Neighborhood
;
Grid
currentGrid
=
ui
->
grid_view
->
get_grid
();
QSize
currentSizeGrid
=
ui
->
grid_view
->
grid_size
();
int
height
=
currentSizeGrid
.
height
();
int
width
=
currentSizeGrid
.
width
();
for
(
int
j
=
0
;
j
<
height
;
j
++
)
{
for
(
int
i
=
0
;
i
<
width
;
i
++
)
{
if
(
currentGrid
.
get_state
({
i
,
j
})
==
1
)
{
Coord
newCoord
=
{
i
-
currentPoint
.
x
,
j
-
currentPoint
.
y
};
newNeighborhood
->
addNeighbor
(
newCoord
,
1
);
std
::
cout
<<
"Nouveau voisin : X="
<<
newCoord
.
x
<<
" Y="
<<
newCoord
.
y
<<
endl
;
fflush
(
stdout
);
}
}
}
return
*
newNeighborhood
;
}
src/uibuildervisitor.cpp
View file @
ce449e49
...
...
@@ -188,10 +188,15 @@ void UIBuilderVisitor::visit(PropertyList &list)
NeighborhoodWidget
*
nw
=
new
NeighborhoodWidget
;
nw
->
show
();
QPushButton
*
validateButton
=
nw
->
getValidateButton
();
QObject
::
connect
(
validateButton
,
&
QPushButton
::
pressed
,
[
&
list
]
()
{
QObject
::
connect
(
validateButton
,
&
QPushButton
::
pressed
,
[
&
list
,
&
nw
]
()
{
list
.
clear
();
Neighborhood
newNeighborhood
=
nw
->
getNeighborhood
();
// TODO a finir
list
.
push_back
();
});
QObject
::
connect
(
validateButton
,
&
QPushButton
::
pressed
,
nw
,
&
QWidget
::
close
);
});
}
}
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