OpenHantek
dsowidget.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0+
2 
3 #pragma once
4 
5 #include <QHBoxLayout>
6 #include <QLabel>
7 #include <QList>
8 #include <QGridLayout>
9 #include <memory>
10 
11 #include "glscope.h"
12 #include "levelslider.h"
14 
15 class SpectrumGenerator;
16 struct DsoSettingsScope;
17 struct DsoSettingsView;
18 class DataGrid;
19 
22 class DsoWidget : public QWidget {
23  Q_OBJECT
24 
25  public:
26  struct Sliders {
31  };
32 
38  DsoWidget(DsoSettingsScope* scope, DsoSettingsView* view, const Dso::ControlSpecification* spec, QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr);
39 
40  // Data arrived
41  void showNew(std::shared_ptr<PPresult> analysedData);
42 
43  protected:
44  virtual void showEvent(QShowEvent *event);
48  void setMeasurementVisible(ChannelID channel);
49  void updateMarkerDetails();
50  void updateSpectrumDetails(ChannelID channel);
51  void updateTriggerDetails();
52  void updateVoltageDetails(ChannelID channel);
53 
54  double mainToZoom(double position) const;
55  double zoomToMain(double position) const;
56 
59 
60  QGridLayout *mainLayout;
61 
62  QHBoxLayout *settingsLayout;
68 
69  QLabel *swTriggerStatus;
70 
71  QHBoxLayout *markerLayout;
72  QLabel *markerInfoLabel;
73  QLabel *markerTimeLabel;
77 
78  QGridLayout *measurementLayout;
79  std::vector<QLabel *> measurementNameLabel;
80  std::vector<QLabel *> measurementGainLabel;
81  std::vector<QLabel *> measurementMagnitudeLabel;
82  std::vector<QLabel *> measurementMiscLabel;
83  std::vector<QLabel *> measurementVppLabel;
84  std::vector<QLabel *> measurementRMSLabel;
85  std::vector<QLabel *> measurementDCLabel;
86  std::vector<QLabel *> measurementACLabel;
87  std::vector<QLabel *> measurementdBLabel;
88  std::vector<QLabel *> measurementFrequencyLabel;
89 
91 
95 
98 
99  private:
100  double samplerate;
101  double timebase;
102  unsigned int dotsOnScreen;
103  double pulseWidth1 = 0.0;
104  double pulseWidth2 = 0.0;
105 
106  public slots:
107  // Horizontal axis
108  // void horizontalFormatChanged(HorizontalFormat format);
109  void updateFrequencybase(double frequencybase);
110  void updateSamplerate(double samplerate);
111  void updateTimebase(double timebase);
112 
113  // Trigger
114  void updateTriggerMode();
115  void updateTriggerSlope();
116  void updateTriggerSource();
117 
118  // Spectrum
119  void updateSpectrumMagnitude(ChannelID channel);
120  void updateSpectrumUsed(ChannelID channel, bool used);
121 
122  // Vertical axis
123  void updateVoltageCoupling(ChannelID channel);
124  void updateMathMode();
125  void updateVoltageGain(ChannelID channel);
126  void updateVoltageUsed(ChannelID channel, bool used);
127 
128  // Menus
129  void updateRecordLength(unsigned long size);
130 
131  // Scope control
132  void updateZoom(bool enabled);
133  void updateCursorGrid(bool enabled);
134 
135  // Scope control
136  void updateSlidersSettings();
137 
138  private slots:
139  // Sliders
140  void updateOffset(ChannelID channel, double value);
141  void updateTriggerOffset(int index, double value, bool mainView = true);
142  void updateTriggerLevel(ChannelID channel, double value);
143  void updateMarker( unsigned marker, double value);
144 
145  signals:
146  // Sliders
147  void voltageOffsetChanged (ChannelID channel, double value);
148  void triggerPositionChanged(double value);
149  void triggerLevelChanged(ChannelID channel, double value);
150 };
void triggerPositionChanged(double value)
The pretrigger has been changed.
void updateTriggerMode()
Handles modeChanged signal from the trigger dock.
Definition: dsowidget.cpp:622
Definition: dsowidget.h:26
QLabel * markerFrequencybaseLabel
The frequencybase for the zoomed scope.
Definition: dsowidget.h:76
void updateVoltageGain(ChannelID channel)
Handles gainChanged signal from the voltage dock.
Definition: dsowidget.cpp:660
void updateVoltageDetails(ChannelID channel)
Update the label about the trigger settings.
Definition: dsowidget.cpp:567
GlScope * mainScope
The main scope screen.
Definition: dsowidget.h:96
DsoSettingsView * view
Definition: dsowidget.h:93
void updateMathMode()
Handles modeChanged signal from the voltage dock.
Definition: dsowidget.cpp:653
QLabel * markerTimebaseLabel
The timebase for the zoomed scope.
Definition: dsowidget.h:75
void updateTimebase(double timebase)
Handles timebaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:596
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:22
DsoSettingsScope * scope
Definition: dsowidget.h:92
double samplerate
Definition: dsowidget.h:100
Sliders mainSliders
Definition: dsowidget.h:57
QLabel * markerFrequencyLabel
The frequency for the time period.
Definition: dsowidget.h:74
std::vector< QLabel * > measurementFrequencyLabel
Frequency of the signal (Hz)
Definition: dsowidget.h:88
void updateTriggerDetails()
Update the label about the trigger settings.
Definition: dsowidget.cpp:539
std::vector< QLabel * > measurementRMSLabel
RMS Amplitude of the signal (V) = sqrt( DC² + AC² )
Definition: dsowidget.h:84
std::vector< QLabel * > measurementDCLabel
DC Amplitude of the signal (V)
Definition: dsowidget.h:85
std::vector< QLabel * > measurementGainLabel
The gain for the voltage (V/div)
Definition: dsowidget.h:80
double pulseWidth2
Definition: dsowidget.h:104
void updateMarkerDetails()
Update the label about the marker measurements.
Definition: dsowidget.cpp:424
std::vector< QLabel * > measurementNameLabel
The name of the channel.
Definition: dsowidget.h:79
QHBoxLayout * settingsLayout
The table for the settings info.
Definition: dsowidget.h:62
std::vector< QLabel * > measurementVppLabel
Peak-to-peak amplitude of the signal (V)
Definition: dsowidget.h:83
std::vector< QLabel * > measurementdBLabel
AC Amplitude in dB.
Definition: dsowidget.h:87
QLabel * swTriggerStatus
The status of SW trigger.
Definition: dsowidget.h:69
Definition: datagrid.h:13
double mainToZoom(double position) const
Translate horizontal position (0..1) from main view to zoom view.
Definition: dsowidget.cpp:810
void setupSliders(Sliders &sliders)
Definition: dsowidget.cpp:327
LevelSlider * triggerLevelSlider
The sliders for the trigger level.
Definition: dsowidget.h:29
void updateZoom(bool enabled)
Show/hide the zoom view.
Definition: dsowidget.cpp:695
virtual void showEvent(QShowEvent *event)
Definition: dsowidget.cpp:767
LevelSlider * triggerOffsetSlider
The slider for the pretrigger.
Definition: dsowidget.h:28
void voltageOffsetChanged(ChannelID channel, double value)
A graph offset has been changed.
void updateCursorGrid(bool enabled)
Definition: dsowidget.cpp:297
DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent=nullptr, Qt::WindowFlags flags=nullptr)
Initializes the components of the oszilloscope-screen.
Definition: dsowidget.cpp:29
QLabel * settingsTriggerLabel
The trigger details.
Definition: dsowidget.h:63
void updateTriggerLevel(ChannelID channel, double value)
Handles valueChanged signal from the trigger level slider.
Definition: dsowidget.cpp:869
double zoomToMain(double position) const
Translate horizontal position (0..1) from zoom view to main view.
Definition: dsowidget.cpp:818
void updateOffset(ChannelID channel, double value)
Handles valueChanged signal from the offset sliders.
Definition: dsowidget.cpp:784
void adaptTriggerOffsetSlider()
Handles signals affecting trigger position in the zoom view.
Definition: dsowidget.cpp:826
void updateTriggerSlope()
Handles slopeChanged signal from the trigger dock.
Definition: dsowidget.cpp:625
void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel)
Set the trigger level sliders minimum and maximum to the new values.
Definition: dsowidget.cpp:380
QLabel * markerInfoLabel
The info about the zoom factor.
Definition: dsowidget.h:72
void updateVoltageUsed(ChannelID channel, bool used)
Handles usedChanged signal from the voltage dock.
Definition: dsowidget.cpp:673
void setMeasurementVisible(ChannelID channel)
Show/Hide a line of the measurement table.
Definition: dsowidget.cpp:393
std::vector< QLabel * > measurementMiscLabel
Coupling or math mode.
Definition: dsowidget.h:82
DataGrid * cursorDataGrid
Definition: dsowidget.h:90
Definition: QtAwesome.h:619
std::vector< QLabel * > measurementMagnitudeLabel
The magnitude for the spectrum (dB/div)
Definition: dsowidget.h:81
LevelSlider * voltageOffsetSlider
The sliders for the graph offsets.
Definition: dsowidget.h:27
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
OpenGL accelerated widget that displays the oscilloscope screen.
Definition: glscope.h:25
LevelSlider * markerSlider
The sliders for the markers.
Definition: dsowidget.h:30
GlScope * zoomScope
The optional magnified scope screen.
Definition: dsowidget.h:97
unsigned int dotsOnScreen
Definition: dsowidget.h:102
QLabel * settingsFrequencybaseLabel
The frequencybase of the main scope.
Definition: dsowidget.h:67
Holds all view settings.
Definition: viewsettings.h:30
void showNew(std::shared_ptr< PPresult > analysedData)
Prints analyzed data.
Definition: dsowidget.cpp:720
QLabel * settingsSamplerateLabel
The samplerate.
Definition: dsowidget.h:65
void updateMarker(unsigned marker, double value)
Handles valueChanged signal from the marker slider.
Definition: dsowidget.cpp:890
QGridLayout * mainLayout
The main layout for this widget.
Definition: dsowidget.h:60
void updateSpectrumDetails(ChannelID channel)
Update the label about the trigger settings.
Definition: dsowidget.cpp:528
QLabel * settingsSamplesOnScreen
The displayed dots on screen.
Definition: dsowidget.h:64
const Dso::ControlSpecification * spec
Definition: dsowidget.h:94
void triggerLevelChanged(ChannelID channel, double value)
A trigger level has been changed.
void updateRecordLength(unsigned long size)
Change the record length.
Definition: dsowidget.cpp:690
unsigned ChannelID
Definition: types.h:6
Sliders zoomSliders
Definition: dsowidget.h:58
void updateSpectrumUsed(ChannelID channel, bool used)
Handles usedChanged signal from the spectrum dock.
Definition: dsowidget.cpp:611
QGridLayout * measurementLayout
The table for the signal details.
Definition: dsowidget.h:78
void updateTriggerOffset(int index, double value, bool mainView=true)
Handles valueChanged signal from the triggerPosition slider.
Definition: dsowidget.cpp:848
QLabel * settingsTimebaseLabel
The timebase of the main scope.
Definition: dsowidget.h:66
void updateSlidersSettings()
Update the sliders settings.
Definition: dsowidget.cpp:897
Holds the settings for the oscilloscope.
Definition: scopesettings.h:75
void updateVoltageCoupling(ChannelID channel)
Handles couplingChanged signal from the voltage dock.
Definition: dsowidget.cpp:646
std::vector< QLabel * > measurementACLabel
AC Amplitude of the signal (V)
Definition: dsowidget.h:86
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:103
void updateSpectrumMagnitude(ChannelID channel)
Handles magnitudeChanged signal from the spectrum dock.
Definition: dsowidget.cpp:606
void updateSamplerate(double samplerate)
Updates the samplerate field after changing the samplerate.
Definition: dsowidget.cpp:587
QLabel * markerTimeLabel
The time period between the markers.
Definition: dsowidget.h:73
void updateFrequencybase(double frequencybase)
Handles frequencybaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:580
QHBoxLayout * markerLayout
The table for the marker details.
Definition: dsowidget.h:71
double timebase
Definition: dsowidget.h:101
void updateTriggerSource()
Handles sourceChanged signal from the trigger dock.
Definition: dsowidget.cpp:628