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
2d5affef
Commit
2d5affef
authored
1 year ago
by
Lan Dam
Browse files
Options
Downloads
Patches
Plain Diff
change rowid to row_id
parent
f214b0e0
No related branches found
No related tags found
1 merge request
!217
Implement dialogs to edit valueColors for 2 multiColorDots plot types
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py
+83
-83
83 additions, 83 deletions
..._helper/edit_value_color_dialog/multi_color_dot_dialog.py
with
83 additions
and
83 deletions
sohstationviewer/view/db_config/value_color_helper/edit_value_color_dialog/multi_color_dot_dialog.py
+
83
−
83
View file @
2d5affef
...
...
@@ -66,7 +66,7 @@ class MultiColorDotDialog(EditValueColorDialog):
# These flags are also used to prevent the case hitting Select Color or
# Save right after user done with editing. In case there is error when
# checking the value, the button click will be canceled too.
self
.
changed_rowid
=
None
self
.
changed_row
_
id
=
None
self
.
select_color_btn_clicked
=
False
self
.
save_colors_btn_clicked
=
False
...
...
@@ -76,8 +76,8 @@ class MultiColorDotDialog(EditValueColorDialog):
# Check box for including data point greater than all the rest
self
.
include_greater_than_chkbox
=
QtWidgets
.
QCheckBox
(
'
Include
'
)
# Keep track of value by rowid
self
.
rowid_value_dict
:
Dict
[
int
,
float
]
=
{}
# Keep track of value by row
_
id
self
.
row
_
id_value_dict
:
Dict
[
int
,
float
]
=
{}
super
(
MultiColorDotDialog
,
self
).
__init__
(
parent
,
value_color_str
)
self
.
setWindowTitle
(
"
Edit Multi Color Dot Plotting
"
)
...
...
@@ -86,7 +86,7 @@ class MultiColorDotDialog(EditValueColorDialog):
self
.
cancel_btn
.
setFocusPolicy
(
QtCore
.
Qt
.
NoFocus
)
self
.
save_colors_btn
.
setFocusPolicy
(
QtCore
.
Qt
.
NoFocus
)
self
.
set_value_rowid_dict
()
self
.
set_value_row
_
id_dict
()
def
setup_ui
(
self
)
->
None
:
...
...
@@ -117,7 +117,7 @@ class MultiColorDotDialog(EditValueColorDialog):
for
i
in
range
(
ROW_TOTAL
):
self
.
higher_bound_lnedits
[
i
].
textChanged
.
connect
(
lambda
arg
,
idx
=
i
:
setattr
(
self
,
'
changed_rowid
'
,
idx
))
lambda
arg
,
idx
=
i
:
setattr
(
self
,
'
changed_row
_
id
'
,
idx
))
self
.
higher_bound_lnedits
[
i
].
editingFinished
.
connect
(
lambda
idx
=
i
:
self
.
on_higher_bound_editing_finished
(
idx
))
# some how pass False to on_select_color, have to handle this
...
...
@@ -127,33 +127,33 @@ class MultiColorDotDialog(EditValueColorDialog):
super
().
connect_signals
()
def
get_comparing_text
(
self
,
rowid
):
def
get_comparing_text
(
self
,
row
_
id
):
pass
def
add_row
(
self
,
rowid
):
def
add_row
(
self
,
row
_
id
):
"""
Adding a row including Lower bound line dit, comparing operator label,
higher bound line edit, select color button, display color label
:param rowid: id of current row
:param row
_
id: id of current row
"""
lower_bound_lnedit
=
QtWidgets
.
QLineEdit
()
lower_bound_lnedit
.
setEnabled
(
False
)
comparing_text
=
self
.
get_comparing_text
(
rowid
)
comparing_text
=
self
.
get_comparing_text
(
row
_
id
)
comparing_label
=
QtWidgets
.
QLabel
(
comparing_text
)
higher_bound_lnedit
=
QtWidgets
.
QLineEdit
()
validator
=
BoundValidator
()
higher_bound_lnedit
.
setValidator
(
validator
)
if
rowid
==
0
:
if
row
_
id
==
0
:
lower_bound_lnedit
.
setHidden
(
True
)
elif
rowid
==
ROW_TOTAL
-
1
:
elif
row
_
id
==
ROW_TOTAL
-
1
:
higher_bound_lnedit
.
setHidden
(
True
)
select_color_btn
=
QtWidgets
.
QPushButton
(
"
Select Color
"
)
select_color_btn
.
clicked
.
connect
(
lambda
:
self
.
on_select_color
(
rowid
))
lambda
:
self
.
on_select_color
(
row
_
id
))
# set focus policy to not be clicked by hitting enter in higher bound
select_color_btn
.
setFocusPolicy
(
QtCore
.
Qt
.
NoFocus
)
...
...
@@ -162,16 +162,16 @@ class MultiColorDotDialog(EditValueColorDialog):
color_label
.
setAutoFillBackground
(
True
)
# layout
self
.
main_layout
.
addWidget
(
lower_bound_lnedit
,
rowid
,
1
,
1
,
1
)
self
.
main_layout
.
addWidget
(
comparing_label
,
rowid
,
2
,
1
,
1
)
self
.
main_layout
.
addWidget
(
higher_bound_lnedit
,
rowid
,
3
,
1
,
1
)
self
.
main_layout
.
addWidget
(
select_color_btn
,
rowid
,
4
,
1
,
1
)
self
.
main_layout
.
addWidget
(
color_label
,
rowid
,
5
,
1
,
1
)
self
.
main_layout
.
addWidget
(
lower_bound_lnedit
,
row
_
id
,
1
,
1
,
1
)
self
.
main_layout
.
addWidget
(
comparing_label
,
row
_
id
,
2
,
1
,
1
)
self
.
main_layout
.
addWidget
(
higher_bound_lnedit
,
row
_
id
,
3
,
1
,
1
)
self
.
main_layout
.
addWidget
(
select_color_btn
,
row
_
id
,
4
,
1
,
1
)
self
.
main_layout
.
addWidget
(
color_label
,
row
_
id
,
5
,
1
,
1
)
return
(
lower_bound_lnedit
,
higher_bound_lnedit
,
select_color_btn
,
color_label
)
def
handle_clear_higher_bound
(
self
,
rowid
):
def
handle_clear_higher_bound
(
self
,
row
_
id
):
"""
If user clear higher_bound
+ in the middle, not allow.
...
...
@@ -180,52 +180,52 @@ class MultiColorDotDialog(EditValueColorDialog):
cleared, and the very end row
'
s value will be set to the higher_bound
of the previous row.
"""
if
rowid
<
len
(
self
.
rowid_value_dict
)
-
1
:
if
row
_
id
<
len
(
self
.
row
_
id_value_dict
)
-
1
:
# If the cleared one isn't the last one, it shouldn't be
# allowed. An Error message should be given.
msg
=
"
Higher bound must be a number
"
QtWidgets
.
QMessageBox
.
information
(
self
,
"
Error
"
,
msg
)
self
.
higher_bound_lnedits
[
rowid
].
setText
(
str
(
self
.
rowid_value_dict
[
rowid
]))
self
.
higher_bound_lnedits
[
row
_
id
].
setText
(
str
(
self
.
row
_
id_value_dict
[
row
_
id
]))
else
:
# If the cleared one is the last one, the lower_bound_lnedit
# of the next row will be cleared too.
if
rowid
==
0
:
if
row
_
id
==
0
:
# If the cleared one is the only one, this shouldn't be
# allowed. A warning should be given.
msg
=
(
"
There should be at least one value
"
"
for this plot type.
"
)
QtWidgets
.
QMessageBox
.
information
(
self
,
"
Error
"
,
msg
)
return
self
.
set_color_enabled
(
rowid
,
False
)
self
.
lower_bound_lnedits
[
rowid
+
1
].
setText
(
''
)
self
.
set_value_rowid_dict
()
self
.
set_color_enabled
(
row
_
id
,
False
)
self
.
lower_bound_lnedits
[
row
_
id
+
1
].
setText
(
''
)
self
.
set_value_row
_
id_dict
()
def
handle_skipping_editing_row
(
self
,
rowid
):
def
handle_skipping_editing_row
(
self
,
row
_
id
):
"""
If user add value in a row that skipping from the last edited row,
it shouldn
'
t be allowed, an Error message should be given before the
higher_bound is cleared, the actions will ignite the call to this
function one more time which should be ignored.
"""
if
self
.
higher_bound_lnedits
[
rowid
].
text
()
==
''
:
if
self
.
higher_bound_lnedits
[
row
_
id
].
text
()
==
''
:
# called by clearing text in this section
return
self
.
changed_rowid
=
None
self
.
changed_row
_
id
=
None
# When user edit the row that skips some row from the last row
# the current higher_bound_lnedit will be cleared
msg
=
(
"
You have to edit rows in order.
\n
"
"
Skipping rows isn
'
t allowed.
"
)
QtWidgets
.
QMessageBox
.
information
(
self
,
"
Error
"
,
msg
)
self
.
higher_bound_lnedits
[
rowid
].
setText
(
''
)
self
.
higher_bound_lnedits
[
row
_
id
].
setText
(
''
)
def
handle_edited_value_not_ascending
(
self
,
rowid
,
prev_higher_bound
,
next_higher_bound
):
self
,
row
_
id
,
prev_higher_bound
,
next_higher_bound
):
"""
If value enter to the current higher_bound_lnedit make it out of
increasing sorting, a warning will be given, and the widget will be
set to the original value.
:param rowid: id of current row
:param row
_
id: id of current row
:param prev_higher_bound: higher_bound value of the previous row
:param next_higher_bound: higher_bound value of the next row
"""
...
...
@@ -237,16 +237,16 @@ class MultiColorDotDialog(EditValueColorDialog):
msg
=
f
"
Value entered must be:
{
cond
}
"
QtWidgets
.
QMessageBox
.
information
(
self
,
"
Error
"
,
msg
)
try
:
self
.
higher_bound_lnedits
[
rowid
].
setText
(
str
(
self
.
rowid_value_dict
[
rowid
]))
self
.
higher_bound_lnedits
[
row
_
id
].
setText
(
str
(
self
.
row
_
id_value_dict
[
row
_
id
]))
except
KeyError
:
# If the current row is the last one, there's no original value
# So the widget will be cleared.
self
.
higher_bound_lnedits
[
rowid
].
setText
(
''
)
self
.
higher_bound_lnedits
[
row
_
id
].
setText
(
''
)
self
.
select_color_btn_clicked
=
False
self
.
save_colors_btn_clicked
=
False
def
on_higher_bound_editing_finished
(
self
,
rowid
:
int
):
def
on_higher_bound_editing_finished
(
self
,
row
_
id
:
int
):
"""
Check value entered for higher bound:
+ If the last row is empty string, that value will be eliminated
...
...
@@ -254,104 +254,104 @@ class MultiColorDotDialog(EditValueColorDialog):
+ If value not greater than previous row and less than latter row,
give error message. -20 and 20 are given to previous or latter
row if not exist b/c they are out of range of bound [-10, 10]
Call set_value_rowid_dict to keep track of value by rowid.
Call set_value_row
_
id_dict to keep track of value by row
_
id.
:param rowid: id of the row being checked.
rowid == self.changed_rowid
when the method is ignited by user editing the row
'
s value (not
by clicking on some buttons)
:param row
_
id: id of the row being checked.
row_id == self.changed_row_id when the method is ignited by
editing the row
'
s value (not
by clicking on some buttons)
"""
if
self
.
changed_rowid
is
None
:
if
self
.
changed_row
_
id
is
None
:
# When the function isn't called from user's changing text on
# a higher_bound_lnedit, this function will be ignored.
return
if
len
(
self
.
rowid_value_dict
)
<
self
.
changed_rowid
<
ROW_TOTAL
-
1
:
self
.
handle_skipping_editing_row
(
rowid
)
if
len
(
self
.
row
_
id_value_dict
)
<
self
.
changed_row
_
id
<
ROW_TOTAL
-
1
:
self
.
handle_skipping_editing_row
(
row
_
id
)
return
self
.
changed_rowid
=
None
self
.
changed_row
_
id
=
None
prev_higher_bound
=
(
float
(
self
.
higher_bound_lnedits
[
rowid
-
1
].
text
())
if
rowid
>
0
else
-
20
)
float
(
self
.
higher_bound_lnedits
[
row
_
id
-
1
].
text
())
if
row
_
id
>
0
else
-
20
)
if
self
.
higher_bound_lnedits
[
rowid
].
text
().
strip
()
==
''
:
self
.
handle_clear_higher_bound
(
rowid
)
if
self
.
higher_bound_lnedits
[
row
_
id
].
text
().
strip
()
==
''
:
self
.
handle_clear_higher_bound
(
row
_
id
)
self
.
select_color_btn_clicked
=
False
self
.
save_colors_btn_clicked
=
False
return
if
rowid
>=
len
(
self
.
rowid_value_dict
)
-
1
:
if
row
_
id
>=
len
(
self
.
row
_
id_value_dict
)
-
1
:
# When the current higher_bound_lnedits is on the last row
# set the limit 20 to be the next_higher_bound
next_higher_bound
=
20
else
:
next_higher_bound
=
float
(
self
.
higher_bound_lnedits
[
rowid
+
1
].
text
())
self
.
higher_bound_lnedits
[
row
_
id
+
1
].
text
())
curr_higher_bound
=
float
(
self
.
higher_bound_lnedits
[
rowid
].
text
())
curr_higher_bound
=
float
(
self
.
higher_bound_lnedits
[
row
_
id
].
text
())
if
(
curr_higher_bound
<=
prev_higher_bound
or
curr_higher_bound
>=
next_higher_bound
):
self
.
handle_edited_value_not_ascending
(
rowid
,
self
.
handle_edited_value_not_ascending
(
row
_
id
,
prev_higher_bound
,
next_higher_bound
)
return
if
((
rowid
==
0
and
self
.
include_less_than_chkbox
.
isChecked
())
or
rowid
!=
0
):
if
((
row
_
id
==
0
and
self
.
include_less_than_chkbox
.
isChecked
())
or
row
_
id
!=
0
):
# Enable button Select Color unless the row is the first row but
# Include checkbox isn't checked
self
.
set_color_enabled
(
rowid
,
True
)
self
.
lower_bound_lnedits
[
rowid
+
1
].
setText
(
str
(
curr_higher_bound
))
self
.
set_value_rowid_dict
()
self
.
set_color_enabled
(
row
_
id
,
True
)
self
.
lower_bound_lnedits
[
row
_
id
+
1
].
setText
(
str
(
curr_higher_bound
))
self
.
set_value_row
_
id_dict
()
if
self
.
save_colors_btn_clicked
:
self
.
on_save_color
()
if
self
.
select_color_btn_clicked
:
self
.
on_select_color
(
rowid
)
self
.
on_select_color
(
row
_
id
)
def
set_value_rowid_dict
(
self
):
def
set_value_row
_
id_dict
(
self
):
"""
Update rowid_value_dict to the current higher bound
Update row
_
id_value_dict to the current higher bound
Update lower bound of the last row which is for greater than all the
rest to be the max of all higher bound
"""
self
.
rowid_value_dict
=
{
i
:
float
(
self
.
higher_bound_lnedits
[
i
].
text
())
for
i
in
range
(
ROW_TOTAL
-
1
)
if
self
.
higher_bound_lnedits
[
i
].
text
()
!=
''
}
self
.
row
_
id_value_dict
=
{
i
:
float
(
self
.
higher_bound_lnedits
[
i
].
text
())
for
i
in
range
(
ROW_TOTAL
-
1
)
if
self
.
higher_bound_lnedits
[
i
].
text
()
!=
''
}
last_row_lnedit
=
self
.
lower_bound_lnedits
[
ROW_TOTAL
-
1
]
if
len
(
self
.
rowid_value_dict
)
==
0
:
if
len
(
self
.
row
_
id_value_dict
)
==
0
:
last_row_lnedit
.
clear
()
else
:
last_row_lnedit
.
setText
(
str
(
max
(
self
.
rowid_value_dict
.
values
())))
last_row_lnedit
.
setText
(
str
(
max
(
self
.
row
_
id_value_dict
.
values
())))
def
set_color_enabled
(
self
,
rowid
:
int
,
enabled
:
bool
):
def
set_color_enabled
(
self
,
row
_
id
:
int
,
enabled
:
bool
):
"""
Enable color: allow to edit and display color
Disable color: disallow to edit and hide color
"""
self
.
select_color_btns
[
rowid
].
setEnabled
(
enabled
)
self
.
color_labels
[
rowid
].
setHidden
(
not
enabled
)
self
.
select_color_btns
[
row
_
id
].
setEnabled
(
enabled
)
self
.
color_labels
[
row
_
id
].
setHidden
(
not
enabled
)
def
on_select_color
(
self
,
rowid
:
int
):
def
on_select_color
(
self
,
row
_
id
:
int
):
"""
When clicking on Select Color button, Color Picker will pop up with
the default color is color_label
'
s color.
User will select a color then save to update the selected color to
the color_label.
"""
if
self
.
changed_rowid
is
not
None
:
if
self
.
changed_row
_
id
is
not
None
:
self
.
select_color_btn_clicked
=
True
self
.
on_higher_bound_editing_finished
(
self
.
changed_rowid
)
self
.
on_higher_bound_editing_finished
(
self
.
changed_row
_
id
)
return
self
.
select_color_btn_clicked
=
False
super
().
on_select_color
(
self
.
color_labels
[
rowid
])
super
().
on_select_color
(
self
.
color_labels
[
row
_
id
])
def
on_include
(
self
,
rowid
:
int
,
chkbox
:
QtWidgets
.
QCheckBox
):
def
on_include
(
self
,
row
_
id
:
int
,
chkbox
:
QtWidgets
.
QCheckBox
):
"""
Enable/Disable Select Color button when include_less_than_chkbox/
include_greater_than_chkbox is checked/unchecked.
"""
self
.
set_color_enabled
(
rowid
,
chkbox
.
isChecked
())
self
.
set_color_enabled
(
row
_
id
,
chkbox
.
isChecked
())
def
set_row
(
self
,
vc_idx
:
int
,
value
:
float
,
color
:
str
):
"""
...
...
@@ -392,9 +392,9 @@ class MultiColorDotDialog(EditValueColorDialog):
+ If include_greater_than_chkbox is checked, format will be:
value<:color
"""
if
self
.
changed_rowid
and
self
.
changed_rowid
<
ROW_TOTAL
-
1
:
if
self
.
changed_row
_
id
and
self
.
changed_row
_
id
<
ROW_TOTAL
-
1
:
self
.
save_colors_btn_clicked
=
True
self
.
on_higher_bound_editing_finished
(
self
.
changed_rowid
)
self
.
on_higher_bound_editing_finished
(
self
.
changed_row
_
id
)
return
self
.
save_colors_btn_clicked
=
False
value_color_list
=
[]
...
...
@@ -427,15 +427,15 @@ class MultiColorDotLowerEqualDialog(MultiColorDotDialog):
super
(
MultiColorDotLowerEqualDialog
,
self
).
__init__
(
parent
,
value_color_str
,
upper_equal
=
False
)
def
get_comparing_text
(
self
,
rowid
:
int
):
def
get_comparing_text
(
self
,
row
_
id
:
int
):
"""
Create text that show relationship between lower_bound and higher_bound
to data for the selected color.
:param rowid: id of current row
:param row
_
id: id of current row
"""
if
rowid
==
0
:
if
row
_
id
==
0
:
comparing_text
=
"
d <
"
elif
rowid
<
ROW_TOTAL
-
1
:
elif
row
_
id
<
ROW_TOTAL
-
1
:
comparing_text
=
"
<= d <
"
else
:
comparing_text
=
"
= d
"
...
...
@@ -471,15 +471,15 @@ class MultiColorDotUpperEqualDialog(MultiColorDotDialog):
super
(
MultiColorDotUpperEqualDialog
,
self
).
__init__
(
parent
,
value_color_str
,
upper_equal
=
True
)
def
get_comparing_text
(
self
,
rowid
):
def
get_comparing_text
(
self
,
row
_
id
):
"""
Create text that show relationship between lower_bound and higher_bound
to data for the selected color.
:param rowid: id of current row
:param row
_
id: id of current row
"""
if
rowid
==
0
:
if
row
_
id
==
0
:
comparing_text
=
"
d <=
"
elif
rowid
<
ROW_TOTAL
-
1
:
elif
row
_
id
<
ROW_TOTAL
-
1
:
comparing_text
=
"
< d <=
"
else
:
comparing_text
=
"
< d
"
...
...
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