diff --git a/src/urh/simulator/Simulator.py b/src/urh/simulator/Simulator.py index d9467a75a6..4083201a9d 100644 --- a/src/urh/simulator/Simulator.py +++ b/src/urh/simulator/Simulator.py @@ -323,7 +323,7 @@ def process_message(self): self.last_sent_message = msg else: # we have to receive a message - self.log_message("Waiting for message {}".format(msg.index())) + self.log_message("Waiting for message {}...".format(msg.index())) sniffer = self.sniffer if sniffer is None: self.log_message("Fatal: No sniffer configured") @@ -334,6 +334,7 @@ def process_message(self): max_retries = self.project_manager.simulator_retries while self.is_simulating and not self.simulation_is_finished() and retry < max_retries: received_msg = self.receive_message(sniffer) + self.log_message(" Received {} data bits".format(len(received_msg))) if not self.is_simulating: return @@ -353,7 +354,7 @@ def process_message(self): received_msg.decoder = new_message.decoder received_msg.message_type = new_message.message_type - self.log_message("Message {}: Check whether received data matches".format(msg.index())) + self.log_message(" Check whether received data matches") check_result, error_msg = self.check_message(received_msg, new_message, retry=retry, msg_index=msg.index()) diff --git a/src/urh/ui/painting/FFTSceneManager.py b/src/urh/ui/painting/FFTSceneManager.py index b6d08a987f..53831d7864 100644 --- a/src/urh/ui/painting/FFTSceneManager.py +++ b/src/urh/ui/painting/FFTSceneManager.py @@ -33,11 +33,9 @@ def show_scene_section(self, x1: float, x2: float, subpath_ranges=None, colors=N def init_scene(self, draw_grid=True): self.scene.draw_grid = draw_grid - minimum = -4.5 - maximum = 2 self.peak = self.plot_data if len(self.peak) < self.num_samples else np.maximum(self.peak, self.plot_data) - self.scene.setSceneRect(0, minimum, self.num_samples, maximum - minimum) + self.scene.setSceneRect(0, -5, self.num_samples, 10) def clear_path(self): for item in self.scene.items(): diff --git a/src/urh/ui/painting/GridScene.py b/src/urh/ui/painting/GridScene.py index 7b25699a9b..397393d86d 100644 --- a/src/urh/ui/painting/GridScene.py +++ b/src/urh/ui/painting/GridScene.py @@ -1,5 +1,5 @@ import numpy as np -from PyQt5.QtCore import QRectF, QLineF, QPointF +from PyQt5.QtCore import QRectF, QLineF, QPointF, Qt from PyQt5.QtGui import QPainter, QFont, QFontMetrics, QPen, QTransform, QBrush from urh import settings @@ -16,10 +16,9 @@ def __init__(self, parent=None): self.frequencies = [] self.frequency_marker = None super().__init__(parent) - self.setSceneRect(0,0,10,10) + self.setSceneRect(0, 0, 10, 10) def drawBackground(self, painter: QPainter, rect: QRectF): - # freqs = np.fft.fftfreq(len(w), 1 / self.sample_rate) if self.draw_grid and len(self.frequencies) > 0: painter.setPen(QPen(painter.pen().color(), 0)) parent_width = self.parent().width() if hasattr(self.parent(), "width") else 750 @@ -39,29 +38,30 @@ def drawBackground(self, painter: QPainter, rect: QRectF): bottom = rect.bottom() - (rect.bottom() % y_grid_size) right_border = int(rect.right()) if rect.right() < len(self.frequencies) else len(self.frequencies) + scale_x, scale_y = util.calc_x_y_scale(rect, self.parent()) + + fh = self.font_metrics.height() x_range = list(range(x_mid, left, -x_grid_size)) + list(range(x_mid, right_border, x_grid_size)) - lines = [QLineF(x, rect.top(), x, bottom) for x in x_range] \ + lines = [QLineF(x, rect.top(), x, bottom-fh*scale_y) for x in x_range] \ + [QLineF(rect.left(), y, rect.right(), y) for y in np.arange(top, bottom, y_grid_size)] + pen = painter.pen() + pen.setStyle(Qt.DotLine) + painter.setPen(pen) painter.drawLines(lines) - scale_x, scale_y = util.calc_x_y_scale(rect, self.parent()) - painter.scale(scale_x, scale_y) counter = -1 # Counter for Label for every second line for x in x_range: freq = self.frequencies[x] counter += 1 + if freq == 0: + counter = 0 - if freq != 0 and (counter % 2 != 0): # Label for every second line + if freq != 0 and (counter % 2 != 0): # Label for every second line continue - if freq != 0: - prefix = "+" if freq > 0 else "" - value = prefix+Formatter.big_value_with_suffix(freq, 2) - else: - counter = 0 - value = Formatter.big_value_with_suffix(self.center_freq) + value = Formatter.big_value_with_suffix(self.center_freq + freq, 2) font_width = self.font_metrics.width(value) painter.drawText(QPointF(x / scale_x - font_width / 2, bottom / scale_y), value)