mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
GCS/scope: A scope gadget to have something more interesting to look at than the emptygadget.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@340 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
3c15818b3b
commit
f49dafca50
10
ground/src/plugins/scope/ScopeGadget.pluginspec
Normal file
10
ground/src/plugins/scope/ScopeGadget.pluginspec
Normal file
@ -0,0 +1,10 @@
|
||||
<plugin name="ScopeGadget" version="1.0.0" compatVersion="1.0.0">
|
||||
<vendor>The OpenPilot Project</vendor>
|
||||
<copyright>(C) 2010 OpenPilot Project</copyright>
|
||||
<license></license>
|
||||
<description>A scope gadget!</description>
|
||||
<url>http://www.openpilot.org</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
17
ground/src/plugins/scope/scope.pro
Normal file
17
ground/src/plugins/scope/scope.pro
Normal file
@ -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
|
21
ground/src/plugins/scope/scopegadget.cpp
Normal file
21
ground/src/plugins/scope/scopegadget.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* scopegadget.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "scopegadget.h"
|
||||
#include "scopegadgetwidget.h"
|
||||
#include <QtGui/QToolBar>
|
||||
|
||||
ScopeGadget::ScopeGadget(ScopeGadgetWidget *widget) :
|
||||
IUAVGadget(widget),
|
||||
m_widget(widget),
|
||||
m_toolbar(new QToolBar())
|
||||
{
|
||||
}
|
||||
|
||||
ScopeGadget::~ScopeGadget()
|
||||
{
|
||||
|
||||
}
|
40
ground/src/plugins/scope/scopegadget.h
Normal file
40
ground/src/plugins/scope/scopegadget.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* scopegadget.h
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef SCOPEGADGET_H_
|
||||
#define SCOPEGADGET_H_
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
class IUAVGadget;
|
||||
//class QList<int>;
|
||||
class QWidget;
|
||||
class QString;
|
||||
class ScopeGadgetWidget;
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class ScopeGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScopeGadget(ScopeGadgetWidget *widget = 0);
|
||||
~ScopeGadget();
|
||||
|
||||
QList<int> 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<int> m_context;
|
||||
};
|
||||
|
||||
|
||||
#endif // SCOPEGADGET_H_
|
28
ground/src/plugins/scope/scopegadgetfactory.cpp
Normal file
28
ground/src/plugins/scope/scopegadgetfactory.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* scopegadgetfactory.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "scopegadgetfactory.h"
|
||||
#include "scopegadgetwidget.h"
|
||||
#include "scopegadget.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
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");
|
||||
}
|
28
ground/src/plugins/scope/scopegadgetfactory.h
Normal file
28
ground/src/plugins/scope/scopegadgetfactory.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* scopegadgetfactory.h
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef SCOPEGADGETFACTORY_H_
|
||||
#define SCOPEGADGETFACTORY_H_
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
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_
|
62
ground/src/plugins/scope/scopegadgetwidget.cpp
Normal file
62
ground/src/plugins/scope/scopegadgetwidget.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* scopegadgetwidget.cpp
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "scopegadgetwidget.h"
|
||||
#include "qwt/src/qwt_plot_curve.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
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; i<points; i++ )
|
||||
{
|
||||
x[i] = (3.0*3.14/double(points))*double(i);
|
||||
sn[i] = 2.0*sin( x[i] );
|
||||
sg[i] = (sn[i]>0)?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
|
||||
}
|
||||
|
28
ground/src/plugins/scope/scopegadgetwidget.h
Normal file
28
ground/src/plugins/scope/scopegadgetwidget.h
Normal file
@ -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 <QtGui/QWidget>
|
||||
//class QWidget;
|
||||
class QwtPlot;
|
||||
|
||||
class ScopeGadgetWidget : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScopeGadgetWidget(QWidget *parent = 0);
|
||||
~ScopeGadgetWidget();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* SCOPEGADGETWIDGET_H_ */
|
46
ground/src/plugins/scope/scopeplugin.cpp
Normal file
46
ground/src/plugins/scope/scopeplugin.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* scopeplugin.cpp
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
#include "scopeplugin.h"
|
||||
#include "scopegadgetfactory.h"
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
|
||||
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)
|
||||
|
27
ground/src/plugins/scope/scopeplugin.h
Normal file
27
ground/src/plugins/scope/scopeplugin.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* scopeplugin.h
|
||||
*
|
||||
* Created on: Mar 6, 2010
|
||||
* Author: peter
|
||||
*/
|
||||
|
||||
#ifndef SCOPEPLUGIN_H_
|
||||
#define SCOPEPLUGIN_H_
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
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_ */
|
Loading…
Reference in New Issue
Block a user