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
5d370387
Commit
5d370387
authored
1 year ago
by
Lucas Philippe
Browse files
Options
Downloads
Patches
Plain Diff
Etape 6 fonctionnelle
parent
7a02cb48
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TP1/BubbleCursor.py
+1
-1
1 addition, 1 deletion
TP1/BubbleCursor.py
TP1/BubbleWidget.py
+19
-1
19 additions, 1 deletion
TP1/BubbleWidget.py
TP1/Target.py
+7
-0
7 additions, 0 deletions
TP1/Target.py
with
27 additions
and
2 deletions
TP1/BubbleCursor.py
+
1
−
1
View file @
5d370387
...
...
@@ -21,7 +21,7 @@ class BubbleCursor:
for
target
in
self
.
targets
:
distance
=
((
self
.
x
-
target
.
x
)
**
2
+
(
self
.
y
-
target
.
y
)
**
2
)
**
0.5
# cf. Theoreme de Pythagore
distance
=
distance
-
target
.
size
/
2
# Prendre la distance avec le contour du cercle et pas le centre
distance
=
distance
-
target
.
size
/
2
# Prendre la distance avec le contour du cercle et pas le centre
if
distance
<
min_distance
:
min_distance
=
distance
self
.
closest
=
target
...
...
This diff is collapsed.
Click to expand it.
TP1/BubbleWidget.py
+
19
−
1
View file @
5d370387
import
csv
import
csv
,
random
,
time
from
PyQt5.QtGui
import
QPainter
from
PyQt5.QtWidgets
import
QWidget
from
Target
import
Target
...
...
@@ -11,6 +11,8 @@ class BubbleWidget(QWidget):
self
.
loadTargets
()
self
.
cursor
=
BubbleCursor
(
self
.
targets
)
self
.
setMouseTracking
(
True
)
self
.
start_time
=
None
self
.
selectRandomTarget
()
def
loadTargets
(
self
):
with
open
(
'
src_tp_bubble.csv
'
,
newline
=
''
)
as
csvfile
:
...
...
@@ -29,3 +31,19 @@ class BubbleWidget(QWidget):
def
mouseMoveEvent
(
self
,
event
):
self
.
cursor
.
move
(
event
.
x
(),
event
.
y
())
self
.
update
()
def
selectRandomTarget
(
self
):
if
self
.
start_time
==
None
:
self
.
start_time
=
time
.
time
()
target
=
random
.
choice
(
self
.
targets
)
target
.
toSelect
=
True
self
.
update
()
def
printTime
(
self
):
print
((
time
.
time
()
-
self
.
start_time
)
*
1000
)
self
.
start_time
=
None
def
mousePressEvent
(
self
,
event
):
if
self
.
cursor
.
closest
.
click_cible
():
self
.
printTime
()
self
.
selectRandomTarget
()
This diff is collapsed.
Click to expand it.
TP1/Target.py
+
7
−
0
View file @
5d370387
...
...
@@ -24,3 +24,10 @@ class Target:
painter
.
setBrush
(
QBrush
(
color
))
painter
.
setPen
(
QPen
(
color
))
painter
.
drawEllipse
(
int
(
self
.
x
-
self
.
size
/
2
),
int
(
self
.
y
-
self
.
size
/
2
),
int
(
self
.
size
),
int
(
self
.
size
))
def
click_cible
(
self
):
if
self
.
toSelect
:
self
.
toSelect
=
False
return
True
return
False
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