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
91fde43b
Commit
91fde43b
authored
1 year ago
by
Lucas Philippe
Browse files
Options
Downloads
Patches
Plain Diff
Etape 7 fonctionnelle
parent
5d370387
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TP1/MainNormal.py
+13
-0
13 additions, 0 deletions
TP1/MainNormal.py
TP1/NormalCursor.py
+26
-0
26 additions, 0 deletions
TP1/NormalCursor.py
TP1/NormalWidget.py
+48
-0
48 additions, 0 deletions
TP1/NormalWidget.py
with
87 additions
and
0 deletions
TP1/MainNormal.py
0 → 100644
+
13
−
0
View file @
91fde43b
from
PyQt5.QtWidgets
import
QApplication
,
QMainWindow
from
NormalWidget
import
NormalWidget
def
main
():
app
=
QApplication
([])
window
=
QMainWindow
()
window
.
resize
(
1024
,
800
)
normalWidget
=
NormalWidget
()
window
.
setCentralWidget
(
normalWidget
)
window
.
show
()
app
.
exec_
()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
TP1/NormalCursor.py
0 → 100644
+
26
−
0
View file @
91fde43b
from
PyQt5.QtGui
import
QColor
class
NormalCursor
:
defaultCol
=
QColor
(
"
blue
"
)
def
__init__
(
self
,
targets
):
self
.
x
=
0
self
.
y
=
0
self
.
targets
=
targets
self
.
closest
=
None
def
move
(
self
,
x
,
y
):
self
.
x
=
x
self
.
y
=
y
previous_closest
=
self
.
closest
for
target
in
self
.
targets
:
distance
=
((
self
.
x
-
target
.
x
)
**
2
+
(
self
.
y
-
target
.
y
)
**
2
)
**
0.5
# cf. Theoreme de Pythagore
if
distance
<
target
.
size
/
2
:
self
.
closest
=
target
self
.
closest
.
highlighted
=
True
if
previous_closest
is
not
None
:
distance
=
((
self
.
x
-
previous_closest
.
x
)
**
2
+
(
self
.
y
-
previous_closest
.
y
)
**
2
)
**
0.5
# cf. Theoreme de Pythagore
if
distance
>
previous_closest
.
size
/
2
:
previous_closest
.
highlighted
=
False
\ No newline at end of file
This diff is collapsed.
Click to expand it.
TP1/NormalWidget.py
0 → 100644
+
48
−
0
View file @
91fde43b
import
csv
,
random
,
time
from
PyQt5.QtGui
import
QPainter
from
PyQt5.QtWidgets
import
QWidget
from
Target
import
Target
from
TP1.NormalCursor
import
NormalCursor
class
NormalWidget
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
self
.
targets
=
[]
self
.
loadTargets
()
self
.
cursor
=
NormalCursor
(
self
.
targets
)
self
.
setMouseTracking
(
True
)
self
.
start_time
=
None
self
.
selectRandomTarget
()
def
loadTargets
(
self
):
with
open
(
'
src_tp_bubble.csv
'
,
newline
=
''
)
as
csvfile
:
reader
=
csv
.
reader
(
csvfile
)
for
row
in
reader
:
if
len
(
row
)
>=
3
:
x
,
y
,
size
=
map
(
int
,
row
[:
3
])
self
.
targets
.
append
(
Target
(
x
,
y
,
size
))
def
paintEvent
(
self
,
event
):
painter
=
QPainter
(
self
)
for
target
in
self
.
targets
:
target
.
paint
(
painter
)
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.
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