Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
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
8bc7db76
Commit
8bc7db76
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
calling get_data_point_info() instead of very complicated code to calculate for data point's info
parent
4ec0c2c2
No related branches found
No related tags found
1 merge request
!159
Correct clicking data point for info
Pipeline
#2879
failed with stage
Stage: Build Env and Test
in 3 minutes and 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+29
-46
29 additions, 46 deletions
...onviewer/view/plotting/plotting_widget/plotting_widget.py
with
29 additions
and
46 deletions
sohstationviewer/view/plotting/plotting_widget/plotting_widget.py
+
29
−
46
View file @
8bc7db76
...
...
@@ -5,6 +5,7 @@ from typing import List, Optional, Union
import
numpy
as
np
import
matplotlib.text
from
matplotlib
import
pyplot
as
pl
from
matplotlib.collections
import
PathCollection
from
matplotlib.transforms
import
Bbox
from
PySide6.QtCore
import
QTimer
,
Qt
from
PySide6
import
QtCore
,
QtWidgets
...
...
@@ -12,9 +13,9 @@ from PySide6.QtWidgets import QWidget, QApplication, QTextBrowser
from
sohstationviewer.conf
import
constants
from
sohstationviewer.view.util.color
import
set_color_mode
from
sohstationviewer.view.util.functions
import
(
get_total_miny_maxy
,
get_index_from_time
)
from
sohstationviewer.view.plotting.plotting_widget.plotting_widget_helper
\
import
get_data_point_info
,
get_total_miny_maxy
from
sohstationviewer.view.plotting.plotting_widget.plotting_axes
import
(
PlottingAxes
)
...
...
@@ -296,50 +297,32 @@ class PlottingWidget(QtWidgets.QScrollArea):
focus SOH tab, roll to the corresponding line.
"""
artist
=
event
.
artist
if
isinstance
(
artist
,
pl
.
Line2D
):
ax
=
artist
.
axes
chan_id
=
ax
.
chan
chan_data
=
self
.
plotting_data1
[
chan_id
]
# list of x values of the plot
x_list
=
artist
.
get_xdata
()
# list of y values of the plot
y_list
=
artist
.
get_ydata
()
# index of the clicked point on the plot
click_plot_index
=
event
.
ind
[
0
]
# time, val of the clicked point
clicked_time
=
x_list
[
click_plot_index
]
clicked_val
=
y_list
[
click_plot_index
]
list_idx
,
section_idx
=
get_index_from_time
(
chan_data
,
clicked_time
,
clicked_val
)
if
list_idx
is
None
:
display_tracking_info
(
self
.
tracking_box
,
"
Point not found.
"
)
return
ax
=
artist
.
axes
clicked_data
=
chan_data
[
'
data
'
][
list_idx
][
section_idx
]
if
hasattr
(
ax
,
'
unit_bw
'
):
clicked_data
=
ax
.
unit_bw
.
format
(
clicked_data
)
formatted_clicked_time
=
format_time
(
clicked_time
,
self
.
date_mode
,
'
HH:MM:SS
'
)
info_str
=
(
f
"
<pre>Channel:
{
chan_id
}
"
f
"
Point:
{
click_plot_index
+
1
}
"
f
"
Time:
{
formatted_clicked_time
}
"
f
"
Value:
{
clicked_data
}
</pre>
"
)
display_tracking_info
(
self
.
tracking_box
,
info_str
)
if
'
logIdx
'
in
chan_data
.
keys
():
# For Reftek, need to hightlight the corresponding
# SOH message line based on the log_idx of the clicked point
self
.
parent
.
search_message_dialog
.
show
()
clicked_log_idx
=
chan_data
[
'
logIdx
'
][
0
][
section_idx
]
try
:
self
.
parent
.
search_message_dialog
.
\
show_log_entry_from_data_index
(
clicked_log_idx
)
except
ValueError
as
e
:
QtWidgets
.
QMessageBox
.
warning
(
self
,
"
Not found
"
,
str
(
e
))
if
isinstance
(
artist
,
pl
.
Line2D
):
# normal channels
click_index
=
event
.
ind
[
0
]
chan_data
=
self
.
plotting_data1
[
ax
.
chan
]
elif
isinstance
(
artist
,
PathCollection
):
# mass position channels
click_index
=
event
.
ind
[
0
]
chan_data
=
self
.
plotting_data2
[
ax
.
chan
]
else
:
return
info_str
=
get_data_point_info
(
click_index
,
ax
,
chan_data
,
self
.
date_mode
)
display_tracking_info
(
self
.
tracking_box
,
info_str
)
if
'
logIdx
'
in
chan_data
.
keys
():
# For Reftek, need to hightlight the corresponding
# SOH message line based on the log_idx of the clicked point
self
.
parent
.
search_message_dialog
.
show
()
clicked_log_idx
=
chan_data
[
'
logIdx
'
][
0
][
click_index
]
try
:
self
.
parent
.
search_message_dialog
.
\
show_log_entry_from_data_index
(
clicked_log_idx
)
except
ValueError
as
e
:
QtWidgets
.
QMessageBox
.
warning
(
self
,
"
Not found
"
,
str
(
e
))
def
on_button_press_event
(
self
,
event
):
"""
...
...
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