draw anti aliased preview of signal

This commit is contained in:
jopohl
2017-02-04 19:08:26 +01:00
parent ce901e4edd
commit 43d0ed15c6
3 changed files with 14 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class InsertSinePlugin(SignalEditorPlugin):
self.dialog_ui = uic.loadUi(os.path.realpath(os.path.join(dirname, "insert_sine_dialog.ui"))) # type: QDialog
self.amplitude = 1
self.frequency = 1e6
self.frequency = 10
self.phase = 0
self.sample_rate = 1e6
self.num_samples = 1e6
@@ -42,6 +42,7 @@ class InsertSinePlugin(SignalEditorPlugin):
def show_insert_sine_dialog(self):
self.dialog_ui.show()
self.__create_dialog_connects()
self.draw_sine_wave()
def draw_sine_wave(self):
self.complex_wave = np.empty(int(self.num_samples), dtype=np.complex64)
@@ -50,6 +51,7 @@ class InsertSinePlugin(SignalEditorPlugin):
self.complex_wave.imag = self.amplitude * np.sin(2 * np.pi * self.frequency * t + self.phase)
self.dialog_ui.graphicsViewSineWave.plot_data(self.complex_wave.imag.astype(np.float32))
self.dialog_ui.graphicsViewSineWave.draw_full()
@pyqtSlot(float)
def on_double_spin_box_amplitude_value_changed(self, value: float):

View File

@@ -160,7 +160,11 @@
</item>
</layout>
</widget>
<widget class="ZoomableGraphicView" name="graphicsViewSineWave"/>
<widget class="ZoomableGraphicView" name="graphicsViewSineWave">
<property name="renderHints">
<set>QPainter::Antialiasing|QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing</set>
</property>
</widget>
</widget>
</item>
</layout>

View File

@@ -1,4 +1,5 @@
from PyQt5.QtCore import pyqtSignal, QRectF
from PyQt5.QtGui import QResizeEvent
from PyQt5.QtGui import QWheelEvent
from PyQt5.QtWidgets import QGraphicsScene
@@ -71,4 +72,8 @@ class ZoomableGraphicView(SelectableGraphicView):
if self.scene_creator is not None:
x1 = self.view_rect().x()
x2 = x1 + self.view_rect().width()
self.scene_creator.show_scene_section(x1, x2)
self.scene_creator.show_scene_section(x1, x2)
def resizeEvent(self, event: QResizeEvent):
self.draw_full()
event.accept()