57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/cosmos/tools/tlm_viewer/widgets/limitsbar_widget.rb', line 57
def paint_implementation(dc)
draw_bar = true
limits_values = @item.limits.values
if limits_values
limits = limits_values[@limits_set]
limits = limits_values[:DEFAULT] unless limits
if limits
red_low = limits[0]
yellow_low = limits[1]
yellow_high = limits[2]
red_high = limits[3]
green_low = limits[4]
green_high = limits[5]
else
draw_bar = false
end
else
draw_bar = false
end
if draw_bar
red_low_width = (0.1 * @bar_width).round
red_high_width = (0.1 * @bar_width).round
inner_value_range = red_high - red_low
yellow_low_width = ((yellow_low - red_low) / inner_value_range * 0.8 * @bar_width).round
yellow_high_width = ((red_high - yellow_high) / inner_value_range * 0.8 * @bar_width).round
if green_high
green_low_width = ((green_low - yellow_low) / inner_value_range * 0.8 * @bar_width).round
green_high_width = ((yellow_high - green_high) / inner_value_range * 0.8 * @bar_width).round
blue_width = @bar_width - red_low_width - yellow_low_width - green_low_width - green_high_width - yellow_high_width - red_high_width
else
green_width = @bar_width - red_low_width - yellow_low_width - yellow_high_width - red_high_width
end
x_pos = @x_pad
y_pos = @y_pad
dc.addRectColorFill(x_pos, y_pos, red_low_width, @bar_height, 'red')
dc.addRectColor(x_pos, y_pos, red_low_width, @bar_height)
x_pos += red_low_width
dc.addRectColorFill(x_pos, y_pos, yellow_low_width, @bar_height, 'yellow')
dc.addRectColor(x_pos, y_pos, yellow_low_width, @bar_height)
x_pos += yellow_low_width
if green_high
dc.addRectColorFill(x_pos, y_pos, green_low_width, @bar_height, 'lime')
dc.addRectColor(x_pos, y_pos, green_low_width, @bar_height)
x_pos += green_low_width
dc.addRectColorFill(x_pos, y_pos, blue_width, @bar_height, 'dodgerblue')
dc.addRectColor(x_pos, y_pos, blue_width, @bar_height)
x_pos += blue_width
dc.addRectColorFill(x_pos, y_pos, green_high_width, @bar_height, 'lime')
dc.addRectColor(x_pos, y_pos, green_high_width, @bar_height)
x_pos += green_high_width
else
dc.addRectColorFill(x_pos, y_pos, green_width, @bar_height, 'lime')
dc.addRectColor(x_pos, y_pos, green_width, @bar_height)
x_pos += green_width
end
dc.addRectColorFill(x_pos, y_pos, yellow_high_width, @bar_height, 'yellow')
dc.addRectColor(x_pos, y_pos, yellow_high_width, @bar_height)
x_pos += yellow_high_width
dc.addRectColorFill(x_pos, y_pos, red_high_width, @bar_height, 'red')
dc.addRectColor(x_pos, y_pos, red_high_width, @bar_height)
x_pos += red_high_width
@bar_scale = (red_high - red_low) / 0.8
@low_value = red_low - 0.1 * @bar_scale
@high_value = red_high + 0.1 * @bar_scale
@line_pos = (@x_pad + (@value - @low_value) / @bar_scale * @bar_width).to_i
if @line_pos < @x_pad
@line_pos = @x_pad
end
if @line_pos > @x_pad + @bar_width
@line_pos = @bar_width + @x_pad
end
dc.addLineColor(@line_pos, @y_pad - 3, @line_pos, @y_pad + @bar_height + 3)
top_triangle = Qt::Polygon.new(3)
top_triangle.setPoint(0, @line_pos, @y_pad - 1)
top_triangle.setPoint(1, @line_pos-5, @y_pad - 6)
top_triangle.setPoint(2, @line_pos+5, @y_pad - 6)
dc.setBrush(Cosmos.getBrush(Cosmos::BLACK))
dc.drawPolygon(top_triangle)
top_triangle.dispose
additional_drawing(dc)
end end
|