dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
scopegadgetoptionspage.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 
28 #include "scopegadgetoptionspage.h"
29 
30 #include <coreplugin/icore.h>
34 
35 #include "vibrationanalysissettings.h"
36 #include "vibrationanalysisoutput.h"
37 
41 
42 #include <qpalette.h>
43 #include <QMessageBox>
44 #include <QMainWindow>
45 
47  : IOptionsPage(parent)
48  , m_config(config)
49  , selectedItem(nullptr)
50 {
51  // nothing to do here...
52 }
53 
59 QWidget *ScopeGadgetOptionsPage::createPage(QWidget *parent)
60 {
61  Q_UNUSED(parent);
62 
63  // main widget
64  QWidget *optionsPageWidget = new QWidget;
65 
66  // Generate UI layout
67  options_page = new Ui::ScopeGadgetOptionsPage();
68  options_page->setupUi(optionsPageWidget);
69 
70  // Set up 2D plots tab
71  options_page->cmb2dPlotType->addItem("Scatter plot", Scopes2dConfig::SCATTERPLOT2D);
72  options_page->cmb2dPlotType->addItem("Histogram", Scopes2dConfig::HISTOGRAM);
73 
74  // Set up x-axis combo box
75  options_page->cmbXAxisScatterplot2d->addItem("Series", Scatterplot2dScopeConfig::SERIES2D);
76  options_page->cmbXAxisScatterplot2d->addItem("Time series",
78 
79  // Set up 3D plots tab
80  options_page->cmb3dPlotType->addItem("Spectrogram", Scopes3dConfig::SPECTROGRAM);
81 
82  options_page->cmbSpectrogramSource->addItem("Custom",
84  options_page->cmbSpectrogramSource->addItem("Vibration Analysis",
86 
87  // Populate colormap combobox.
88  options_page->cmbColorMapSpectrogram->addItem("Standard", ColorMap::STANDARD);
89  options_page->cmbColorMapSpectrogram->addItem("Jet", ColorMap::JET);
90 
91  // Fills the combo boxes for the UAVObjects
92  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
93  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
94  QVector<QVector<UAVDataObject *>> objList = objManager->getDataObjectsVector();
95  QStringList toAdd;
96 
97  QString previous = NULL;
98 
99  foreach (QVector<UAVDataObject *> list, objList) {
100  foreach (UAVDataObject *obj, list) {
101  QString name = obj->getName();
102 
103  if (obj->isSingleInstance()) {
104  toAdd.append(name);
105  } else if (name != previous) { // Checks to see if we're duplicating UAVOs because of
106  // multiple instances
107  toAdd.append(name);
108  }
109 
110  previous = name;
111  }
112  }
113 
114  std::sort(toAdd.begin(), toAdd.end());
115 
116  foreach (QString elem, toAdd) {
117  // Before we only added items to the spectrogram if they were not
118  // single instance; assuming that was in error
119  options_page->cmbUAVObjects->addItem(elem);
120  options_page->cmbUAVObjectsSpectrogram->addItem(elem);
121  }
122 
123  QStringList mathFunctions;
124  mathFunctions << "None"
125  << "Boxcar average"
126  << "Standard deviation"
127  << "FFT";
128 
129  options_page->mathFunctionComboBox->addItems(mathFunctions);
130  options_page->cmbMathFunctionSpectrogram->addItems(mathFunctions);
131 
132  // Check that an index is currently selected, and update if true
133  if (options_page->cmbUAVObjects->currentIndex() >= 0) {
134  on_cmbUAVObjects_currentIndexChanged(options_page->cmbUAVObjects->currentText());
135  }
136 
137  // Add scaling items
138  options_page->cmbScale->addItem("10^-9", -9);
139  options_page->cmbScale->addItem("10^-6", -6);
140  options_page->cmbScale->addItem("10^-5", -5);
141  options_page->cmbScale->addItem("10^-4", -4);
142  options_page->cmbScale->addItem("10^-3", -3);
143  options_page->cmbScale->addItem(".01", -2);
144  options_page->cmbScale->addItem(".1", -1);
145  options_page->cmbScale->addItem("1", 0);
146  options_page->cmbScale->addItem("10", 1);
147  options_page->cmbScale->addItem("100", 2);
148  options_page->cmbScale->addItem("10^3", 3);
149  options_page->cmbScale->addItem("10^4", 4);
150  options_page->cmbScale->addItem("10^5", 5);
151  options_page->cmbScale->addItem("10^6", 6);
152  options_page->cmbScale->addItem("10^9", 9);
153  options_page->cmbScale->addItem("10^12", 12);
154 
155  // Set default scaling to 10^0
156  options_page->cmbScale->setCurrentIndex(options_page->cmbScale->findData(0));
157 
158  // Configure color button
159  options_page->btnColor->setAutoFillBackground(true);
160 
161  // Generate style sheet for data sources list
162  dataSourceStyleSheetTemplate = "QListView::item:selected {border: 2px solid white; background: "
163  "rgba(255,255,255,50); selection-color: rgba(%1,%2,%3,255) }";
164 
165  // Connect signals to slots
166  connect(options_page->cmbXAxisScatterplot2d,
167  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
168  &ScopeGadgetOptionsPage::on_cmbXAxisScatterplot2d_currentIndexChanged);
169  connect(options_page->cmb2dPlotType,
170  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
171  &ScopeGadgetOptionsPage::on_cmb2dPlotType_currentIndexChanged);
172  connect(options_page->cmb3dPlotType,
173  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
174  &ScopeGadgetOptionsPage::on_cmb3dPlotType_currentIndexChanged);
175  connect(options_page->cmbUAVObjects,
176  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
177  &ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged);
178  connect(options_page->cmbUAVObjectsSpectrogram,
179  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
180  &ScopeGadgetOptionsPage::on_cmbUAVObjectsSpectrogram_currentIndexChanged);
181  connect(options_page->btnAdd2dCurve, &QAbstractButton::clicked, this,
182  &ScopeGadgetOptionsPage::on_btnAdd2dCurve_clicked);
183  connect(options_page->btnApply2dCurve, &QAbstractButton::clicked, this,
184  &ScopeGadgetOptionsPage::on_btnApply2dCurve_clicked);
185  connect(options_page->btnRemove2dCurve, &QAbstractButton::clicked, this,
186  &ScopeGadgetOptionsPage::on_btnRemove2dCurve_clicked);
187  connect(options_page->lst2dCurves, &QListWidget::currentRowChanged, this,
188  &ScopeGadgetOptionsPage::on_lst2dCurves_currentRowChanged);
189  connect(options_page->btnColor, &QAbstractButton::clicked, this,
190  &ScopeGadgetOptionsPage::on_btnColor_clicked);
191  connect(options_page->mathFunctionComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
192  this, &ScopeGadgetOptionsPage::on_mathFunctionComboBox_currentIndexChanged);
193  connect(options_page->cmbSpectrogramSource,
194  QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this,
195  &ScopeGadgetOptionsPage::on_cmbSpectrogramSource_currentIndexChanged);
196  connect(options_page->lst2dCurves, &QListWidget::itemClicked, this,
197  &ScopeGadgetOptionsPage::on_lst2dItem_clicked);
198 
199  // Configuration the GUI elements to reflect the scope settings
200  if (m_config)
201  m_config->getScope()->setGuiConfiguration(options_page);
202 
203  // Cascading update on the UI elements
204  emit on_cmb2dPlotType_currentIndexChanged(options_page->cmb2dPlotType->currentText());
205  emit on_cmb3dPlotType_currentIndexChanged(options_page->cmb3dPlotType->currentText());
206  emit on_cmbUAVObjectsSpectrogram_currentIndexChanged(
207  options_page->cmbUAVObjectsSpectrogram->currentText());
208 
209  // Disable mouse wheel events //TODO: DOES NOT WORK
210  foreach (QSpinBox *sp, findChildren<QSpinBox *>()) {
211  sp->installEventFilter(this);
212  }
213  foreach (QDoubleSpinBox *sp, findChildren<QDoubleSpinBox *>()) {
214  sp->installEventFilter(this);
215  }
216  foreach (QSlider *sp, findChildren<QSlider *>()) {
217  sp->installEventFilter(this);
218  }
219  foreach (QComboBox *sp, findChildren<QComboBox *>()) {
220  sp->installEventFilter(this);
221  }
222 
223  return optionsPageWidget;
224 }
225 
232 bool ScopeGadgetOptionsPage::eventFilter(QObject *obj, QEvent *evt)
233 {
234  // Filter all wheel events, and ignore them
235  if (evt->type() == QEvent::Wheel
236  && (qobject_cast<QAbstractSpinBox *>(obj) || qobject_cast<QComboBox *>(obj)
237  || qobject_cast<QAbstractSlider *>(obj))) {
238  evt->ignore();
239  return true;
240  }
241  return ScopeGadgetOptionsPage::eventFilter(obj, evt);
242 }
243 
244 void ScopeGadgetOptionsPage::on_mathFunctionComboBox_currentIndexChanged(int currentIndex)
245 {
246  if (currentIndex > 0) {
247  options_page->spnMeanSamples->setEnabled(true);
248  } else {
249  options_page->spnMeanSamples->setEnabled(false);
250  }
251 }
252 
258 void ScopeGadgetOptionsPage::on_cmbSpectrogramSource_currentIndexChanged(QString currentText)
259 {
260  if (currentText
261  == options_page->cmbSpectrogramSource->itemText(
262  options_page->cmbSpectrogramSource->findData(
264  int vibrationTestIdx =
265  options_page->cmbUAVObjectsSpectrogram->findText("VibrationTestOutput");
266  options_page->cmbUAVObjectsSpectrogram->setCurrentIndex(vibrationTestIdx);
267  options_page->cmbUAVObjectsSpectrogram->setEnabled(false);
268 
269  // Load UAVO
270  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
271  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
272  VibrationAnalysisOutput *vibrationAnalysisOutput =
273  VibrationAnalysisOutput::GetInstance(objManager);
274  VibrationAnalysisSettings *vibrationAnalysisSettings =
275  VibrationAnalysisSettings::GetInstance(objManager);
276  VibrationAnalysisSettings::DataFields vibrationAnalysisSettingsData =
277  vibrationAnalysisSettings->getData();
278 
279  // Set combobox field to UAVO name
280  options_page->cmbUAVObjectsSpectrogram->setCurrentIndex(
281  options_page->cmbUAVObjectsSpectrogram->findText(vibrationAnalysisOutput->getName()));
282  // Get the window size
283  int fftWindowSize;
284  switch (vibrationAnalysisSettingsData.FFTWindowSize) {
285  default:
286  case VibrationAnalysisSettings::FFTWINDOWSIZE_16:
287  fftWindowSize = 16;
288  break;
289  case VibrationAnalysisSettings::FFTWINDOWSIZE_64:
290  fftWindowSize = 64;
291  break;
292  case VibrationAnalysisSettings::FFTWINDOWSIZE_256:
293  fftWindowSize = 256;
294  break;
295  case VibrationAnalysisSettings::FFTWINDOWSIZE_1024:
296  fftWindowSize = 1024;
297  break;
298  }
299 
300  // Set spinbox range before setting value
301  options_page->sbSpectrogramWidth->setRange(0, fftWindowSize / 2);
302 
303  // Set values to UAVO
304  options_page->sbSpectrogramWidth->setValue(fftWindowSize / 2);
305  options_page->sbSpectrogramFrequency->setValue(
306  1000.0f / vibrationAnalysisSettingsData.SampleRate); // Sample rate is in ms
307 
308  options_page->sbSpectrogramFrequency->setEnabled(false);
309  options_page->sbSpectrogramWidth->setEnabled(false);
310 
311  options_page->cmbUavoFieldSpectrogram->clear();
312 
313  UAVObject *inst = objManager->getObject(vibrationAnalysisOutput->getObjID());
314 
315  QList<UAVObjectField *> fieldList = inst->getFields();
316 
317  foreach (UAVObjectField *field, fieldList) {
318  if (field->getType() == UAVObjectField::STRING
319  || field->getType() == UAVObjectField::ENUM)
320  continue;
321 
322  if (field->getElementNames().count() > 1) {
323  options_page->cmbUavoFieldSpectrogram->addItem(field->getName());
324  }
325  }
326 
327  } else {
328  options_page->cmbUAVObjectsSpectrogram->setEnabled(true);
329  }
330 }
331 
336 void ScopeGadgetOptionsPage::on_btnColor_clicked()
337 {
338  QColor color = QColorDialog::getColor(QColor(options_page->btnColor->text()));
339  if (color.isValid()) {
340  setButtonColor(color);
341  }
342 }
343 
348 void ScopeGadgetOptionsPage::set2dYAxisWidgetFromDataSource()
349 {
350  bool parseOK = false;
351  QListWidgetItem *listItem = options_page->lst2dCurves->currentItem();
352 
353  if (listItem == nullptr)
354  return;
355 
356  // Fetch data from teh listItem. The data is stored by user role + offset
357  int currentIndex = options_page->cmbUAVObjects->findText(
358  listItem->data(Qt::UserRole + UR_UAVOBJECT).toString());
359  options_page->cmbUAVObjects->setCurrentIndex(currentIndex);
360 
361  currentIndex =
362  options_page->cmbUAVField->findText(listItem->data(Qt::UserRole + UR_UAVFIELD).toString());
363  options_page->cmbUAVField->setCurrentIndex(currentIndex);
364 
365  currentIndex = options_page->cmbScale->findData(listItem->data(Qt::UserRole + UR_SCALE),
366  Qt::UserRole, Qt::MatchExactly);
367  options_page->cmbScale->setCurrentIndex(currentIndex);
368 
369  // Get graph color
370  QVariant varColor = listItem->data(Qt::UserRole + UR_COLOR);
371  int rgb = varColor.toInt(&parseOK);
372  if (!parseOK)
373  rgb = QColor(Qt::red).rgb();
374 
375  // Set button color
376  setButtonColor(QColor((QRgb)rgb));
377 
378  // Set selected color
379  QString styleSheet = dataSourceStyleSheetTemplate.arg(QColor((QRgb)rgb).red())
380  .arg(QColor((QRgb)rgb).green())
381  .arg(QColor((QRgb)rgb).blue());
382  options_page->lst2dCurves->setStyleSheet(styleSheet);
383 
384  unsigned int mean = listItem->data(Qt::UserRole + UR_MEAN).toUInt(&parseOK);
385  if (!parseOK)
386  mean = 1;
387  options_page->spnMeanSamples->setValue(mean);
388 
389  currentIndex = options_page->mathFunctionComboBox->findText(
390  listItem->data(Qt::UserRole + UR_MATHFUNCTION).toString());
391  options_page->mathFunctionComboBox->setCurrentIndex(currentIndex);
392 }
393 
399 void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
400 {
401  // TODO: Understand why this doesn't work when starting a new page. It only works when
402  // physically clicking on the button
403  options_page->btnColor->setText(color.name());
404  options_page->btnColor->setPalette(QPalette(color));
405 }
406 
412 void ScopeGadgetOptionsPage::on_cmbUAVObjects_currentIndexChanged(QString val)
413 {
414  options_page->cmbUAVField->clear();
415 
416  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
417  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
418  UAVDataObject *objData = dynamic_cast<UAVDataObject *>(objManager->getObject(val));
419 
420  if (objData == NULL)
421  return;
422 
423  QList<UAVObjectField *> fieldList = objData->getFields();
424  foreach (UAVObjectField *field, fieldList) {
425  if (field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM)
426  continue;
427 
428  if (field->getElementNames().count() > 1) {
429  foreach (QString elemName, field->getElementNames()) {
430  options_page->cmbUAVField->addItem(field->getName() + "-" + elemName);
431  }
432  } else
433  options_page->cmbUAVField->addItem(field->getName());
434  }
435 }
436 
443 void ScopeGadgetOptionsPage::on_cmbUAVObjectsSpectrogram_currentIndexChanged(QString val)
444 {
445  options_page->cmbUavoFieldSpectrogram->clear();
446 
447  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
448  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
449  UAVDataObject *objData = dynamic_cast<UAVDataObject *>(objManager->getObject(val));
450 
451  if (objData == NULL)
452  return;
453 
454  QList<UAVObjectField *> fieldList = objData->getFields();
455  foreach (UAVObjectField *field, fieldList) {
456 
457  if (field->getType() == UAVObjectField::STRING || field->getType() == UAVObjectField::ENUM)
458  continue;
459 
460  if (field->getElementNames().count() > 1) {
461  foreach (QString elemName, field->getElementNames()) {
462  options_page->cmbUavoFieldSpectrogram->addItem(field->getName() + "-" + elemName);
463  }
464  } else
465  options_page->cmbUavoFieldSpectrogram->addItem(field->getName());
466  }
467 
468  // Get range from UAVO name
469  unsigned int maxWidth = objManager->getNumInstances(objData->getObjID());
470  options_page->sbSpectrogramWidth->setRange(0, maxWidth);
471  options_page->sbSpectrogramWidth->setValue(maxWidth);
472 }
473 
479 {
480  // The GUI settings are read by the appropriate subclass
481  if (m_config)
482  m_config->applyGuiConfiguration(options_page);
483 }
484 
488 void ScopeGadgetOptionsPage::on_btnAdd2dCurve_clicked()
489 {
490  bool parseOK = false;
491  QString uavObject = options_page->cmbUAVObjects->currentText();
492  QString uavField = options_page->cmbUAVField->currentText();
493  int scale =
494  options_page->cmbScale->itemData(options_page->cmbScale->currentIndex()).toInt(&parseOK);
495 
496  if (!parseOK)
497  scale = 0;
498 
499  unsigned int mean = options_page->spnMeanSamples->value();
500  QString mathFunction = options_page->mathFunctionComboBox->currentText();
501 
502  QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
503 
504  // Add curve
505  addPlot2dCurveConfig(uavObject, uavField, scale, mean, mathFunction, varColor);
506 }
507 
511 void ScopeGadgetOptionsPage::on_btnApply2dCurve_clicked()
512 {
513  bool parseOK = false;
514  QString uavObjectName = options_page->cmbUAVObjects->currentText();
515  QString uavFieldName = options_page->cmbUAVField->currentText();
516  int scale =
517  options_page->cmbScale->itemData(options_page->cmbScale->currentIndex()).toInt(&parseOK);
518 
519  if (!parseOK)
520  scale = 0;
521 
522  unsigned int mean = options_page->spnMeanSamples->value();
523  QString mathFunction = options_page->mathFunctionComboBox->currentText();
524 
525  QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
526 
527  // Apply curve settings
528  QListWidgetItem *listWidgetItem = options_page->lst2dCurves->currentItem();
529  if (listWidgetItem == NULL) {
530  QMessageBox msgBox(dynamic_cast<QWidget *>(Core::ICore::instance()->mainWindow()));
531  msgBox.setText(tr("No curve selected."));
532  msgBox.setInformativeText(tr("Please select a curve or generate one with the "
533  "+"
534  " symbol."));
535  msgBox.setStandardButtons(QMessageBox::Ok);
536  msgBox.exec();
537 
538  return;
539  }
540 
541  qDebug() << uavObjectName << " " << uavFieldName << " " << scale << " " << mean << " "
542  << mathFunction << " " << varColor << " ";
543 
544  setPlot2dCurveProperties(listWidgetItem, uavObjectName, uavFieldName, scale, mean, mathFunction,
545  varColor);
546 }
547 
551 void ScopeGadgetOptionsPage::on_btnRemove2dCurve_clicked()
552 {
553  options_page->lst2dCurves->takeItem(options_page->lst2dCurves->currentIndex().row());
554 }
555 
565 void ScopeGadgetOptionsPage::addPlot2dCurveConfig(QString uavObjectName, QString uavFieldName,
566  int scale, unsigned int mean,
567  QString mathFunction, QVariant varColor)
568 {
569  QString listItemDisplayText = uavObjectName + "." + uavFieldName; // Generate the name
570  options_page->lst2dCurves->addItem(listItemDisplayText); // Add the name to the list
571  int itemIdx = options_page->lst2dCurves->count() - 1; // Get the index number for the new value
572  QListWidgetItem *listWidgetItem =
573  options_page->lst2dCurves->item(itemIdx); // Find the widget item
574 
575  // Apply all settings to curve
576  setPlot2dCurveProperties(listWidgetItem, uavObjectName, uavFieldName, scale, mean, mathFunction,
577  varColor);
578 
579  // Select the row with the new name
580  options_page->lst2dCurves->setCurrentRow(itemIdx);
581 }
582 
595 void ScopeGadgetOptionsPage::setPlot2dCurveProperties(QListWidgetItem *listWidgetItem,
596  QString uavObject, QString uavField,
597  int scale, unsigned int mean,
598  QString mathFunction, QVariant varColor)
599 {
600  bool parseOK = false;
601  QString listItemDisplayText;
602  QRgb rgbColor;
603 
604  if (uavObject != "") {
605  // Set the properties of the newly added list item
606  listItemDisplayText = uavObject + "." + uavField;
607  rgbColor = (QRgb)varColor.toInt(&parseOK);
608  if (!parseOK)
609  rgbColor = qRgb(255, 0, 0);
610  } else {
611  listItemDisplayText = "New graph";
612  rgbColor = qRgb(255, 0, 0);
613  }
614 
615  // Set text
616  listWidgetItem->setText(listItemDisplayText);
617 
618  // Set selected color. Both color sets are necessary.
619  QColor color = QColor(rgbColor);
620  QString styleSheet = dataSourceStyleSheetTemplate.arg(QColor(rgbColor).red())
621  .arg(QColor(rgbColor).green())
622  .arg(QColor(rgbColor).blue());
623  listWidgetItem->setTextColor(color); // This one sets the text color when unselected...
624  options_page->lst2dCurves->setStyleSheet(
625  styleSheet); //.. and this one sets the text color when selected
626 
627  // Store some additional data for the plot curve on the list item
628  listWidgetItem->setData(Qt::UserRole + UR_UAVOBJECT, QVariant(uavObject));
629  listWidgetItem->setData(Qt::UserRole + UR_UAVFIELD, QVariant(uavField));
630  listWidgetItem->setData(Qt::UserRole + UR_SCALE, QVariant(scale));
631  listWidgetItem->setData(Qt::UserRole + UR_COLOR, varColor);
632  listWidgetItem->setData(Qt::UserRole + UR_MEAN, QVariant(mean));
633  listWidgetItem->setData(Qt::UserRole + UR_MATHFUNCTION, QVariant(mathFunction));
634 }
635 
636 // TODO: Document why finish() is here and what it's supposed to do. Clearly nothing right now.
638 
644 void ScopeGadgetOptionsPage::on_lst2dCurves_currentRowChanged(int currentRow)
645 {
646  Q_UNUSED(currentRow);
647  set2dYAxisWidgetFromDataSource();
648 }
649 
655 void ScopeGadgetOptionsPage::on_cmbXAxisScatterplot2d_currentIndexChanged(QString currentText)
656 {
657  if (currentText == "Series") {
658  options_page->spnDataSize->setSuffix(" samples");
659  } else if (currentText == "Time series") {
660  options_page->spnDataSize->setSuffix(" seconds");
661  }
662 }
663 
668 void ScopeGadgetOptionsPage::on_cmb2dPlotType_currentIndexChanged(QString currentText)
669 {
670  if (currentText == "Scatter plot") {
671  options_page->sw2dXAxis->setCurrentWidget(options_page->sw2dSeriesStack);
672  on_cmbXAxisScatterplot2d_currentIndexChanged(
673  options_page->cmbXAxisScatterplot2d->currentText());
674  } else if (currentText == "Histogram") {
675  options_page->spnMaxNumBins->setSuffix(" bins");
676  options_page->sw2dXAxis->setCurrentWidget(options_page->sw2dHistogramStack);
677  }
678 }
679 
685 void ScopeGadgetOptionsPage::on_lst2dItem_clicked(QListWidgetItem *listItem)
686 {
687  if (listItem == selectedItem) {
688  listItem->setSelected(false);
689  options_page->lst2dCurves->setCurrentRow(-1);
690  selectedItem = nullptr;
691  } else {
692  selectedItem = listItem;
693  }
694 }
695 
700 void ScopeGadgetOptionsPage::on_cmb3dPlotType_currentIndexChanged(QString currentText)
701 {
702  if (currentText == "Spectrogram") {
703  options_page->stackedWidget3dPlots->setCurrentWidget(options_page->sw3dSpectrogramStack);
704 
705  // Set the spectrogram source combobox to custom spectrogram by default
706  options_page->cmbSpectrogramSource->setCurrentIndex(
707  options_page->cmbSpectrogramSource->findData(
709  } else if (currentText == "Time series") {
710  options_page->stackedWidget3dPlots->setCurrentWidget(options_page->sw3dTimeSeriesStack);
711  }
712 }
virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *)=0
void apply()
ScopeGadgetOptionsPage::apply Called when the user presses OK. Applies the current values to the scop...
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
bool isSingleInstance()
Definition: uavobject.cpp:123
static ICore * instance()
Definition: coreimpl.cpp:46
QString getName() const
QList< UAVObjectField * > getFields()
Definition: uavobject.cpp:196
QStringList getElementNames() const
void applyGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
ScopeGadgetConfiguration::applyGuiConfiguration Uses GUI information to create new scopes...
QString getName()
Definition: uavobject.cpp:131
QWidget * createPage(QWidget *parent)
ScopeGadgetOptionsPage::createPage creates options page widget (uses the UI file) ...
UAVObject * getObject(const QString &name, quint32 instId=0)
QVector< QVector< UAVDataObject * > > getDataObjectsVector()
qint32 getNumInstances(const QString &name)
FieldType getType() const
ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent=nullptr)