Revize 81e08f8f
Přidáno uživatelem Jan Rach před téměř 4 roky(ů)
aswi2021vochomurka/view/main_view.py | ||
---|---|---|
102 | 102 |
self.figureDict = {} |
103 | 103 |
self.widgetDict = {} |
104 | 104 |
self.widgetList = [] |
105 |
self.focusDict = {} |
|
105 | 106 |
|
106 | 107 |
self.setMinimumSize(QSize(1200, 800)) |
107 | 108 |
self.setWindowTitle("MQTT client") |
... | ... | |
159 | 160 |
|
160 | 161 |
figure = plt.figure(figure.number) |
161 | 162 |
figure.suptitle(message.topic) |
163 |
length = len(self.dataDict[message.topic]) |
|
164 |
if self.focusDict[message.topic] is True: |
|
165 |
plt.xlim(length - 10, length) |
|
166 |
else: |
|
167 |
plt.xlim(0 ,length) |
|
168 |
|
|
162 | 169 |
plt.plot(self.dataDict[message.topic]) |
163 | 170 |
|
164 | 171 |
if message.topic in self.dataDict2: |
... | ... | |
174 | 181 |
canvas = FigureCanvas(figure) |
175 | 182 |
self.layout = QHBoxLayout() |
176 | 183 |
|
184 |
self.focusDict[message.topic] = False |
|
185 |
|
|
186 |
plt.xlim(0, 1) |
|
177 | 187 |
plt.plot(self.dataDict[message.topic]) |
178 | 188 |
|
179 | 189 |
figure.suptitle(message.topic) |
... | ... | |
193 | 203 |
button2.clicked.connect(lambda: self.deleteSecond(message.topic)) |
194 | 204 |
button2.setFixedSize(QSize(40, 40)) |
195 | 205 |
|
206 |
buttonF = QPushButton('Foc') |
|
207 |
buttonF.clicked.connect(lambda: self.focusSwitch(message.topic)) |
|
208 |
buttonF.setFixedSize(QSize(40, 40)) |
|
209 |
|
|
196 | 210 |
self.layout.addWidget(canvas) |
197 | 211 |
|
198 | 212 |
boxLayout = QVBoxLayout() |
199 | 213 |
boxLayout.addWidget(button) |
200 | 214 |
boxLayout.addWidget(button2) |
215 |
boxLayout.addWidget(buttonF) |
|
201 | 216 |
boxLayout.setAlignment(button, QtCore.Qt.AlignTop) |
202 | 217 |
boxLayout.setAlignment(button2, QtCore.Qt.AlignTop) |
218 |
boxLayout.setAlignment(buttonF, QtCore.Qt.AlignTop) |
|
203 | 219 |
self.layout.addLayout(boxLayout) |
204 | 220 |
widget.setMinimumSize(QSize(500, 500)) |
205 | 221 |
|
... | ... | |
228 | 244 |
|
229 | 245 |
figure = plt.figure(figure.number) |
230 | 246 |
figure.suptitle(topic) |
247 |
|
|
248 |
length = len(self.dataDict[topic]) |
|
249 |
if self.focusDict[topic] is True: |
|
250 |
plt.xlim(length - 10, length) |
|
251 |
else: |
|
252 |
plt.xlim(0, length) |
|
253 |
|
|
231 | 254 |
plt.plot(self.dataDict[topic]) |
232 | 255 |
plt.plot(self.dataDict2[topic]) |
233 | 256 |
|
... | ... | |
244 | 267 |
|
245 | 268 |
figure = plt.figure(figure.number) |
246 | 269 |
figure.suptitle(topic) |
270 |
|
|
271 |
length = len(self.dataDict[topic]) |
|
272 |
if self.focusDict[topic] is True: |
|
273 |
plt.xlim(length - 10, length) |
|
274 |
else: |
|
275 |
plt.xlim(0, length) |
|
276 |
|
|
247 | 277 |
plt.plot(self.dataDict[topic]) |
248 | 278 |
|
249 | 279 |
self.canvasDict[topic].draw() |
250 | 280 |
|
281 |
def focusSwitch(self, topic: str): |
|
282 |
if self.focusDict[topic] is False: |
|
283 |
self.focusDict[topic] = True |
|
284 |
else: |
|
285 |
self.focusDict[topic] = False |
|
286 |
|
|
287 |
length = len(self.dataDict[topic]) |
|
288 |
if self.focusDict[topic] is True: |
|
289 |
plt.xlim(length - 10, length) |
|
290 |
else: |
|
291 |
plt.xlim(0, length) |
|
292 |
|
|
293 |
self.canvasDict[topic].draw() |
|
294 |
|
|
251 | 295 |
def deletePlot(self, topic: str): |
252 | 296 |
""" |
253 | 297 |
Deletes plot |
... | ... | |
260 | 304 |
del self.widgetDict[topic] |
261 | 305 |
del self.canvasDict[topic] |
262 | 306 |
del self.figureDict[topic] |
307 |
del self.focusDict[topic] |
|
263 | 308 |
del self.dataDict[topic] |
264 | 309 |
if topic in self.dataDict2: |
265 | 310 |
del self.dataDict2[topic] |
... | ... | |
307 | 352 |
self.widgetList.clear() |
308 | 353 |
self.canvasDict.clear() |
309 | 354 |
self.figureDict.clear() |
355 |
self.focusDict.clear() |
|
310 | 356 |
self.dataDict.clear() |
311 | 357 |
self.dataDict2.clear() |
312 | 358 |
|
359 |
self.chartsNum = 0 |
|
360 |
|
|
313 | 361 |
self.disconnect() |
314 | 362 |
self.worker.params = self.getConfigParams() |
315 | 363 |
self.workerThread.start() |
Také k dispozici: Unified diff
Re: #8968 - adjustments for plot focus button