diff --git a/ground/share/openpilotgcs/gauges/gauges.pro b/ground/share/openpilotgcs/gauges/gauges.pro new file mode 100644 index 000000000..aa811bce0 --- /dev/null +++ b/ground/share/openpilotgcs/gauges/gauges.pro @@ -0,0 +1,30 @@ +include(../../../openpilotgcs.pri) + +COLLECTIONS = default bling + +TEMPLATE = app +TARGET = phony_target2 +CONFIG -= qt +QT = +LIBS = + +isEmpty(vcproj) { + QMAKE_LINK = @: IGNORE THIS LINE + OBJECTS_DIR = + win32:CONFIG -= embed_manifest_exe +} else { + CONFIG += console + PHONY_DEPS = . + phony_src.input = PHONY_DEPS + phony_src.output = phony.c + phony_src.variable_out = GENERATED_SOURCES + phony_src.commands = echo int main() { return 0; } > phony.c + phony_src.name = CREATE phony.c + phony_src.CONFIG += combine + QMAKE_EXTRA_COMPILERS += phony_src +} + +gauges.files = $$PWD/$$COLLECTIONS +gauges.path = /share/openpilotgcs/gauges +gauges.CONFIG += no_check_exist +INSTALLS += gauges diff --git a/ground/share/openpilotgcs/models/models.pro b/ground/share/openpilotgcs/models/models.pro new file mode 100644 index 000000000..ea81e96c8 --- /dev/null +++ b/ground/share/openpilotgcs/models/models.pro @@ -0,0 +1,30 @@ +include(../../../openpilotgcs.pri) + +COLLECTIONS = Easystar + +TEMPLATE = app +TARGET = phony_target2 +CONFIG -= qt +QT = +LIBS = + +isEmpty(vcproj) { + QMAKE_LINK = @: IGNORE THIS LINE + OBJECTS_DIR = + win32:CONFIG -= embed_manifest_exe +} else { + CONFIG += console + PHONY_DEPS = . + phony_src.input = PHONY_DEPS + phony_src.output = phony.c + phony_src.variable_out = GENERATED_SOURCES + phony_src.commands = echo int main() { return 0; } > phony.c + phony_src.name = CREATE phony.c + phony_src.CONFIG += combine + QMAKE_EXTRA_COMPILERS += phony_src +} + +models.files = $$PWD/$$COLLECTIONS +models.path = /share/openpilotgcs/models +models.CONFIG += no_check_exist +INSTALLS += models diff --git a/ground/share/openpilotgcs/pfd/pfd.pro b/ground/share/openpilotgcs/pfd/pfd.pro new file mode 100644 index 000000000..5954374a6 --- /dev/null +++ b/ground/share/openpilotgcs/pfd/pfd.pro @@ -0,0 +1,30 @@ +include(../../../openpilotgcs.pri) + +COLLECTIONS = default + +TEMPLATE = app +TARGET = phony_target2 +CONFIG -= qt +QT = +LIBS = + +isEmpty(vcproj) { + QMAKE_LINK = @: IGNORE THIS LINE + OBJECTS_DIR = + win32:CONFIG -= embed_manifest_exe +} else { + CONFIG += console + PHONY_DEPS = . + phony_src.input = PHONY_DEPS + phony_src.output = phony.c + phony_src.variable_out = GENERATED_SOURCES + phony_src.commands = echo int main() { return 0; } > phony.c + phony_src.name = CREATE phony.c + phony_src.CONFIG += combine + QMAKE_EXTRA_COMPILERS += phony_src +} + +pfd.files = $$PWD/$$COLLECTIONS +pfd.path = /share/openpilotgcs/pfd +pfd.CONFIG += no_check_exist +INSTALLS += pfd diff --git a/ground/share/openpilotgcs/translations/README b/ground/share/openpilotgcs/translations/Readme.txt similarity index 100% rename from ground/share/openpilotgcs/translations/README rename to ground/share/openpilotgcs/translations/Readme.txt diff --git a/ground/share/share.pro b/ground/share/share.pro index e5dc3af0d..72b305268 100644 --- a/ground/share/share.pro +++ b/ground/share/share.pro @@ -1,4 +1,11 @@ TEMPLATE = subdirs SUBDIRS = openpilotgcs/translations SUBDIRS += openpilotgcs/sounds +SUBDIRS += openpilotgcs/gauges +SUBDIRS += openpilotgcs/models +SUBDIRS += openpilotgcs/pfd + + + + diff --git a/ground/src/plugins/dial/dial.pro b/ground/src/plugins/dial/dial.pro index 1985b8ed7..4ad150f45 100644 --- a/ground/src/plugins/dial/dial.pro +++ b/ground/src/plugins/dial/dial.pro @@ -18,5 +18,4 @@ SOURCES += dialgadgetconfiguration.cpp SOURCES += dialgadgetoptionspage.cpp OTHER_FILES += DialGadget.pluginspec FORMS += dialgadgetoptionspage.ui -RESOURCES += dial.qrc \ - dial.qrc +RESOURCES += dial.qrc diff --git a/ground/src/plugins/ipconnection/ipconnection_global.h b/ground/src/plugins/ipconnection/ipconnection_global.h index 0dd7bee9f..a54dd8613 100644 --- a/ground/src/plugins/ipconnection/ipconnection_global.h +++ b/ground/src/plugins/ipconnection/ipconnection_global.h @@ -1,39 +1,39 @@ -/** - ****************************************************************************** - * - * @file IPconnection_global.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup IPconnection_plugin - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef IPconnection_GLOBAL_H -#define IPconnection_GLOBAL_H - -#include - -#if defined(IPconnection_LIBRARY) -# define IPconnection_EXPORT Q_DECL_EXPORT -#else -# define IPconnection_EXPORT Q_DECL_IMPORT -#endif - -#endif // IPconnection_GLOBAL_H +/** + ****************************************************************************** + * + * @file IPconnection_global.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef IPconnection_GLOBAL_H +#define IPconnection_GLOBAL_H + +#include + +#if defined(IPconnection_LIBRARY) +# define IPconnection_EXPORT Q_DECL_EXPORT +#else +# define IPconnection_EXPORT Q_DECL_IMPORT +#endif + +#endif // IPconnection_GLOBAL_H diff --git a/ground/src/plugins/ipconnection/ipconnectionconfiguration.cpp b/ground/src/plugins/ipconnection/ipconnectionconfiguration.cpp index 91a1b2ced..7a1da838e 100644 --- a/ground/src/plugins/ipconnection/ipconnectionconfiguration.cpp +++ b/ground/src/plugins/ipconnection/ipconnectionconfiguration.cpp @@ -1,92 +1,92 @@ -/** - ****************************************************************************** - * - * @file IPconnectionconfiguration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup map - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ipconnectionconfiguration.h" -#include -#include - -IPconnectionConfiguration::IPconnectionConfiguration(QString classId, const QByteArray &state, QObject *parent) : - IUAVGadgetConfiguration(classId, parent), - m_HostName("127.0.0.1"), - m_Port(1000), - m_UseTCP(1) -{ - settings = Core::ICore::instance()->settings(); -} -IPconnectionConfiguration::~IPconnectionConfiguration() -{ -} -IUAVGadgetConfiguration *IPconnectionConfiguration::clone() -{ - IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId()); - m->m_Port = m_Port; - m->m_HostName = m_HostName; - m->m_UseTCP = m_UseTCP; - return m; -} - -QByteArray IPconnectionConfiguration::saveState() const -{ - QByteArray bytes; - QDataStream stream(&bytes, QIODevice::WriteOnly); - stream << m_Port; - stream << m_HostName; - stream << m_UseTCP; - return bytes; - -} - - -void IPconnectionConfiguration::savesettings() const -{ - settings->beginGroup(QLatin1String("IPconnection")); - - settings->beginWriteArray("Current"); - settings->setArrayIndex(0); - settings->setValue(QLatin1String("HostName"), m_HostName); - settings->setValue(QLatin1String("Port"), m_Port); - settings->setValue(QLatin1String("UseTCP"), m_UseTCP); - settings->endArray(); - settings->endGroup(); -} - - -void IPconnectionConfiguration::restoresettings() -{ - settings->beginGroup(QLatin1String("IPconnection")); - - settings->beginReadArray("Current"); - settings->setArrayIndex(0); - m_HostName = (settings->value(QLatin1String("HostName"), tr("")).toString()); - m_Port = (settings->value(QLatin1String("Port"), tr("")).toInt()); - m_UseTCP = (settings->value(QLatin1String("UseTCP"), tr("")).toInt()); - settings->endArray(); - settings->endGroup(); - - -} - +/** + ****************************************************************************** + * + * @file IPconnectionconfiguration.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ipconnectionconfiguration.h" +#include +#include + +IPconnectionConfiguration::IPconnectionConfiguration(QString classId, const QByteArray &state, QObject *parent) : + IUAVGadgetConfiguration(classId, parent), + m_HostName("127.0.0.1"), + m_Port(1000), + m_UseTCP(1) +{ + settings = Core::ICore::instance()->settings(); +} +IPconnectionConfiguration::~IPconnectionConfiguration() +{ +} +IUAVGadgetConfiguration *IPconnectionConfiguration::clone() +{ + IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId()); + m->m_Port = m_Port; + m->m_HostName = m_HostName; + m->m_UseTCP = m_UseTCP; + return m; +} + +QByteArray IPconnectionConfiguration::saveState() const +{ + QByteArray bytes; + QDataStream stream(&bytes, QIODevice::WriteOnly); + stream << m_Port; + stream << m_HostName; + stream << m_UseTCP; + return bytes; + +} + + +void IPconnectionConfiguration::savesettings() const +{ + settings->beginGroup(QLatin1String("IPconnection")); + + settings->beginWriteArray("Current"); + settings->setArrayIndex(0); + settings->setValue(QLatin1String("HostName"), m_HostName); + settings->setValue(QLatin1String("Port"), m_Port); + settings->setValue(QLatin1String("UseTCP"), m_UseTCP); + settings->endArray(); + settings->endGroup(); +} + + +void IPconnectionConfiguration::restoresettings() +{ + settings->beginGroup(QLatin1String("IPconnection")); + + settings->beginReadArray("Current"); + settings->setArrayIndex(0); + m_HostName = (settings->value(QLatin1String("HostName"), tr("")).toString()); + m_Port = (settings->value(QLatin1String("Port"), tr("")).toInt()); + m_UseTCP = (settings->value(QLatin1String("UseTCP"), tr("")).toInt()); + settings->endArray(); + settings->endGroup(); + + +} + diff --git a/ground/src/plugins/ipconnection/ipconnectionconfiguration.h b/ground/src/plugins/ipconnection/ipconnectionconfiguration.h index ed89f699d..b1a83afb5 100644 --- a/ground/src/plugins/ipconnection/ipconnectionconfiguration.h +++ b/ground/src/plugins/ipconnection/ipconnectionconfiguration.h @@ -1,73 +1,73 @@ -/** - ****************************************************************************** - * - * @file IPconnectionconfiguration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup map - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef IPconnectionCONFIGURATION_H -#define IPconnectionCONFIGURATION_H - -#include -#include -#include - -using namespace Core; - -class IPconnectionConfiguration : public IUAVGadgetConfiguration -{ -Q_OBJECT -Q_PROPERTY(QString HostName READ HostName WRITE setHostName) -Q_PROPERTY(int Port READ Port WRITE setPort) -Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP) - -public: - explicit IPconnectionConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); - virtual ~IPconnectionConfiguration(); - QByteArray saveState() const; - //void savesettings(QSettings* settings) const; - //void restoresettings(QSettings* settings); - void savesettings() const; - void restoresettings(); - IUAVGadgetConfiguration *clone(); - - QString HostName() const { return m_HostName; } - int Port() const { return m_Port; } - int UseTCP() const { return m_UseTCP; } - - -public slots: - void setHostName(QString HostName) { m_HostName = HostName; } - void setPort(int Port) { m_Port = Port; } - void setUseTCP(int UseTCP) { m_UseTCP = UseTCP; } - -private: - QString m_HostName; - int m_Port; - int m_UseTCP; - QSettings* settings; - - -}; - -#endif // IPconnectionCONFIGURATION_H +/** + ****************************************************************************** + * + * @file IPconnectionconfiguration.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef IPconnectionCONFIGURATION_H +#define IPconnectionCONFIGURATION_H + +#include +#include +#include + +using namespace Core; + +class IPconnectionConfiguration : public IUAVGadgetConfiguration +{ +Q_OBJECT +Q_PROPERTY(QString HostName READ HostName WRITE setHostName) +Q_PROPERTY(int Port READ Port WRITE setPort) +Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP) + +public: + explicit IPconnectionConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); + virtual ~IPconnectionConfiguration(); + QByteArray saveState() const; + //void savesettings(QSettings* settings) const; + //void restoresettings(QSettings* settings); + void savesettings() const; + void restoresettings(); + IUAVGadgetConfiguration *clone(); + + QString HostName() const { return m_HostName; } + int Port() const { return m_Port; } + int UseTCP() const { return m_UseTCP; } + + +public slots: + void setHostName(QString HostName) { m_HostName = HostName; } + void setPort(int Port) { m_Port = Port; } + void setUseTCP(int UseTCP) { m_UseTCP = UseTCP; } + +private: + QString m_HostName; + int m_Port; + int m_UseTCP; + QSettings* settings; + + +}; + +#endif // IPconnectionCONFIGURATION_H diff --git a/ground/src/plugins/ipconnection/ipconnectionoptionspage.cpp b/ground/src/plugins/ipconnection/ipconnectionoptionspage.cpp index f44abb3bb..273aee409 100644 --- a/ground/src/plugins/ipconnection/ipconnectionoptionspage.cpp +++ b/ground/src/plugins/ipconnection/ipconnectionoptionspage.cpp @@ -1,82 +1,82 @@ -/** - ****************************************************************************** - * - * @file IPconnectionoptionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup map - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ipconnectionoptionspage.h" -#include "ipconnectionconfiguration.h" -#include -#include -#include -#include -#include -#include -#include - -#include "ui_ipconnectionoptionspage.h" - - -IPconnectionOptionsPage::IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent) : - IOptionsPage(parent), - m_config(config) -{ - -} -IPconnectionOptionsPage::~IPconnectionOptionsPage() -{ -} -QWidget *IPconnectionOptionsPage::createPage(QWidget *parent) -{ - - m_page = new Ui::IPconnectionOptionsPage(); - QWidget *w = new QWidget(parent); - m_page->setupUi(w); - - m_page->Port->setValue(m_config->Port()); - m_page->HostName->setText(m_config->HostName()); - m_page->UseTCP->setChecked(m_config->UseTCP()?true:false); - m_page->UseUDP->setChecked(m_config->UseTCP()?false:true); - - return w; -} - -void IPconnectionOptionsPage::apply() -{ - m_config->setPort(m_page->Port->value()); - m_config->setHostName(m_page->HostName->text()); - m_config->setUseTCP(m_page->UseTCP->isChecked()?1:0); - m_config->savesettings(); - - emit availableDevChanged(); - - - -} - -void IPconnectionOptionsPage::finish() -{ - delete m_page; -} - +/** + ****************************************************************************** + * + * @file IPconnectionoptionspage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "ipconnectionoptionspage.h" +#include "ipconnectionconfiguration.h" +#include +#include +#include +#include +#include +#include +#include + +#include "ui_ipconnectionoptionspage.h" + + +IPconnectionOptionsPage::IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent) : + IOptionsPage(parent), + m_config(config) +{ + +} +IPconnectionOptionsPage::~IPconnectionOptionsPage() +{ +} +QWidget *IPconnectionOptionsPage::createPage(QWidget *parent) +{ + + m_page = new Ui::IPconnectionOptionsPage(); + QWidget *w = new QWidget(parent); + m_page->setupUi(w); + + m_page->Port->setValue(m_config->Port()); + m_page->HostName->setText(m_config->HostName()); + m_page->UseTCP->setChecked(m_config->UseTCP()?true:false); + m_page->UseUDP->setChecked(m_config->UseTCP()?false:true); + + return w; +} + +void IPconnectionOptionsPage::apply() +{ + m_config->setPort(m_page->Port->value()); + m_config->setHostName(m_page->HostName->text()); + m_config->setUseTCP(m_page->UseTCP->isChecked()?1:0); + m_config->savesettings(); + + emit availableDevChanged(); + + + +} + +void IPconnectionOptionsPage::finish() +{ + delete m_page; +} + diff --git a/ground/src/plugins/ipconnection/ipconnectionoptionspage.h b/ground/src/plugins/ipconnection/ipconnectionoptionspage.h index 83c3db1e2..0ad3d44fb 100644 --- a/ground/src/plugins/ipconnection/ipconnectionoptionspage.h +++ b/ground/src/plugins/ipconnection/ipconnectionoptionspage.h @@ -1,71 +1,71 @@ -/** - ****************************************************************************** - * - * @file IPconnectionoptionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup map - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef IPconnectionOPTIONSPAGE_H -#define IPconnectionOPTIONSPAGE_H - -#include "coreplugin/dialogs/ioptionspage.h" - -class IPconnectionConfiguration; - -namespace Core { - class IUAVGadgetConfiguration; -} - -namespace Ui { - class IPconnectionOptionsPage; -} - -using namespace Core; - -class IPconnectionOptionsPage : public IOptionsPage -{ -Q_OBJECT -public: - explicit IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent = 0); - virtual ~IPconnectionOptionsPage(); - - QString id() const { return QLatin1String("settings"); } - QString trName() const { return tr("settings"); } - QString category() const { return "IP Network Telemetry"; }; - QString trCategory() const { return "IP Network Telemetry"; }; - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -signals: - void availableDevChanged(); - -public slots: -private: - IPconnectionConfiguration *m_config; - Ui::IPconnectionOptionsPage *m_page; - -}; - -#endif // IPconnectionOPTIONSPAGE_H +/** + ****************************************************************************** + * + * @file IPconnectionoptionspage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef IPconnectionOPTIONSPAGE_H +#define IPconnectionOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" + +class IPconnectionConfiguration; + +namespace Core { + class IUAVGadgetConfiguration; +} + +namespace Ui { + class IPconnectionOptionsPage; +} + +using namespace Core; + +class IPconnectionOptionsPage : public IOptionsPage +{ +Q_OBJECT +public: + explicit IPconnectionOptionsPage(IPconnectionConfiguration *config, QObject *parent = 0); + virtual ~IPconnectionOptionsPage(); + + QString id() const { return QLatin1String("settings"); } + QString trName() const { return tr("settings"); } + QString category() const { return "IP Network Telemetry"; }; + QString trCategory() const { return "IP Network Telemetry"; }; + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +signals: + void availableDevChanged(); + +public slots: +private: + IPconnectionConfiguration *m_config; + Ui::IPconnectionOptionsPage *m_page; + +}; + +#endif // IPconnectionOPTIONSPAGE_H diff --git a/ground/src/plugins/ipconnection/ipconnectionplugin.cpp b/ground/src/plugins/ipconnection/ipconnectionplugin.cpp index f39fc662c..e390e112f 100644 --- a/ground/src/plugins/ipconnection/ipconnectionplugin.cpp +++ b/ground/src/plugins/ipconnection/ipconnectionplugin.cpp @@ -5,7 +5,7 @@ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief Register connection object for the core connection manager * @see The GNU Public License (GPL) Version 3 - * @defgroup IPconnection_plugin + * @defgroup IPconnectionplugin * @{ * *****************************************************************************/ diff --git a/ground/src/plugins/ipconnection/ipconnectionplugin.h b/ground/src/plugins/ipconnection/ipconnectionplugin.h index c319bc808..43ef81a29 100644 --- a/ground/src/plugins/ipconnection/ipconnectionplugin.h +++ b/ground/src/plugins/ipconnection/ipconnectionplugin.h @@ -1,98 +1,98 @@ -/** - ****************************************************************************** - * - * @file IPconnectionplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief - * @see The GNU Public License (GPL) Version 3 - * @defgroup IPconnection_plugin - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef IPconnectionPLUGIN_H -#define IPconnectionPLUGIN_H - -#include "ipconnection_global.h" -#include "ipconnectionoptionspage.h" -#include "ipconnectionconfiguration.h" -#include "coreplugin/iconnection.h" -#include -//#include - - -class QAbstractSocket; -class QTcpSocket; -class QUdpSocket; - -class IConnection; -/** -* Define a connection via the IConnection interface -* Plugin will add a instance of this class to the pool, -* so the connection manager can use it. -*/ -class IPconnection_EXPORT IPconnectionConnection - : public Core::IConnection -{ - Q_OBJECT -public: - IPconnectionConnection(); - virtual ~IPconnectionConnection(); - - virtual QStringList availableDevices(); - virtual QIODevice *openDevice(const QString &deviceName); - virtual void closeDevice(const QString &deviceName); - - virtual QString connectionName(); - virtual QString shortName(); - - IPconnectionConfiguration * Config() const { return m_config; } - IPconnectionOptionsPage * Optionspage() const { return m_optionspage; } - - - -protected slots: - void onEnumerationChanged(); -private: - QAbstractSocket *tcpSocket; - IPconnectionConfiguration *m_config; - IPconnectionOptionsPage *m_optionspage; - //QSettings* settings; - -}; - - -class IPconnection_EXPORT IPconnectionPlugin - : public ExtensionSystem::IPlugin -{ - Q_OBJECT - -public: - IPconnectionPlugin(); - ~IPconnectionPlugin(); - - virtual bool initialize(const QStringList &arguments, QString *error_message); - virtual void extensionsInitialized(); - -private: - IPconnectionConnection *m_connection; - -}; - - -#endif // IPconnectionPLUGIN_H +/** + ****************************************************************************** + * + * @file IPconnectionplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief + * @see The GNU Public License (GPL) Version 3 + * @defgroup IPconnectionplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef IPconnectionPLUGIN_H +#define IPconnectionPLUGIN_H + +#include "ipconnection_global.h" +#include "ipconnectionoptionspage.h" +#include "ipconnectionconfiguration.h" +#include "coreplugin/iconnection.h" +#include +//#include + + +class QAbstractSocket; +class QTcpSocket; +class QUdpSocket; + +class IConnection; +/** +* Define a connection via the IConnection interface +* Plugin will add a instance of this class to the pool, +* so the connection manager can use it. +*/ +class IPconnection_EXPORT IPconnectionConnection + : public Core::IConnection +{ + Q_OBJECT +public: + IPconnectionConnection(); + virtual ~IPconnectionConnection(); + + virtual QStringList availableDevices(); + virtual QIODevice *openDevice(const QString &deviceName); + virtual void closeDevice(const QString &deviceName); + + virtual QString connectionName(); + virtual QString shortName(); + + IPconnectionConfiguration * Config() const { return m_config; } + IPconnectionOptionsPage * Optionspage() const { return m_optionspage; } + + + +protected slots: + void onEnumerationChanged(); +private: + QAbstractSocket *tcpSocket; + IPconnectionConfiguration *m_config; + IPconnectionOptionsPage *m_optionspage; + //QSettings* settings; + +}; + + +class IPconnection_EXPORT IPconnectionPlugin + : public ExtensionSystem::IPlugin +{ + Q_OBJECT + +public: + IPconnectionPlugin(); + ~IPconnectionPlugin(); + + virtual bool initialize(const QStringList &arguments, QString *error_message); + virtual void extensionsInitialized(); + +private: + IPconnectionConnection *m_connection; + +}; + + +#endif // IPconnectionPLUGIN_H diff --git a/ground/src/plugins/ipconnection/ui_ipconnectionoptionspage.h b/ground/src/plugins/ipconnection/ui_ipconnectionoptionspage.h deleted file mode 100644 index 4e3058063..000000000 --- a/ground/src/plugins/ipconnection/ui_ipconnectionoptionspage.h +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'IPconnectionoptionspage.ui' -** -** Created: Sun Jun 27 12:45:24 2010 -** by: Qt User Interface Compiler version 4.6.2 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_TCPTELEMETRYOPTIONSPAGE_H -#define UI_TCPTELEMETRYOPTIONSPAGE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_IPconnectionOptionsPage -{ -public: - QGridLayout *gridLayout; - QSpacerItem *horizontalSpacer; - QRadioButton *UseTCP; - QRadioButton *UseUDP; - QSpinBox *Port; - QLabel *label_3; - QLineEdit *HostName; - QLabel *label_2; - - void setupUi(QWidget *IPconnectionOptionsPage) - { - if (IPconnectionOptionsPage->objectName().isEmpty()) - IPconnectionOptionsPage->setObjectName(QString::fromUtf8("IPconnectionOptionsPage")); - IPconnectionOptionsPage->resize(388, 300); - gridLayout = new QGridLayout(IPconnectionOptionsPage); - gridLayout->setContentsMargins(0, 0, 0, 0); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - gridLayout->addItem(horizontalSpacer, 0, 3, 1, 1); - - UseTCP = new QRadioButton(IPconnectionOptionsPage); - UseTCP->setObjectName(QString::fromUtf8("UseTCP")); - - gridLayout->addWidget(UseTCP, 2, 2, 1, 1); - - UseUDP = new QRadioButton(IPconnectionOptionsPage); - UseUDP->setObjectName(QString::fromUtf8("UseUDP")); - - gridLayout->addWidget(UseUDP, 3, 2, 1, 1); - - Port = new QSpinBox(IPconnectionOptionsPage); - Port->setObjectName(QString::fromUtf8("Port")); - Port->setMinimum(1); - Port->setMaximum(999999); - - gridLayout->addWidget(Port, 4, 2, 1, 1); - - label_3 = new QLabel(IPconnectionOptionsPage); - label_3->setObjectName(QString::fromUtf8("label_3")); - - gridLayout->addWidget(label_3, 4, 1, 1, 1); - - HostName = new QLineEdit(IPconnectionOptionsPage); - HostName->setObjectName(QString::fromUtf8("HostName")); - - gridLayout->addWidget(HostName, 0, 2, 1, 1); - - label_2 = new QLabel(IPconnectionOptionsPage); - label_2->setObjectName(QString::fromUtf8("label_2")); - - gridLayout->addWidget(label_2, 0, 1, 1, 1); - - - retranslateUi(IPconnectionOptionsPage); - - QMetaObject::connectSlotsByName(IPconnectionOptionsPage); - } // setupUi - - void retranslateUi(QWidget *IPconnectionOptionsPage) - { - IPconnectionOptionsPage->setWindowTitle(QApplication::translate("IPconnectionOptionsPage", "Form", 0, QApplication::UnicodeUTF8)); - UseTCP->setText(QApplication::translate("IPconnectionOptionsPage", "TCP connection", 0, QApplication::UnicodeUTF8)); - UseUDP->setText(QApplication::translate("IPconnectionOptionsPage", "UDP connection", 0, QApplication::UnicodeUTF8)); - label_3->setText(QApplication::translate("IPconnectionOptionsPage", "Port", 0, QApplication::UnicodeUTF8)); - label_2->setText(QApplication::translate("IPconnectionOptionsPage", "Host Name/Number", 0, QApplication::UnicodeUTF8)); - } // retranslateUi - -}; - -namespace Ui { - class IPconnectionOptionsPage: public Ui_IPconnectionOptionsPage {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_TCPTELEMETRYOPTIONSPAGE_H diff --git a/ground/src/plugins/scope/plotdata.cpp b/ground/src/plugins/scope/plotdata.cpp index 7120796c6..72b4e024b 100644 --- a/ground/src/plugins/scope/plotdata.cpp +++ b/ground/src/plugins/scope/plotdata.cpp @@ -1,138 +1,138 @@ -/** - ****************************************************************************** - * - * @file plotdata.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Implementation of plotdata. - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "plotdata.h" -#include - -PlotData::PlotData(QString* p_uavObject, QString* p_uavField) -{ - uavObject = new QString(*p_uavObject); - uavField = new QString(*p_uavField); - - xData = new QVector(); - yData = new QVector(); - - curve = 0; - scalePower = 0; - yMinimum = 0; - yMaximum = 0; - - m_xWindowSize = 0; -} - -PlotData::~PlotData() -{ - delete uavObject; - delete uavField; - delete xData; - delete yData; -} - - -bool SequencialPlotData::append(UAVObject* obj) -{ - if (*uavObject == obj->getName()) { - //Get the field of interest - UAVObjectField* field = obj->getField(*uavField); - - if (field) { - //Shift data forward and put the new value at the front - yData->append(field->getDouble() * pow(10, scalePower)); - if (yData->size() > m_xWindowSize) { - yData->pop_front(); - - //Make the x-axis values scroll... - //xData->append( xData->last() + 1 ); - //xData->pop_front(); - } else - xData->insert(xData->size(), xData->size()); - - dataChanged(); - return true; - } - } - - return false; -} - -bool ChronoPlotData::append(UAVObject* obj) -{ - if (*uavObject == obj->getName()) { - //Get the field of interest - UAVObjectField* field = obj->getField(*uavField); - - if (field) { - //Put the new value at the front - QDateTime NOW = QDateTime::currentDateTime(); - - double newestValue = NOW.toTime_t() + NOW.time().msec() / 1000.0; - xData->append(newestValue); - yData->append(field->getDouble() * pow(10, scalePower)); - - //Remove stale data - removeStaleData(); - - dataChanged(); - return true; - } - } - - return false; -} - -void ChronoPlotData::removeStaleData() -{ - double newestValue; - double oldestValue; - - while (1) { - if (xData->size() == 0) - break; - - newestValue = xData->last(); - oldestValue = xData->first(); - - if (newestValue - oldestValue > m_xWindowSize) { - yData->pop_front(); - xData->pop_front(); - } else - break; - } -} - -void ChronoPlotData::removeStaleDataTimeout() -{ - removeStaleData(); - dataChanged(); -} - -bool UAVObjectPlotData::append(UAVObject* obj) -{ - return false; -} - +/** + ****************************************************************************** + * + * @file plotdata.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of plotdata. + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "plotdata.h" +#include + +PlotData::PlotData(QString* p_uavObject, QString* p_uavField) +{ + uavObject = new QString(*p_uavObject); + uavField = new QString(*p_uavField); + + xData = new QVector(); + yData = new QVector(); + + curve = 0; + scalePower = 0; + yMinimum = 0; + yMaximum = 0; + + m_xWindowSize = 0; +} + +PlotData::~PlotData() +{ + delete uavObject; + delete uavField; + delete xData; + delete yData; +} + + +bool SequencialPlotData::append(UAVObject* obj) +{ + if (*uavObject == obj->getName()) { + //Get the field of interest + UAVObjectField* field = obj->getField(*uavField); + + if (field) { + //Shift data forward and put the new value at the front + yData->append(field->getDouble() * pow(10, scalePower)); + if (yData->size() > m_xWindowSize) { + yData->pop_front(); + + //Make the x-axis values scroll... + //xData->append( xData->last() + 1 ); + //xData->pop_front(); + } else + xData->insert(xData->size(), xData->size()); + + dataChanged(); + return true; + } + } + + return false; +} + +bool ChronoPlotData::append(UAVObject* obj) +{ + if (*uavObject == obj->getName()) { + //Get the field of interest + UAVObjectField* field = obj->getField(*uavField); + + if (field) { + //Put the new value at the front + QDateTime NOW = QDateTime::currentDateTime(); + + double newestValue = NOW.toTime_t() + NOW.time().msec() / 1000.0; + xData->append(newestValue); + yData->append(field->getDouble() * pow(10, scalePower)); + + //Remove stale data + removeStaleData(); + + dataChanged(); + return true; + } + } + + return false; +} + +void ChronoPlotData::removeStaleData() +{ + double newestValue; + double oldestValue; + + while (1) { + if (xData->size() == 0) + break; + + newestValue = xData->last(); + oldestValue = xData->first(); + + if (newestValue - oldestValue > m_xWindowSize) { + yData->pop_front(); + xData->pop_front(); + } else + break; + } +} + +void ChronoPlotData::removeStaleDataTimeout() +{ + removeStaleData(); + dataChanged(); +} + +bool UAVObjectPlotData::append(UAVObject* obj) +{ + return false; +} + diff --git a/ground/src/plugins/scope/plotdata.h b/ground/src/plugins/scope/plotdata.h index f504e2225..52702d486 100644 --- a/ground/src/plugins/scope/plotdata.h +++ b/ground/src/plugins/scope/plotdata.h @@ -1,142 +1,142 @@ -/** - ****************************************************************************** - * - * @file plotdata.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Object that manages the data for a curve. - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PLOTDATA_H -#define PLOTDATA_H - -#include "uavobjects/uavobject.h" -#include "uavobjects/altitudeactual.h" -#include "uavobjects/positionactual.h" - - -#include "qwt/src/qwt.h" -#include "qwt/src/qwt_plot.h" -#include "qwt/src/qwt_plot_curve.h" -#include "qwt/src/qwt_scale_draw.h" -#include "qwt/src/qwt_scale_widget.h" - -#include -#include -#include - -enum PlotType { - SequencialPlot, - ChronoPlot, - UAVObjectPlot, - - NPlotTypes -}; - - -class PlotData : public QObject -{ - Q_OBJECT - -public: - PlotData(QString* uavObject, QString* uavField); - ~PlotData(); - - QString* uavObject; - QString* uavField; - QwtPlotCurve* curve; - QVector* xData; - QVector* yData; - int scalePower; //This is the power to wich each value must be raised - double yMinimum; - double yMaximum; - - double m_xWindowSize; - - virtual bool append(UAVObject* obj) = 0; - virtual PlotType plotType() = 0; - -signals: - void dataChanged(); -}; - -class SequencialPlotData : public PlotData -{ - Q_OBJECT -public: - SequencialPlotData(QString* uavObject, QString* uavField) - : PlotData(uavObject, uavField) {} - ~SequencialPlotData() {} - - bool append(UAVObject* obj); - - virtual PlotType plotType() { - return SequencialPlot; - } -}; - -class ChronoPlotData : public PlotData -{ - Q_OBJECT -public: - ChronoPlotData(QString* uavObject, QString* uavField) - : PlotData(uavObject, uavField) { - scalePower = 1; - //Setup timer - timer = new QTimer(); - connect(timer, SIGNAL(timeout()), this, SLOT(removeStaleDataTimeout())); - timer->start(100); - } - ~ChronoPlotData() { - delete timer; - } - - bool append(UAVObject* obj); - - virtual PlotType plotType() { - return ChronoPlot; - } -private: - //QDateTime m_epoch; - void removeStaleData(); - - QTimer *timer; - -private slots: - void removeStaleDataTimeout(); -}; - -class UAVObjectPlotData : public PlotData -{ - Q_OBJECT -public: - UAVObjectPlotData(QString* uavObject, QString* uavField) - : PlotData(uavObject, uavField) {} - ~UAVObjectPlotData() {} - - bool append(UAVObject* obj); - - virtual PlotType plotType() { - return UAVObjectPlot; - } -}; - -#endif // PLOTDATA_H +/** + ****************************************************************************** + * + * @file plotdata.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Object that manages the data for a curve. + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PLOTDATA_H +#define PLOTDATA_H + +#include "uavobjects/uavobject.h" +#include "uavobjects/altitudeactual.h" +#include "uavobjects/positionactual.h" + + +#include "qwt/src/qwt.h" +#include "qwt/src/qwt_plot.h" +#include "qwt/src/qwt_plot_curve.h" +#include "qwt/src/qwt_scale_draw.h" +#include "qwt/src/qwt_scale_widget.h" + +#include +#include +#include + +enum PlotType { + SequencialPlot, + ChronoPlot, + UAVObjectPlot, + + NPlotTypes +}; + + +class PlotData : public QObject +{ + Q_OBJECT + +public: + PlotData(QString* uavObject, QString* uavField); + ~PlotData(); + + QString* uavObject; + QString* uavField; + QwtPlotCurve* curve; + QVector* xData; + QVector* yData; + int scalePower; //This is the power to wich each value must be raised + double yMinimum; + double yMaximum; + + double m_xWindowSize; + + virtual bool append(UAVObject* obj) = 0; + virtual PlotType plotType() = 0; + +signals: + void dataChanged(); +}; + +class SequencialPlotData : public PlotData +{ + Q_OBJECT +public: + SequencialPlotData(QString* uavObject, QString* uavField) + : PlotData(uavObject, uavField) {} + ~SequencialPlotData() {} + + bool append(UAVObject* obj); + + virtual PlotType plotType() { + return SequencialPlot; + } +}; + +class ChronoPlotData : public PlotData +{ + Q_OBJECT +public: + ChronoPlotData(QString* uavObject, QString* uavField) + : PlotData(uavObject, uavField) { + scalePower = 1; + //Setup timer + timer = new QTimer(); + connect(timer, SIGNAL(timeout()), this, SLOT(removeStaleDataTimeout())); + timer->start(100); + } + ~ChronoPlotData() { + delete timer; + } + + bool append(UAVObject* obj); + + virtual PlotType plotType() { + return ChronoPlot; + } +private: + //QDateTime m_epoch; + void removeStaleData(); + + QTimer *timer; + +private slots: + void removeStaleDataTimeout(); +}; + +class UAVObjectPlotData : public PlotData +{ + Q_OBJECT +public: + UAVObjectPlotData(QString* uavObject, QString* uavField) + : PlotData(uavObject, uavField) {} + ~UAVObjectPlotData() {} + + bool append(UAVObject* obj); + + virtual PlotType plotType() { + return UAVObjectPlot; + } +}; + +#endif // PLOTDATA_H diff --git a/ground/src/plugins/scope/scopegadget.cpp b/ground/src/plugins/scope/scopegadget.cpp index 723856c9d..a3e05941a 100644 --- a/ground/src/plugins/scope/scopegadget.cpp +++ b/ground/src/plugins/scope/scopegadget.cpp @@ -1,40 +1,40 @@ -/** - ****************************************************************************** - * - * @file scopegadget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Gadget configuration - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "scopegadget.h" -#include "scopegadgetwidget.h" - -ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) : - IUAVGadget(classId, parent), - m_widget(widget) -{ -} - -ScopeGadget::~ScopeGadget() -{ - -} +/** + ****************************************************************************** + * + * @file scopegadget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Gadget configuration + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "scopegadget.h" +#include "scopegadgetwidget.h" + +ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) : + IUAVGadget(classId, parent), + m_widget(widget) +{ +} + +ScopeGadget::~ScopeGadget() +{ + +} diff --git a/ground/src/plugins/scope/scopegadget.h b/ground/src/plugins/scope/scopegadget.h index 0c4564446..b44a6fe32 100644 --- a/ground/src/plugins/scope/scopegadget.h +++ b/ground/src/plugins/scope/scopegadget.h @@ -1,65 +1,65 @@ -/** - ****************************************************************************** - * - * @file scopegadget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#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(QString classId, ScopeGadgetWidget *widget, QWidget *parent = 0); - ~ScopeGadget(); - - QList context() const { - return m_context; - } - QWidget *widget() { - return m_widget; - } - QString contextHelpId() const { - return QString(); - } - -private: - QWidget *m_widget; - QList m_context; -}; - - -#endif // SCOPEGADGET_H_ +/** + ****************************************************************************** + * + * @file scopegadget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#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(QString classId, ScopeGadgetWidget *widget, QWidget *parent = 0); + ~ScopeGadget(); + + QList context() const { + return m_context; + } + QWidget *widget() { + return m_widget; + } + QString contextHelpId() const { + return QString(); + } + +private: + QWidget *m_widget; + QList m_context; +}; + + +#endif // SCOPEGADGET_H_ diff --git a/ground/src/plugins/scope/scopegadgetconfiguration.cpp b/ground/src/plugins/scope/scopegadgetconfiguration.cpp index 963622c2a..0cd794ed2 100644 --- a/ground/src/plugins/scope/scopegadgetconfiguration.cpp +++ b/ground/src/plugins/scope/scopegadgetconfiguration.cpp @@ -1,72 +1,72 @@ -/** - ****************************************************************************** - * - * @file scopegadgetconfiguration.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget configuration - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "scopegadgetconfiguration.h" -#include - -ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) : - IUAVGadgetConfiguration(classId, parent) -{ -} - -/** - * Clones a configuration. - * - */ -IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() -{ - ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId()); - //m->m_defaultDial=m_defaultDial; - return m; -} -/** - * Saves a configuration. - * - */ -QByteArray ScopeGadgetConfiguration::saveState() const -{ - QByteArray bytes; -// QDataStream stream(&bytes, QIODevice::WriteOnly); -// stream << m_defaultDial; -// stream << dialBackgroundID; -// stream << dialForegroundID; -// stream << dialNeedleID1; -// stream << dialNeedleID2; -// stream << needle1MinValue; -// stream << needle1MaxValue; -// stream << needle2MinValue; -// stream << needle2MaxValue; -// stream << needle1DataObject; -// stream << needle1ObjectField; -// stream << needle2DataObject; -// stream << needle2ObjectField; -// stream << needle1Factor; -// stream << needle2Factor; - - return bytes; -} - +/** + ****************************************************************************** + * + * @file scopegadgetconfiguration.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget configuration + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "scopegadgetconfiguration.h" +#include + +ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) : + IUAVGadgetConfiguration(classId, parent) +{ +} + +/** + * Clones a configuration. + * + */ +IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone() +{ + ScopeGadgetConfiguration *m = new ScopeGadgetConfiguration(this->classId()); + //m->m_defaultDial=m_defaultDial; + return m; +} +/** + * Saves a configuration. + * + */ +QByteArray ScopeGadgetConfiguration::saveState() const +{ + QByteArray bytes; +// QDataStream stream(&bytes, QIODevice::WriteOnly); +// stream << m_defaultDial; +// stream << dialBackgroundID; +// stream << dialForegroundID; +// stream << dialNeedleID1; +// stream << dialNeedleID2; +// stream << needle1MinValue; +// stream << needle1MaxValue; +// stream << needle2MinValue; +// stream << needle2MaxValue; +// stream << needle1DataObject; +// stream << needle1ObjectField; +// stream << needle2DataObject; +// stream << needle2ObjectField; +// stream << needle1Factor; +// stream << needle2Factor; + + return bytes; +} + diff --git a/ground/src/plugins/scope/scopegadgetconfiguration.h b/ground/src/plugins/scope/scopegadgetconfiguration.h index bed54cb19..056433f68 100644 --- a/ground/src/plugins/scope/scopegadgetconfiguration.h +++ b/ground/src/plugins/scope/scopegadgetconfiguration.h @@ -1,46 +1,46 @@ -/** - ****************************************************************************** - * - * @file scopegadgetconfiguration.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget configuration - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef SCOPEGADGETCONFIGURATION_H -#define SCOPEGADGETCONFIGURATION_H - -#include - -using namespace Core; - -class ScopeGadgetConfiguration : public IUAVGadgetConfiguration -{ - Q_OBJECT -public: - explicit ScopeGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); - - - QByteArray saveState() const; - IUAVGadgetConfiguration *clone(); -}; - -#endif // SCOPEGADGETCONFIGURATION_H +/** + ****************************************************************************** + * + * @file scopegadgetconfiguration.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget configuration + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SCOPEGADGETCONFIGURATION_H +#define SCOPEGADGETCONFIGURATION_H + +#include + +using namespace Core; + +class ScopeGadgetConfiguration : public IUAVGadgetConfiguration +{ + Q_OBJECT +public: + explicit ScopeGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); + + + QByteArray saveState() const; + IUAVGadgetConfiguration *clone(); +}; + +#endif // SCOPEGADGETCONFIGURATION_H diff --git a/ground/src/plugins/scope/scopegadgetfactory.cpp b/ground/src/plugins/scope/scopegadgetfactory.cpp index 93cefaaa0..b0ce1430a 100644 --- a/ground/src/plugins/scope/scopegadgetfactory.cpp +++ b/ground/src/plugins/scope/scopegadgetfactory.cpp @@ -1,59 +1,59 @@ -/** - ****************************************************************************** - * - * @file scopegadgetfactory.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Gadget Factory - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "scopegadgetfactory.h" -#include "scopegadgetwidget.h" -#include "scopegadgetconfiguration.h" -#include "scopegadgetoptionspage.h" -#include "scopegadget.h" -#include - -ScopeGadgetFactory::ScopeGadgetFactory(QObject *parent) : - IUAVGadgetFactory(QString("ScopeGadget"), - tr("Scope Gadget"), - parent) -{ -} - -ScopeGadgetFactory::~ScopeGadgetFactory() -{ -} - -Core::IUAVGadget* ScopeGadgetFactory::createGadget(QWidget *parent) -{ - ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent); - return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent); -} - -IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(const QByteArray &state) -{ - return new ScopeGadgetConfiguration(QString("ScopeGadget"), state); -} - -IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) -{ - return new ScopeGadgetOptionsPage(qobject_cast(config)); -} +/** + ****************************************************************************** + * + * @file scopegadgetfactory.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Gadget Factory + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "scopegadgetfactory.h" +#include "scopegadgetwidget.h" +#include "scopegadgetconfiguration.h" +#include "scopegadgetoptionspage.h" +#include "scopegadget.h" +#include + +ScopeGadgetFactory::ScopeGadgetFactory(QObject *parent) : + IUAVGadgetFactory(QString("ScopeGadget"), + tr("Scope Gadget"), + parent) +{ +} + +ScopeGadgetFactory::~ScopeGadgetFactory() +{ +} + +Core::IUAVGadget* ScopeGadgetFactory::createGadget(QWidget *parent) +{ + ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent); + return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent); +} + +IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(const QByteArray &state) +{ + return new ScopeGadgetConfiguration(QString("ScopeGadget"), state); +} + +IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) +{ + return new ScopeGadgetOptionsPage(qobject_cast(config)); +} diff --git a/ground/src/plugins/scope/scopegadgetfactory.h b/ground/src/plugins/scope/scopegadgetfactory.h index 7c479b08b..addfcec63 100644 --- a/ground/src/plugins/scope/scopegadgetfactory.h +++ b/ground/src/plugins/scope/scopegadgetfactory.h @@ -1,53 +1,53 @@ -/** - ****************************************************************************** - * - * @file scopegadgetfactory.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget Factory - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef SCOPEGADGETFACTORY_H_ -#define SCOPEGADGETFACTORY_H_ - -#include - -namespace Core -{ -class IUAVGadget; -class IUAVGadgetFactory; -} - -using namespace Core; - -class ScopeGadgetFactory : public IUAVGadgetFactory -{ - Q_OBJECT -public: - ScopeGadgetFactory(QObject *parent = 0); - ~ScopeGadgetFactory(); - - Core::IUAVGadget *createGadget(QWidget *parent); - IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); - IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); -}; - -#endif // SCOPEGADGETFACTORY_H_ +/** + ****************************************************************************** + * + * @file scopegadgetfactory.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget Factory + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SCOPEGADGETFACTORY_H_ +#define SCOPEGADGETFACTORY_H_ + +#include + +namespace Core +{ +class IUAVGadget; +class IUAVGadgetFactory; +} + +using namespace Core; + +class ScopeGadgetFactory : public IUAVGadgetFactory +{ + Q_OBJECT +public: + ScopeGadgetFactory(QObject *parent = 0); + ~ScopeGadgetFactory(); + + Core::IUAVGadget *createGadget(QWidget *parent); + IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); + IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); +}; + +#endif // SCOPEGADGETFACTORY_H_ diff --git a/ground/src/plugins/scope/scopegadgetoptionspage.cpp b/ground/src/plugins/scope/scopegadgetoptionspage.cpp index 63ee1aecf..bb177d585 100644 --- a/ground/src/plugins/scope/scopegadgetoptionspage.cpp +++ b/ground/src/plugins/scope/scopegadgetoptionspage.cpp @@ -1,75 +1,75 @@ -/** - ****************************************************************************** - * - * @file scopegadgetoptionspage.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget options page - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "scopegadgetoptionspage.h" -#include "scopegadgetconfiguration.h" -#include "ui_scopegadgetoptionspage.h" - -#include "extensionsystem/pluginmanager.h" -#include "uavobjects/uavobjectmanager.h" -#include "uavobjects/uavdataobject.h" - -ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) : - IOptionsPage(parent), - m_config(config) -{ - //nothing to do here... -} - -//creates options page widget (uses the UI file) -QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) -{ - options_page = new Ui::ScopeGadgetOptionsPage(); - //main widget - QWidget *optionsPageWidget = new QWidget; - //main layout - options_page->setupUi(optionsPageWidget); - - //TODO: Rest of the init stuff here - - - return optionsPageWidget; -} - -/** - * Called when the user presses apply or OK. - * - * Saves the current values - * - */ -void ScopeGadgetOptionsPage::apply() -{ - - //Apply configuration changes - // m_config->setDialFile(options_page->svgSourceFile->text()); - -} - -void ScopeGadgetOptionsPage::finish() -{ - -} +/** + ****************************************************************************** + * + * @file scopegadgetoptionspage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget options page + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "scopegadgetoptionspage.h" +#include "scopegadgetconfiguration.h" +#include "ui_scopegadgetoptionspage.h" + +#include "extensionsystem/pluginmanager.h" +#include "uavobjects/uavobjectmanager.h" +#include "uavobjects/uavdataobject.h" + +ScopeGadgetOptionsPage::ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent) : + IOptionsPage(parent), + m_config(config) +{ + //nothing to do here... +} + +//creates options page widget (uses the UI file) +QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent) +{ + options_page = new Ui::ScopeGadgetOptionsPage(); + //main widget + QWidget *optionsPageWidget = new QWidget; + //main layout + options_page->setupUi(optionsPageWidget); + + //TODO: Rest of the init stuff here + + + return optionsPageWidget; +} + +/** + * Called when the user presses apply or OK. + * + * Saves the current values + * + */ +void ScopeGadgetOptionsPage::apply() +{ + + //Apply configuration changes + // m_config->setDialFile(options_page->svgSourceFile->text()); + +} + +void ScopeGadgetOptionsPage::finish() +{ + +} diff --git a/ground/src/plugins/scope/scopegadgetoptionspage.h b/ground/src/plugins/scope/scopegadgetoptionspage.h index f457bfa10..b19919981 100644 --- a/ground/src/plugins/scope/scopegadgetoptionspage.h +++ b/ground/src/plugins/scope/scopegadgetoptionspage.h @@ -1,66 +1,66 @@ -/** - ****************************************************************************** - * - * @file scopegadgetoptionspage.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget options page - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef SCOPEGADGETOPTIONSPAGE_H -#define SCOPEGADGETOPTIONSPAGE_H - -#include "coreplugin/dialogs/ioptionspage.h" -#include "QString" -#include -#include - -namespace Core -{ -class IUAVGadgetConfiguration; -} - -class ScopeGadgetConfiguration; - -namespace Ui -{ -class ScopeGadgetOptionsPage; -} - -using namespace Core; - -class ScopeGadgetOptionsPage : public IOptionsPage -{ - Q_OBJECT -public: - explicit ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent = 0); - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -private: - Ui::ScopeGadgetOptionsPage *options_page; - ScopeGadgetConfiguration *m_config; - -}; - -#endif // SCOPEGADGETOPTIONSPAGE_H +/** + ****************************************************************************** + * + * @file scopegadgetoptionspage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget options page + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SCOPEGADGETOPTIONSPAGE_H +#define SCOPEGADGETOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" +#include "QString" +#include +#include + +namespace Core +{ +class IUAVGadgetConfiguration; +} + +class ScopeGadgetConfiguration; + +namespace Ui +{ +class ScopeGadgetOptionsPage; +} + +using namespace Core; + +class ScopeGadgetOptionsPage : public IOptionsPage +{ + Q_OBJECT +public: + explicit ScopeGadgetOptionsPage(ScopeGadgetConfiguration *config, QObject *parent = 0); + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +private: + Ui::ScopeGadgetOptionsPage *options_page; + ScopeGadgetConfiguration *m_config; + +}; + +#endif // SCOPEGADGETOPTIONSPAGE_H diff --git a/ground/src/plugins/scope/scopegadgetwidget.cpp b/ground/src/plugins/scope/scopegadgetwidget.cpp index fdf4347b8..fdac2f615 100644 --- a/ground/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/src/plugins/scope/scopegadgetwidget.cpp @@ -1,315 +1,315 @@ -/** - ****************************************************************************** - * - * @file scopegadgetwidget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Gadget Widget - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "uavobjects/uavobjectmanager.h" -#include "extensionsystem/pluginmanager.h" -//#include "uavobjects/uavobject.h" -//#include "uavobjects/uavdataobject.h" -//#include "uavobjects/uavobjectfield.h" -//#include "uavobjects/uavmetaobject.h" - -#include "scopegadgetwidget.h" -#include "qwt/src/qwt_plot_curve.h" -#include "qwt/src/qwt_legend.h" - -#include -#include -#include -#include -#include -#include -#include - - -TestDataGen* ScopeGadgetWidget::testDataGen; - -ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent) -{ - //setupExamplePlot(); - //Setup defaults - //setupSequencialPlot(); - setupChronoPlot(); - addCurvePlot(QString("AltitudeActual"), QString("Altitude"), -1, QPen(Qt::blue)); - addCurvePlot(QString("AltitudeActual"), QString("Temperature"), 0, QPen(Qt::red)); - - //if(testDataGen == 0) - // testDataGen = new TestDataGen(); -} - -void ScopeGadgetWidget::preparePlot(PlotType plotType) -{ - m_plotType = plotType; - - clearCurvePlots(); - - setMinimumSize(64, 64); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - // Show a title - setTitle("Scope"); - - // Show a legend at the bottom - if (legend() == 0) { - QwtLegend *legend = new QwtLegend(); - legend->setFrameStyle(QFrame::Box | QFrame::Sunken); - insertLegend(legend, QwtPlot::BottomLegend); - } -} - -void ScopeGadgetWidget::setupSequencialPlot() -{ - //setAutoReplot(true); - m_xWindowSize = 100; - preparePlot(SequencialPlot); - - setAxisTitle(QwtPlot::xBottom, "Index"); - setAxisScale(QwtPlot::xBottom, 0, m_xWindowSize); - //setAxisLabelRotation(QwtPlot::xBottom, -50.0); - setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); -} - -void ScopeGadgetWidget::setupChronoPlot() -{ - //setAutoReplot(true); - m_xWindowSize = 100; - preparePlot(ChronoPlot); - - setAxisTitle(QwtPlot::xBottom, "Time [h:m:s]"); - setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw()); - uint NOW = QDateTime::currentDateTime().toTime_t(); - setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize, NOW); - setAxisLabelRotation(QwtPlot::xBottom, -50.0); - setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); - - /* - In situations, when there is a label at the most right position of the - scale, additional space is needed to display the overlapping part - of the label would be taken by reducing the width of scale and canvas. - To avoid this "jumping canvas" effect, we add a permanent margin. - We don't need to do the same for the left border, because there - is enough space for the overlapping label below the left scale. - */ - - QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom); - const int fmh = QFontMetrics(scaleWidget->font()).height(); - scaleWidget->setMinBorderDist(0, fmh / 2); -} - -void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor, QPen pen) -{ - PlotData* plotData; - - if (m_plotType == SequencialPlot) - plotData = new SequencialPlotData(&uavObject, &uavField); - else if (m_plotType == ChronoPlot) - plotData = new ChronoPlotData(&uavObject, &uavField); - else if (m_plotType == UAVObjectPlot) - plotData = new UAVObjectPlotData(&uavObject, &uavField); - - plotData->m_xWindowSize = m_xWindowSize; - plotData->scalePower = scaleOrderFactor; - - //If the y-bounds are supplied, set them - if (plotData->yMinimum != plotData->yMaximum) - setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum); - - //Create the curve - QString curveName = *(plotData->uavObject) + "." + *(plotData->uavField); - QwtPlotCurve* plotCurve = new QwtPlotCurve(curveName); - plotCurve->setPen(pen); - plotCurve->setData(*plotData->xData, *plotData->yData); - plotCurve->attach(this); - plotData->curve = plotCurve; - - //Keep the curve details for later - m_curvesData.insert(curveName, plotData); - - //Get the object to monitor - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject(*(plotData->uavObject))); - - //Link to the signal of new data only if this UAVObject has not been to connected yet - if (!m_connectedUAVObjects.contains(obj->getName())) { - m_connectedUAVObjects.append(obj->getName()); - connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*))); - } - - connect(plotData, SIGNAL(dataChanged()), this, SLOT(replotNewData())); -} - -void ScopeGadgetWidget::removeCurvePlot(QString uavObject, QString uavField) -{ - QString curveName = uavObject + "." + uavField; - - PlotData* plotData = m_curvesData.take(curveName); - m_curvesData.remove(curveName); - plotData->curve->detach(); - - delete plotData; -} - -void ScopeGadgetWidget::uavObjectReceived(UAVObject* obj) -{ - foreach(PlotData* plotData, m_curvesData.values()) { - plotData->append(obj); - plotData->curve->setData(*plotData->xData, *plotData->yData); - } -} - -void ScopeGadgetWidget::replotNewData() -{ - if (m_plotType == ChronoPlot) { - uint NOW = QDateTime::currentDateTime().toTime_t(); - setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize, NOW); - } - replot(); -} - - -void ScopeGadgetWidget::setupExamplePlot() -{ - preparePlot(SequencialPlot); - - // 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 cs[ 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]); - cs[i] = 3.0 * cos(x[i]); - sg[i] = (sn[i] > 0) ? 1 : ((sn[i] < 0) ? -1 : 0); - } - - // add curves - QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); - curve1->setPen(QPen(Qt::blue)); - QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); - curve2->setPen(QPen(Qt::red)); - QwtPlotCurve *curve3 = new QwtPlotCurve("Curve 3"); - curve3->setPen(QPen(Qt::green)); - - // copy the data into the curves - curve1->setData(x, sn, points); - curve2->setData(x, cs, points); - curve3->setData(x, sg, points); - - - - curve1->attach(this); - curve2->attach(this); - curve3->attach(this); - - - - // finally, refresh the plot - replot(); -} - - -ScopeGadgetWidget::~ScopeGadgetWidget() -{ - //Get the object to de-monitor - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - - foreach(QString uavObjName, m_connectedUAVObjects) { - UAVDataObject* obj = dynamic_cast(objManager->getObject(uavObjName)); - disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*))); - } - - clearCurvePlots(); -} - -void ScopeGadgetWidget::clearCurvePlots() -{ - foreach(PlotData* plotData, m_curvesData.values()) { - plotData->curve->detach(); - delete plotData->curve; - - delete plotData; - } - - m_curvesData.clear(); -} - -TestDataGen::TestDataGen() -{ - // Get required UAVObjects - ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager* objManager = pm->getObject(); - - altActual = AltitudeActual::GetInstance(objManager); - gps = PositionActual::GetInstance(objManager); - - //Setup timer - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(genTestData())); - timer->start(100); -} - -void TestDataGen::genTestData() -{ - // Update AltitudeActual object - AltitudeActual::DataFields altActualData; - altActualData.Altitude = 500 * sin(0.1 * testTime) + 200 * cos(0.4 * testTime) + 800; - altActualData.Temperature = 30 * sin(0.05 * testTime); - altActualData.Pressure = 100; - altActual->setData(altActualData); - - - // Update gps objects - PositionActual::DataFields gpsData; - gpsData.Altitude = 0; - gpsData.Heading = 0; - gpsData.Groundspeed = 0; - gpsData.Latitude = 0; - gpsData.Longitude = 0; - gpsData.Satellites = 10; - gps->setData(gpsData); - - testTime++; -} - -TestDataGen::~TestDataGen() -{ - if (timer) - timer->stop(); - - delete timer; -} - - +/** + ****************************************************************************** + * + * @file scopegadgetwidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Gadget Widget + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "uavobjects/uavobjectmanager.h" +#include "extensionsystem/pluginmanager.h" +//#include "uavobjects/uavobject.h" +//#include "uavobjects/uavdataobject.h" +//#include "uavobjects/uavobjectfield.h" +//#include "uavobjects/uavmetaobject.h" + +#include "scopegadgetwidget.h" +#include "qwt/src/qwt_plot_curve.h" +#include "qwt/src/qwt_legend.h" + +#include +#include +#include +#include +#include +#include +#include + + +TestDataGen* ScopeGadgetWidget::testDataGen; + +ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent) +{ + //setupExamplePlot(); + //Setup defaults + //setupSequencialPlot(); + setupChronoPlot(); + addCurvePlot(QString("AltitudeActual"), QString("Altitude"), -1, QPen(Qt::blue)); + addCurvePlot(QString("AltitudeActual"), QString("Temperature"), 0, QPen(Qt::red)); + + //if(testDataGen == 0) + // testDataGen = new TestDataGen(); +} + +void ScopeGadgetWidget::preparePlot(PlotType plotType) +{ + m_plotType = plotType; + + clearCurvePlots(); + + setMinimumSize(64, 64); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + // Show a title + setTitle("Scope"); + + // Show a legend at the bottom + if (legend() == 0) { + QwtLegend *legend = new QwtLegend(); + legend->setFrameStyle(QFrame::Box | QFrame::Sunken); + insertLegend(legend, QwtPlot::BottomLegend); + } +} + +void ScopeGadgetWidget::setupSequencialPlot() +{ + //setAutoReplot(true); + m_xWindowSize = 100; + preparePlot(SequencialPlot); + + setAxisTitle(QwtPlot::xBottom, "Index"); + setAxisScale(QwtPlot::xBottom, 0, m_xWindowSize); + //setAxisLabelRotation(QwtPlot::xBottom, -50.0); + setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); +} + +void ScopeGadgetWidget::setupChronoPlot() +{ + //setAutoReplot(true); + m_xWindowSize = 100; + preparePlot(ChronoPlot); + + setAxisTitle(QwtPlot::xBottom, "Time [h:m:s]"); + setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw()); + uint NOW = QDateTime::currentDateTime().toTime_t(); + setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize, NOW); + setAxisLabelRotation(QwtPlot::xBottom, -50.0); + setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); + + /* + In situations, when there is a label at the most right position of the + scale, additional space is needed to display the overlapping part + of the label would be taken by reducing the width of scale and canvas. + To avoid this "jumping canvas" effect, we add a permanent margin. + We don't need to do the same for the left border, because there + is enough space for the overlapping label below the left scale. + */ + + QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom); + const int fmh = QFontMetrics(scaleWidget->font()).height(); + scaleWidget->setMinBorderDist(0, fmh / 2); +} + +void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor, QPen pen) +{ + PlotData* plotData; + + if (m_plotType == SequencialPlot) + plotData = new SequencialPlotData(&uavObject, &uavField); + else if (m_plotType == ChronoPlot) + plotData = new ChronoPlotData(&uavObject, &uavField); + else if (m_plotType == UAVObjectPlot) + plotData = new UAVObjectPlotData(&uavObject, &uavField); + + plotData->m_xWindowSize = m_xWindowSize; + plotData->scalePower = scaleOrderFactor; + + //If the y-bounds are supplied, set them + if (plotData->yMinimum != plotData->yMaximum) + setAxisScale(QwtPlot::yLeft, plotData->yMinimum, plotData->yMaximum); + + //Create the curve + QString curveName = *(plotData->uavObject) + "." + *(plotData->uavField); + QwtPlotCurve* plotCurve = new QwtPlotCurve(curveName); + plotCurve->setPen(pen); + plotCurve->setData(*plotData->xData, *plotData->yData); + plotCurve->attach(this); + plotData->curve = plotCurve; + + //Keep the curve details for later + m_curvesData.insert(curveName, plotData); + + //Get the object to monitor + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + UAVDataObject* obj = dynamic_cast(objManager->getObject(*(plotData->uavObject))); + + //Link to the signal of new data only if this UAVObject has not been to connected yet + if (!m_connectedUAVObjects.contains(obj->getName())) { + m_connectedUAVObjects.append(obj->getName()); + connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*))); + } + + connect(plotData, SIGNAL(dataChanged()), this, SLOT(replotNewData())); +} + +void ScopeGadgetWidget::removeCurvePlot(QString uavObject, QString uavField) +{ + QString curveName = uavObject + "." + uavField; + + PlotData* plotData = m_curvesData.take(curveName); + m_curvesData.remove(curveName); + plotData->curve->detach(); + + delete plotData; +} + +void ScopeGadgetWidget::uavObjectReceived(UAVObject* obj) +{ + foreach(PlotData* plotData, m_curvesData.values()) { + plotData->append(obj); + plotData->curve->setData(*plotData->xData, *plotData->yData); + } +} + +void ScopeGadgetWidget::replotNewData() +{ + if (m_plotType == ChronoPlot) { + uint NOW = QDateTime::currentDateTime().toTime_t(); + setAxisScale(QwtPlot::xBottom, NOW - m_xWindowSize, NOW); + } + replot(); +} + + +void ScopeGadgetWidget::setupExamplePlot() +{ + preparePlot(SequencialPlot); + + // 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 cs[ 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]); + cs[i] = 3.0 * cos(x[i]); + sg[i] = (sn[i] > 0) ? 1 : ((sn[i] < 0) ? -1 : 0); + } + + // add curves + QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); + curve1->setPen(QPen(Qt::blue)); + QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); + curve2->setPen(QPen(Qt::red)); + QwtPlotCurve *curve3 = new QwtPlotCurve("Curve 3"); + curve3->setPen(QPen(Qt::green)); + + // copy the data into the curves + curve1->setData(x, sn, points); + curve2->setData(x, cs, points); + curve3->setData(x, sg, points); + + + + curve1->attach(this); + curve2->attach(this); + curve3->attach(this); + + + + // finally, refresh the plot + replot(); +} + + +ScopeGadgetWidget::~ScopeGadgetWidget() +{ + //Get the object to de-monitor + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + + foreach(QString uavObjName, m_connectedUAVObjects) { + UAVDataObject* obj = dynamic_cast(objManager->getObject(uavObjName)); + disconnect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(uavObjectReceived(UAVObject*))); + } + + clearCurvePlots(); +} + +void ScopeGadgetWidget::clearCurvePlots() +{ + foreach(PlotData* plotData, m_curvesData.values()) { + plotData->curve->detach(); + delete plotData->curve; + + delete plotData; + } + + m_curvesData.clear(); +} + +TestDataGen::TestDataGen() +{ + // Get required UAVObjects + ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager* objManager = pm->getObject(); + + altActual = AltitudeActual::GetInstance(objManager); + gps = PositionActual::GetInstance(objManager); + + //Setup timer + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(genTestData())); + timer->start(100); +} + +void TestDataGen::genTestData() +{ + // Update AltitudeActual object + AltitudeActual::DataFields altActualData; + altActualData.Altitude = 500 * sin(0.1 * testTime) + 200 * cos(0.4 * testTime) + 800; + altActualData.Temperature = 30 * sin(0.05 * testTime); + altActualData.Pressure = 100; + altActual->setData(altActualData); + + + // Update gps objects + PositionActual::DataFields gpsData; + gpsData.Altitude = 0; + gpsData.Heading = 0; + gpsData.Groundspeed = 0; + gpsData.Latitude = 0; + gpsData.Longitude = 0; + gpsData.Satellites = 10; + gps->setData(gpsData); + + testTime++; +} + +TestDataGen::~TestDataGen() +{ + if (timer) + timer->stop(); + + delete timer; +} + + diff --git a/ground/src/plugins/scope/scopegadgetwidget.h b/ground/src/plugins/scope/scopegadgetwidget.h index eb8f61afd..d2f8a8d55 100644 --- a/ground/src/plugins/scope/scopegadgetwidget.h +++ b/ground/src/plugins/scope/scopegadgetwidget.h @@ -1,117 +1,117 @@ -/** - ****************************************************************************** - * - * @file scopegadgetwidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin Gadget Widget - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef SCOPEGADGETWIDGET_H_ -#define SCOPEGADGETWIDGET_H_ - -#include "plotdata.h" -#include "uavobjects/uavobject.h" -#include "uavobjects/altitudeactual.h" -#include "uavobjects/positionactual.h" - - -#include "qwt/src/qwt.h" -#include "qwt/src/qwt_plot.h" -#include "qwt/src/qwt_plot_curve.h" -#include "qwt/src/qwt_scale_draw.h" -#include "qwt/src/qwt_scale_widget.h" - -#include -#include -#include - -class TimeScaleDraw : public QwtScaleDraw -{ -public: - TimeScaleDraw() { - baseTime = QDateTime::currentDateTime().toTime_t(); - } - virtual QwtText label(double v) const { - QDateTime upTime = QDateTime::fromTime_t((uint)v); - return upTime.toLocalTime().toString("hh:mm:ss"); - } -private: - double baseTime; -}; - -class TestDataGen : QObject -{ - Q_OBJECT - -public: - - TestDataGen(); - ~TestDataGen(); - -private: - AltitudeActual* altActual; - PositionActual* gps; - - QTimer *timer; - double testTime; - -private slots: - void genTestData(); -}; - - -class ScopeGadgetWidget : public QwtPlot -{ - Q_OBJECT - -public: - ScopeGadgetWidget(QWidget *parent = 0); - ~ScopeGadgetWidget(); - - -private slots: - void uavObjectReceived(UAVObject*); - void replotNewData(); - -private: - - void preparePlot(PlotType plotType); - void setupExamplePlot(); - void setupSequencialPlot(); - void setupChronoPlot(); - void setupUAVObjectPlot(); - - void addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor = 0, QPen pen = QPen(Qt::black)); - void removeCurvePlot(QString uavObject, QString uavField); - void clearCurvePlots(); - - PlotType m_plotType; - - double m_xWindowSize; - QVector m_connectedUAVObjects; - QMap m_curvesData; - - static TestDataGen* testDataGen; -}; - - -#endif /* SCOPEGADGETWIDGET_H_ */ +/** + ****************************************************************************** + * + * @file scopegadgetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin Gadget Widget + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SCOPEGADGETWIDGET_H_ +#define SCOPEGADGETWIDGET_H_ + +#include "plotdata.h" +#include "uavobjects/uavobject.h" +#include "uavobjects/altitudeactual.h" +#include "uavobjects/positionactual.h" + + +#include "qwt/src/qwt.h" +#include "qwt/src/qwt_plot.h" +#include "qwt/src/qwt_plot_curve.h" +#include "qwt/src/qwt_scale_draw.h" +#include "qwt/src/qwt_scale_widget.h" + +#include +#include +#include + +class TimeScaleDraw : public QwtScaleDraw +{ +public: + TimeScaleDraw() { + baseTime = QDateTime::currentDateTime().toTime_t(); + } + virtual QwtText label(double v) const { + QDateTime upTime = QDateTime::fromTime_t((uint)v); + return upTime.toLocalTime().toString("hh:mm:ss"); + } +private: + double baseTime; +}; + +class TestDataGen : QObject +{ + Q_OBJECT + +public: + + TestDataGen(); + ~TestDataGen(); + +private: + AltitudeActual* altActual; + PositionActual* gps; + + QTimer *timer; + double testTime; + +private slots: + void genTestData(); +}; + + +class ScopeGadgetWidget : public QwtPlot +{ + Q_OBJECT + +public: + ScopeGadgetWidget(QWidget *parent = 0); + ~ScopeGadgetWidget(); + + +private slots: + void uavObjectReceived(UAVObject*); + void replotNewData(); + +private: + + void preparePlot(PlotType plotType); + void setupExamplePlot(); + void setupSequencialPlot(); + void setupChronoPlot(); + void setupUAVObjectPlot(); + + void addCurvePlot(QString uavObject, QString uavField, int scaleOrderFactor = 0, QPen pen = QPen(Qt::black)); + void removeCurvePlot(QString uavObject, QString uavField); + void clearCurvePlots(); + + PlotType m_plotType; + + double m_xWindowSize; + QVector m_connectedUAVObjects; + QMap m_curvesData; + + static TestDataGen* testDataGen; +}; + + +#endif /* SCOPEGADGETWIDGET_H_ */ diff --git a/ground/src/plugins/scope/scopeplugin.cpp b/ground/src/plugins/scope/scopeplugin.cpp index 44a3e73a8..42ec108f4 100644 --- a/ground/src/plugins/scope/scopeplugin.cpp +++ b/ground/src/plugins/scope/scopeplugin.cpp @@ -1,66 +1,66 @@ -/** - ****************************************************************************** - * - * @file scopeplugin.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#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); - - return true; -} - -void ScopePlugin::extensionsInitialized() -{ - // Do nothing -} - -void ScopePlugin::shutdown() -{ - // Do nothing -} -Q_EXPORT_PLUGIN(ScopePlugin) - +/** + ****************************************************************************** + * + * @file scopeplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#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); + + 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 index 9d8299c8a..c735a8058 100644 --- a/ground/src/plugins/scope/scopeplugin.h +++ b/ground/src/plugins/scope/scopeplugin.h @@ -1,46 +1,46 @@ -/** - ****************************************************************************** - * - * @file scopeplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Scope Plugin - * @see The GNU Public License (GPL) Version 3 - * @defgroup Scope - * @{ - * - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#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_ */ +/** + ****************************************************************************** + * + * @file scopeplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Scope Plugin + * @see The GNU Public License (GPL) Version 3 + * @defgroup scopeplugin + * @{ + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#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_ */