dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
scopesconfig.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  *
29  * Additional note on redistribution: The copyright and license notices above
30  * must be maintained in each individual source file that is a derivative work
31  * of this source file; otherwise redistribution is prohibited.
32  */
33 
34 #ifndef SCOPESCONFIG_H
35 #define SCOPESCONFIG_H
36 
40 #include "uavobjects/uavobject.h"
41 
43 #include "qwt/src/qwt_color_map.h"
44 #include "scopegadgetwidget.h"
45 #include "ui_scopegadgetoptionspage.h"
46 
51 
56 class ScopeConfig : public QObject
57 {
58  Q_OBJECT
59 public:
60  virtual int getScopeDimensions() = 0;
61  virtual void saveConfiguration(QSettings *qSettings) = 0;
62  virtual int getScopeType() = 0;
63  virtual void loadConfiguration(ScopeGadgetWidget *) = 0;
64  virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *) = 0;
65 
67  void setRefreshInterval(int val) { m_refreshInterval = val; }
68 
69  virtual void preparePlot(ScopeGadgetWidget *) = 0;
70  virtual ScopeConfig *cloneScope(ScopeConfig *histogramSourceConfigs) = 0;
71 
72 protected:
73  int m_refreshInterval; // The interval to replot the curve widget. The data buffer is refresh as
74  // the data comes in.
76 
77  QString getUavObjectFieldUnits(QString uavObjectName, QString uavObjectFieldName)
78  {
79  // Get the uav object
80  ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
81  UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
82  UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject(uavObjectName));
83  if (!obj) {
84  qDebug() << "In scope gadget, UAVObject " << uavObjectName << " is missing";
85  return "";
86  }
87  UAVObjectField *field = obj->getField(uavObjectFieldName);
88  if (!field) {
89  qDebug() << "In scope gadget, in fields loaded from GCS config file, field"
90  << uavObjectFieldName << " of UAVObject " << uavObjectName << " is missing";
91  return "";
92  }
93 
94  // Get the units
95  QString units = field->getUnits();
96  if (units == nullptr)
97  units = QString();
98 
99  return units;
100  }
101 };
102 
103 #endif // SCOPESCONFIG_H
virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *)=0
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
virtual int getScopeType()=0
virtual void loadConfiguration(ScopeGadgetWidget *)=0
PlotDimensions m_plotDimensions
Definition: scopesconfig.h:75
virtual ScopeConfig * cloneScope(ScopeConfig *histogramSourceConfigs)=0
The ScopeConfig class The parent class for scope configuration classes data sources.
Definition: scopesconfig.h:56
void setRefreshInterval(int val)
Definition: scopesconfig.h:67
virtual void preparePlot(ScopeGadgetWidget *)=0
int getRefreshInterval()
Definition: scopesconfig.h:66
int m_refreshInterval
Definition: scopesconfig.h:73
QString getUavObjectFieldUnits(QString uavObjectName, QString uavObjectFieldName)
Definition: scopesconfig.h:77
QString getUnits() const
Scope Plugin Gadget Widget.
virtual void saveConfiguration(QSettings *qSettings)=0
UAVObject * getObject(const QString &name, quint32 instId=0)
virtual int getScopeDimensions()=0
PlotDimensions
The Plot3dType enum Defines the different type of plots.
Definition: scopesconfig.h:50