Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyicon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
Fraser William Goldsworth
pyicon
Commits
d93401f3
Commit
d93401f3
authored
2 months ago
by
Nils Brüggemann
Committed by
Fraser William Goldsworth
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
pyic_view: Adds ability to zoom in map.
parent
06c72f5d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/pyic_view.py
+67
-0
67 additions, 0 deletions
scripts/pyic_view.py
with
67 additions
and
0 deletions
scripts/pyic_view.py
+
67
−
0
View file @
d93401f3
...
...
@@ -164,6 +164,25 @@ class view(object):
res_menu
.
grid
(
row
=
3
,
column
=
0
)
res_menu
.
bind
(
"
<<ComboboxSelected>>
"
,
self
.
make_new_axis
)
# Button to activate zoom mode
self
.
zoom_button
=
ttk
.
Button
(
root
,
text
=
"
Enable Zoom
"
,
command
=
self
.
activate_zoom
)
self
.
zoom_button
.
grid
(
row
=
3
,
column
=
2
)
# Variables to store zoom area
self
.
press_event
=
None
self
.
rect
=
None
# Variables to store zoom area
self
.
press_event
=
None
self
.
rect
=
None
# proj entry
print
(
'
Setup proj dropdown
'
)
res_menu
=
ttk
.
Combobox
(
root
,
textvariable
=
self
.
selected_proj
,
values
=
self
.
proj_all
,
state
=
"
readonly
"
)
res_menu
.
grid
(
row
=
3
,
column
=
3
)
res_menu
.
bind
(
"
<<ComboboxSelected>>
"
,
self
.
make_new_axis
)
# initial plot
self
.
plot_data
()
self
.
canvas
.
draw
()
...
...
@@ -173,6 +192,54 @@ class view(object):
root
.
mainloop
()
return
# for zoom
def
activate_zoom
(
self
):
"""
Activates zooming mode by connecting event handlers.
"""
self
.
cid_press
=
self
.
canvas
.
mpl_connect
(
"
button_press_event
"
,
self
.
on_press
)
self
.
cid_release
=
self
.
canvas
.
mpl_connect
(
"
button_release_event
"
,
self
.
on_release
)
self
.
cid_motion
=
self
.
canvas
.
mpl_connect
(
"
motion_notify_event
"
,
self
.
on_motion
)
# for zoom
def
on_press
(
self
,
event
):
"""
Stores the initial click position.
"""
if
event
.
xdata
is
not
None
and
event
.
ydata
is
not
None
:
self
.
press_event
=
(
event
.
xdata
,
event
.
ydata
)
self
.
rect
=
self
.
ax
.
add_patch
(
plt
.
Rectangle
(
self
.
press_event
,
0
,
0
,
fill
=
False
,
color
=
"
red
"
,
linestyle
=
"
dashed
"
))
self
.
canvas
.
draw
()
# for zoom
def
on_motion
(
self
,
event
):
"""
Updates the rectangle while dragging.
"""
if
self
.
press_event
and
event
.
xdata
is
not
None
and
event
.
ydata
is
not
None
:
x0
,
y0
=
self
.
press_event
width
=
event
.
xdata
-
x0
height
=
event
.
ydata
-
y0
self
.
rect
.
set_width
(
width
)
self
.
rect
.
set_height
(
height
)
self
.
canvas
.
draw
()
# for zoom
def
on_release
(
self
,
event
):
"""
Zooms into the selected rectangle and removes it.
"""
if
self
.
press_event
and
event
.
xdata
is
not
None
and
event
.
ydata
is
not
None
:
x0
,
y0
=
self
.
press_event
x1
,
y1
=
event
.
xdata
,
event
.
ydata
# Ensure correct ordering of coordinates
self
.
ax
.
set_xlim
(
min
(
x0
,
x1
),
max
(
x0
,
x1
))
self
.
ax
.
set_ylim
(
min
(
y0
,
y1
),
max
(
y0
,
y1
))
# Remove the rectangle and redraw
self
.
rect
.
remove
()
self
.
rect
=
None
self
.
press_event
=
None
self
.
canvas
.
draw
()
# Disable event handlers after zooming
self
.
canvas
.
mpl_disconnect
(
self
.
cid_press
)
self
.
canvas
.
mpl_disconnect
(
self
.
cid_release
)
self
.
canvas
.
mpl_disconnect
(
self
.
cid_motion
)
def
load_data
(
self
):
print
(
'
opening dataset
'
)
mfdset_kwargs
=
dict
(
...
...
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