OpenHantek
Loading...
Searching...
No Matches
dsowidget.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#pragma once
4
5#include <QGridLayout>
6#include <QHBoxLayout>
7#include <QLabel>
8#include <QList>
9#include <memory>
10
11#include "glscope.h"
13#include "levelslider.h"
14#include "viewsettings.h"
15
17struct DsoSettingsScope;
18struct DsoSettingsView;
19class DataGrid;
20
23class DsoWidget : public QWidget {
24 Q_OBJECT
25
26 public:
33
39 DsoWidget( DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent = nullptr );
40
41 ~DsoWidget() override;
42
43 // Data arrived
44 void showNew( std::shared_ptr< PPresult > analysedData );
45
48
49 protected:
50 virtual void showEvent( QShowEvent *event ) override;
51 void setupSliders( Sliders &sliders );
54 void setMeasurementVisible( ChannelID channel );
56 void updateSpectrumDetails( ChannelID channel );
58 void updateVoltageDetails( ChannelID channel );
59
60 double mainToZoom( double position ) const;
61 double zoomToMain( double position ) const;
62
65
66 QGridLayout *mainLayout;
67
68 QHBoxLayout *settingsLayout;
75
77
78 QHBoxLayout *markerLayout;
84
85 QGridLayout *measurementLayout;
86 std::vector< QLabel * > measurementNameLabel;
87 std::vector< QLabel * > measurementGainLabel;
88 std::vector< QLabel * > measurementMagnitudeLabel;
89 std::vector< QLabel * > measurementMiscLabel;
90 std::vector< QLabel * > measurementVppLabel;
91 std::vector< QLabel * > measurementRMSLabel;
92 std::vector< QLabel * > measurementDCLabel;
93 std::vector< QLabel * > measurementACLabel;
94 std::vector< QLabel * > measurementdBLabel;
95 std::vector< QLabel * > measurementFrequencyLabel;
96 std::vector< QLabel * > measurementNoteLabel;
97 std::vector< QLabel * > measurementRMSPowerLabel;
98 std::vector< QLabel * > measurementTHDLabel;
99
101
105
108
109 private:
111 unsigned oversample = 1;
112 double timebase;
113 double pulseWidth1 = 0.0;
114 double pulseWidth2 = 0.0;
115 double zoomFactor = 1.0;
118 void setColors();
119 std::vector< Unit > voltageUnits = { UNIT_VOLTS, UNIT_VOLTS, UNIT_VOLTS };
121 QPoint cursorGlobalPosition = QPoint();
122 QPointF cursorMeasurementPosition = QPointF();
124 void switchToMarker();
125 void showCursorMessage( QPoint globalPos = QPoint(), const QString &message = QString() );
126 void updateItem( ChannelID index, bool switchOn = false );
127
128 public slots:
129 // Horizontal axis
130 // void horizontalFormatChanged(HorizontalFormat format);
131 void updateFrequencybase( double frequencybase );
132 void updateSamplerate( double samplerate );
133 void updateOversample( unsigned oversample );
134 void updateTimebase( double timebase );
135
136 // Trigger
137 void updateTriggerMode();
138 void updateTriggerSlope();
139 void updateTriggerSource();
140
141 // Spectrum
142 void updateSpectrumMagnitude( ChannelID channel );
143 void updateSpectrumUsed( ChannelID channel, bool used );
144
145 // Vertical axis
146 void updateVoltageCoupling( ChannelID channel );
147 void updateMathMode();
148 void updateVoltageGain( ChannelID channel );
149 void updateVoltageUsed( ChannelID channel, bool used );
150
151 // Menus
152 void updateRecordLength( int size );
153
154 // Scope control
155 void updateZoom( bool enabled );
156 void updateCursorGrid( bool enabled );
157 void wheelEvent( QWheelEvent *event ) override;
158
159 // Scope control
161
162 private slots:
163 // Sliders
164 void updateOffset( ChannelID channel, double value, bool pressed, QPoint globalPos );
165 void updateTriggerPosition( int index, double value, bool pressed, QPoint globalPos, bool mainView = true );
166 void updateTriggerLevel( ChannelID channel, double value, bool pressed, QPoint globalPos );
167 void updateMarker( unsigned marker, double value );
168
169 signals:
170 // Sliders
171 void voltageOffsetChanged( ChannelID channel, double value );
172 void triggerPositionChanged( double value );
173 void triggerLevelChanged( ChannelID channel, double value );
174};
Definition datagrid.h:13
double pulseWidth1
Definition dsowidget.h:113
void updateMarker(unsigned marker, double value)
Handles valueChanged signal from the marker slider.
Definition dsowidget.cpp:1254
QLabel * markerTimebaseLabel
The timebase for the zoomed scope.
Definition dsowidget.h:82
Sliders mainSliders
Definition dsowidget.h:63
void showCursorMessage(QPoint globalPos=QPoint(), const QString &message=QString())
Definition dsowidget.cpp:1090
void updateVoltageDetails(ChannelID channel)
Update the label about the voltage settings.
Definition dsowidget.cpp:734
double timebase
Definition dsowidget.h:112
QLabel * markerFrequencybaseLabel
The frequencybase for the zoomed scope.
Definition dsowidget.h:83
std::vector< QLabel * > measurementVppLabel
Peak-to-peak amplitude of the signal (V).
Definition dsowidget.h:90
DsoSettingsView * view
Definition dsowidget.h:103
QGridLayout * mainLayout
The main layout for this widget.
Definition dsowidget.h:66
GlScope * zoomScope
The optional magnified scope screen.
Definition dsowidget.h:107
QLabel * markerInfoLabel
The info about the zoom factor.
Definition dsowidget.h:79
DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent=nullptr)
Initializes the components of the oszilloscope-screen.
Definition dsowidget.cpp:28
int mainScopeRow
Definition dsowidget.h:116
QLabel * markerTimeLabel
The time period between the markers.
Definition dsowidget.h:80
std::vector< QLabel * > measurementFrequencyLabel
Frequency of the signal (Hz).
Definition dsowidget.h:95
std::vector< Unit > voltageUnits
Definition dsowidget.h:119
const Dso::ControlSpecification * spec
Definition dsowidget.h:104
QLabel * settingsFrequencybaseLabel
The frequencybase of the main scope.
Definition dsowidget.h:74
~DsoWidget() override
Definition dsowidget.cpp:307
void updateMarkerDetails()
Update the label about the marker measurements.
Definition dsowidget.cpp:569
void updateTriggerLevel(ChannelID channel, double value, bool pressed, QPoint globalPos)
Handles valueChanged signal from the trigger level slider.
Definition dsowidget.cpp:1223
QLabel * swTriggerStatus
The status of SW trigger.
Definition dsowidget.h:76
std::vector< QLabel * > measurementdBLabel
AC Amplitude in dB.
Definition dsowidget.h:94
QLabel * settingsSamplerateLabel
The samplerate.
Definition dsowidget.h:71
void voltageOffsetChanged(ChannelID channel, double value)
A graph offset has been changed.
void switchToPrintColors()
Definition dsowidget.cpp:313
void updateOversample(unsigned oversample)
Updates the oversample field after changing the oversampling.
Definition dsowidget.cpp:767
QPoint cursorGlobalPosition
Definition dsowidget.h:121
void updateCursorGrid(bool enabled)
Definition dsowidget.cpp:383
DataGrid * cursorDataGrid
Definition dsowidget.h:100
void updateTriggerDetails()
Update the label about the trigger settings.
Definition dsowidget.cpp:702
QLabel * settingsTriggerLabel
The trigger details.
Definition dsowidget.h:69
void updateSamplerate(double samplerate)
Updates the samplerate field after changing the samplerate.
Definition dsowidget.cpp:758
void updateTriggerSlope()
Handles slopeChanged signal from the trigger dock.
Definition dsowidget.cpp:824
void updateTriggerMode()
Handles modeChanged signal from the trigger dock.
Definition dsowidget.cpp:816
std::vector< QLabel * > measurementACLabel
AC Amplitude of the signal (V).
Definition dsowidget.h:93
QLabel * settingsSamplesOnScreen
The displayed dots on screen.
Definition dsowidget.h:70
void showNew(std::shared_ptr< PPresult > analysedData)
Prints analyzed data.
Definition dsowidget.cpp:949
void triggerLevelChanged(ChannelID channel, double value)
A trigger level has been changed.
unsigned oversample
Definition dsowidget.h:111
virtual void showEvent(QShowEvent *event) override
Definition dsowidget.cpp:1097
std::vector< QLabel * > measurementTHDLabel
THD of the signal in Watts.
Definition dsowidget.h:98
void updateMathMode()
Handles modeChanged signal from the voltage dock.
Definition dsowidget.cpp:854
std::vector< QLabel * > measurementMagnitudeLabel
The magnitude for the spectrum (dB/div).
Definition dsowidget.h:88
void setMeasurementVisible(ChannelID channel)
Show/Hide a line of the measurement table.
Definition dsowidget.cpp:526
double zoomFactor
Definition dsowidget.h:115
double zoomToMain(double position) const
Translate horizontal position (0..1) from zoom view to main view.
Definition dsowidget.cpp:1158
std::vector< QLabel * > measurementRMSPowerLabel
RMS Power in Watts.
Definition dsowidget.h:97
double samplerate
Definition dsowidget.h:110
DsoSettingsScope * scope
Definition dsowidget.h:102
Sliders zoomSliders
Definition dsowidget.h:64
std::vector< QLabel * > measurementDCLabel
DC Amplitude of the signal (V).
Definition dsowidget.h:92
void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel)
Set the trigger level sliders minimum and maximum to the new values.
Definition dsowidget.cpp:512
std::vector< QLabel * > measurementMiscLabel
Coupling or math mode.
Definition dsowidget.h:89
QLabel * markerFrequencyLabel
The frequency for the time period.
Definition dsowidget.h:81
void updateSlidersSettings()
Update the sliders settings.
Definition dsowidget.cpp:1264
double pulseWidth2
Definition dsowidget.h:114
void updateVoltageUsed(ChannelID channel, bool used)
Handles usedChanged signal from the voltage dock.
Definition dsowidget.cpp:878
void switchToMarker()
Definition dsowidget.cpp:904
void updateItem(ChannelID index, bool switchOn=false)
Definition dsowidget.cpp:420
void updateVoltageCoupling(ChannelID channel)
Handles couplingChanged signal from the voltage dock.
Definition dsowidget.cpp:846
void setColors()
Definition dsowidget.cpp:329
void triggerPositionChanged(double value)
The pretrigger has been changed.
void updateTriggerPosition(int index, double value, bool pressed, QPoint globalPos, bool mainView=true)
Handles valueChanged signal from the triggerPosition slider.
Definition dsowidget.cpp:1191
ChannelID selectedCursor
Definition dsowidget.h:123
void updateSpectrumUsed(ChannelID channel, bool used)
Handles usedChanged signal from the spectrum dock.
Definition dsowidget.cpp:795
QHBoxLayout * settingsLayout
The table for the settings info.
Definition dsowidget.h:68
void adaptTriggerPositionSlider()
Handles signals affecting trigger position in the zoom view.
Definition dsowidget.cpp:1168
void updateSpectrumMagnitude(ChannelID channel)
Handles magnitudeChanged signal from the spectrum dock.
Definition dsowidget.cpp:786
QLabel * settingsOversampleLabel
The oversample factor.
Definition dsowidget.h:72
void updateTimebase(double timebase)
Handles timebaseChanged signal from the horizontal dock.
Definition dsowidget.cpp:775
QHBoxLayout * markerLayout
The table for the marker details.
Definition dsowidget.h:78
GlScope * mainScope
The main scope screen.
Definition dsowidget.h:106
void wheelEvent(QWheelEvent *event) override
Definition dsowidget.cpp:934
void updateOffset(ChannelID channel, double value, bool pressed, QPoint globalPos)
Handles valueChanged signal from the offset sliders.
Definition dsowidget.cpp:1116
std::vector< QLabel * > measurementGainLabel
The gain for the voltage (V/div).
Definition dsowidget.h:87
void updateRecordLength(int size)
Change the record length.
Definition dsowidget.cpp:899
QLabel * settingsTimebaseLabel
The timebase of the main scope.
Definition dsowidget.h:73
void restoreScreenColors()
Definition dsowidget.cpp:321
bool cursorMeasurementValid
Definition dsowidget.h:120
double mainToZoom(double position) const
Translate horizontal position (0..1) from main view to zoom view.
Definition dsowidget.cpp:1148
std::vector< QLabel * > measurementRMSLabel
RMS Amplitude of the signal (V) = sqrt( DC² + AC² ).
Definition dsowidget.h:91
QGridLayout * measurementLayout
The table for the signal details.
Definition dsowidget.h:85
void updateZoom(bool enabled)
Show/hide the zoom view.
Definition dsowidget.cpp:912
int zoomScopeRow
Definition dsowidget.h:117
QPointF cursorMeasurementPosition
Definition dsowidget.h:122
void updateVoltageGain(ChannelID channel)
Handles gainChanged signal from the voltage dock.
Definition dsowidget.cpp:864
void updateSpectrumDetails(ChannelID channel)
Update the label about the spectrum settings.
Definition dsowidget.cpp:691
std::vector< QLabel * > measurementNoteLabel
Note value of the signal.
Definition dsowidget.h:96
void updateTriggerSource()
Handles sourceChanged signal from the trigger dock.
Definition dsowidget.cpp:828
void updateFrequencybase(double frequencybase)
Handles frequencybaseChanged signal from the horizontal dock.
Definition dsowidget.cpp:750
std::vector< QLabel * > measurementNameLabel
The name of the channel.
Definition dsowidget.h:86
void setupSliders(Sliders &sliders)
Definition dsowidget.cpp:448
OpenGL accelerated widget that displays the oscilloscope screen.
Definition glscope.h:29
Slider widget for multiple level sliders. These are used for the trigger levels, offsets and so on.
Definition levelslider.h:28
Analyzes the data from the dso. Calculates the spectrum and various data about the signal and saves t...
Definition spectrumgenerator.h:26
@ UNIT_VOLTS
Definition printutils.h:12
Holds the settings for the oscilloscope.
Definition scopesettings.h:100
Holds all view settings.
Definition viewsettings.h:35
Definition dsowidget.h:27
LevelSlider * markerSlider
The sliders for the markers.
Definition dsowidget.h:31
LevelSlider * triggerPositionSlider
The slider for the pretrigger.
Definition dsowidget.h:29
LevelSlider * voltageOffsetSlider
The sliders for the graph offsets.
Definition dsowidget.h:28
LevelSlider * triggerLevelSlider
The sliders for the trigger level.
Definition dsowidget.h:30
Stores the specifications of the currently connected device.
Definition controlspecification.h:42
unsigned ChannelID
Definition types.h:6