OpenHantek
dsowidget.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0+
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 
16 class SpectrumGenerator;
17 struct DsoSettingsScope;
18 struct DsoSettingsView;
19 class DataGrid;
20 
23 class DsoWidget : public QWidget {
24  Q_OBJECT
25 
26  public:
27  struct Sliders {
32  };
33 
39  DsoWidget( DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent = nullptr );
40 
41  ~DsoWidget();
42 
43  // Data arrived
44  void showNew( std::shared_ptr< PPresult > analysedData );
45 
46  void switchToPrintColors();
47  void restoreScreenColors();
48 
49  protected:
50  virtual void showEvent( QShowEvent *event );
51  void setupSliders( Sliders &sliders );
54  void setMeasurementVisible( ChannelID channel );
55  void updateMarkerDetails();
56  void updateSpectrumDetails( ChannelID channel );
57  void updateTriggerDetails();
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 
75  QLabel *swTriggerStatus;
76 
77  QHBoxLayout *markerLayout;
78  QLabel *markerInfoLabel;
79  QLabel *markerTimeLabel;
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 * > measurementRMSPowerLabel;
96  std::vector< QLabel * > measurementTHDLabel;
97 
99 
103 
106 
107  private:
108  double samplerate;
109  double timebase;
110  unsigned int dotsOnScreen;
111  double pulseWidth1 = 0.0;
112  double pulseWidth2 = 0.0;
113  void setColors();
114 
115  public slots:
116  // Horizontal axis
117  // void horizontalFormatChanged(HorizontalFormat format);
118  void updateFrequencybase( double frequencybase );
119  void updateSamplerate( double samplerate );
120  void updateTimebase( double timebase );
121 
122  // Trigger
123  void updateTriggerMode();
124  void updateTriggerSlope();
125  void updateTriggerSource();
126 
127  // Spectrum
128  void updateSpectrumMagnitude( ChannelID channel );
129  void updateSpectrumUsed( ChannelID channel, bool used );
130 
131  // Vertical axis
132  void updateVoltageCoupling( ChannelID channel );
133  void updateMathMode();
134  void updateVoltageGain( ChannelID channel );
135  void updateVoltageUsed( ChannelID channel, bool used );
136 
137  // Menus
138  void updateRecordLength( unsigned long size );
139 
140  // Scope control
141  void updateZoom( bool enabled );
142  void updateCursorGrid( bool enabled );
143 
144  // Scope control
145  void updateSlidersSettings();
146 
147  private slots:
148  // Sliders
149  void updateOffset( ChannelID channel, double value );
150  void updateTriggerPosition( int index, double value, bool mainView = true );
151  void updateTriggerLevel( ChannelID channel, double value );
152  void updateMarker( unsigned marker, double value );
153 
154  signals:
155  // Sliders
156  void voltageOffsetChanged( ChannelID channel, double value );
157  void triggerPositionChanged( double value );
158  void triggerLevelChanged( ChannelID channel, double value );
159 };
void triggerPositionChanged(double value)
The pretrigger has been changed.
void updateTriggerMode()
Handles modeChanged signal from the trigger dock.
Definition: dsowidget.cpp:756
~DsoWidget()
Definition: dsowidget.cpp:322
Definition: dsowidget.h:27
QLabel * markerFrequencybaseLabel
The frequencybase for the zoomed scope.
Definition: dsowidget.h:82
void updateVoltageGain(ChannelID channel)
Handles gainChanged signal from the voltage dock.
Definition: dsowidget.cpp:797
void updateTriggerPosition(int index, double value, bool mainView=true)
Handles valueChanged signal from the triggerPosition slider.
Definition: dsowidget.cpp:1028
void updateVoltageDetails(ChannelID channel)
Update the label about the trigger settings.
Definition: dsowidget.cpp:685
GlScope * mainScope
The main scope screen.
Definition: dsowidget.h:104
DsoSettingsView * view
Definition: dsowidget.h:101
void updateMathMode()
Handles modeChanged signal from the voltage dock.
Definition: dsowidget.cpp:790
std::vector< QLabel *> measurementMagnitudeLabel
The magnitude for the spectrum (dB/div)
Definition: dsowidget.h:87
void restoreScreenColors()
Definition: dsowidget.cpp:336
void adaptTriggerPositionSlider()
Handles signals affecting trigger position in the zoom view.
Definition: dsowidget.cpp:1005
std::vector< QLabel *> measurementFrequencyLabel
Frequency of the signal (Hz)
Definition: dsowidget.h:94
QLabel * markerTimebaseLabel
The timebase for the zoomed scope.
Definition: dsowidget.h:81
void updateTimebase(double timebase)
Handles timebaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:718
std::vector< QLabel *> measurementRMSPowerLabel
RMS Power in Watts.
Definition: dsowidget.h:95
Slider widget for multiple level sliders. These are used for the trigger levels, offsets and so on...
Definition: levelslider.h:28
The widget for the oszilloscope-screen This widget contains the scopes and all level sliders...
Definition: dsowidget.h:23
DsoSettingsScope * scope
Definition: dsowidget.h:100
double samplerate
Definition: dsowidget.h:108
Sliders mainSliders
Definition: dsowidget.h:63
QLabel * markerFrequencyLabel
The frequency for the time period.
Definition: dsowidget.h:80
void updateTriggerDetails()
Update the label about the trigger settings.
Definition: dsowidget.cpp:654
std::vector< QLabel *> measurementACLabel
AC Amplitude of the signal (V)
Definition: dsowidget.h:92
std::vector< QLabel *> measurementGainLabel
The gain for the voltage (V/div)
Definition: dsowidget.h:86
void setColors()
Definition: dsowidget.cpp:344
double pulseWidth2
Definition: dsowidget.h:112
void updateMarkerDetails()
Update the label about the marker measurements.
Definition: dsowidget.cpp:530
QHBoxLayout * settingsLayout
The table for the settings info.
Definition: dsowidget.h:68
QLabel * swTriggerStatus
The status of SW trigger.
Definition: dsowidget.h:75
std::vector< QLabel *> measurementMiscLabel
Coupling or math mode.
Definition: dsowidget.h:88
Definition: datagrid.h:13
double mainToZoom(double position) const
Translate horizontal position (0..1) from main view to zoom view.
Definition: dsowidget.cpp:985
void setupSliders(Sliders &sliders)
Definition: dsowidget.cpp:422
LevelSlider * triggerLevelSlider
The sliders for the trigger level.
Definition: dsowidget.h:30
std::vector< QLabel *> measurementdBLabel
AC Amplitude in dB.
Definition: dsowidget.h:93
void updateZoom(bool enabled)
Show/hide the zoom view.
Definition: dsowidget.cpp:838
virtual void showEvent(QShowEvent *event)
Definition: dsowidget.cpp:933
void voltageOffsetChanged(ChannelID channel, double value)
A graph offset has been changed.
void updateCursorGrid(bool enabled)
Definition: dsowidget.cpp:391
QLabel * settingsTriggerLabel
The trigger details.
Definition: dsowidget.h:69
void updateTriggerLevel(ChannelID channel, double value)
Handles valueChanged signal from the trigger level slider.
Definition: dsowidget.cpp:1052
double zoomToMain(double position) const
Translate horizontal position (0..1) from zoom view to main view.
Definition: dsowidget.cpp:995
LevelSlider * triggerPositionSlider
The slider for the pretrigger.
Definition: dsowidget.h:29
void updateOffset(ChannelID channel, double value)
Handles valueChanged signal from the offset sliders.
Definition: dsowidget.cpp:951
void updateTriggerSlope()
Handles slopeChanged signal from the trigger dock.
Definition: dsowidget.cpp:760
void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel)
Set the trigger level sliders minimum and maximum to the new values.
Definition: dsowidget.cpp:478
QLabel * markerInfoLabel
The info about the zoom factor.
Definition: dsowidget.h:78
void updateVoltageUsed(ChannelID channel, bool used)
Handles usedChanged signal from the voltage dock.
Definition: dsowidget.cpp:813
void setMeasurementVisible(ChannelID channel)
Show/Hide a line of the measurement table.
Definition: dsowidget.cpp:492
DataGrid * cursorDataGrid
Definition: dsowidget.h:98
void switchToPrintColors()
Definition: dsowidget.cpp:328
Definition: QtAwesome.h:725
LevelSlider * voltageOffsetSlider
The sliders for the graph offsets.
Definition: dsowidget.h:28
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
OpenGL accelerated widget that displays the oscilloscope screen.
Definition: glscope.h:29
LevelSlider * markerSlider
The sliders for the markers.
Definition: dsowidget.h:31
std::vector< QLabel *> measurementVppLabel
Peak-to-peak amplitude of the signal (V)
Definition: dsowidget.h:89
GlScope * zoomScope
The optional magnified scope screen.
Definition: dsowidget.h:105
std::vector< QLabel *> measurementTHDLabel
THD of the signal in Watts.
Definition: dsowidget.h:96
unsigned int dotsOnScreen
Definition: dsowidget.h:110
QLabel * settingsFrequencybaseLabel
The frequencybase of the main scope.
Definition: dsowidget.h:73
Holds all view settings.
Definition: viewsettings.h:35
void showNew(std::shared_ptr< PPresult > analysedData)
Prints analyzed data.
Definition: dsowidget.cpp:858
QLabel * settingsSamplerateLabel
The samplerate.
Definition: dsowidget.h:71
void updateMarker(unsigned marker, double value)
Handles valueChanged signal from the marker slider.
Definition: dsowidget.cpp:1080
QGridLayout * mainLayout
The main layout for this widget.
Definition: dsowidget.h:66
void updateSpectrumDetails(ChannelID channel)
Update the label about the spectrum settings.
Definition: dsowidget.cpp:643
QLabel * settingsSamplesOnScreen
The displayed dots on screen.
Definition: dsowidget.h:70
const Dso::ControlSpecification * spec
Definition: dsowidget.h:102
void triggerLevelChanged(ChannelID channel, double value)
A trigger level has been changed.
void updateRecordLength(unsigned long size)
Change the record length.
Definition: dsowidget.cpp:832
unsigned ChannelID
Definition: types.h:6
Sliders zoomSliders
Definition: dsowidget.h:64
void updateSpectrumUsed(ChannelID channel, bool used)
Handles usedChanged signal from the spectrum dock.
Definition: dsowidget.cpp:737
QGridLayout * measurementLayout
The table for the signal details.
Definition: dsowidget.h:84
QLabel * settingsTimebaseLabel
The timebase of the main scope.
Definition: dsowidget.h:72
void updateSlidersSettings()
Update the sliders settings.
Definition: dsowidget.cpp:1088
DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent=nullptr)
Initializes the components of the oszilloscope-screen.
Definition: dsowidget.cpp:30
Holds the settings for the oscilloscope.
Definition: scopesettings.h:82
void updateVoltageCoupling(ChannelID channel)
Handles couplingChanged signal from the voltage dock.
Definition: dsowidget.cpp:782
std::vector< QLabel *> measurementRMSLabel
RMS Amplitude of the signal (V) = sqrt( DC² + AC² )
Definition: dsowidget.h:90
Analyzes the data from the dso. Calculates the spectrum and various data about the signal and saves t...
Definition: spectrumgenerator.h:24
double pulseWidth1
Definition: dsowidget.h:111
void updateSpectrumMagnitude(ChannelID channel)
Handles magnitudeChanged signal from the spectrum dock.
Definition: dsowidget.cpp:729
void updateSamplerate(double samplerate)
Updates the samplerate field after changing the samplerate.
Definition: dsowidget.cpp:708
std::vector< QLabel *> measurementDCLabel
DC Amplitude of the signal (V)
Definition: dsowidget.h:91
QLabel * markerTimeLabel
The time period between the markers.
Definition: dsowidget.h:79
void updateFrequencybase(double frequencybase)
Handles frequencybaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:700
QHBoxLayout * markerLayout
The table for the marker details.
Definition: dsowidget.h:77
std::vector< QLabel *> measurementNameLabel
The name of the channel.
Definition: dsowidget.h:85
double timebase
Definition: dsowidget.h:109
void updateTriggerSource()
Handles sourceChanged signal from the trigger dock.
Definition: dsowidget.cpp:764