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;
74
76
77 QHBoxLayout *markerLayout;
83
84 QGridLayout *measurementLayout;
85 std::vector< QLabel * > measurementNameLabel;
86 std::vector< QLabel * > measurementGainLabel;
87 std::vector< QLabel * > measurementMagnitudeLabel;
88 std::vector< QLabel * > measurementMiscLabel;
89 std::vector< QLabel * > measurementVppLabel;
90 std::vector< QLabel * > measurementRMSLabel;
91 std::vector< QLabel * > measurementDCLabel;
92 std::vector< QLabel * > measurementACLabel;
93 std::vector< QLabel * > measurementdBLabel;
94 std::vector< QLabel * > measurementFrequencyLabel;
95 std::vector< QLabel * > measurementNoteLabel;
96 std::vector< QLabel * > measurementRMSPowerLabel;
97 std::vector< QLabel * > measurementTHDLabel;
98
100
104
107
108 private:
110 double timebase;
111 double pulseWidth1 = 0.0;
112 double pulseWidth2 = 0.0;
113 double zoomFactor = 1.0;
116 void setColors();
117 std::vector< Unit > voltageUnits = { UNIT_VOLTS, UNIT_VOLTS, UNIT_VOLTS };
119 QPoint cursorGlobalPosition = QPoint();
120 QPointF cursorMeasurementPosition = QPointF();
122 void switchToMarker();
123 void showCursorMessage( QPoint globalPos = QPoint(), const QString &message = QString() );
124 void updateItem( ChannelID index, bool switchOn = false );
125
126 public slots:
127 // Horizontal axis
128 // void horizontalFormatChanged(HorizontalFormat format);
129 void updateFrequencybase( double frequencybase );
130 void updateSamplerate( double samplerate );
131 void updateTimebase( double timebase );
132
133 // Trigger
134 void updateTriggerMode();
135 void updateTriggerSlope();
136 void updateTriggerSource();
137
138 // Spectrum
139 void updateSpectrumMagnitude( ChannelID channel );
140 void updateSpectrumUsed( ChannelID channel, bool used );
141
142 // Vertical axis
143 void updateVoltageCoupling( ChannelID channel );
144 void updateMathMode();
145 void updateVoltageGain( ChannelID channel );
146 void updateVoltageUsed( ChannelID channel, bool used );
147
148 // Menus
149 void updateRecordLength( int size );
150
151 // Scope control
152 void updateZoom( bool enabled );
153 void updateCursorGrid( bool enabled );
154 void wheelEvent( QWheelEvent *event ) override;
155
156 // Scope control
158
159 private slots:
160 // Sliders
161 void updateOffset( ChannelID channel, double value, bool pressed, QPoint globalPos );
162 void updateTriggerPosition( int index, double value, bool pressed, QPoint globalPos, bool mainView = true );
163 void updateTriggerLevel( ChannelID channel, double value, bool pressed, QPoint globalPos );
164 void updateMarker( unsigned marker, double value );
165
166 signals:
167 // Sliders
168 void voltageOffsetChanged( ChannelID channel, double value );
169 void triggerPositionChanged( double value );
170 void triggerLevelChanged( ChannelID channel, double value );
171};
Definition datagrid.h:13
double pulseWidth1
Definition dsowidget.h:111
void updateMarker(unsigned marker, double value)
Handles valueChanged signal from the marker slider.
Definition dsowidget.cpp:1241
QLabel * markerTimebaseLabel
The timebase for the zoomed scope.
Definition dsowidget.h:81
Sliders mainSliders
Definition dsowidget.h:63
void showCursorMessage(QPoint globalPos=QPoint(), const QString &message=QString())
Definition dsowidget.cpp:1078
void updateVoltageDetails(ChannelID channel)
Update the label about the voltage settings.
Definition dsowidget.cpp:729
double timebase
Definition dsowidget.h:110
QLabel * markerFrequencybaseLabel
The frequencybase for the zoomed scope.
Definition dsowidget.h:82
std::vector< QLabel * > measurementVppLabel
Peak-to-peak amplitude of the signal (V)
Definition dsowidget.h:89
DsoSettingsView * view
Definition dsowidget.h:102
QGridLayout * mainLayout
The main layout for this widget.
Definition dsowidget.h:66
GlScope * zoomScope
The optional magnified scope screen.
Definition dsowidget.h:106
QLabel * markerInfoLabel
The info about the zoom factor.
Definition dsowidget.h:78
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:114
QLabel * markerTimeLabel
The time period between the markers.
Definition dsowidget.h:79
std::vector< QLabel * > measurementFrequencyLabel
Frequency of the signal (Hz)
Definition dsowidget.h:94
std::vector< Unit > voltageUnits
Definition dsowidget.h:117
const Dso::ControlSpecification * spec
Definition dsowidget.h:103
QLabel * settingsFrequencybaseLabel
The frequencybase of the main scope.
Definition dsowidget.h:73
~DsoWidget() override
Definition dsowidget.cpp:302
void updateMarkerDetails()
Update the label about the marker measurements.
Definition dsowidget.cpp:564
void updateTriggerLevel(ChannelID channel, double value, bool pressed, QPoint globalPos)
Handles valueChanged signal from the trigger level slider.
Definition dsowidget.cpp:1210
QLabel * swTriggerStatus
The status of SW trigger.
Definition dsowidget.h:75
std::vector< QLabel * > measurementdBLabel
AC Amplitude in dB.
Definition dsowidget.h:93
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:308
QPoint cursorGlobalPosition
Definition dsowidget.h:119
void updateCursorGrid(bool enabled)
Definition dsowidget.cpp:378
DataGrid * cursorDataGrid
Definition dsowidget.h:99
void updateTriggerDetails()
Update the label about the trigger settings.
Definition dsowidget.cpp:697
QLabel * settingsTriggerLabel
The trigger details.
Definition dsowidget.h:69
void updateSamplerate(double samplerate)
Updates the samplerate field after changing the samplerate.
Definition dsowidget.cpp:753
void updateTriggerSlope()
Handles slopeChanged signal from the trigger dock.
Definition dsowidget.cpp:812
void updateTriggerMode()
Handles modeChanged signal from the trigger dock.
Definition dsowidget.cpp:804
std::vector< QLabel * > measurementACLabel
AC Amplitude of the signal (V)
Definition dsowidget.h:92
QLabel * settingsSamplesOnScreen
The displayed dots on screen.
Definition dsowidget.h:70
void showNew(std::shared_ptr< PPresult > analysedData)
Prints analyzed data.
Definition dsowidget.cpp:937
void triggerLevelChanged(ChannelID channel, double value)
A trigger level has been changed.
virtual void showEvent(QShowEvent *event) override
Definition dsowidget.cpp:1085
std::vector< QLabel * > measurementTHDLabel
THD of the signal in Watts.
Definition dsowidget.h:97
void updateMathMode()
Handles modeChanged signal from the voltage dock.
Definition dsowidget.cpp:842
std::vector< QLabel * > measurementMagnitudeLabel
The magnitude for the spectrum (dB/div)
Definition dsowidget.h:87
void setMeasurementVisible(ChannelID channel)
Show/Hide a line of the measurement table.
Definition dsowidget.cpp:521
double zoomFactor
Definition dsowidget.h:113
double zoomToMain(double position) const
Translate horizontal position (0..1) from zoom view to main view.
Definition dsowidget.cpp:1145
std::vector< QLabel * > measurementRMSPowerLabel
RMS Power in Watts.
Definition dsowidget.h:96
double samplerate
Definition dsowidget.h:109
DsoSettingsScope * scope
Definition dsowidget.h:101
Sliders zoomSliders
Definition dsowidget.h:64
std::vector< QLabel * > measurementDCLabel
DC Amplitude of the signal (V)
Definition dsowidget.h:91
void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel)
Set the trigger level sliders minimum and maximum to the new values.
Definition dsowidget.cpp:507
std::vector< QLabel * > measurementMiscLabel
Coupling or math mode.
Definition dsowidget.h:88
QLabel * markerFrequencyLabel
The frequency for the time period.
Definition dsowidget.h:80
void updateSlidersSettings()
Update the sliders settings.
Definition dsowidget.cpp:1251
double pulseWidth2
Definition dsowidget.h:112
void updateVoltageUsed(ChannelID channel, bool used)
Handles usedChanged signal from the voltage dock.
Definition dsowidget.cpp:866
void switchToMarker()
Definition dsowidget.cpp:892
void updateItem(ChannelID index, bool switchOn=false)
Definition dsowidget.cpp:415
void updateVoltageCoupling(ChannelID channel)
Handles couplingChanged signal from the voltage dock.
Definition dsowidget.cpp:834
void setColors()
Definition dsowidget.cpp:324
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:1178
ChannelID selectedCursor
Definition dsowidget.h:121
void updateSpectrumUsed(ChannelID channel, bool used)
Handles usedChanged signal from the spectrum dock.
Definition dsowidget.cpp:783
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:1155
void updateSpectrumMagnitude(ChannelID channel)
Handles magnitudeChanged signal from the spectrum dock.
Definition dsowidget.cpp:774
void updateTimebase(double timebase)
Handles timebaseChanged signal from the horizontal dock.
Definition dsowidget.cpp:763
QHBoxLayout * markerLayout
The table for the marker details.
Definition dsowidget.h:77
GlScope * mainScope
The main scope screen.
Definition dsowidget.h:105
void wheelEvent(QWheelEvent *event) override
Definition dsowidget.cpp:922
void updateOffset(ChannelID channel, double value, bool pressed, QPoint globalPos)
Handles valueChanged signal from the offset sliders.
Definition dsowidget.cpp:1103
std::vector< QLabel * > measurementGainLabel
The gain for the voltage (V/div)
Definition dsowidget.h:86
void updateRecordLength(int size)
Change the record length.
Definition dsowidget.cpp:887
QLabel * settingsTimebaseLabel
The timebase of the main scope.
Definition dsowidget.h:72
void restoreScreenColors()
Definition dsowidget.cpp:316
bool cursorMeasurementValid
Definition dsowidget.h:118
double mainToZoom(double position) const
Translate horizontal position (0..1) from main view to zoom view.
Definition dsowidget.cpp:1135
std::vector< QLabel * > measurementRMSLabel
RMS Amplitude of the signal (V) = sqrt( DC² + AC² )
Definition dsowidget.h:90
QGridLayout * measurementLayout
The table for the signal details.
Definition dsowidget.h:84
void updateZoom(bool enabled)
Show/hide the zoom view.
Definition dsowidget.cpp:900
int zoomScopeRow
Definition dsowidget.h:115
QPointF cursorMeasurementPosition
Definition dsowidget.h:120
void updateVoltageGain(ChannelID channel)
Handles gainChanged signal from the voltage dock.
Definition dsowidget.cpp:852
void updateSpectrumDetails(ChannelID channel)
Update the label about the spectrum settings.
Definition dsowidget.cpp:686
std::vector< QLabel * > measurementNoteLabel
Note value of the signal.
Definition dsowidget.h:95
void updateTriggerSource()
Handles sourceChanged signal from the trigger dock.
Definition dsowidget.cpp:816
void updateFrequencybase(double frequencybase)
Handles frequencybaseChanged signal from the horizontal dock.
Definition dsowidget.cpp:745
std::vector< QLabel * > measurementNameLabel
The name of the channel.
Definition dsowidget.h:85
void setupSliders(Sliders &sliders)
Definition dsowidget.cpp:443
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:88
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