Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PHILIPPE-iihm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lucas Philippe
PHILIPPE-iihm
Commits
7a02cb48
Commit
7a02cb48
authored
1 year ago
by
Lucas Philippe
Browse files
Options
Downloads
Patches
Plain Diff
Correction de la Q5 (fonctionnel)
parent
e1dd373c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
TP1/BubbleCursor.py
+15
-19
15 additions, 19 deletions
TP1/BubbleCursor.py
TP1/BubbleWidget.py
+0
-2
0 additions, 2 deletions
TP1/BubbleWidget.py
TP1/MainBubble.py
+0
-3
0 additions, 3 deletions
TP1/MainBubble.py
TP1/Target.py
+10
-6
10 additions, 6 deletions
TP1/Target.py
with
25 additions
and
30 deletions
TP1/BubbleCursor.py
+
15
−
19
View file @
7a02cb48
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtGui
import
QColor
class
BubbleCursor
:
class
BubbleCursor
:
defaultCol
=
QColor
(
"
green
"
)
defaultCol
=
QColor
(
"
blue
"
)
def
__init__
(
self
,
targets
):
def
__init__
(
self
,
targets
):
self
.
x
=
0
self
.
x
=
0
...
@@ -9,30 +9,26 @@ class BubbleCursor:
...
@@ -9,30 +9,26 @@ class BubbleCursor:
self
.
size
=
50
self
.
size
=
50
self
.
targets
=
targets
self
.
targets
=
targets
self
.
closest
=
None
self
.
closest
=
None
def
paint
(
self
,
painter
):
def
paint
(
self
,
painter
):
painter
.
setBrush
(
self
.
defaultCol
)
painter
.
setBrush
(
self
.
defaultCol
)
painter
.
drawEllipse
(
self
.
x
-
self
.
size
,
self
.
y
-
self
.
size
,
self
.
size
*
2
,
self
.
size
*
2
)
painter
.
drawEllipse
(
int
(
self
.
x
-
self
.
size
),
int
(
self
.
y
-
self
.
size
),
int
(
self
.
size
*
2
),
int
(
self
.
size
*
2
))
def
move
(
self
,
moveX
,
moveY
):
self
.
x
=
moveX
self
.
y
=
moveY
self
.
closest
=
None
minDistance
=
float
(
'
inf
'
)
for
target
in
self
.
targets
:
def
move
(
self
,
x
,
y
):
target
.
highlighted
=
False
self
.
x
=
x
self
.
y
=
y
min_distance
=
float
(
"
inf
"
)
# variable valeur infini pour démarrer la recherche de min
previous_closest
=
self
.
closest
for
target
in
self
.
targets
:
for
target
in
self
.
targets
:
distance
=
self
.
distanceToTarget
(
target
)
distance
=
((
self
.
x
-
target
.
x
)
**
2
+
(
self
.
y
-
target
.
y
)
**
2
)
**
0.5
# cf. Theoreme de Pythagore
if
distance
<
minDistance
:
distance
=
distance
-
target
.
size
/
2
# Prendre la distance avec le contour du cercle et pas le centre
minDistance
=
distance
if
distance
<
min_distance
:
min_distance
=
distance
self
.
closest
=
target
self
.
closest
=
target
self
.
size
=
min_distance
if
self
.
closest
is
not
None
:
if
previous_closest
!=
self
.
closest
:
if
previous_closest
:
previous_closest
.
highlighted
=
False
self
.
closest
.
highlighted
=
True
self
.
closest
.
highlighted
=
True
self
.
size
=
minDistance
-
self
.
closest
.
size
/
2
def
distanceToTarget
(
self
,
target
):
distanceCentre
=
((
self
.
x
-
target
.
x
)
**
2
+
(
self
.
y
-
target
.
y
)
**
2
)
**
0.5
return
abs
(
distanceCentre
-
target
.
size
/
2
)
This diff is collapsed.
Click to expand it.
TP1/BubbleWidget.py
+
0
−
2
View file @
7a02cb48
...
@@ -21,13 +21,11 @@ class BubbleWidget(QWidget):
...
@@ -21,13 +21,11 @@ class BubbleWidget(QWidget):
self
.
targets
.
append
(
Target
(
x
,
y
,
size
))
self
.
targets
.
append
(
Target
(
x
,
y
,
size
))
def
paintEvent
(
self
,
event
):
def
paintEvent
(
self
,
event
):
print
(
"
paintEvent appelé
"
)
painter
=
QPainter
(
self
)
painter
=
QPainter
(
self
)
for
target
in
self
.
targets
:
for
target
in
self
.
targets
:
target
.
paint
(
painter
)
target
.
paint
(
painter
)
self
.
cursor
.
paint
(
painter
)
self
.
cursor
.
paint
(
painter
)
def
mouseMoveEvent
(
self
,
event
):
def
mouseMoveEvent
(
self
,
event
):
print
(
"
mouseMoveEvent appelé
"
)
self
.
cursor
.
move
(
event
.
x
(),
event
.
y
())
self
.
cursor
.
move
(
event
.
x
(),
event
.
y
())
self
.
update
()
self
.
update
()
This diff is collapsed.
Click to expand it.
TP1/MainBubble.py
+
0
−
3
View file @
7a02cb48
...
@@ -7,11 +7,8 @@ def main():
...
@@ -7,11 +7,8 @@ def main():
app
=
QApplication
(
sys
.
argv
)
app
=
QApplication
(
sys
.
argv
)
main_window
=
QMainWindow
()
main_window
=
QMainWindow
()
main_window
.
resize
(
1024
,
800
)
main_window
.
resize
(
1024
,
800
)
bubble_widget
=
BubbleWidget
()
bubble_widget
=
BubbleWidget
()
main_window
.
setCentralWidget
(
bubble_widget
)
main_window
.
setCentralWidget
(
bubble_widget
)
main_window
.
show
()
main_window
.
show
()
sys
.
exit
(
app
.
exec_
())
sys
.
exit
(
app
.
exec_
())
...
...
This diff is collapsed.
Click to expand it.
TP1/Target.py
+
10
−
6
View file @
7a02cb48
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtGui
import
QColor
,
QBrush
,
QPen
class
Target
:
class
Target
:
defaultCol
=
QColor
(
"
green
"
)
defaultCol
=
QColor
(
"
green
"
)
...
@@ -13,10 +14,13 @@ class Target:
...
@@ -13,10 +14,13 @@ class Target:
self
.
highlighted
=
False
self
.
highlighted
=
False
def
paint
(
self
,
painter
):
def
paint
(
self
,
painter
):
color
=
self
.
defaultCol
if
self
.
toSelect
:
if
self
.
toSelect
:
painter
.
setBrush
(
self
.
toSelectCol
)
color
=
self
.
toSelectCol
elif
self
.
highlighted
:
elif
self
.
highlighted
:
painter
.
setBrush
(
self
.
highlightCol
)
color
=
self
.
highlightCol
else
:
painter
.
setBrush
(
self
.
defaultCol
)
painter
.
setBrush
(
QBrush
(
color
))
painter
.
drawEllipse
(
self
.
x
-
self
.
size
/
2
,
self
.
y
-
self
.
size
/
2
,
self
.
size
,
self
.
size
)
painter
.
setPen
(
QPen
(
color
))
\ No newline at end of file
painter
.
drawEllipse
(
int
(
self
.
x
-
self
.
size
/
2
),
int
(
self
.
y
-
self
.
size
/
2
),
int
(
self
.
size
),
int
(
self
.
size
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment