Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Public
PASSOFT
SOHViewer
Commits
3671b74e
Commit
3671b74e
authored
10 months ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
implement zoom out task when shift_click on left side of a plot
parent
16751350
No related branches found
Branches containing commit
No related tags found
2 merge requests
!325
Show chagelog to user
,
!323
zoom out
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+32
-2
32 additions, 2 deletions
...onviewer/view/plotting/plotting_widget/plotting_widget.py
with
32 additions
and
2 deletions
sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+
32
−
2
View file @
3671b74e
"""
"""
Class of which object is used to plot data
Class of which object is used to plot data
"""
"""
from
typing
import
List
,
Optional
,
Union
from
typing
import
List
,
Optional
,
Union
,
Tuple
import
math
import
math
import
numpy
as
np
import
numpy
as
np
import
matplotlib.text
import
matplotlib.text
...
@@ -71,6 +71,12 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -71,6 +71,12 @@ class PlottingWidget(QtWidgets.QScrollArea):
self
.
min_x
=
0
self
.
min_x
=
0
self
.
max_x
=
0
self
.
max_x
=
0
"""
"""
zoom_minmax_list: list of x ranges of zooming. The first range is the
original of x ranges. If there is more than one ranges the plotting has
been zoomed in.
"""
self
.
zoom_minmax_list
:
List
[
Tuple
[
float
,
float
]]
=
[]
"""
plotting_bot: float - bottom of a current plot, decrease by plot_h
plotting_bot: float - bottom of a current plot, decrease by plot_h
return from self.get_height() whenever a new plot is added
return from self.get_height() whenever a new plot is added
"""
"""
...
@@ -349,6 +355,19 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -349,6 +355,19 @@ class PlottingWidget(QtWidgets.QScrollArea):
self
.
zoom_marker2
.
set_visible
(
False
)
self
.
zoom_marker2
.
set_visible
(
False
)
self
.
plotting_axes
.
canvas
.
draw
()
self
.
plotting_axes
.
canvas
.
draw
()
def
zoom_out
(
self
):
"""
Zoom out by setting limit to the previous range when there
'
s at least
one zoom-in.
"""
if
len
(
self
.
zoom_minmax_list
)
>
1
:
self
.
min_x
,
self
.
max_x
=
self
.
zoom_minmax_list
[
-
2
]
self
.
zoom_minmax_list
.
pop
(
-
1
)
self
.
set_lim
(
is_zoom_in
=
False
)
self
.
zoom_marker1
.
set_visible
(
False
)
self
.
zoom_marker2
.
set_visible
(
False
)
self
.
plotting_axes
.
canvas
.
draw
()
def
eventFilter
(
self
,
target
:
QObject
,
event
:
QEvent
)
->
bool
:
def
eventFilter
(
self
,
target
:
QObject
,
event
:
QEvent
)
->
bool
:
"""
"""
Reimplements: QObject.eventFilter()
Reimplements: QObject.eventFilter()
...
@@ -587,6 +606,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -587,6 +606,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
def
on_shift_click
(
self
,
xdata
):
def
on_shift_click
(
self
,
xdata
):
"""
"""
On shift + left click:
On shift + left click:
if click on the left of a plot, do zoom out to the previous range
if zoom_marker1 not shown yet:
if zoom_marker1 not shown yet:
+ hide ruler
+ hide ruler
+ connect zoom_marker2 to follow mouse
+ connect zoom_marker2 to follow mouse
...
@@ -597,6 +617,10 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -597,6 +617,10 @@ class PlottingWidget(QtWidgets.QScrollArea):
:param xdata: float - time value of a channel plot
:param xdata: float - time value of a channel plot
"""
"""
if
xdata
<
self
.
min_x
:
# click on left of plot
self
.
zoom_out
()
return
if
not
self
.
zoom_marker1_shown
:
if
not
self
.
zoom_marker1_shown
:
self
.
ruler
.
set_visible
(
False
)
self
.
ruler
.
set_visible
(
False
)
self
.
set_ruler_visibled
(
self
.
zoom_marker1
,
xdata
)
self
.
set_ruler_visibled
(
self
.
zoom_marker1
,
xdata
)
...
@@ -673,8 +697,10 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -673,8 +697,10 @@ class PlottingWidget(QtWidgets.QScrollArea):
or
min
(
gap
)
<=
self
.
min_x
<=
max
(
gap
)
or
min
(
gap
)
<=
self
.
min_x
<=
max
(
gap
)
or
min
(
gap
)
<=
self
.
max_x
<=
max
(
gap
))
or
min
(
gap
)
<=
self
.
max_x
<=
max
(
gap
))
def
set_lim
(
self
,
first_time
=
False
):
def
set_lim
(
self
,
first_time
=
False
,
is_zoom_in
=
True
):
"""
"""
+ Append to zoom_minmax_list if called from a zoom_in. First time
plotting is considered a zoom_in to create first x range in the list.
+ Re-decimate channel data to get more detail when zoom in
+ Re-decimate channel data to get more detail when zoom in
(get_zoom_data)
(get_zoom_data)
+ Update timestamp bar with new ticks info
+ Update timestamp bar with new ticks info
...
@@ -683,7 +709,11 @@ class PlottingWidget(QtWidgets.QScrollArea):
...
@@ -683,7 +709,11 @@ class PlottingWidget(QtWidgets.QScrollArea):
:param first_time: bool - flag shows that this set_lim is called the
:param first_time: bool - flag shows that this set_lim is called the
fist time for this data set or not.
fist time for this data set or not.
:param is_zoom_in: if set_lim comes from zoom_in task
"""
"""
if
is_zoom_in
:
self
.
zoom_minmax_list
.
append
((
self
.
min_x
,
self
.
max_x
))
self
.
plotting_axes
.
update_timestamp_bar
(
self
.
timestamp_bar_top
)
self
.
plotting_axes
.
update_timestamp_bar
(
self
.
timestamp_bar_top
)
self
.
plotting_axes
.
update_timestamp_bar
(
self
.
timestamp_bar_bottom
)
self
.
plotting_axes
.
update_timestamp_bar
(
self
.
timestamp_bar_bottom
)
if
self
.
gap_bar
is
not
None
:
if
self
.
gap_bar
is
not
None
:
...
...
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