From 532fc3071a9fb850bdb97f0b030937f835f38d34 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 10 Jul 2012 00:26:59 +0200 Subject: [PATCH 1/3] OP-39 Initial commit. Created new sub project to plugins project. Added plug-in and registering menu item to start the wizard. Created SetupWizard sub class of QWizard to host logic for wizard traversal and data collection. --- ground/openpilotgcs/src/plugins/plugins.pro | 7 ++ .../setupwizard/SetupWizard.pluginspec | 10 +++ .../src/plugins/setupwizard/setupwizard.cpp | 37 ++++++++ .../src/plugins/setupwizard/setupwizard.h | 41 +++++++++ .../src/plugins/setupwizard/setupwizard.pro | 13 +++ .../plugins/setupwizard/setupwizardplugin.cpp | 85 +++++++++++++++++++ .../plugins/setupwizard/setupwizardplugin.h | 50 +++++++++++ 7 files changed, 243 insertions(+) create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/SetupWizard.pluginspec create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 154335e3a..c2c7c922b 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -210,6 +210,13 @@ plugin_uavobjectwidgetutils.depends += plugin_uavobjects plugin_uavobjectwidgetutils.depends += plugin_uavsettingsimportexport SUBDIRS += plugin_uavobjectwidgetutils +# Setup Wizard plugin +plugin_setupwizard.subdir = setupwizard +plugin_setupwizard.depends = plugin_coreplugin +plugin_setupwizard.depends += plugin_uavobjects +plugin_setupwizard.depends += plugin_uavsettingsimportexport +SUBDIRS += plugin_setupwizard + # Junsi Powerlog plugin #plugin_powerlog.subdir = powerlog #plugin_powerlog.depends = plugin_coreplugin diff --git a/ground/openpilotgcs/src/plugins/setupwizard/SetupWizard.pluginspec b/ground/openpilotgcs/src/plugins/setupwizard/SetupWizard.pluginspec new file mode 100644 index 000000000..4425b290e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/SetupWizard.pluginspec @@ -0,0 +1,10 @@ + + The OpenPilot Project + (C) 2012 OpenPilot Project + The GNU Public License (GPL) Version 3 + A plugin that provides a setup wizard for easy initial setup of airframes. + http://www.openpilot.org + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp new file mode 100644 index 000000000..1513b40b2 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -0,0 +1,37 @@ +/** + ****************************************************************************** + * + * @file setupwizard.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Setup Wizard Plugin + * @{ + * @brief A Wizards to make the initial setup easy for everyone. + *****************************************************************************/ +/* + * 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 "setupwizard.h" + +SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) +{ + setWindowTitle("GCS Setup Wizard"); + QWizardPage* page = new QWizardPage(); + page->setFixedSize(300, 300); + addPage(page); +} + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h new file mode 100644 index 000000000..7bd907cad --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -0,0 +1,41 @@ +/** + ****************************************************************************** + * + * @file setupwizard.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Setup Wizard Plugin + * @{ + * @brief A Wizards to make the initial setup easy for everyone. + *****************************************************************************/ +/* + * 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 SETUPWIZARD_H +#define SETUPWIZARD_H + +#include + +class SetupWizard : public QWizard +{ + Q_OBJECT + +public: + SetupWizard(QWidget *parent = 0); +}; + +#endif // SETUPWIZARD_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro new file mode 100644 index 000000000..cc5122a25 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -0,0 +1,13 @@ + +TEMPLATE = lib +TARGET = SetupWizard + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) + +HEADERS += setupwizardplugin.h \ + setupwizard.h +SOURCES += setupwizardplugin.cpp \ + setupwizard.cpp + +OTHER_FILES += SetupWizard.pluginspec \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp new file mode 100644 index 000000000..5ac0b4c6c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp @@ -0,0 +1,85 @@ +/** + ****************************************************************************** + * + * @file donothingplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup SetupWizardPlugin Do Nothing Plugin + * @{ + * @brief A Setup Wizard 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 + */ +#include "setupwizardplugin.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +SetupWizardPlugin::SetupWizardPlugin() +{ + // Do nothing +} + +SetupWizardPlugin::~SetupWizardPlugin() +{ +} + +bool SetupWizardPlugin::initialize(const QStringList& args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + + // Add Menu entry + Core::ActionManager* am = Core::ICore::instance()->actionManager(); + Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); + + Core::Command* cmd = am->registerAction(new QAction(this), + "SetupWizardPlugin.ShowSetupWizard", + QList() << + Core::Constants::C_GLOBAL_ID); + cmd->setDefaultKeySequence(QKeySequence("Ctrl+W")); + cmd->action()->setText(tr("GCS Setup Wizard")); + + ac->menu()->addSeparator(); + ac->appendGroup("Wizard"); + ac->addAction(cmd, "Wizard"); + + connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(showSetupWizard())); + return true; +} + +void SetupWizardPlugin::extensionsInitialized() +{ +} + +void SetupWizardPlugin::shutdown() +{ +} + +void SetupWizardPlugin::showSetupWizard() +{ + SetupWizard().exec(); +} + +Q_EXPORT_PLUGIN(SetupWizardPlugin) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h new file mode 100644 index 000000000..dcff10a60 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * + * @file donothingplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup DoNothingPlugin Do Nothing Plugin + * @{ + * @brief A minimal example 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 SETUPWIZARDPLUGIN_H +#define SETUPWIZARDPLUGIN_H + +#include +#include +#include "setupwizard.h" + +class SetupWizardPlugin : public ExtensionSystem::IPlugin +{ + Q_OBJECT +public: + SetupWizardPlugin(); + ~SetupWizardPlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString * errorString); + void shutdown(); + +private slots: + void showSetupWizard(); + +}; + +#endif // SETUPWIZARDPLUGIN_H From 559be15142c5d6ef425b855aeee673a181ad023f Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 11 Jul 2012 01:00:41 +0200 Subject: [PATCH 2/3] OP-39 Start and End pages added. Placeholder text added. --- .../src/plugins/setupwizard/pages/endpage.cpp | 15 ++++ .../src/plugins/setupwizard/pages/endpage.h | 22 +++++ .../src/plugins/setupwizard/pages/endpage.ui | 80 +++++++++++++++++++ .../plugins/setupwizard/pages/startpage.cpp | 14 ++++ .../src/plugins/setupwizard/pages/startpage.h | 22 +++++ .../plugins/setupwizard/pages/startpage.ui | 56 +++++++++++++ .../src/plugins/setupwizard/setupwizard.cpp | 27 +++++-- .../src/plugins/setupwizard/setupwizard.h | 8 +- .../src/plugins/setupwizard/setupwizard.pro | 14 +++- .../plugins/setupwizard/setupwizardplugin.cpp | 4 +- .../plugins/setupwizard/setupwizardplugin.h | 4 +- 11 files changed, 252 insertions(+), 14 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp new file mode 100644 index 000000000..3270e23ff --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp @@ -0,0 +1,15 @@ +#include "endpage.h" +#include "ui_endpage.h" + +EndPage::EndPage(QWidget *parent) : + QWizardPage(parent), + ui(new Ui::EndPage) +{ + setFinalPage(true); + ui->setupUi(this); +} + +EndPage::~EndPage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h new file mode 100644 index 000000000..e4179e677 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h @@ -0,0 +1,22 @@ +#ifndef ENDPAGE_H +#define ENDPAGE_H + +#include + +namespace Ui { +class EndPage; +} + +class EndPage : public QWizardPage +{ + Q_OBJECT + +public: + explicit EndPage(QWidget *parent = 0); + ~EndPage(); + +private: + Ui::EndPage *ui; +}; + +#endif // ENDPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui new file mode 100644 index 000000000..cc0a5c162 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui @@ -0,0 +1,80 @@ + + + EndPage + + + + 0 + 0 + 600 + 400 + + + + + 600 + 400 + + + + WizardPage + + + + + 20 + 20 + 550 + 141 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Setup complete</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">The wizard have now gathered enough information to create a baseline configuration for your OpenPilot controller board to use with your vehicle.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">You now have two choices:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">- Upload configuration directly to the currently connected OpenPilot controller board.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">- Save the configuration to a file for later uploading using the configuration import plugin in GCS.</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 420 + 290 + 125 + 23 + + + + Save configuration... + + + + + + 420 + 340 + 125 + 23 + + + + Uppload configuration + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp new file mode 100644 index 000000000..f36631bb0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp @@ -0,0 +1,14 @@ +#include "startpage.h" +#include "ui_startpage.h" + +StartPage::StartPage(QWidget *parent) : + QWizardPage(parent), + ui(new Ui::StartPage) +{ + ui->setupUi(this); +} + +StartPage::~StartPage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h new file mode 100644 index 000000000..f6cf9b6cd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h @@ -0,0 +1,22 @@ +#ifndef STARTPAGE_H +#define STARTPAGE_H + +#include + +namespace Ui { +class StartPage; +} + +class StartPage : public QWizardPage +{ + Q_OBJECT + +public: + explicit StartPage(QWidget *parent = 0); + ~StartPage(); + +private: + Ui::StartPage *ui; +}; + +#endif // STARTPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui new file mode 100644 index 000000000..0f656f35c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui @@ -0,0 +1,56 @@ + + + StartPage + + + + 0 + 0 + 640 + 400 + + + + + 640 + 400 + + + + WizardPage + + + + + 20 + 20 + 550 + 350 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Welcome to the OpenPilot Setup Wizard</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This wizard will guide you through the basic steps of setting up your OpenPilot controller board. The following pages contains simple questions about your vehicle and its characteristics. </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">From the information </span><span style=" font-size:10pt;">gathered</span><span style=" font-size:10pt;"> the wizard will create a baseline configuration that should be good enough for you to get a quick start using your OpenPilot product.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">The baseline configuration can, if desired, be uploaded to the OpenPilot Controller board at the end of this wizard.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This wizard does not contain the full range of settings available in the GCS Config plugin. All configuration parameters can be changed at later by using the GCS Config plugin.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Ok, lets start the configuration by clicking on the 'Next' button below.</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 1513b40b2..26a5e386a 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -7,7 +7,7 @@ * @{ * @addtogroup Setup Wizard Plugin * @{ - * @brief A Wizards to make the initial setup easy for everyone. + * @brief A Wizard to make the initial setup easy for everyone. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -26,12 +26,29 @@ */ #include "setupwizard.h" +#include "pages/startpage.h" +#include "pages/endpage.h" SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) { - setWindowTitle("GCS Setup Wizard"); - QWizardPage* page = new QWizardPage(); - page->setFixedSize(300, 300); - addPage(page); + setWindowTitle("OpenPilot Setup Wizard"); + createPages(); } +int SetupWizard::nextId() const +{ + switch (currentId()) { + case PAGE_START: + return PAGE_END; + default: + return -1; + } +} + +void SetupWizard::createPages() +{ + setPage(PAGE_START, new StartPage()); + setPage(PAGE_END, new EndPage()); + + setStartId(PAGE_START); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h index 7bd907cad..42f75556a 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -32,10 +32,14 @@ class SetupWizard : public QWizard { - Q_OBJECT + Q_OBJECT public: - SetupWizard(QWidget *parent = 0); + SetupWizard(QWidget *parent = 0); + int nextId() const; +private: + enum {PAGE_START, PAGE_END}; + void createPages(); }; #endif // SETUPWIZARD_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index cc5122a25..20d13155d 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -6,8 +6,16 @@ include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) HEADERS += setupwizardplugin.h \ - setupwizard.h + setupwizard.h \ + pages/startpage.h \ + pages/endpage.h SOURCES += setupwizardplugin.cpp \ - setupwizard.cpp + setupwizard.cpp \ + pages/startpage.cpp \ + pages/endpage.cpp -OTHER_FILES += SetupWizard.pluginspec \ No newline at end of file +OTHER_FILES += SetupWizard.pluginspec + +FORMS += \ + pages/startpage.ui \ + pages/endpage.ui \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp index 5ac0b4c6c..a6dddbd4c 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp @@ -5,7 +5,7 @@ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @addtogroup GCSPlugins GCS Plugins * @{ - * @addtogroup SetupWizardPlugin Do Nothing Plugin + * @addtogroup SetupWizardPlugin * @{ * @brief A Setup Wizard Plugin *****************************************************************************/ @@ -59,7 +59,7 @@ bool SetupWizardPlugin::initialize(const QStringList& args, QString *errMsg) QList() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+W")); - cmd->action()->setText(tr("GCS Setup Wizard")); + cmd->action()->setText(tr("OpenPilot Setup Wizard")); ac->menu()->addSeparator(); ac->appendGroup("Wizard"); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h index dcff10a60..4caecbcd0 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h @@ -5,9 +5,9 @@ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @addtogroup GCSPlugins GCS Plugins * @{ - * @addtogroup DoNothingPlugin Do Nothing Plugin + * @addtogroup SetupWizardPlugin * @{ - * @brief A minimal example plugin + * @brief A Setup Wizard Plugin *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify From ebe76e4ae65f7b4b94f705e7a418699936186494 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 17 Jul 2012 01:24:22 +0200 Subject: [PATCH 3/3] OP-39 Added some pages and some functionality to the OP SetupWizard. --- .../plugins/coreplugin/connectionmanager.cpp | 143 +++++------ .../plugins/coreplugin/connectionmanager.h | 32 ++- .../setupwizard/pages/abstractwizardpage.cpp | 35 +++ .../setupwizard/pages/abstractwizardpage.h | 48 ++++ .../setupwizard/pages/controllerpage.cpp | 225 ++++++++++++++++++ .../setupwizard/pages/controllerpage.h | 67 ++++++ .../setupwizard/pages/controllerpage.ui | 163 +++++++++++++ .../src/plugins/setupwizard/pages/endpage.cpp | 30 ++- .../src/plugins/setupwizard/pages/endpage.h | 33 ++- .../src/plugins/setupwizard/pages/endpage.ui | 2 +- .../setupwizard/pages/fixedwingpage.cpp | 42 ++++ .../plugins/setupwizard/pages/fixedwingpage.h | 49 ++++ .../setupwizard/pages/fixedwingpage.ui | 43 ++++ .../plugins/setupwizard/pages/helipage.cpp | 42 ++++ .../src/plugins/setupwizard/pages/helipage.h | 49 ++++ .../src/plugins/setupwizard/pages/helipage.ui | 43 ++++ .../plugins/setupwizard/pages/multipage.cpp | 125 ++++++++++ .../src/plugins/setupwizard/pages/multipage.h | 59 +++++ .../plugins/setupwizard/pages/multipage.ui | 146 ++++++++++++ .../pages/notyetimplementedpage.cpp | 42 ++++ .../setupwizard/pages/notyetimplementedpage.h | 49 ++++ .../pages/notyetimplementedpage.ui | 43 ++++ .../plugins/setupwizard/pages/startpage.cpp | 30 ++- .../src/plugins/setupwizard/pages/startpage.h | 32 ++- .../plugins/setupwizard/pages/surfacepage.cpp | 42 ++++ .../plugins/setupwizard/pages/surfacepage.h | 49 ++++ .../plugins/setupwizard/pages/surfacepage.ui | 43 ++++ .../plugins/setupwizard/pages/vehiclepage.cpp | 61 +++++ .../plugins/setupwizard/pages/vehiclepage.h | 50 ++++ .../plugins/setupwizard/pages/vehiclepage.ui | 168 +++++++++++++ .../src/plugins/setupwizard/setupwizard.cpp | 59 ++++- .../src/plugins/setupwizard/setupwizard.h | 20 +- .../src/plugins/setupwizard/setupwizard.pro | 36 ++- .../plugins/setupwizard/setupwizardplugin.cpp | 4 +- .../plugins/setupwizard/setupwizardplugin.h | 4 +- .../plugins/setupwizard/wizardResources.qrc | 3 + 36 files changed, 2002 insertions(+), 109 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index f49d98c0e..5fa2ead50 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -44,15 +44,15 @@ namespace Core { ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack) : - QWidget(mainWindow), // Pip - m_availableDevList(0), + QWidget(mainWindow), // Pip + m_availableDevList(0), m_connectBtn(0), - m_ioDev(NULL), - m_mainWindow(mainWindow) + m_ioDev(NULL), + m_mainWindow(mainWindow) { - // Q_UNUSED(mainWindow); + // Q_UNUSED(mainWindow); -/* QVBoxLayout *top = new QVBoxLayout; + /* QVBoxLayout *top = new QVBoxLayout; top->setSpacing(0); top->setMargin(0);*/ @@ -72,7 +72,7 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge m_connectBtn->setEnabled(false); layout->addWidget(m_connectBtn); -/* Utils::StyledBar *bar = new Utils::StyledBar; + /* Utils::StyledBar *bar = new Utils::StyledBar; bar->setLayout(layout); top->addWidget(bar);*/ @@ -81,33 +81,29 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge // modeStack->insertCornerWidget(modeStack->cornerWidgetCount()-1, this); modeStack->setCornerWidget(this, Qt::TopRightCorner); - QObject::connect(m_connectBtn, SIGNAL(pressed()), this, SLOT(onConnectPressed())); + QObject::connect(m_connectBtn, SIGNAL(pressed()), this, SLOT(onConnectPressed())); } ConnectionManager::~ConnectionManager() { - disconnectDevice(); // Pip - suspendPolling(); // Pip + disconnectDevice(); // Pip + suspendPolling(); // Pip } void ConnectionManager::init() { //register to the plugin manager so we can receive //new connection object from plugins - QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(objectAdded(QObject*)), this, SLOT(objectAdded(QObject*))); - QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject*)), this, SLOT(aboutToRemoveObject(QObject*))); + QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(objectAdded(QObject*)), this, SLOT(objectAdded(QObject*))); + QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject*)), this, SLOT(aboutToRemoveObject(QObject*))); } /** * Method called when the user clicks the "Connect" button */ -bool ConnectionManager::connectDevice() +bool ConnectionManager::connectDevice(devListItem device) { - devListItem connection_device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(),Qt::ToolTipRole).toString()); - if (!connection_device.connection) - return false; - - QIODevice *io_dev = connection_device.connection->openDevice(connection_device.Name); + QIODevice *io_dev = device.connection->openDevice(device.Name); if (!io_dev) return false; @@ -115,23 +111,23 @@ bool ConnectionManager::connectDevice() // check if opening the device worked if (!io_dev->isOpen()) { - qDebug() << "Error: io_dev->isOpen() returned FALSE .. could not open connection to " << connection_device.devName + qDebug() << "Error: io_dev->isOpen() returned FALSE .. could not open connection to " << device.devName << ": " << io_dev->errorString(); // close the device // EDOUARD: why do we close if we could not open ??? try { - connection_device.connection->closeDevice(connection_device.devName); + device.connection->closeDevice(device.devName); } catch (...) { // handle exception - qDebug() << "Exception: connection_device.connection->closeDevice(" << connection_device.devName << ")"; + qDebug() << "Exception: connection_device.connection->closeDevice(" << device.devName << ")"; } return false; } // we appear to have connected to the device OK // remember the connection/device details - m_connectionDevice = connection_device; + m_connectionDevice = device; m_ioDev = io_dev; connect(m_connectionDevice.connection, SIGNAL(destroyed(QObject *)), this, SLOT(onConnectionDestroyed(QObject *)), Qt::QueuedConnection); @@ -171,6 +167,8 @@ bool ConnectionManager::disconnectDevice() m_connectionDevice.connection = NULL; m_ioDev = NULL; + emit deviceDisconnected(); + m_connectBtn->setText("Connect"); m_availableDevList->setEnabled(true); @@ -184,7 +182,7 @@ void ConnectionManager::objectAdded(QObject *obj) { //Check if a plugin added a connection object to the pool IConnection *connection = Aggregation::query(obj); - if (!connection) return; + if (!connection) return; //qDebug() << "Connection object registered:" << connection->connectionName(); //qDebug() << connection->availableDevices(); @@ -196,23 +194,23 @@ void ConnectionManager::objectAdded(QObject *obj) // to do things m_connectionsList.append(connection); - QObject::connect(connection, SIGNAL(availableDevChanged(IConnection *)), this, SLOT(devChanged(IConnection *))); + QObject::connect(connection, SIGNAL(availableDevChanged(IConnection *)), this, SLOT(devChanged(IConnection *))); } void ConnectionManager::aboutToRemoveObject(QObject *obj) { //Check if a plugin added a connection object to the pool IConnection *connection = Aggregation::query(obj); - if (!connection) return; + if (!connection) return; - if (m_connectionDevice.connection && m_connectionDevice.connection == connection) // Pip - { // we are currently using the one that is about to be removed - m_connectionDevice.connection = NULL; - m_ioDev = NULL; - } + if (m_connectionDevice.connection && m_connectionDevice.connection == connection) // Pip + { // we are currently using the one that is about to be removed + m_connectionDevice.connection = NULL; + m_ioDev = NULL; + } - if (m_connectionsList.contains(connection)) - m_connectionsList.removeAt(m_connectionsList.indexOf(connection)); + if (m_connectionsList.contains(connection)) + m_connectionsList.removeAt(m_connectionsList.indexOf(connection)); } @@ -230,8 +228,11 @@ void ConnectionManager::onConnectPressed() { // Check if we have a ioDev already created: if (!m_ioDev) - { // connecting - connectDevice(); + { + // connecting to currently selected device + devListItem device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(), Qt::ToolTipRole).toString()); + if (device.connection) + connectDevice(device); } else { // disconnecting @@ -244,9 +245,9 @@ void ConnectionManager::onConnectPressed() */ devListItem ConnectionManager::findDevice(const QString &devName) { - foreach (devListItem d, m_devList) + foreach (devListItem d, m_devList) { - if (d.devName == devName) + if (d.devName == devName) return d; } @@ -264,13 +265,13 @@ devListItem ConnectionManager::findDevice(const QString &devName) */ void ConnectionManager::suspendPolling() { - foreach (IConnection *cnx, m_connectionsList) - { + foreach (IConnection *cnx, m_connectionsList) + { cnx->suspendPolling(); } - m_connectBtn->setEnabled(false); - m_availableDevList->setEnabled(false); + m_connectBtn->setEnabled(false); + m_availableDevList->setEnabled(false); } /** @@ -279,13 +280,13 @@ void ConnectionManager::suspendPolling() */ void ConnectionManager::resumePolling() { - foreach (IConnection *cnx, m_connectionsList) - { + foreach (IConnection *cnx, m_connectionsList) + { cnx->resumePolling(); } - m_connectBtn->setEnabled(true); - m_availableDevList->setEnabled(true); + m_connectBtn->setEnabled(true); + m_availableDevList->setEnabled(true); } /** @@ -294,21 +295,21 @@ void ConnectionManager::resumePolling() */ void ConnectionManager::unregisterAll(IConnection *connection) { - for (QLinkedList::iterator iter = m_devList.begin(); iter != m_devList.end(); ) - { - if (iter->connection == connection) - { - if (m_connectionDevice.connection && m_connectionDevice.connection == connection) - { // we are currently using the one we are about to erase - //onConnectionClosed(m_connectionDevice.connection); - disconnectDevice(); - } + for (QLinkedList::iterator iter = m_devList.begin(); iter != m_devList.end(); ) + { + if (iter->connection == connection) + { + if (m_connectionDevice.connection && m_connectionDevice.connection == connection) + { // we are currently using the one we are about to erase + //onConnectionClosed(m_connectionDevice.connection); + disconnectDevice(); + } - iter = m_devList.erase(iter); - } - else - ++iter; - } + iter = m_devList.erase(iter); + } + else + ++iter; + } } /** @@ -347,7 +348,7 @@ void ConnectionManager::devChanged(IConnection *connection) unregisterAll(connection); //and add them back in the list - QList availableDev = connection->availableDevices(); + QList availableDev = connection->availableDevices(); foreach (IConnection::device dev, availableDev) { QString cbName = connection->shortName() + ": " + dev.name; @@ -355,32 +356,35 @@ void ConnectionManager::devChanged(IConnection *connection) registerDevice(connection,cbName,dev.name,disp); } + qDebug() << "# devices " << m_devList.count(); + emit availableDevicesChanged(m_devList); + //add all the list again to the combobox - foreach (devListItem d, m_devList) + foreach (devListItem device, m_devList) { - m_availableDevList->addItem(d.displayName); - m_availableDevList->setItemData(m_availableDevList->count()-1,(const QString)d.devName,Qt::ToolTipRole); - if(!m_ioDev && d.displayName.startsWith("USB")) + m_availableDevList->addItem(device.displayName); + m_availableDevList->setItemData(m_availableDevList->count() - 1, (const QString)device.devName,Qt::ToolTipRole); + if(!m_ioDev && device.displayName.startsWith("USB")) { if(m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) - m_availableDevList->setCurrentIndex(m_availableDevList->count()-1); + m_availableDevList->setCurrentIndex(m_availableDevList->count() - 1); + if(m_mainWindow->generalSettings()->autoConnect()) { - connectDevice(); - qDebug()<<"ConnectionManager::devChanged autoconnected USB device"; + connectDevice(device); + qDebug() << "ConnectionManager::devChanged autoconnected USB device"; } } } if(m_ioDev)//if a device is connected make it the one selected on the dropbox { - for(int x=0;xcount();++x) + for(int x=0; x < m_availableDevList->count(); ++x) { if(m_connectionDevice.devName==m_availableDevList->itemData(x,Qt::ToolTipRole).toString()) m_availableDevList->setCurrentIndex(x); } } - //disable connection button if the liNameif (m_availableDevList->count() > 0) if (m_availableDevList->count() > 0) m_connectBtn->setEnabled(true); @@ -388,7 +392,7 @@ void ConnectionManager::devChanged(IConnection *connection) m_connectBtn->setEnabled(false); } -} + void Core::ConnectionManager::connectionsCallBack() { @@ -398,4 +402,5 @@ void Core::ConnectionManager::connectionsCallBack() } connectionBackup.clear(); disconnect(ExtensionSystem::PluginManager::instance(),SIGNAL(pluginsLoadEnded()),this,SLOT(connectionsCallBack())); +} } //namespace Core diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 289e65590..4d57319ae 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -46,12 +46,12 @@ QT_END_NAMESPACE namespace Core { - class IConnection; +class IConnection; namespace Internal { - class FancyTabWidget; - class FancyActionBar; - class MainWindow; +class FancyTabWidget; +class FancyActionBar; +class MainWindow; } // namespace Internal @@ -75,19 +75,28 @@ public: void init(); QIODevice* getCurrentConnection() { return m_ioDev; } - devListItem getCurrentDevice() { return m_connectionDevice;} + devListItem getCurrentDevice() { return m_connectionDevice; } + devListItem findDevice(const QString &devName); + + QLinkedList getAvailableDevices() { return m_devList; } + + bool isConnected() { return m_ioDev != 0; } + + bool connectDevice(devListItem device); bool disconnectDevice(); + void suspendPolling(); void resumePolling(); protected: void unregisterAll(IConnection *connection); void registerDevice(IConnection *conn, const QString &devN, const QString &name, const QString &disp); - devListItem findDevice(const QString &devName); signals: void deviceConnected(QIODevice *dev); + void deviceDisconnected(); void deviceAboutToDisconnect(); + void availableDevicesChanged(const QLinkedList devices); private slots: void objectAdded(QObject *obj); @@ -96,9 +105,9 @@ private slots: void onConnectPressed(); void devChanged(IConnection *connection); -// void onConnectionClosed(QObject *obj); - void onConnectionDestroyed(QObject *obj); - void connectionsCallBack(); //used to call devChange after all the plugins are loaded + // void onConnectionClosed(QObject *obj); + void onConnectionDestroyed(QObject *obj); + void connectionsCallBack(); //used to call devChange after all the plugins are loaded protected: QComboBox *m_availableDevList; QPushButton *m_connectBtn; @@ -112,9 +121,8 @@ protected: QIODevice *m_ioDev; private: - bool connectDevice(); - Internal::MainWindow *m_mainWindow; - QList connectionBackup; + Internal::MainWindow *m_mainWindow; + QList connectionBackup; }; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.cpp new file mode 100644 index 000000000..31425fc34 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.cpp @@ -0,0 +1,35 @@ +/** + ****************************************************************************** + * + * @file abstractwizardpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup AbstractWizardPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "abstractwizardpage.h" + +AbstractWizardPage::AbstractWizardPage(SetupWizard* wizard, QWidget *parent) : + QWizardPage(parent) +{ + m_wizard = wizard; + setFixedSize(600, 400); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.h new file mode 100644 index 000000000..072d619e7 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/abstractwizardpage.h @@ -0,0 +1,48 @@ +/** + ****************************************************************************** + * + * @file abstractwizardpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup AbstractWizardPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 ABSTRACTWIZARDPAGE_H +#define ABSTRACTWIZARDPAGE_H + +#include +#include "setupwizard.h" + +class AbstractWizardPage : public QWizardPage +{ + Q_OBJECT +protected: + explicit AbstractWizardPage(SetupWizard *wizard, QWidget *parent = 0); + +private: + SetupWizard *m_wizard; + +public: + SetupWizard* getWizard() { return m_wizard; } + +}; + +#endif // ABSTRACTWIZARDPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.cpp new file mode 100644 index 000000000..7d66957d9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.cpp @@ -0,0 +1,225 @@ +/** + ****************************************************************************** + * + * @file controllerpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup ControllerPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "controllerpage.h" +#include "ui_controllerpage.h" +#include "setupwizard.h" + +#include +#include + +ControllerPage::ControllerPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::ControllerPage) +{ + ui->setupUi(this); + + m_connectionManager = Core::ICore::instance()->connectionManager(); + Q_ASSERT(m_connectionManager); + connect(m_connectionManager, SIGNAL(availableDevicesChanged(QLinkedList)), this, SLOT(devicesChanged(QLinkedList))); + + connect(m_connectionManager, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(connectionStatusChanged())); + connect(m_connectionManager, SIGNAL(deviceDisconnected()), this, SLOT(connectionStatusChanged())); + + connect(ui->manualCB, SIGNAL(toggled(bool)), this, SLOT(identificationModeChanged())); + connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect())); + + setupBoardTypes(); + setupDeviceList(); +} + +ControllerPage::~ControllerPage() +{ + delete ui; +} + +void ControllerPage::initializePage() +{ + if(anyControllerConnected()) { + SetupWizard::CONTROLLER_TYPE type = getControllerType(); + setControllerType(type); + } + else { + setControllerType(SetupWizard::CONTROLLER_UNKNOWN); + } + emit completeChanged(); +} + +bool ControllerPage::isComplete() const +{ + return (ui->manualCB->isChecked() && ui->boardTypeCombo->currentIndex() > 0) || + (!ui->manualCB->isChecked() && m_connectionManager->isConnected() && ui->boardTypeCombo->currentIndex() > 0); +} + +bool ControllerPage::validatePage() +{ + getWizard()->setControllerType((SetupWizard::CONTROLLER_TYPE)ui->boardTypeCombo->itemData(ui->boardTypeCombo->currentIndex()).toInt()); + return true; +} + +bool ControllerPage::anyControllerConnected() +{ + return m_connectionManager->isConnected(); +} + +SetupWizard::CONTROLLER_TYPE ControllerPage::getControllerType() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager* utilMngr = pm->getObject(); + int id = utilMngr->getBoardModel(); + + switch (id) { + case 0x0301: + return SetupWizard::CONTROLLER_PIPX; + case 0x0401: + return SetupWizard::CONTROLLER_CC; + case 0x0402: + return SetupWizard::CONTROLLER_CC3D; + case 0x0901: + return SetupWizard::CONTROLLER_REVO; + default: + return SetupWizard::CONTROLLER_UNKNOWN; + } +} + +void ControllerPage::setupDeviceList() +{ + devicesChanged(m_connectionManager->getAvailableDevices()); + connectionStatusChanged(); +} + +void ControllerPage::setupBoardTypes() +{ + QVariant v(0); + ui->boardTypeCombo->addItem("", SetupWizard::CONTROLLER_UNKNOWN); + ui->boardTypeCombo->addItem("OpenPilot CopterControl (CC)", SetupWizard::CONTROLLER_CC); + ui->boardTypeCombo->addItem("OpenPilot CopterControl (CC3D)", SetupWizard::CONTROLLER_CC3D); + ui->boardTypeCombo->addItem("OpenPilot Revolution", SetupWizard::CONTROLLER_REVO); + ui->boardTypeCombo->model()->setData(ui->boardTypeCombo->model()->index(ui->boardTypeCombo->count() - 1, 0), v, Qt::UserRole - 1); + ui->boardTypeCombo->addItem("OP PipX Modem", SetupWizard::CONTROLLER_PIPX); + ui->boardTypeCombo->model()->setData(ui->boardTypeCombo->model()->index(ui->boardTypeCombo->count() - 1, 0), v, Qt::UserRole - 1); +} + +void ControllerPage::setControllerType(SetupWizard::CONTROLLER_TYPE type) +{ + for(int i = 0; i < ui->boardTypeCombo->count(); ++i) { + if(ui->boardTypeCombo->itemData(i) == type) { + ui->boardTypeCombo->setCurrentIndex(i); + break; + } + } +} + +void ControllerPage::devicesChanged(QLinkedList devices) +{ + // Get the selected item before the update if any + QString currSelectedDeviceName = ui->deviceCombo->currentIndex() != -1 ? + ui->deviceCombo->itemData(ui->deviceCombo->currentIndex(), Qt::ToolTipRole).toString() : ""; + + // Clear the box + ui->deviceCombo->clear(); + + int indexOfSelectedItem = -1; + int i = 0; + + // Loop and fill the combo with items from connectionmanager + foreach (Core::devListItem device, devices) + { + ui->deviceCombo->addItem(device.displayName); + QString deviceName = (const QString)device.devName; + ui->deviceCombo->setItemData(ui->deviceCombo->count() - 1, deviceName, Qt::ToolTipRole); + if(currSelectedDeviceName != "" && currSelectedDeviceName == deviceName) { + indexOfSelectedItem = i; + } + i++; + } + + // Re select the item that was selected before if any + if(indexOfSelectedItem != -1) { + ui->deviceCombo->setCurrentIndex(indexOfSelectedItem); + } + connectionStatusChanged(); +} + +void ControllerPage::connectionStatusChanged() +{ + if(m_connectionManager->isConnected()) { + ui->deviceCombo->setEnabled(false); + ui->connectButton->setText(tr("Disconnect")); + ui->boardTypeCombo->setEnabled(false); + ui->manualCB->setEnabled(false); + QString connectedDeviceName = m_connectionManager->getCurrentDevice().devName; + for(int i = 0; i < ui->deviceCombo->count(); ++i) { + if(connectedDeviceName == ui->deviceCombo->itemData(i, Qt::ToolTipRole).toString()) { + ui->deviceCombo->setCurrentIndex(i); + break; + } + } + + SetupWizard::CONTROLLER_TYPE type = getControllerType(); + setControllerType(type); + } + else { + ui->deviceCombo->setEnabled(true); + ui->connectButton->setText(tr("Connect")); + ui->boardTypeCombo->setEnabled(false); + ui->manualCB->setEnabled(true); + ui->boardTypeCombo->model()->setData(ui->boardTypeCombo->model()->index(0, 0), QVariant(0), Qt::UserRole - 1); + setControllerType(SetupWizard::CONTROLLER_UNKNOWN); + } + emit completeChanged(); +} + +void ControllerPage::identificationModeChanged() +{ + if(ui->manualCB->isChecked()) { + ui->deviceCombo->setEnabled(false); + ui->boardTypeCombo->setEnabled(true); + ui->connectButton->setEnabled(false); + ui->boardTypeCombo->setCurrentIndex(1); + ui->boardTypeCombo->model()->setData(ui->boardTypeCombo->model()->index(0, 0), QVariant(0), Qt::UserRole - 1); + } + else { + ui->connectButton->setEnabled(ui->deviceCombo->count() > 0); + ui->deviceCombo->setEnabled(!m_connectionManager->isConnected()); + ui->boardTypeCombo->model()->setData(ui->boardTypeCombo->model()->index(0, 0), QVariant(1), Qt::UserRole - 1); + ui->boardTypeCombo->setCurrentIndex(0); + ui->boardTypeCombo->setEnabled(false); + } + emit completeChanged(); +} + +void ControllerPage::connectDisconnect() +{ + if(m_connectionManager->isConnected()) { + m_connectionManager->disconnectDevice(); + } + else { + m_connectionManager->connectDevice(m_connectionManager->findDevice(ui->deviceCombo->itemData(ui->deviceCombo->currentIndex(), Qt::ToolTipRole).toString())); + } + emit completeChanged(); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.h new file mode 100644 index 000000000..b9b8ae111 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.h @@ -0,0 +1,67 @@ +/** + ****************************************************************************** + * + * @file controllerpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup ControllerPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 CONTROLLERPAGE_H +#define CONTROLLERPAGE_H + +#include +#include +#include "setupwizard.h" +#include "abstractwizardpage.h" + +namespace Ui { +class ControllerPage; +} + +class ControllerPage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit ControllerPage(SetupWizard *wizard, QWidget *parent = 0); + ~ControllerPage(); + void initializePage(); + bool isComplete() const; + bool validatePage(); + +private: + Ui::ControllerPage *ui; + bool anyControllerConnected(); + SetupWizard::CONTROLLER_TYPE getControllerType(); + void setupDeviceList(); + void setupBoardTypes(); + void setControllerType(SetupWizard::CONTROLLER_TYPE type); + Core::ConnectionManager *m_connectionManager; + +private slots: + void devicesChanged(QLinkedList devices); + void connectionStatusChanged(); + void identificationModeChanged(); + void connectDisconnect(); +}; + +#endif // CONTROLLERPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.ui new file mode 100644 index 000000000..a949d6a1d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/controllerpage.ui @@ -0,0 +1,163 @@ + + + ControllerPage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 20 + 20 + 550 + 241 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot board identification</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">To continue we need to know what kind of OpenPilot board you want the wizard to create a configuration for. The wizard will try to automatically detect what type of board you have connected.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Please connect the board to a free usb port on your computer, or if a serial modem like BlueTooth, PipX or other is used, then power up the board and select the device to connect with from the list below. Then press Connect.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">If the board already is connected and succesfully detected the board type will allready be displayed. You can disconnect and select another device if you need to detect another board.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">If your board isnt detected or if you want to create a configuration for a board that is not connected. Then select the Manual selection option below and select the board type from the drop down menu.</span></p></body></html> + + + Qt::AutoText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 20 + 270 + 560 + 110 + + + + + 8 + + + + OpenPilot board type + + + + false + + + + 150 + 70 + 260 + 22 + + + + + + + 150 + 30 + 260 + 22 + + + + + + + 434 + 70 + 111 + 23 + + + + Connect + + + + + + 441 + 33 + 101 + 17 + + + + Manual selection + + + + + + 20 + 32 + 121 + 16 + + + + + 75 + true + + + + Connection device: + + + + + + 20 + 72 + 131 + 16 + + + + + 75 + true + + + + Detected board type: + + + deviceCombo + connectButton + boardTypeCombo + manualCB + label_2 + label_3 + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp index 3270e23ff..dda55196e 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.cpp @@ -1,8 +1,34 @@ +/** + ****************************************************************************** + * + * @file endpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Setup Wizard Plugin + * @{ + * @brief A Wizard to make the initial setup easy for everyone. + *****************************************************************************/ +/* + * 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 "endpage.h" #include "ui_endpage.h" -EndPage::EndPage(QWidget *parent) : - QWizardPage(parent), +EndPage::EndPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), ui(new Ui::EndPage) { setFinalPage(true); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h index e4179e677..afbeb6177 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.h @@ -1,18 +1,45 @@ +/** + ****************************************************************************** + * + * @file endpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup + * @{ + * @brief + *****************************************************************************/ +/* + * 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 ENDPAGE_H #define ENDPAGE_H -#include +#include "abstractwizardpage.h" namespace Ui { class EndPage; } -class EndPage : public QWizardPage +class EndPage : public AbstractWizardPage { Q_OBJECT public: - explicit EndPage(QWidget *parent = 0); + explicit EndPage(SetupWizard *wizard, QWidget *parent = 0); ~EndPage(); private: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui index cc0a5c162..f72b2d718 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/endpage.ui @@ -71,7 +71,7 @@ p, li { white-space: pre-wrap; } - Uppload configuration + Upload configuration diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp new file mode 100644 index 000000000..7295cc8a3 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * + * @file fixedwingpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup FixedWingPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "fixedwingpage.h" +#include "ui_fixedwingpage.h" + +FixedWingPage::FixedWingPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::FixedWingPage) +{ + ui->setupUi(this); + setFinalPage(true); +} + +FixedWingPage::~FixedWingPage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h new file mode 100644 index 000000000..697721a9e --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file fixedwingpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup FixedWingPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 FIXEDWINGPAGE_H +#define FIXEDWINGPAGE_H + +#include "abstractwizardpage.h" + +namespace Ui { +class FixedWingPage; +} + +class FixedWingPage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit FixedWingPage(SetupWizard *wizard, QWidget *parent = 0); + ~FixedWingPage(); + +private: + Ui::FixedWingPage *ui; +}; + +#endif // FIXEDWINGPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui new file mode 100644 index 000000000..0e4fde978 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui @@ -0,0 +1,43 @@ + + + FixedWingPage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 50 + 160 + 500 + 41 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">The fixed wing part the OpenPilot Setup Wizard is not yet implemented</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + Qt::AlignHCenter|Qt::AlignTop + + + true + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.cpp new file mode 100644 index 000000000..93bfc3503 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.cpp @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * + * @file helipage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup HeliPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "helipage.h" +#include "ui_helipage.h" + +HeliPage::HeliPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::HeliPage) +{ + ui->setupUi(this); + setFinalPage(true); +} + +HeliPage::~HeliPage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.h new file mode 100644 index 000000000..2b2b5b894 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file helipage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup HeliPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 HELIPAGE_H +#define HELIPAGE_H + +#include "abstractwizardpage.h" + +namespace Ui { +class HeliPage; +} + +class HeliPage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit HeliPage(SetupWizard *wizard, QWidget *parent = 0); + ~HeliPage(); + +private: + Ui::HeliPage *ui; +}; + +#endif // HELIPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.ui new file mode 100644 index 000000000..c3c6efd11 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/helipage.ui @@ -0,0 +1,43 @@ + + + HeliPage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 50 + 160 + 500 + 41 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">The helicopter part the OpenPilot Setup Wizard is not yet implemented</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + Qt::AlignHCenter|Qt::AlignTop + + + true + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.cpp new file mode 100644 index 000000000..56ffa5fb0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.cpp @@ -0,0 +1,125 @@ +/** + ****************************************************************************** + * + * @file multipage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup MultiPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "multipage.h" +#include "ui_multipage.h" +#include "setupwizard.h" + +MultiPage::MultiPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::MultiPage) +{ + ui->setupUi(this); + + QSvgRenderer *renderer = new QSvgRenderer(); + renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); + multiPic = new QGraphicsSvgItem(); + multiPic->setSharedRenderer(renderer); + QGraphicsScene *scene = new QGraphicsScene(this); + scene->addItem(multiPic); + ui->typeGraphicsView->setScene(scene); + + setupMultiTypesCombo(); + + // Default to Quad X since it is the most common setup + ui->typeCombo->setCurrentIndex(1); + connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImageAndDescription())); +} + +MultiPage::~MultiPage() +{ + delete ui; +} + +void MultiPage::initializePage() +{ + updateImageAndDescription(); +} + +void MultiPage::setupMultiTypesCombo() +{ + ui->typeCombo->addItem("Tricopter", SetupWizard::MULTI_ROTOR_TRI_Y); + ui->typeCombo->addItem("Quadcopter X", SetupWizard::MULTI_ROTOR_QUAD_X); + ui->typeCombo->addItem("Quadcopter +", SetupWizard::MULTI_ROTOR_QUAD_PLUS); + ui->typeCombo->addItem("Hexacopter", SetupWizard::MULTI_ROTOR_HEXA); + ui->typeCombo->addItem("Hexacopter Coax", SetupWizard::MULTI_ROTOR_HEXA_COAX_Y); + ui->typeCombo->addItem("Hexacopter H", SetupWizard::MULTI_ROTOR_HEXA_H); + ui->typeCombo->addItem("Octocopter", SetupWizard::MULTI_ROTOR_OCTO); + ui->typeCombo->addItem("Octocopter Coax X", SetupWizard::MULTI_ROTOR_OCTO_COAX_X); + ui->typeCombo->addItem("Octocopter Coax +", SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS); + ui->typeCombo->addItem("Octocopter V", SetupWizard::MULTI_ROTOR_OCTO_V); +} + +void MultiPage::updateImageAndDescription() +{ + SetupWizard::MULTI_ROTOR_SUB_TYPE type = (SetupWizard::MULTI_ROTOR_SUB_TYPE) ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); + QString elementId = ""; + QString description = "Descriptive text with information about "; + description.append(ui->typeCombo->currentText()); + description.append(" multirotors."); + switch(type) + { + case SetupWizard::MULTI_ROTOR_TRI_Y: + elementId = "tri"; + break; + case SetupWizard::MULTI_ROTOR_QUAD_X: + elementId = "quad-x"; + break; + case SetupWizard::MULTI_ROTOR_QUAD_PLUS: + elementId = "quad-plus"; + break; + case SetupWizard::MULTI_ROTOR_HEXA: + elementId = "quad-hexa"; + break; + case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: + elementId = "hexa-coax"; + break; + case SetupWizard::MULTI_ROTOR_HEXA_H: + elementId = "quad-hexa-H"; + break; + case SetupWizard::MULTI_ROTOR_OCTO: + elementId = "quad-octo"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_COAX_X: + elementId = "octo-coax-X"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS: + elementId = "octo-coax-P"; + break; + case SetupWizard::MULTI_ROTOR_OCTO_V: + elementId = "quad-octo-v"; + break; + default: + elementId = ""; + break; + } + multiPic->setElementId(elementId); + ui->typeGraphicsView->setSceneRect(multiPic->boundingRect()); + ui->typeGraphicsView->fitInView(multiPic, Qt::KeepAspectRatio); + + ui->typeDescription->setText(description); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.h new file mode 100644 index 000000000..bc9f822ad --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.h @@ -0,0 +1,59 @@ +/** + ****************************************************************************** + * + * @file multipage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup MultiPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 MULTIPAGE_H +#define MULTIPAGE_H + +#include +#include + +#include "abstractwizardpage.h" + +namespace Ui { +class MultiPage; +} + +class MultiPage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit MultiPage(SetupWizard *wizard, QWidget *parent = 0); + ~MultiPage(); + + void initializePage(); + +private: + Ui::MultiPage *ui; + void setupMultiTypesCombo(); + QGraphicsSvgItem *multiPic; + +private slots: + void updateImageAndDescription(); +}; + +#endif // MULTIPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui new file mode 100644 index 000000000..2c33fb4d5 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/multipage.ui @@ -0,0 +1,146 @@ + + + MultiPage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 20 + 20 + 541 + 151 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot multirotor configuration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This part of the wizard will set up the OpenPilot controller for use with a flying platform with multiple rotors. The wizard supports the most common types of multirotors. Other variants of multirotors can be configured by using custom configuration options in the configuration plugin in GCS.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Please select the type of multirotor you want to create a configuration for below:</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 20 + 180 + 561 + 200 + + + + + 10 + + + + Multirotor type selection + + + + + 20 + 32 + 121 + 16 + + + + + 75 + true + + + + Multirotor type: + + + + + + 150 + 30 + 220 + 22 + + + + + + + 390 + 30 + 150 + 150 + + + + + 0 + 0 + + + + QFrame::NoFrame + + + 0 + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + false + + + + + + 20 + 69 + 351 + 111 + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.cpp new file mode 100644 index 000000000..57a43fda8 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.cpp @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * + * @file notyetimplementedpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup NotYetImplementedPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "notyetimplementedpage.h" +#include "ui_notyetimplementedpage.h" + +NotYetImplementedPage::NotYetImplementedPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::NotYetImplementedPage) +{ + ui->setupUi(this); + setFinalPage(true); +} + +NotYetImplementedPage::~NotYetImplementedPage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.h new file mode 100644 index 000000000..4f323d9fc --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file notyetimplementedpage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup NotYetImplementedPage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 NOTYETIMPLEMENTEDPAGE_H +#define NOTYETIMPLEMENTEDPAGE_H + +#include "abstractwizardpage.h" + +namespace Ui { +class NotYetImplementedPage; +} + +class NotYetImplementedPage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit NotYetImplementedPage(SetupWizard *wizard, QWidget *parent = 0); + ~NotYetImplementedPage(); + +private: + Ui::NotYetImplementedPage *ui; +}; + +#endif // NOTYETIMPLEMENTEDPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.ui new file mode 100644 index 000000000..b5b54240d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/notyetimplementedpage.ui @@ -0,0 +1,43 @@ + + + NotYetImplementedPage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 50 + 190 + 501 + 31 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">This part the OpenPilot Setup Wizard is not yet implemented</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp index f36631bb0..46110a9e4 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.cpp @@ -1,8 +1,34 @@ +/** + ****************************************************************************** + * + * @file startpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Setup Wizard Plugin + * @{ + * @brief A Wizard to make the initial setup easy for everyone. + *****************************************************************************/ +/* + * 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 "startpage.h" #include "ui_startpage.h" -StartPage::StartPage(QWidget *parent) : - QWizardPage(parent), +StartPage::StartPage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), ui(new Ui::StartPage) { ui->setupUi(this); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h index f6cf9b6cd..3e9e120cc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.h @@ -1,18 +1,44 @@ +/** + ****************************************************************************** + * + * @file startpage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup Setup Wizard Plugin + * @{ + * @brief A Wizard to make the initial setup easy for everyone. + *****************************************************************************/ +/* + * 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 STARTPAGE_H #define STARTPAGE_H -#include +#include "abstractwizardpage.h" namespace Ui { class StartPage; } -class StartPage : public QWizardPage +class StartPage : public AbstractWizardPage { Q_OBJECT public: - explicit StartPage(QWidget *parent = 0); + explicit StartPage(SetupWizard *wizard, QWidget *parent = 0); ~StartPage(); private: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.cpp new file mode 100644 index 000000000..a28724f2f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.cpp @@ -0,0 +1,42 @@ +/** + ****************************************************************************** + * + * @file surfacepage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup SurfacePage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "surfacepage.h" +#include "ui_surfacepage.h" + +SurfacePage::SurfacePage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::SurfacePage) +{ + ui->setupUi(this); + setFinalPage(true); +} + +SurfacePage::~SurfacePage() +{ + delete ui; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.h new file mode 100644 index 000000000..593aa1fca --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.h @@ -0,0 +1,49 @@ +/** + ****************************************************************************** + * + * @file surfacepage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup SurfacePage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 SURFACEPAGE_H +#define SURFACEPAGE_H + +#include "abstractwizardpage.h" + +namespace Ui { +class SurfacePage; +} + +class SurfacePage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit SurfacePage(SetupWizard *wizard, QWidget *parent = 0); + ~SurfacePage(); + +private: + Ui::SurfacePage *ui; +}; + +#endif // SURFACEPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.ui new file mode 100644 index 000000000..988bc300a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/surfacepage.ui @@ -0,0 +1,43 @@ + + + SurfacePage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 50 + 160 + 500 + 41 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">The surface vehicle part the OpenPilot Setup Wizard is not yet implemented</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + Qt::AlignHCenter|Qt::AlignTop + + + true + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp new file mode 100644 index 000000000..a616a1194 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp @@ -0,0 +1,61 @@ +/** + ****************************************************************************** + * + * @file vehiclepage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup VehiclePage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 "vehiclepage.h" +#include "ui_vehiclepage.h" + +VehiclePage::VehiclePage(SetupWizard *wizard, QWidget *parent) : + AbstractWizardPage(wizard, parent), + ui(new Ui::VehiclePage) +{ + ui->setupUi(this); +} + +VehiclePage::~VehiclePage() +{ + delete ui; +} + +bool VehiclePage::validatePage() +{ + if(ui->multirotorButton->isChecked()) { + getWizard()->setVehicleType(SetupWizard::VEHICLE_MULTI); + } + else if(ui->fixedwingButton->isChecked()) { + getWizard()->setVehicleType(SetupWizard::VEHICLE_FIXEDWING); + } + else if(ui->heliButton->isChecked()) { + getWizard()->setVehicleType(SetupWizard::VEHICLE_HELI); + } + else if(ui->surfaceButton->isChecked()) { + getWizard()->setVehicleType(SetupWizard::VEHICLE_SURFACE); + } + else { + getWizard()->setVehicleType(SetupWizard::VEHICLE_UNKNOWN); + } + return true; +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h new file mode 100644 index 000000000..5e72a3d21 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * + * @file vehiclepage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup VehiclePage + * @{ + * @brief + *****************************************************************************/ +/* + * 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 VEHICLEPAGE_H +#define VEHICLEPAGE_H + +#include "abstractwizardpage.h" + +namespace Ui { +class VehiclePage; +} + +class VehiclePage : public AbstractWizardPage +{ + Q_OBJECT + +public: + explicit VehiclePage(SetupWizard *wizard, QWidget *parent = 0); + ~VehiclePage(); + bool validatePage(); + +private: + Ui::VehiclePage *ui; +}; + +#endif // VEHICLEPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui new file mode 100644 index 000000000..fdc2d47d2 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui @@ -0,0 +1,168 @@ + + + VehiclePage + + + + 0 + 0 + 600 + 400 + + + + WizardPage + + + + + 20 + 20 + 550 + 131 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Vehicle type selection</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">To continue the wizard needs to know what type of vehicle that the OpenPilot controller board is going to be used with. This step is cruicial since most of the following configuration is unique per vehicle type.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">So go ahead and select the type of vehicle you want to create a configuration for.</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 20 + 200 + 561 + 181 + + + + + 0 + 0 + + + + Supported vehicle types + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + 50 + 40 + 100 + 100 + + + + Tricopter, Quadcopter, Hexacopter, Octocopter + + + Multirotor + + + true + + + true + + + true + + + false + + + + + + 170 + 40 + 100 + 100 + + + + Airplane, Sloper, Jet + + + Fixed wing + + + true + + + true + + + false + + + + + + 290 + 40 + 100 + 100 + + + + Helicopter + + + true + + + true + + + false + + + + + + 410 + 40 + 100 + 100 + + + + Car, Boat, U-Boat + + + Surface + + + true + + + true + + + false + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 26a5e386a..f11762bf6 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file setupwizard.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup Setup Wizard Plugin @@ -28,27 +28,72 @@ #include "setupwizard.h" #include "pages/startpage.h" #include "pages/endpage.h" +#include "pages/controllerpage.h" +#include "pages/vehiclepage.h" +#include "pages/multipage.h" +#include "pages/fixedwingpage.h" +#include "pages/helipage.h" +#include "pages/surfacepage.h" +#include "pages/notyetimplementedpage.h" SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent) { setWindowTitle("OpenPilot Setup Wizard"); + m_controllerType = CONTROLLER_UNKNOWN; + m_vehicleType = VEHICLE_UNKNOWN; createPages(); } int SetupWizard::nextId() const { switch (currentId()) { - case PAGE_START: - return PAGE_END; - default: - return -1; + case PAGE_START: + return PAGE_CONTROLLER; + case PAGE_CONTROLLER: { + switch(getControllerType()) + { + case CONTROLLER_CC: + case CONTROLLER_CC3D: + return PAGE_VEHICLES; + default: + return PAGE_NOTYETIMPLEMENTED; + } + } + case PAGE_VEHICLES: { + switch(getVehicleType()) + { + case VEHICLE_FIXEDWING: + return PAGE_FIXEDWING; + case VEHICLE_HELI: + return PAGE_HELI; + case VEHICLE_SURFACE: + return PAGE_SURFACE; + case VEHICLE_MULTI: + return PAGE_MULTI; + default: + return PAGE_NOTYETIMPLEMENTED; + } + } + case PAGE_MULTI: + return PAGE_END; + case PAGE_NOTYETIMPLEMENTED: + return PAGE_END; + default: + return -1; } } void SetupWizard::createPages() { - setPage(PAGE_START, new StartPage()); - setPage(PAGE_END, new EndPage()); + setPage(PAGE_START, new StartPage(this)); + setPage(PAGE_CONTROLLER, new ControllerPage(this)); + setPage(PAGE_VEHICLES, new VehiclePage(this)); + setPage(PAGE_MULTI, new MultiPage(this)); + setPage(PAGE_FIXEDWING, new FixedWingPage(this)); + setPage(PAGE_HELI, new HeliPage(this)); + setPage(PAGE_SURFACE, new SurfacePage(this)); + setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this)); + setPage(PAGE_END, new EndPage(this)); setStartId(PAGE_START); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h index 42f75556a..34b20dd81 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -2,7 +2,7 @@ ****************************************************************************** * * @file setupwizard.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup Setup Wizard Plugin @@ -37,9 +37,25 @@ class SetupWizard : public QWizard public: SetupWizard(QWidget *parent = 0); int nextId() const; + enum CONTROLLER_TYPE {CONTROLLER_UNKNOWN, CONTROLLER_CC, CONTROLLER_CC3D, CONTROLLER_REVO, CONTROLLER_PIPX}; + enum VEHICLE_TYPE {VEHICLE_UNKNOWN, VEHICLE_MULTI, VEHICLE_FIXEDWING, VEHICLE_HELI, VEHICLE_SURFACE}; + enum MULTI_ROTOR_SUB_TYPE {MULTI_ROTOR_UNKNOWN, MULTI_ROTOR_TRI_Y, MULTI_ROTOR_QUAD_X, MULTI_ROTOR_QUAD_PLUS, + MULTI_ROTOR_HEXA, MULTI_ROTOR_HEXA_H, MULTI_ROTOR_HEXA_COAX_Y, MULTI_ROTOR_OCTO, + MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS}; + + void setControllerType(SetupWizard::CONTROLLER_TYPE type) { m_controllerType = type; } + SetupWizard::CONTROLLER_TYPE getControllerType() const { return m_controllerType; } + + void setVehicleType(SetupWizard::VEHICLE_TYPE type) { m_vehicleType = type; } + SetupWizard::VEHICLE_TYPE getVehicleType() const { return m_vehicleType; } + private: - enum {PAGE_START, PAGE_END}; + enum {PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING, + PAGE_HELI, PAGE_SURFACE, PAGE_NOTYETIMPLEMENTED, PAGE_END}; void createPages(); + + CONTROLLER_TYPE m_controllerType; + VEHICLE_TYPE m_vehicleType; }; #endif // SETUPWIZARD_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index 20d13155d..98ece1c83 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -1,21 +1,49 @@ TEMPLATE = lib TARGET = SetupWizard - +QT += svg + include(../../openpilotgcsplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) +include(../../plugins/uavobjectutil/uavobjectutil.pri) HEADERS += setupwizardplugin.h \ setupwizard.h \ pages/startpage.h \ - pages/endpage.h + pages/endpage.h \ + pages/controllerpage.h \ + pages/vehiclepage.h \ + pages/notyetimplementedpage.h \ + pages/multipage.h \ + pages/fixedwingpage.h \ + pages/helipage.h \ + pages/surfacepage.h \ + pages/abstractwizardpage.h SOURCES += setupwizardplugin.cpp \ setupwizard.cpp \ pages/startpage.cpp \ - pages/endpage.cpp + pages/endpage.cpp \ + pages/controllerpage.cpp \ + pages/vehiclepage.cpp \ + pages/notyetimplementedpage.cpp \ + pages/multipage.cpp \ + pages/fixedwingpage.cpp \ + pages/helipage.cpp \ + pages/surfacepage.cpp \ + pages/abstractwizardpage.cpp OTHER_FILES += SetupWizard.pluginspec FORMS += \ pages/startpage.ui \ - pages/endpage.ui \ No newline at end of file + pages/endpage.ui \ + pages/controllerpage.ui \ + pages/vehiclepage.ui \ + pages/notyetimplementedpage.ui \ + pages/multipage.ui \ + pages/fixedwingpage.ui \ + pages/helipage.ui \ + pages/surfacepage.ui + +RESOURCES += \ + wizardResources.qrc diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp index a6dddbd4c..9f5b5c67b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.cpp @@ -1,8 +1,8 @@ /** ****************************************************************************** * - * @file donothingplugin.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @file setupwizardplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup SetupWizardPlugin diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h index 4caecbcd0..96ca9e038 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizardplugin.h @@ -1,8 +1,8 @@ /** ****************************************************************************** * - * @file donothingplugin.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @file setupwizardplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup SetupWizardPlugin diff --git a/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc new file mode 100644 index 000000000..1358ce976 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc @@ -0,0 +1,3 @@ + + +