dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
scopegadgetconfiguration.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
32 
39 ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings *qSettings,
40  QObject *parent)
41  : IUAVGadgetConfiguration(classId, parent)
42  , m_scope(nullptr)
43 {
44  // Default for scopes
45  int refreshInterval = 50;
46 
47  // if a saved configuration exists load it
48  if (qSettings != nullptr) {
49 
50  PlotDimensions plotDimensions = (PlotDimensions)qSettings->value("plotDimensions").toInt();
51 
52  switch (plotDimensions) {
53  case PLOT2D:
54  default: {
55  // Start reading new XML block
56  qSettings->beginGroup(QString("plot2d"));
57 
58  Scopes2dConfig::Plot2dType plot2dType =
59  (Scopes2dConfig::Plot2dType)qSettings->value("plot2dType").toUInt();
60  switch (plot2dType) {
62  m_scope = new HistogramScopeConfig(qSettings);
63  break;
64  }
66  default: {
67  m_scope = new Scatterplot2dScopeConfig(qSettings);
68  break;
69  }
70  }
71 
72  // Stop reading XML block
73  qSettings->endGroup();
74 
75  break;
76  }
77  case PLOT3D: {
78  // Start reading new XML block
79  qSettings->beginGroup(QString("plot3d"));
80 
81  Scopes3dConfig::Plot3dType plot3dType =
82  (Scopes3dConfig::Plot3dType)qSettings->value("plot3dType")
83  .toUInt(); //<--TODO: This requires that the enum values be defined at 0,1,...n
84  switch (plot3dType) {
85  default:
87  m_scope = new SpectrogramScopeConfig(qSettings);
88  break;
89  }
90  }
91 
92  // Stop reading XML block
93  qSettings->endGroup();
94 
95  break;
96  }
97  }
98  m_scope->setRefreshInterval(refreshInterval);
99  } else {
100  // Default config is just a simple 2D scatterplot
101  m_scope = new Scatterplot2dScopeConfig();
102  }
103 }
104 
109 void ScopeGadgetConfiguration::applyGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
110 {
111  // Default for scopes
112  int refreshInterval = 50;
113 
114  if (options_page->tabWidget2d3d->currentWidget() == options_page->tabPlot2d) { //--- 2D ---//
115  Scopes2dConfig::Plot2dType plot2dType =
116  (Scopes2dConfig::Plot2dType)options_page->cmb2dPlotType
117  ->itemData(options_page->cmb2dPlotType->currentIndex())
118  .toUInt(); // This is safe because the item data is defined from the enum.
119  switch (plot2dType) {
121  m_scope = new HistogramScopeConfig(options_page);
122  break;
123  }
125  default: {
126  m_scope = new Scatterplot2dScopeConfig(options_page);
127  break;
128  }
129  }
130 
131  } else if (options_page->tabWidget2d3d->currentWidget()
132  == options_page->tabPlot3d) { //--- 3D ---//
133 
134  if (options_page->stackedWidget3dPlots->currentWidget()
135  == options_page->sw3dSpectrogramStack) {
136  m_scope = new SpectrogramScopeConfig(options_page);
137  } else if (options_page->stackedWidget3dPlots->currentWidget()
138  == options_page->sw3dTimeSeriesStack) {
139  }
140  }
141 
142  m_scope->setRefreshInterval(refreshInterval);
143 }
144 
149 {
150 }
151 
156 IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
157 {
159  m->m_scope = this->getScope()->cloneScope(m_scope);
160 
161  return m;
162 }
163 
169 void ScopeGadgetConfiguration::saveConfig(QSettings *qSettings) const
170 {
171  qSettings->setValue("plotDimensions", m_scope->getScopeDimensions());
172  qSettings->setValue("refreshInterval", m_scope->getRefreshInterval());
173 
174  m_scope->saveConfiguration(qSettings);
175 }
The Scatterplot2dScopeConfig class The scatterplot scope configuration.
The SpectrogramScopeConfig class The spectrogram scope configuration.
Plot3dType
The Plot3dType enum Defines the different type of plots.
Plot2dType
The Plot2dType enum Defines the different type of plots.
~ScopeGadgetConfiguration()
ScopeGadgetConfiguration::~ScopeGadgetConfiguration Destructor clears 2D and 3D plot data...
IUAVGadgetConfiguration * clone()
ScopeGadgetConfiguration::clone Clones a configuration.
virtual ScopeConfig * cloneScope(ScopeConfig *histogramSourceConfigs)=0
void setRefreshInterval(int val)
Definition: scopesconfig.h:67
int getRefreshInterval()
Definition: scopesconfig.h:66
The HistogramScopeConfig class The histogram scope configuration.
void applyGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
ScopeGadgetConfiguration::applyGuiConfiguration Uses GUI information to create new scopes...
ScopeGadgetConfiguration(QString classId, QSettings *qSettings=nullptr, QObject *parent=nullptr)
ScopeGadgetConfiguration::ScopeGadgetConfiguration Constructor for scope gadget settings.
virtual void saveConfiguration(QSettings *qSettings)=0
virtual int getScopeDimensions()=0
PlotDimensions
The Plot3dType enum Defines the different type of plots.
Definition: scopesconfig.h:50