diff --git a/ground/src/plugins/scope/ScopeGadget.pluginspec b/ground/src/plugins/scope/ScopeGadget.pluginspec new file mode 100644 index 000000000..989e2eee2 --- /dev/null +++ b/ground/src/plugins/scope/ScopeGadget.pluginspec @@ -0,0 +1,10 @@ + + The OpenPilot Project + (C) 2010 OpenPilot Project + + A scope gadget! + http://www.openpilot.org + + + + diff --git a/ground/src/plugins/scope/scope.pro b/ground/src/plugins/scope/scope.pro new file mode 100644 index 000000000..2fc7ae286 --- /dev/null +++ b/ground/src/plugins/scope/scope.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +TARGET = ScopeGadget + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../libs/qwt/qwt.pri) + +HEADERS += scopeplugin.h +HEADERS += scopegadget.h +HEADERS += scopegadgetwidget.h +HEADERS += scopegadgetfactory.h +SOURCES += scopeplugin.cpp +SOURCES += scopegadget.cpp +SOURCES += scopegadgetfactory.cpp +SOURCES += scopegadgetwidget.cpp + +OTHER_FILES += ScopeGadget.pluginspec diff --git a/ground/src/plugins/scope/scopegadget.cpp b/ground/src/plugins/scope/scopegadget.cpp new file mode 100644 index 000000000..86a2020e3 --- /dev/null +++ b/ground/src/plugins/scope/scopegadget.cpp @@ -0,0 +1,21 @@ +/* + * scopegadget.cpp + * + * Created on: Mar 11, 2010 + * Author: peter + */ +#include "scopegadget.h" +#include "scopegadgetwidget.h" +#include + +ScopeGadget::ScopeGadget(ScopeGadgetWidget *widget) : + IUAVGadget(widget), + m_widget(widget), + m_toolbar(new QToolBar()) +{ +} + +ScopeGadget::~ScopeGadget() +{ + +} diff --git a/ground/src/plugins/scope/scopegadget.h b/ground/src/plugins/scope/scopegadget.h new file mode 100644 index 000000000..8136c8e54 --- /dev/null +++ b/ground/src/plugins/scope/scopegadget.h @@ -0,0 +1,40 @@ +/* + * scopegadget.h + * + * Created on: Mar 11, 2010 + * Author: peter + */ + +#ifndef SCOPEGADGET_H_ +#define SCOPEGADGET_H_ + +#include + +class IUAVGadget; +//class QList; +class QWidget; +class QString; +class ScopeGadgetWidget; + +using namespace Core; + +class ScopeGadget : public Core::IUAVGadget +{ + Q_OBJECT +public: + ScopeGadget(ScopeGadgetWidget *widget = 0); + ~ScopeGadget(); + + QList context() const { return m_context; } + QWidget *widget() { return m_widget; } + QString contextHelpId() const { return QString(); } + + QWidget *toolBar() { return m_toolbar; } +private: + QWidget *m_widget; + QWidget *m_toolbar; + QList m_context; +}; + + +#endif // SCOPEGADGET_H_ diff --git a/ground/src/plugins/scope/scopegadgetfactory.cpp b/ground/src/plugins/scope/scopegadgetfactory.cpp new file mode 100644 index 000000000..93269b08e --- /dev/null +++ b/ground/src/plugins/scope/scopegadgetfactory.cpp @@ -0,0 +1,28 @@ +/* + * scopegadgetfactory.cpp + * + * Created on: Mar 11, 2010 + * Author: peter + */ +#include "scopegadgetfactory.h" +#include "scopegadgetwidget.h" +#include "scopegadget.h" +#include + +ScopeGadgetFactory::ScopeGadgetFactory(QObject *parent) : IUAVGadgetFactory(parent) +{ +} + +ScopeGadgetFactory::~ScopeGadgetFactory() +{ + +} + +Core::IUAVGadget* ScopeGadgetFactory::createUAVGadget(QWidget *parent) { + ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent); + return new ScopeGadget(gadgetWidget); +} + +QString ScopeGadgetFactory::name() { + return QString("ScopeGadget"); +} diff --git a/ground/src/plugins/scope/scopegadgetfactory.h b/ground/src/plugins/scope/scopegadgetfactory.h new file mode 100644 index 000000000..e05ec7f52 --- /dev/null +++ b/ground/src/plugins/scope/scopegadgetfactory.h @@ -0,0 +1,28 @@ +/* + * scopegadgetfactory.h + * + * Created on: Mar 6, 2010 + * Author: peter + */ + +#ifndef SCOPEGADGETFACTORY_H_ +#define SCOPEGADGETFACTORY_H_ + +#include + +using namespace Core; +class IUAVGadget; +class IUAVGadgetFactory; + +class ScopeGadgetFactory : public Core::IUAVGadgetFactory +{ + Q_OBJECT +public: + ScopeGadgetFactory(QObject *parent = 0); + ~ScopeGadgetFactory(); + + Core::IUAVGadget *createUAVGadget(QWidget *parent); + QString name(); +}; + +#endif // SCOPEGADGETFACTORY_H_ diff --git a/ground/src/plugins/scope/scopegadgetwidget.cpp b/ground/src/plugins/scope/scopegadgetwidget.cpp new file mode 100644 index 000000000..c2809e99f --- /dev/null +++ b/ground/src/plugins/scope/scopegadgetwidget.cpp @@ -0,0 +1,62 @@ +/* + * scopegadgetwidget.cpp + * + * Created on: Mar 6, 2010 + * Author: peter + */ +#include "scopegadgetwidget.h" +#include "qwt/src/qwt_plot_curve.h" + +#include +#include +#include +#include +#include + +ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent) +{ + setMinimumSize(64,64); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + // Show a title + setTitle("Sine"); + + // Show a legend at the bottom +// setAutoLegend( true ); +// setLegendPos( Qwt::Bottom ); + + // Show the axes + setAxisTitle( xBottom, "x" ); + setAxisTitle( yLeft, "y" ); + + // Calculate the data, 500 points each + const int points = 500; + double x[ points ]; + double sn[ points ]; + double sg[ points ]; + + for( int i=0; i0)?1:((sn[i]<0)?-1:0); + } + // add curves + QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); + QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); + + // copy the data into the curves + curve1->setData(x, sn, points); + curve2->setData(x, sg, points); + + curve1->attach(this); + curve2->attach(this); + + // finally, refresh the plot + replot(); +} + +ScopeGadgetWidget::~ScopeGadgetWidget() +{ + // Do nothing +} + diff --git a/ground/src/plugins/scope/scopegadgetwidget.h b/ground/src/plugins/scope/scopegadgetwidget.h new file mode 100644 index 000000000..de52f5407 --- /dev/null +++ b/ground/src/plugins/scope/scopegadgetwidget.h @@ -0,0 +1,28 @@ +/* + * scopegadgetwidget.h + * + * Created on: Mar 6, 2010 + * Author: peter + */ + +#ifndef SCOPEGADGETWIDGET_H_ +#define SCOPEGADGETWIDGET_H_ + +#include "qwt/src/qwt.h" +#include "qwt/src/qwt_plot.h" +//#include +//class QWidget; +class QwtPlot; + +class ScopeGadgetWidget : public QwtPlot +{ + Q_OBJECT + +public: + ScopeGadgetWidget(QWidget *parent = 0); + ~ScopeGadgetWidget(); + +private: +}; + +#endif /* SCOPEGADGETWIDGET_H_ */ diff --git a/ground/src/plugins/scope/scopeplugin.cpp b/ground/src/plugins/scope/scopeplugin.cpp new file mode 100644 index 000000000..fa1a3ae75 --- /dev/null +++ b/ground/src/plugins/scope/scopeplugin.cpp @@ -0,0 +1,46 @@ +/* + * scopeplugin.cpp + * + * Created on: Mar 6, 2010 + * Author: peter + */ +#include "scopeplugin.h" +#include "scopegadgetfactory.h" +#include +#include +#include +#include + + +ScopePlugin::ScopePlugin() +{ + // Do nothing +} + +ScopePlugin::~ScopePlugin() +{ + // Do nothing +} + +bool ScopePlugin::initialize(const QStringList& args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + mf = new ScopeGadgetFactory(this); + addAutoReleasedObject(mf); + qDebug() << "ScopePlugin::initialize()"; + + return true; +} + +void ScopePlugin::extensionsInitialized() +{ + // Do nothing +} + +void ScopePlugin::shutdown() +{ + // Do nothing +} +Q_EXPORT_PLUGIN(ScopePlugin) + diff --git a/ground/src/plugins/scope/scopeplugin.h b/ground/src/plugins/scope/scopeplugin.h new file mode 100644 index 000000000..1daba10c9 --- /dev/null +++ b/ground/src/plugins/scope/scopeplugin.h @@ -0,0 +1,27 @@ +/* + * scopeplugin.h + * + * Created on: Mar 6, 2010 + * Author: peter + */ + +#ifndef SCOPEPLUGIN_H_ +#define SCOPEPLUGIN_H_ + +#include + +class ScopeGadgetFactory; + +class ScopePlugin : public ExtensionSystem::IPlugin +{ +public: + ScopePlugin(); + ~ScopePlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString * errorString); + void shutdown(); +private: + ScopeGadgetFactory *mf; +}; +#endif /* SCOPEPLUGIN_H_ */