OpenHantek
dsowidget.h
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"
13 #include "hantekdso/controlspecification.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 
27  struct Sliders {
32  };
33 
39  DsoWidget(DsoSettingsScope* scope, DsoSettingsView* view, const Dso::ControlSpecification* spec, QWidget *parent = 0, Qt::WindowFlags flags = 0);
40 
41  // Data arrived
42  void showNew(std::shared_ptr<PPresult> data);
43 
44  protected:
45  virtual void showEvent(QShowEvent *event);
46  void setupSliders(Sliders &sliders);
47  void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel);
49  void setMeasurementVisible(ChannelID channel);
50  void updateMarkerDetails();
51  void updateSpectrumDetails(ChannelID channel);
52  void updateTriggerDetails();
53  void updateVoltageDetails(ChannelID channel);
54 
55  double mainToZoom(double position) const;
56  double zoomToMain(double position) const;
57 
58  Sliders mainSliders;
59  Sliders zoomSliders;
60 
61  QGridLayout *mainLayout;
62 
63  QHBoxLayout *settingsLayout;
69 
70  QLabel *swTriggerStatus;
71 
72  QHBoxLayout *markerLayout;
73  QLabel *markerInfoLabel;
74  QLabel *markerTimeLabel;
78 
79  QGridLayout *measurementLayout;
80  std::vector<QLabel *> measurementNameLabel;
81  std::vector<QLabel *> measurementGainLabel;
82  std::vector<QLabel *> measurementMagnitudeLabel;
83  std::vector<QLabel *> measurementMiscLabel;
84  std::vector<QLabel *> measurementAmplitudeLabel;
85  std::vector<QLabel *> measurementFrequencyLabel;
86 
87  DataGrid *cursorDataGrid;
88 
89  DsoSettingsScope* scope;
90  DsoSettingsView* view;
91  const Dso::ControlSpecification* spec;
92 
95 
96  public slots:
97  // Horizontal axis
98  // void horizontalFormatChanged(HorizontalFormat format);
99  void updateFrequencybase(double frequencybase);
100  void updateSamplerate(double samplerate);
101  void updateTimebase(double timebase);
102 
103  // Trigger
104  void updateTriggerMode();
105  void updateTriggerSlope();
106  void updateTriggerSource();
107 
108  // Spectrum
109  void updateSpectrumMagnitude(ChannelID channel);
110  void updateSpectrumUsed(ChannelID channel, bool used);
111 
112  // Vertical axis
113  void updateVoltageCoupling(ChannelID channel);
114  void updateMathMode();
115  void updateVoltageGain(ChannelID channel);
116  void updateVoltageUsed(ChannelID channel, bool used);
117 
118  // Menus
119  void updateRecordLength(unsigned long size);
120 
121  // Scope control
122  void updateZoom(bool enabled);
123  void updateCursorGrid(bool enabled);
124 
125  private slots:
126  // Sliders
127  void updateOffset(ChannelID channel, double value);
128  void updateTriggerPosition(int index, double value, bool mainView = true);
129  void updateTriggerLevel(ChannelID channel, double value);
130  void updateMarker(int marker, double value);
131 
132  signals:
133  // Sliders
134  void offsetChanged(ChannelID channel, double value);
135  void triggerPositionChanged(double value);
136  void triggerLevelChanged(ChannelID channel, double value);
137 };
void triggerPositionChanged(double value)
The pretrigger has been changed.
void updateTriggerMode()
Handles modeChanged signal from the trigger dock.
Definition: dsowidget.cpp:514
Definition: dsowidget.h:27
QLabel * markerFrequencybaseLabel
The frequencybase for the zoomed scope.
Definition: dsowidget.h:77
void updateVoltageGain(ChannelID channel)
Handles gainChanged signal from the voltage dock.
Definition: dsowidget.cpp:557
void updateVoltageDetails(ChannelID channel)
Update the label about the trigger settings.
Definition: dsowidget.cpp:463
GlScope * mainScope
The main scope screen.
Definition: dsowidget.h:93
void updateMathMode()
Handles modeChanged signal from the voltage dock.
Definition: dsowidget.cpp:550
void adaptTriggerPositionSlider()
Handles signals affecting trigger position in the zoom view.
Definition: dsowidget.cpp:703
QLabel * markerTimebaseLabel
The timebase for the zoomed scope.
Definition: dsowidget.h:76
void showNew(std::shared_ptr< PPresult > data)
Prints analyzed data.
Definition: dsowidget.cpp:618
void updateTimebase(double timebase)
Handles timebaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:488
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
QLabel * markerFrequencyLabel
The frequency for the time period.
Definition: dsowidget.h:75
std::vector< QLabel * > measurementFrequencyLabel
Frequency of the signal (Hz)
Definition: dsowidget.h:85
void updateTriggerDetails()
Update the label about the trigger settings.
Definition: dsowidget.cpp:448
LevelSlider * offsetSlider
The sliders for the graph offsets.
Definition: dsowidget.h:28
std::vector< QLabel * > measurementGainLabel
The gain for the voltage (V/div)
Definition: dsowidget.h:81
DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::ControlSpecification *spec, QWidget *parent=0, Qt::WindowFlags flags=0)
Initializes the components of the oszilloscope-screen.
Definition: dsowidget.cpp:29
void updateMarkerDetails()
Update the label about the marker measurements.
Definition: dsowidget.cpp:389
std::vector< QLabel * > measurementNameLabel
The name of the channel.
Definition: dsowidget.h:80
QHBoxLayout * settingsLayout
The table for the settings info.
Definition: dsowidget.h:63
QLabel * swTriggerStatus
The status of SW trigger.
Definition: dsowidget.h:70
Definition: datagrid.h:13
double mainToZoom(double position) const
Translate horizontal position (0..1) from main view to zoom view.
Definition: dsowidget.cpp:687
LevelSlider * triggerLevelSlider
The sliders for the trigger level.
Definition: dsowidget.h:30
void updateZoom(bool enabled)
Show/hide the zoom view.
Definition: dsowidget.cpp:593
QLabel * settingsTriggerLabel
The trigger details.
Definition: dsowidget.h:64
double zoomToMain(double position) const
Translate horizontal position (0..1) from zoom view to main view.
Definition: dsowidget.cpp:695
LevelSlider * triggerPositionSlider
The slider for the pretrigger.
Definition: dsowidget.h:29
void updateTriggerSlope()
Handles slopeChanged signal from the trigger dock.
Definition: dsowidget.cpp:517
void adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel)
Set the trigger level sliders minimum and maximum to the new values.
Definition: dsowidget.cpp:342
QLabel * markerInfoLabel
The info about the zoom factor.
Definition: dsowidget.h:73
void updateVoltageUsed(ChannelID channel, bool used)
Handles usedChanged signal from the voltage dock.
Definition: dsowidget.cpp:571
void setMeasurementVisible(ChannelID channel)
Show/Hide a line of the measurement table.
Definition: dsowidget.cpp:350
std::vector< QLabel * > measurementMiscLabel
Coupling or math mode.
Definition: dsowidget.h:83
std::vector< QLabel * > measurementMagnitudeLabel
The magnitude for the spectrum (dB/div)
Definition: dsowidget.h:82
Stores the specifications of the currently connected device.
Definition: controlspecification.h:47
OpenGL accelerated widget that displays the oscilloscope screen.
Definition: glscope.h:25
LevelSlider * markerSlider
The sliders for the markers.
Definition: dsowidget.h:31
GlScope * zoomScope
The optional magnified scope screen.
Definition: dsowidget.h:94
void offsetChanged(ChannelID channel, double value)
A graph offset has been changed.
QLabel * settingsFrequencybaseLabel
The frequencybase of the main scope.
Definition: dsowidget.h:68
Holds all view settings.
Definition: viewsettings.h:30
QLabel * settingsSamplerateLabel
The samplerate.
Definition: dsowidget.h:66
QGridLayout * mainLayout
The main layout for this widget.
Definition: dsowidget.h:61
void updateSpectrumDetails(ChannelID channel)
Update the label about the trigger settings.
Definition: dsowidget.cpp:437
std::vector< QLabel * > measurementAmplitudeLabel
Amplitude of the signal (V)
Definition: dsowidget.h:84
void triggerLevelChanged(ChannelID channel, double value)
A trigger level has been changed.
void updateRecordLength(unsigned long size)
Change the record length.
Definition: dsowidget.cpp:588
QLabel * settingsRecordLengthLabel
The record length.
Definition: dsowidget.h:65
void updateSpectrumUsed(ChannelID channel, bool used)
Handles usedChanged signal from the spectrum dock.
Definition: dsowidget.cpp:501
QGridLayout * measurementLayout
The table for the signal details.
Definition: dsowidget.h:79
QLabel * settingsTimebaseLabel
The timebase of the main scope.
Definition: dsowidget.h:67
Holds the settings for the oscilloscope.
Definition: scopesettings.h:77
void updateVoltageCoupling(ChannelID channel)
Handles couplingChanged signal from the voltage dock.
Definition: dsowidget.cpp:543
Analyzes the data from the dso. Calculates the spectrum and various data about the signal and saves t...
Definition: spectrumgenerator.h:24
void updateSpectrumMagnitude(ChannelID channel)
Handles magnitudeChanged signal from the spectrum dock.
Definition: dsowidget.cpp:496
void updateSamplerate(double samplerate)
Updates the samplerate field after changing the samplerate.
Definition: dsowidget.cpp:482
QLabel * markerTimeLabel
The time period between the markers.
Definition: dsowidget.h:74
void updateFrequencybase(double frequencybase)
Handles frequencybaseChanged signal from the horizontal dock.
Definition: dsowidget.cpp:476
QHBoxLayout * markerLayout
The table for the marker details.
Definition: dsowidget.h:72
void updateTriggerSource()
Handles sourceChanged signal from the trigger dock.
Definition: dsowidget.cpp:520