Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software_public/passoft/sohstationviewer
1 result
Show changes
Commits on Source (6)
......@@ -33,6 +33,15 @@ class LineDotDialog(EditValueColorDialog):
self.dot_color_label.setFixedWidth(30)
self.dot_color_label.setAutoFillBackground(True)
# check box to include zero in value_color_str or not
self.zero_include_chkbox = QtWidgets.QCheckBox('Included')
# Widget that allow user to add/edit zero's color
self.select_zero_color_btn = QtWidgets.QPushButton("Select Color")
# Widget to display dot's color
self.zero_color_label = QtWidgets.QLabel()
self.zero_color_label.setFixedWidth(30)
self.zero_color_label.setAutoFillBackground(True)
super(LineDotDialog, self).__init__(parent, value_color_str)
self.setWindowTitle("Edit Line/Dot Plotting's Colors")
......@@ -48,7 +57,12 @@ class LineDotDialog(EditValueColorDialog):
self.main_layout.addWidget(self.dot_color_label, 1, 2, 1, 1)
self.main_layout.addWidget(self.select_dot_color_btn, 1, 3, 1, 1)
self.setup_complete_buttons(2)
self.main_layout.addWidget(self.zero_include_chkbox, 2, 0, 1, 1)
self.main_layout.addWidget(QtWidgets.QLabel('Zero Color'), 2, 1, 1, 1)
self.main_layout.addWidget(self.zero_color_label, 2, 2, 1, 1)
self.main_layout.addWidget(self.select_zero_color_btn, 2, 3, 1, 1)
self.setup_complete_buttons(3)
def connect_signals(self) -> None:
self.select_line_color_btn.clicked.connect(
......@@ -56,6 +70,9 @@ class LineDotDialog(EditValueColorDialog):
self.select_dot_color_btn.clicked.connect(
lambda: self.on_select_color(self.dot_color_label))
self.dot_include_chkbox.clicked.connect(self.on_click_include_dot)
self.select_zero_color_btn.clicked.connect(
lambda: self.on_select_color(self.zero_color_label))
self.zero_include_chkbox.clicked.connect(self.on_click_include_zero)
super().connect_signals()
def on_click_include_dot(self):
......@@ -67,12 +84,22 @@ class LineDotDialog(EditValueColorDialog):
self.select_dot_color_btn.setEnabled(enabled)
self.dot_color_label.setHidden(not enabled)
def on_click_include_zero(self):
"""
Enable/disable select color and show/hide color label according to
dot_include_chkbox is checked or unchecked.
"""
enabled = self.zero_include_chkbox.isChecked()
self.select_zero_color_btn.setEnabled(enabled)
self.zero_color_label.setHidden(not enabled)
def set_value(self):
"""
Change the corresponding color_labels's color according to the color
from value_color_str.
"""
self.dot_include_chkbox.setChecked(False)
self.zero_include_chkbox.setChecked(False)
if self.value_color_str == "":
return
vc_parts = self.value_color_str.split('|')
......@@ -83,6 +110,11 @@ class LineDotDialog(EditValueColorDialog):
if obj_type == 'Dot':
display_color(self.dot_color_label, color)
self.dot_include_chkbox.setChecked(True)
if obj_type == 'Zero':
display_color(self.zero_color_label, color)
self.zero_include_chkbox.setChecked(True)
self.on_click_include_dot()
self.on_click_include_zero()
def save_color(self):
"""
......@@ -94,6 +126,10 @@ class LineDotDialog(EditValueColorDialog):
if self.dot_include_chkbox.isChecked():
dot_color = self.dot_color_label.palette().window().color().name()
self.value_color_str += f"|Dot:{dot_color.upper()}"
if self.zero_include_chkbox.isChecked():
zero_color = \
self.zero_color_label.palette().window().color().name()
self.value_color_str += f"|Zero:{zero_color.upper()}"
self.accept()
......
......@@ -384,8 +384,8 @@ class MultiColorDotDialog(EditValueColorDialog):
if color == 'not plot':
self.set_color_enabled(vc_idx, False)
else:
self.set_color_enabled(vc_idx, True)
display_color(self.color_labels[vc_idx], color)
self.set_color_enabled(vc_idx, True)
def save_color(self):
"""
......
......@@ -142,9 +142,10 @@ class ValueColorEdit(QTextEdit):
if background == 'B':
palette.setColor(QtGui.QPalette.ColorRole.Text, Qt.white)
palette.setColor(QtGui.QPalette.ColorRole.Base, Qt.black)
palette.setColor(QtGui.QPalette.ColorRole.PlaceholderText,
Qt.lightGray)
self.setPalette(palette)
else:
palette.setColor(QtGui.QPalette.ColorRole.Text, Qt.black)
palette.setColor(QtGui.QPalette.ColorRole.Base, Qt.white)
self.setPalette(palette)
def set_value_color(self, value_color_str: str) -> None:
"""
......
......@@ -324,30 +324,41 @@ class Plotting:
for cStr in color_parts:
obj, c = cStr.split(':')
colors[obj] = c
l_color = '#00FF00'
has_dot = False
l_color = '#00FF00' # default Line color
if 'Line' in colors:
l_color = colors['Line']
has_dot = False # Optional dot
if 'Dot' in colors:
d_color = colors['Dot']
has_dot = True
else:
d_color = l_color
if chan_id == 'GPS Lk/Unlk':
has_zero = False # Optional zero
if 'Zero' in colors:
z_color = colors['Zero']
has_zero = True
if chan_id == 'GPS Lk/Unlk':
info = "GPS Clock Power"
if has_zero:
sample_no_list = []
ax.x_bottom = x_list[0][np.where(y_list[0] == -1)[0]]
# compute x_bottom, x_center, x_top for labels of total numbers on
# the left of the channel
ax.x_bottom = x_list[0][np.where(y_list[0] < 0)[0]]
sample_no_list.append(ax.x_bottom.size)
ax.x_center = x_list[0][np.where(y_list[0] == 0)[0]]
sample_no_list.append(ax.x_center.size)
ax.x_top = x_list[0][np.where(y_list[0] == 1)[0]]
ax.x_top = x_list[0][np.where(y_list[0] > 0)[0]]
sample_no_list.append(ax.x_top.size)
sample_no_colors = [d_color, z_color, d_color]
sample_no_pos = [0.05, 0.5, 0.95]
top_bottom_index = np.where(y_list[0] != 0)[0]
# for plotting top & bottom
top_bottom_index = np.where(y_list[0] != 0)[0]
x_list = [x_list[0][top_bottom_index]]
y_list = [y_list[0][top_bottom_index]]
......@@ -362,7 +373,6 @@ class Plotting:
picker=True, pickradius=3)
ax.chan_plots.append(chan_plot)
info = "GPS Clock Power"
else:
sample_no_list = [None, sum([len(x) for x in x_list]), None]
sample_no_colors = [None, d_color, None]
......
......@@ -12,11 +12,11 @@ plot_types = {
" Dots are plotted with color #FF0000\n"
"If Dot is not defined, dots won't be displayed.\n"
"If L is not defined, lines will be plotted with color "
"#00FF00.\n"
"Optionally, a color for points with value 0 can be defined "
"This is currently only used for channel GPS Lk/Unlk.\n"
"Ex: Zero:#0000FF means points with value are plotted with "
"color #0000FF."
"#00FF00.\n\n"
"If Zero is defined, this plot type will plot a line through "
"bottom points (<0) and top points (>0). Zero points will be "
"plotted in the middle."
"Ex: Line:#00FF00|Dot:#FF0000|Zero:#0000FF"
),
"plot_function": "plot_lines_dots",
"value_pattern": re.compile('^(L|D|Z|Line|Dot|Zero)$'),
......
......@@ -37,11 +37,11 @@ class TestValidateValueColorStr(BaseTestCase):
" Dots are plotted with color #FF0000\n"
"If Dot is not defined, dots won't be displayed.\n"
"If L is not defined, lines will be plotted with color "
"#00FF00.\n"
"Optionally, a color for points with value 0 can be defined "
"This is currently only used for channel GPS Lk/Unlk.\n"
"Ex: Zero:#0000FF means points with value are plotted with "
"color #0000FF.")
"#00FF00.\n\n"
"If Zero is defined, this plot type will plot a line through "
"bottom points (<0) and top points (>0). Zero points will be "
"plotted in the middle."
"Ex: Line:#00FF00|Dot:#FF0000|Zero:#0000FF")
)
def test_up_down_dots(self):
......