Commit f4e7354a authored by Mariano Lizarraga's avatar Mariano Lizarraga

Merge branch 'experimental' of github.com:pixhawk/qgroundcontrol into experimental

parents da15b657 f2ec2953
*.swp
*.nfs
CMakeFiles
*Makefile*
tags
build
......
[submodule "MAVLink"]
path = MAVLink
url = git://github.com/pixhawk/mavlink.git
[submodule "thirdParty/mavlink"]
path = thirdParty/mavlink
url = https://github.com/pixhawk/mavlink.git
This diff is collapsed.
FIND_PATH(FLITE_INCLUDE_DIR flite/flite.h)
FIND_LIBRARY(FLITE_MAIN_LIB NAMES flite)
FIND_LIBRARY(FLITE_CMULEX_LIB NAMES flite_cmulex)
FIND_LIBRARY(FLITE_CMU_US_KAL_LIB NAMES flite_cmu_us_kal)
FIND_LIBRARY(FLITE_US_ENGLISH_LIB NAMES flite_usenglish)
SET(FLITE_LIBRARIES
${FLITE_MAIN_LIB}
${FLITE_CMULEX_LIB}
${FLITE_CMU_US_KAL_LIB}
${FLITE_US_ENGLISH_LIB}
)
IF(FLITE_INCLUDE_DIR AND FLITE_LIBRARIES)
SET(FLITE_FOUND TRUE)
ENDIF(FLITE_INCLUDE_DIR AND FLITE_LIBRARIES)
IF(FLITE_FOUND)
IF (NOT Flite_FIND_QUIETLY)
MESSAGE(STATUS "Found flite includes: ${FLITE_INCLUDE_DIR}/flite/flite.h")
MESSAGE(STATUS "Found flite library: ${FLITE_LIBRARIES}")
ENDIF (NOT Flite_FIND_QUIETLY)
ELSE(FLITE_FOUND)
IF (Flite_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find flite development files")
ENDIF (Flite_FIND_REQUIRED)
ENDIF(FLITE_FOUND)
# - Try to find MAVLINK
# Once done, this will define
#
# MAVLINK_FOUND - system has scicoslab
# MAVLINK_INCLUDE_DIRS - the scicoslab include directories
include(LibFindMacros)
# Include dir
find_path(MAVLINK_INCLUDE_DIR
NAMES mavlink_types.h
PATHS
/usr/include/mavlink
/usr/local/include/mavlink
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(MAVLINK_PROCESS_INCLUDES MAVLINK_INCLUDE_DIR)
libfind_process(MAVLINK)
# Find libphonon
# Once done this will define
#
# PHONON_FOUND - system has Phonon Library
# PHONON_INCLUDES - the Phonon include directory
# PHONON_LIBS - link these to use Phonon
# PHONON_VERSION - the version of the Phonon Library
# Copyright (c) 2008, Matthias Kretz <kretz@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro(_phonon_find_version)
set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/phonon/phononnamespace.h")
if (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
set(_phonon_namespace_header_file "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
endif (APPLE AND EXISTS "${PHONON_INCLUDE_DIR}/Headers/phononnamespace.h")
file(READ ${_phonon_namespace_header_file} _phonon_header LIMIT 5000 OFFSET 1000)
string(REGEX MATCH "define PHONON_VERSION_STR \"(4\\.[0-9]+\\.[0-9a-z]+)\"" _phonon_version_match "${_phonon_header}")
set(PHONON_VERSION "${CMAKE_MATCH_1}")
endmacro(_phonon_find_version)
# the dirs listed with HINTS are searched before the default sets of dirs
find_library(PHONON_LIBRARY NAMES phonon HINTS ${KDE4_LIB_INSTALL_DIR} ${QT_LIBRARY_DIR})
find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h HINTS ${KDE4_INCLUDE_INSTALL_DIR} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ${QT_LIBRARY_DIR})
if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY})
set(PHONON_INCLUDES ${PHONON_INCLUDE_DIR}/phonon ${PHONON_INCLUDE_DIR}/KDE ${PHONON_INCLUDE_DIR})
_phonon_find_version()
endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Phonon DEFAULT_MSG PHONON_INCLUDE_DIR PHONON_LIBRARY)
mark_as_advanced(PHONON_INCLUDE_DIR PHONON_LIBRARY)
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
macro (libfind_package PREFIX)
set (LIBFIND_PACKAGE_ARGS ${ARGN})
if (${PREFIX}_FIND_QUIETLY)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
endif (${PREFIX}_FIND_QUIETLY)
if (${PREFIX}_FIND_REQUIRED)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
endif (${PREFIX}_FIND_REQUIRED)
find_package(${LIBFIND_PACKAGE_ARGS})
endmacro (libfind_package)
# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
# where they added pkg_check_modules. Consequently I need to support both in my scripts
# to avoid those deprecated warnings. Here's a helper that does just that.
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
macro (libfind_pkg_check_modules PREFIX PKGNAME)
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
endmacro (libfind_pkg_check_modules)
# Do the final processing once the paths have been detected.
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
# all the variables, each of which contain one include directory.
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
# Also handles errors in case library detection was required, etc.
macro (libfind_process PREFIX)
# Skip processing if already processed during this run
if (NOT ${PREFIX}_FOUND)
# Start with the assumption that the library was found
set (${PREFIX}_FOUND TRUE)
# Process all includes and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
if (${i})
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Process all libraries and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_LIBS})
if (${i})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Print message and/or exit on fatal error
if (${PREFIX}_FOUND)
if (NOT ${PREFIX}_FIND_QUIETLY)
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
endif (NOT ${PREFIX}_FIND_QUIETLY)
else (${PREFIX}_FOUND)
if (${PREFIX}_FIND_REQUIRED)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
endif (${PREFIX}_FOUND)
endif (NOT ${PREFIX}_FOUND)
endmacro (libfind_process)
macro(libfind_library PREFIX basename)
set(TMP "")
if(MSVC80)
set(TMP -vc80)
endif(MSVC80)
if(MSVC90)
set(TMP -vc90)
endif(MSVC90)
set(${PREFIX}_LIBNAMES ${basename}${TMP})
if(${ARGC} GREATER 2)
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
endif(${ARGC} GREATER 2)
find_library(${PREFIX}_LIBRARY
NAMES ${${PREFIX}_LIBNAMES}
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
)
endmacro(libfind_library)
#!/bin/bash
PS3='Please enter your choice: '
LIST="in_source_build install_build grab_debian_dependencies package_source package remake clean END"
MAKEARGS="-j8"
echo
echo in_source_build: is used for development and you can start the scicoslab toolbox by typing scicoslab in the oooark source directory
echo install_build: is used for building before final installation to the system.
echo grab_debian_dependencies: installs all the required packages for debian based systems \(ubuntu maverick/ debian squeeze,lenny\)
echo remake: calls make again after project has been configured as install or in source build
echo package_source: creates a source package for distribution
echo package: creates binary packages for distribution
echo clean: removes the build directory
echo
select OPT in $LIST
do
if [ $OPT = "in_source_build" ] &> /dev/null
then
echo you chose in source build
mkdir -p build && cd build && cmake -DIN_SRC_BUILD:bool=TRUE .. && make $MAKEARGS
exit 0
elif [ $OPT = "install_build" ] &> /dev/null
then
echo you chose install build
mkdir -p build && cd build && cmake .. && make $MAKEARGS
exit 0
elif [ $OPT = "grab_debian_dependencies" ] &> /dev/null
then
echo you chose to install debian dependencies
sudo apt-get install cmake libqt4-dev flite1-dev libphonon-dev libopenscenegraph-dev
exit 0
elif [ $OPT = "remake" ] &> /dev/null
then
echo you chose to recall make on the previously configured build
cd build && make $MAKEARGS
exit 0
elif [ $OPT = "package_source" ] &> /dev/null
then
echo you chose to package the source
mkdir -p build && cd build && cmake .. && make package_source
exit 0
elif [ $OPT = "package" ] &> /dev/null
then
echo you chose to package the binary
mkdir -p build && cd build && cmake .. && make package
exit 0
elif [ $OPT = "clean" ] &> /dev/null
then
echo you chose to clean the build
rm -rf build
elif [ $OPT = "END" ] &> /dev/null
then
exit 0
fi
done
#!/bin/bash
ctags -RV --c++-kinds=+p --fields=+iaS --extra=+q \
. \
/usr/include/qt4 \
/usr/include/osg*
......@@ -362,7 +362,6 @@ function updateWaypoint(id, index, lat, lon, alt, action)
location.setAltitude(alt);
waypoints[index].setGeometry(location);
waypoints[index].setDescription(index+"");
console.log('WP LOC:' + lat + lon + alt);
}
else
{
......@@ -373,7 +372,7 @@ function updateWaypoint(id, index, lat, lon, alt, action)
if (index < 10) numberstring = '0' + numberstring
icon.setHref('http://google-maps-icons.googlecode.com/files/red' + numberstring +'.png');
var style = ge.createStyle('');
console.log('WP ICON created:' + 'http://google-maps-icons.googlecode.com/files/red' + numberstring +'.png');
//console.log('WP ICON created:' + 'http://google-maps-icons.googlecode.com/files/red' + numberstring +'.png');
style.getIconStyle().setIcon(icon);
//style.getIconStyle().setScale(0.5);
placemark.setStyleSelector(style);
......@@ -424,7 +423,7 @@ function createAircraft(id, type, color)
//planeColor = color;
createTrail(id, color);
console.log(color);
//console.log(color);
}
function createTrail(id, color)
......
......@@ -86,6 +86,13 @@ border: 1px solid #777777;
QMainWindow::separator:hover {
background: white;
}
QGCToolWidgetItem {
border: 1px solid #66666B;
border-radius: 3px;
padding: 10px 0px 0px 0px;
margin-top: 1ex; /* leave space at the top for the title */
}
QDockWidget {
border: 1px solid #32345E;
......
......@@ -202,7 +202,12 @@ message("Compiling for linux 32")
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph libraries
LIBS += -losg \
-losgViewer
-losgViewer \
-losgGA \
-losgDB \
-losgText \
-lOpenThreads
DEFINES += QGC_OSG_ENABLED
}
......@@ -273,7 +278,12 @@ linux-g++-64 {
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph libraries
LIBS += -losg \
-losgViewer
-losgViewer \
-losgGA \
-losgDB \
-losgText \
-lOpenThreads
DEFINES += QGC_OSG_ENABLED
}
......@@ -342,10 +352,10 @@ INCLUDEPATH += $$BASEDIR/lib/osgEarth/win32/include \
LIBS += -L$$BASEDIR/lib/osgEarth_3rdparty/win32/OpenSceneGraph-2.8.2/lib \
-losg \
-losgViewer \
-losgGA \
-losgDB \
-losgText \
-lOpenThreads
-losgGA \
-losgDB \
-losgText \
-lOpenThreads
DEFINES += QGC_OSG_ENABLED
exists($$BASEDIR/lib/osgEarth123) {
DEPENDENCIES_PRESENT += osgearth
......@@ -401,7 +411,7 @@ win32-g++ {
debug {
#DESTDIR = $$BUILDDIR/debug
CONFIG += console
CONFIG += console
}
release {
......@@ -455,3 +465,4 @@ win32-g++ {
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += -Wl,-E
}
# vim:ts=4:sw=4:expandtab
......@@ -153,11 +153,14 @@ FORMS += src/ui/MainWindow.ui \
src/ui/designer/QGCToolWidget.ui \
src/ui/designer/QGCParamSlider.ui \
src/ui/designer/QGCActionButton.ui \
src/ui/designer/QGCCommandButton.ui \
src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCWaypointListMulti.ui \
src/ui/mission/QGCCustomWaypointAction.ui \
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/QGCSettingsWidget.ui
src/ui/QGCSettingsWidget.ui \
src/ui/mission/QGCMissionDoWidget.ui \
src/ui/mission/QGCMissionConditionWidget.ui
INCLUDEPATH += src \
src/ui \
......@@ -262,6 +265,7 @@ HEADERS += src/MG.h \
src/ui/designer/QGCToolWidget.h \
src/ui/designer/QGCParamSlider.h \
src/ui/designer/QGCActionButton.h \
src/ui/designer/QGCCommandButton.h \
src/ui/designer/QGCToolWidgetItem.h \
src/ui/QGCMAVLinkLogPlayer.h \
src/comm/MAVLinkSimulationWaypointPlanner.h \
......@@ -269,7 +273,10 @@ HEADERS += src/MG.h \
src/uas/QGCMAVLinkUASFactory.h \
src/ui/QGCWaypointListMulti.h \
src/ui/QGCUDPLinkConfiguration.h \
src/ui/QGCSettingsWidget.h
src/ui/QGCSettingsWidget.h \
src/ui/mission/QGCMissionDoWidget.h \
src/ui/mission/QGCMissionConditionWidget.h \
src/uas/QGCUASParamManager.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008: {
......@@ -389,6 +396,7 @@ SOURCES += src/main.cc \
src/ui/designer/QGCToolWidget.cc \
src/ui/designer/QGCParamSlider.cc \
src/ui/designer/QGCActionButton.cc \
src/ui/designer/QGCCommandButton.cc \
src/ui/designer/QGCToolWidgetItem.cc \
src/ui/QGCMAVLinkLogPlayer.cc \
src/comm/MAVLinkSimulationWaypointPlanner.cc \
......@@ -396,7 +404,10 @@ SOURCES += src/main.cc \
src/uas/QGCMAVLinkUASFactory.cc \
src/ui/QGCWaypointListMulti.cc \
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/QGCSettingsWidget.cc
src/ui/QGCSettingsWidget.cc \
src/ui/mission/QGCMissionDoWidget.cc \
src/ui/mission/QGCMissionConditionWidget.cc \
src/uas/QGCUASParamManager.cc
macx|win32-msvc2008: {
SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -36,7 +36,8 @@ This file is part of the PIXHAWK project
#include <QTimer>
#include <QStringList>
#ifdef Q_OS_MAC
#include <Phonon>
#include <MediaObject>
#include <AudioOutput>
#endif
#ifdef Q_OS_LINUX
//#include <flite/flite.h>
......
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Brief Description
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include <QFile>
#include <QFlags>
#include <QThread>
#include <QSplashScreen>
#include <QPixmap>
#include <QDesktopWidget>
#include <QPainter>
#include <QStyleFactory>
#include <QAction>
#include <MissionLog.h>
#include <MG.h>
#include <QDebug>
/**
* @brief Constructor for the mission log
*
**/
MissionLog::MissionLog(QObject* parent) : QObject(parent)
{
logLines = new QMap<QString, LogLine*>();
logFiles = new QMap<QString, QFile*>();
}
/**
* @brief Destructor for the mission log. It closes all files
*
**/
MissionLog::~MissionLog()
{
delete logFiles;
delete logLines;
}
void MissionLog::startLog(UASInterface* uas, QString format)
{
QString separator;
if (format.contains(",")) separator = ",";
if (format.contains(";")) separator = ";";
if (format.contains("\t")) separator = "\t";
QStringList fields = format.split(separator);
}
void MissionLog::stopLog(UASInterface* uas, QString format)
{
// TODO Check if file has to be closed explicitely
logFiles->remove(format);
}
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Brief Description
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _MISSIONLOG_H_
#define _MISSIONLOG_H_
#include <QString>
#include <QFile>
#include <QMap>
#include <UASInterface.h>
/**
* @brief Log the mission executed by this groundstation
*
* Displays all events in a console window and writes (if enabled) all events to a logfile
*
**/
class MissionLog : public QObject {
Q_OBJECT
public:
MissionLog(QObject* parent = NULL);
~MissionLog();
public slots:
void startLog(UASInterface* uas, QString format);
void stopLog(UASInterface* uas, QString format);
protected:
/**
* @brief This nested class is just a data container for a log line
*/
class LogFile
{
public:
void setField(QString id, double value)
{
//fields->value(id.trimmed()) = value;
fieldsDone++;
if (fieldsDone == fields->size()) writeLine();
}
protected:
QMap<QString, double>* fields;
int fieldsDone;
QFile* file;
LogFile(QFile* file, QString format)
{
fields = new QMap<QString, double>();
fieldsDone = 0;
file->open(QIODevice::WriteOnly | QIODevice::Text);
}
void addField(QString id)
{
fields->insert(id, 0.0f);
}
void writeLine()
{
QString line = "";
// Iterate through the fields
// Reset value to zero after write
line += "\n";
file->write(line.toAscii());
file->flush();
}
};
QMap<QString, LogFile*>* logFiles;
private:
};
#endif // _MISSIONLOG_H_
......@@ -29,8 +29,10 @@ This file is part of the QGROUNDCONTROL project
*
*/
#include "Waypoint.h"
#include <QStringList>
#include <QDebug>
#include "Waypoint.h"
Waypoint::Waypoint(quint16 _id, double _x, double _y, double _z, double _param1, double _param2, double _param3, double _param4,
bool _autocontinue, bool _current, MAV_FRAME _frame, MAV_CMD _action)
......@@ -229,6 +231,8 @@ void Waypoint::setAcceptanceRadius(double radius)
void Waypoint::setParam1(double param1)
{
qDebug() << "SENDER:" << QObject::sender();
qDebug() << "PARAM1 SET REQ:" << param1;
if (this->param1 != param1)
{
this->param1 = param1;
......
#include "PxMAV.h"
#include <QtCore>
PxMAV::PxMAV() :
UAS(NULL, 0)
{
}
PxMAV::PxMAV(MAVLinkProtocol* mavlink, int id) :
UAS(mavlink, id)
{
}
/**
* This function is called by MAVLink once a complete, uncorrupted (CRC check valid)
* mavlink packet is received.
*
* @param link Hardware link the message came from (e.g. /dev/ttyUSB0 or UDP port).
* messages can be sent back to the system via this link
* @param message MAVLink message, as received from the MAVLink protocol stack
*/
void PxMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
{
// Let UAS handle the default message set
UAS::receiveMessage(link, message);
mavlink_message_t* msg = &message;
//qDebug() << "PX RECEIVED" << msg->sysid << msg->compid << msg->msgid;
// Handle your special messages
switch (msg->msgid)
{
case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT:
{
mavlink_watchdog_heartbeat_t payload;
mavlink_msg_watchdog_heartbeat_decode(msg, &payload);
emit watchdogReceived(this->uasId, payload.watchdog_id, payload.process_count);
}
break;
case MAVLINK_MSG_ID_WATCHDOG_PROCESS_INFO:
{
mavlink_watchdog_process_info_t payload;
mavlink_msg_watchdog_process_info_decode(msg, &payload);
emit processReceived(this->uasId, payload.watchdog_id, payload.process_id, QString((const char*)payload.name), QString((const char*)payload.arguments), payload.timeout);
}
break;
case MAVLINK_MSG_ID_WATCHDOG_PROCESS_STATUS:
{
mavlink_watchdog_process_status_t payload;
mavlink_msg_watchdog_process_status_decode(msg, &payload);
emit processChanged(this->uasId, payload.watchdog_id, payload.process_id, payload.state, (payload.muted == 1) ? true : false, payload.crashes, payload.pid);
}
break;
case MAVLINK_MSG_ID_DEBUG_VECT:
{
mavlink_debug_vect_t vect;
mavlink_msg_debug_vect_decode(msg, &vect);
QString str((const char*)vect.name);
emit valueChanged(uasId, str+".x", vect.x, MG::TIME::getGroundTimeNow());
emit valueChanged(uasId, str+".y", vect.y, MG::TIME::getGroundTimeNow());
emit valueChanged(uasId, str+".z", vect.z, MG::TIME::getGroundTimeNow());
}
break;
case MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE:
{
mavlink_vision_position_estimate_t pos;
mavlink_msg_vision_position_estimate_decode(&message, &pos);
quint64 time = getUnixTime(pos.usec);
emit valueChanged(uasId, "vis. time", pos.usec, time);
emit valueChanged(uasId, "vis. roll", pos.roll, time);
emit valueChanged(uasId, "vis. pitch", pos.pitch, time);
emit valueChanged(uasId, "vis. yaw", pos.yaw, time);
emit valueChanged(uasId, "vis. x", pos.x, time);
emit valueChanged(uasId, "vis. y", pos.y, time);
emit valueChanged(uasId, "vis. z", pos.z, time);
emit valueChanged(uasId, "vis. vx", pos.vx, time);
emit valueChanged(uasId, "vis. vy", pos.vy, time);
emit valueChanged(uasId, "vis. vz", pos.vz, time);
emit valueChanged(uasId, "vis. vyaw", pos.vyaw, time);
// Set internal state
if (!positionLock)
{
// If position was not locked before, notify positive
// GAudioOutput::instance()->notifyPositive();
}
positionLock = true;
}
break;
default:
// Do nothing
break;
}
}
void PxMAV::sendProcessCommand(int watchdogId, int processId, unsigned int command)
{
mavlink_watchdog_command_t payload;
payload.target_system_id = uasId;
payload.watchdog_id = watchdogId;
payload.process_id = processId;
payload.command_id = (uint8_t)command;
mavlink_message_t msg;
mavlink_msg_watchdog_command_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &payload);
sendMessage(msg);
}
Q_EXPORT_PLUGIN2(pixhawk_plugins, PxMAV)
#ifndef PXMAV_H
#define PXMAV_H
#include "UAS.h"
class PxMAV : public UAS
{
Q_OBJECT
Q_INTERFACES(UASInterface)
public:
PxMAV(MAVLinkProtocol* mavlink, int id);
PxMAV();
public slots:
/** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
/** @brief Send a command to an onboard process */
void sendProcessCommand(int watchdogId, int processId, unsigned int command);
signals:
void watchdogReceived(int systemId, int watchdogId, unsigned int processCount);
void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);
void processChanged(int systemId, int watchdogId, int processId, int state, bool muted, int crashed, int pid);
};
#endif // PXMAV_H
#include "Logfile.h"
#include <QDebug>
LogFile::LogFile(UASInterface* uas, QString filename, QString formatString)
{
this->uas = uas;
connect(this->uas, SIGNAL(valueChanged(int, QString, double, quint64)), this, SLOT(addValue(int, QString, double, quint64)));
file = new QFile(filename);
separator = ",";
this->formatString = formatString;
if (file->open(QIODevice::WriteOnly | QIODevice::Text))
{
out = new QTextStream(file);
}
}
LogFile::~LogFile()
{
out->flush();
file->close();
delete out;
delete file;
}
void LogFile::addValue(int uas, QString id, double value, quint64 timestamp)
{
//out.atEnd()->append() << separator << value;
if (formatString == id)
{
out->operator <<(timestamp);
out->operator <<(separator);
out->operator <<(value);
out->operator <<("\n");
out->flush();
}
}
//std::ofstream markerlog("mavserial_markerlog.txt");
//std::ofstream attitudelog("mavserial_attitudelog.txt");
void LogFile::addValue(QString id, double value)
{
//out.atEnd()->append() << separator << value;
//qDebug() << id << value;
}
#ifndef LOGFILE_H
#define LOGFILE_H
#include <QFile>
#include <QTextStream>
#include <UASInterface.h>
class LogFile : public QObject
{
Q_OBJECT
public:
LogFile(UASInterface* uas, QString filename, QString formatString="");
~LogFile();
public slots:
void addValue(QString id, double value);
void addValue(int uas, QString id, double value, quint64 timestamp);
protected:
QFile* file;
QTextStream* out;
QString separator;
QString formatString;
UASInterface* uas;
};
#endif // LOGFILE_H
#include "QGCUASParamManager.h"
#include "UASInterface.h"
QGCUASParamManager::QGCUASParamManager(UASInterface* uas, QWidget *parent) :
QWidget(parent),
mav(uas),
transmissionListMode(false),
transmissionActive(false),
transmissionTimeout(0),
retransmissionTimeout(350),
rewriteTimeout(500),
retransmissionBurstRequestSize(2)
{
uas->setParamManager(this);
}
/**
* The .. signal is emitted
*/
void QGCUASParamManager::requestParameterListUpdate(int component)
{
}
#ifndef QGCUASPARAMMANAGER_H
#define QGCUASPARAMMANAGER_H
#include <QWidget>
#include <QMap>
#include <QTimer>
class UASInterface;
class QGCUASParamManager : public QWidget
{
Q_OBJECT
public:
QGCUASParamManager(UASInterface* uas, QWidget *parent = 0);
QList<QString> getParameterNames(int component) const { return parameters.value(component)->keys(); }
QList<float> getParameterValues(int component) const { return parameters.value(component)->values(); }
float getParameterValue(int component, const QString& parameter) const { return parameters.value(component)->value(parameter); }
/** @brief Request an update for the parameter list */
void requestParameterListUpdate(int component = 0);
/** @brief Request an update for this specific parameter */
virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
signals:
void parameterChanged(int component, QString parameter, float value);
void parameterChanged(int component, int parameterIndex, float value);
void parameterListUpToDate(int component);
public slots:
/** @brief Write one parameter to the MAV */
virtual void setParameter(int component, QString parameterName, float value) = 0;
/** @brief Request list of parameters from MAV */
virtual void requestParameterList() = 0;
protected:
UASInterface* mav; ///< The MAV this widget is controlling
QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
QMap<int, QMap<QString, float>* > parameters; ///< All parameters
QVector<bool> received; ///< Successfully received parameters
QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
QMap<int, QMap<QString, float>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
quint64 transmissionTimeout; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
int rewriteTimeout; ///< Write request timeout, in milliseconds
int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst
};
#endif // QGCUASPARAMMANAGER_H
......@@ -29,7 +29,7 @@
UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
uasId(id),
startTime(MG::TIME::getGroundTimeNow()),
startTime(QGC::groundTimeMilliseconds()),
commStatus(COMM_DISCONNECTED),
name(""),
autopilot(-1),
......@@ -73,7 +73,8 @@ yaw(0.0),
statusTimeout(new QTimer(this)),
paramsOnceRequested(false),
airframe(0),
attitudeKnown(false)
attitudeKnown(false),
paramManager(NULL)
{
color = UASInterface::getNextColor();
setBattery(LIPOLY, 3);
......@@ -1076,7 +1077,6 @@ void UAS::setHomePosition(double lat, double lon, double alt)
void UAS::setLocalOriginAtCurrentGPSPosition()
{
bool result = false;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
......@@ -1787,6 +1787,38 @@ void UAS::setUASName(const QString& name)
emit systemSpecsChanged(uasId);
}
void UAS::executeCommand(MAV_CMD command)
{
mavlink_message_t msg;
mavlink_command_t cmd;
cmd.command = (uint8_t)command;
cmd.confirmation = 0;
cmd.param1 = 0.0f;
cmd.param2 = 0.0f;
cmd.param3 = 0.0f;
cmd.param4 = 0.0f;
cmd.target_system = uasId;
cmd.target_component = 0;
mavlink_msg_command_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &cmd);
sendMessage(msg);
}
void UAS::executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, int component)
{
mavlink_message_t msg;
mavlink_command_t cmd;
cmd.command = (uint8_t)command;
cmd.confirmation = confirmation;
cmd.param1 = param1;
cmd.param2 = param2;
cmd.param3 = param3;
cmd.param4 = param4;
cmd.target_system = uasId;
cmd.target_component = component;
mavlink_msg_command_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &cmd);
sendMessage(msg);
}
/**
* Sets an action
*
......
......@@ -176,6 +176,7 @@ protected: //COMMENTS FOR TEST UNIT
bool paramsOnceRequested; ///< If the parameter list has been read at least once
int airframe; ///< The airframe type
bool attitudeKnown; ///< True if attitude was received, false else
QGCUASParamManager* paramManager; ///< Parameter manager class
public:
/** @brief Set the current battery type */
......@@ -192,6 +193,11 @@ public:
bool isAuto();
UASWaypointManager* getWaypointManager() { return &waypointManager; }
/** @brief Get reference to the param manager **/
QGCUASParamManager* getParamManager() const { return paramManager; }
// TODO Will be removed
/** @brief Set reference to the param manager **/
void setParamManager(QGCUASParamManager* manager) { paramManager = manager; }
int getSystemType();
QImage getImage();
void requestImage(); // ?
......@@ -208,6 +214,10 @@ public slots:
void setUASName(const QString& name);
/** @brief Executes an action **/
void setAction(MAV_ACTION action);
/** @brief Executes a command **/
void executeCommand(MAV_CMD command);
/** @brief Executes a command **/
void executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, int component);
/** @brief Set the current battery type and voltages */
void setBatterySpecs(const QString& specs);
/** @brief Get the current battery type and specs */
......
......@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project
#include "LinkInterface.h"
#include "ProtocolInterface.h"
#include "UASWaypointManager.h"
#include "QGCUASParamManager.h"
#include "RadioCalibration/RadioCalibrationData.h"
/**
......@@ -85,6 +86,11 @@ public:
/** @brief Get reference to the waypoint manager **/
virtual UASWaypointManager* getWaypointManager(void) = 0;
/** @brief Get reference to the param manager **/
virtual QGCUASParamManager* getParamManager() const = 0;
// TODO Will be removed
/** @brief Set reference to the param manager **/
virtual void setParamManager(QGCUASParamManager* manager) = 0;
/* COMMUNICATION FLAGS */
......@@ -183,6 +189,10 @@ public slots:
virtual void setUASName(const QString& name) = 0;
/** @brief Sets an action **/
virtual void setAction(MAV_ACTION action) = 0;
/** @brief Execute command immediately **/
virtual void executeCommand(MAV_CMD command) = 0;
/** @brief Executes a command **/
virtual void executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, int component) = 0;
/** @brief Selects the airframe */
virtual void setAirframe(int airframe) = 0;
......
......@@ -307,9 +307,11 @@ void MainWindow::buildCustomWidget()
if (!dock)
{
QDockWidget* dock = new QDockWidget(widgets.at(i)->windowTitle(), this);
dock->setObjectName(widgets.at(i)->objectName()+"_DOCK");
dock->setWidget(widgets.at(i));
connect(widgets.at(i), SIGNAL(destroyed()), dock, SLOT(deleteLater()));
QAction* showAction = new QAction(widgets.at(i)->windowTitle(), this);
showAction->setCheckable(true);
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
widgets.at(i)->setMainMenuAction(showAction);
......@@ -1044,6 +1046,7 @@ void MainWindow::createCustomWidget()
dock->setWidget(tool);
QAction* showAction = new QAction("Show Unnamed Tool", this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
tool->setMainMenuAction(showAction);
......
......@@ -43,18 +43,8 @@ This file is part of the QGROUNDCONTROL project
* @param parent Parent widget
*/
QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
QWidget(parent),
mav(uas),
components(new QMap<int, QTreeWidgetItem*>()),
paramGroups(),
changedValues(),
parameters(),
transmissionListMode(false),
transmissionActive(false),
transmissionTimeout(0),
retransmissionTimeout(350),
rewriteTimeout(500),
retransmissionBurstRequestSize(2)
QGCUASParamManager(uas, parent),
components(new QMap<int, QTreeWidgetItem*>())
{
// Load settings
loadSettings();
......@@ -756,6 +746,15 @@ void QGCParamWidget::retransmissionGuardTick()
}
/**
* The .. signal is emitted
*/
void QGCParamWidget::requestParameterUpdate(int component, const QString& parameter)
{
}
/**
* @param component the subsystem which has the parameter
* @param parameterName name of the parameter, as delivered by the system
......
......@@ -37,16 +37,17 @@ This file is part of the QGROUNDCONTROL project
#include <QLabel>
#include <QTimer>
#include "QGCUASParamManager.h"
#include "UASInterface.h"
/**
* @brief Widget to read/set onboard parameters
*/
class QGCParamWidget : public QWidget
class QGCParamWidget : public QGCUASParamManager
{
Q_OBJECT
public:
explicit QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
/** @brief Get the UAS of this widget */
UASInterface* getUAS();
signals:
......@@ -63,6 +64,8 @@ public slots:
void addParameter(int uas, int component, QString parameterName, float value);
/** @brief Request list of parameters from MAV */
void requestParameterList();
/** @brief Request one single parameter */
void requestParameterUpdate(int component, const QString& parameter);
/** @brief Set one parameter, changes value in RAM of MAV */
void setParameter(int component, QString parameterName, float value);
/** @brief Set all parameters, changes the value in RAM of MAV */
......@@ -85,24 +88,10 @@ public slots:
void retransmissionGuardTick();
protected:
UASInterface* mav; ///< The MAV this widget is controlling
QTreeWidget* tree; ///< The parameter tree
QLabel* statusLabel; ///< Parameter transmission label
QMap<int, QTreeWidgetItem*>* components; ///< The list of components
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
QMap<int, QMap<QString, float>* > parameters; ///< All parameters
QVector<bool> received; ///< Successfully received parameters
QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
QMap<int, QMap<QString, float>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
quint64 transmissionTimeout; ///< Timeout
QTimer retransmissionTimer; ///< Timer handling parameter retransmission
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
int rewriteTimeout; ///< Write request timeout, in milliseconds
int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst
/** @brief Activate / deactivate parameter retransmission */
void setRetransmissionGuardEnabled(bool enabled);
......
......@@ -36,19 +36,18 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) :
customCommand->setupUi(m_ui->customActionWidget);
// add actions
m_ui->comboBox_action->addItem(tr("Navigate"),MAV_CMD_NAV_WAYPOINT);
m_ui->comboBox_action->addItem(tr("TakeOff"),MAV_CMD_NAV_TAKEOFF);
m_ui->comboBox_action->addItem(tr("Loiter Unlim."),MAV_CMD_NAV_LOITER_UNLIM);
m_ui->comboBox_action->addItem(tr("Loiter Time"),MAV_CMD_NAV_LOITER_TIME);
m_ui->comboBox_action->addItem(tr("Loiter Turns"),MAV_CMD_NAV_LOITER_TURNS);
m_ui->comboBox_action->addItem(tr("Ret. to Launch"),MAV_CMD_NAV_RETURN_TO_LAUNCH);
m_ui->comboBox_action->addItem(tr("Land"),MAV_CMD_NAV_LAND);
m_ui->comboBox_action->addItem(tr("NAV: Waypoint"),MAV_CMD_NAV_WAYPOINT);
m_ui->comboBox_action->addItem(tr("NAV: TakeOff"),MAV_CMD_NAV_TAKEOFF);
m_ui->comboBox_action->addItem(tr("NAV: Loiter Unlim."),MAV_CMD_NAV_LOITER_UNLIM);
m_ui->comboBox_action->addItem(tr("NAV: Loiter Time"),MAV_CMD_NAV_LOITER_TIME);
m_ui->comboBox_action->addItem(tr("NAV: Loiter Turns"),MAV_CMD_NAV_LOITER_TURNS);
m_ui->comboBox_action->addItem(tr("NAV: Ret. to Launch"),MAV_CMD_NAV_RETURN_TO_LAUNCH);
m_ui->comboBox_action->addItem(tr("NAV: Land"),MAV_CMD_NAV_LAND);
// m_ui->comboBox_action->addItem(tr("NAV: Target"),MAV_CMD_NAV_TARGET);
//m_ui->comboBox_action->addItem(tr("IF: Delay over"),MAV_CMD_CONDITION_DELAY);
//m_ui->comboBox_action->addItem(tr("IF: Yaw angle is"),MAV_CMD_CONDITION_YAW);
//m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP);
m_ui->comboBox_action->addItem(tr("Other"), MAV_CMD_ENUM_END);
// m_ui->comboBox_action->addItem(tr("Delay"), MAV_ACTION_DELAY_BEFORE_COMMAND);
// m_ui->comboBox_action->addItem(tr("Ascend/Descent"), MAV_ACTION_ASCEND_AT_RATE);
// m_ui->comboBox_action->addItem(tr("Change Mode"), MAV_ACTION_CHANGE_MODE);
// m_ui->comboBox_action->addItem(tr("Relay ON"), MAV_ACTION_RELAY_ON);
// m_ui->comboBox_action->addItem(tr("Relay OFF"), MAV_ACTION_RELAY_OFF);
// add frames
m_ui->comboBox_frame->addItem("Global",MAV_FRAME_GLOBAL);
......@@ -205,6 +204,17 @@ void WaypointView::updateActionView(int action)
m_ui->orbitSpinBox->show();
m_ui->holdTimeSpinBox->show();
break;
case MAV_CMD_NAV_ORIENTATION_TARGET:
m_ui->orbitSpinBox->hide();
m_ui->takeOffAngleSpinBox->hide();
m_ui->turnsSpinBox->hide();
m_ui->holdTimeSpinBox->show();
m_ui->customActionWidget->hide();
m_ui->autoContinue->show();
m_ui->acceptanceSpinBox->hide();
m_ui->yawSpinBox->hide();
break;
default:
break;
}
......@@ -252,6 +262,7 @@ void WaypointView::changedAction(int index)
void WaypointView::changeViewMode(QGC_WAYPOINTVIEW_MODE mode)
{
viewMode = mode;
switch (mode)
{
case QGC_WAYPOINTVIEW_MODE_NAV:
......@@ -276,6 +287,9 @@ void WaypointView::changeViewMode(QGC_WAYPOINTVIEW_MODE mode)
m_ui->lonSpinBox->hide();
m_ui->altSpinBox->hide();
int action_index = m_ui->comboBox_action->findData(MAV_CMD_ENUM_END);
m_ui->comboBox_action->setCurrentIndex(action_index);
// Show action widget
if (!m_ui->customActionWidget->isVisible())
{
......@@ -287,6 +301,7 @@ void WaypointView::changeViewMode(QGC_WAYPOINTVIEW_MODE mode)
}
break;
}
}
void WaypointView::updateFrameView(int frame)
......@@ -429,9 +444,12 @@ void WaypointView::updateValues()
}
else
{
// Action ID known, update
m_ui->comboBox_action->setCurrentIndex(action_index);
updateActionView(action);
if (viewMode != QGC_WAYPOINTVIEW_MODE_DIRECT_EDITING)
{
// Action ID known, update
m_ui->comboBox_action->setCurrentIndex(action_index);
updateActionView(action);
}
}
}
switch(action)
......@@ -450,7 +468,9 @@ void WaypointView::updateValues()
if (m_ui->yawSpinBox->value() != wp->getYaw())
{
if (!m_ui->yawSpinBox->isVisible()) m_ui->yawSpinBox->blockSignals(true);
m_ui->yawSpinBox->setValue(wp->getYaw());
if (!m_ui->yawSpinBox->isVisible()) m_ui->yawSpinBox->blockSignals(false);
}
if (m_ui->selectedBox->isChecked() != wp->getCurrent())
{
......@@ -463,23 +483,33 @@ void WaypointView::updateValues()
m_ui->idLabel->setText(QString("%1").arg(wp->getId()));
if (m_ui->orbitSpinBox->value() != wp->getLoiterOrbit())
{
if (!m_ui->orbitSpinBox->isVisible()) m_ui->orbitSpinBox->blockSignals(true);
m_ui->orbitSpinBox->setValue(wp->getLoiterOrbit());
if (!m_ui->orbitSpinBox->isVisible()) m_ui->orbitSpinBox->blockSignals(false);
}
if (m_ui->acceptanceSpinBox->value() != wp->getAcceptanceRadius())
{
if (!m_ui->acceptanceSpinBox->isVisible()) m_ui->acceptanceSpinBox->blockSignals(true);
m_ui->acceptanceSpinBox->setValue(wp->getAcceptanceRadius());
if (!m_ui->acceptanceSpinBox->isVisible()) m_ui->acceptanceSpinBox->blockSignals(false);
}
if (m_ui->holdTimeSpinBox->value() != wp->getHoldTime())
{
if (!m_ui->holdTimeSpinBox->isVisible()) m_ui->holdTimeSpinBox->blockSignals(true);
m_ui->holdTimeSpinBox->setValue(wp->getHoldTime());
if (!m_ui->holdTimeSpinBox->isVisible()) m_ui->holdTimeSpinBox->blockSignals(false);
}
if (m_ui->turnsSpinBox->value() != wp->getTurns())
{
if (!m_ui->turnsSpinBox->isVisible()) m_ui->turnsSpinBox->blockSignals(true);
m_ui->turnsSpinBox->setValue(wp->getTurns());
if (!m_ui->turnsSpinBox->isVisible()) m_ui->turnsSpinBox->blockSignals(false);
}
if (m_ui->takeOffAngleSpinBox->value() != wp->getParam1())
{
if (!m_ui->takeOffAngleSpinBox->isVisible()) m_ui->takeOffAngleSpinBox->blockSignals(true);
m_ui->takeOffAngleSpinBox->setValue(wp->getParam1());
if (!m_ui->takeOffAngleSpinBox->isVisible()) m_ui->takeOffAngleSpinBox->blockSignals(false);
}
// UPDATE CUSTOM ACTION WIDGET
......
......@@ -13,12 +13,33 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout" columnstretch="100,100,50">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
......@@ -54,6 +75,12 @@
</item>
<item row="1" column="2">
<widget class="QPushButton" name="actionButton">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Button name</string>
</property>
......
#include "QGCCommandButton.h"
#include "ui_QGCCommandButton.h"
#include "MAVLinkProtocol.h"
#include "UASManager.h"
QGCCommandButton::QGCCommandButton(QWidget *parent) :
QGCToolWidgetItem("Command Button", parent),
ui(new Ui::QGCCommandButton),
uas(NULL)
{
ui->setupUi(this);
connect(ui->commandButton, SIGNAL(clicked()), this, SLOT(sendCommand()));
connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
connect(ui->editButtonName, SIGNAL(textChanged(QString)), this, SLOT(setCommandButtonName(QString)));
connect(ui->editCommandComboBox, SIGNAL(currentIndexChanged(QString)), ui->nameLabel, SLOT(setText(QString)));
// Hide all edit items
ui->editCommandComboBox->hide();
ui->editFinishButton->hide();
ui->editNameLabel->hide();
ui->editButtonName->hide();
ui->editConfirmationCheckBox->hide();
ui->editComponentSpinBox->hide();
ui->editParamsVisibleCheckBox->hide();
ui->editParam1SpinBox->hide();
ui->editParam2SpinBox->hide();
ui->editParam3SpinBox->hide();
ui->editParam4SpinBox->hide();
ui->editLine1->hide();
ui->editLine2->hide();
ui->editLine1->setStyleSheet("QWidget { border: 1px solid #66666B; border-radius: 3px; padding: 10px 0px 0px 0px; background: #111122; }");
ui->editLine2->setStyleSheet("QWidget { border: 1px solid #66666B; border-radius: 3px; padding: 10px 0px 0px 0px; background: #111122; }");
// Add commands to combo box
ui->editCommandComboBox->addItem("DO: Control Video", MAV_CMD_DO_CONTROL_VIDEO);
ui->editCommandComboBox->addItem("PREFLIGHT: Calibration", MAV_CMD_PREFLIGHT_CALIBRATION);
}
QGCCommandButton::~QGCCommandButton()
{
delete ui;
}
void QGCCommandButton::sendCommand()
{
if (QGCToolWidgetItem::uas)
{
// FIXME
int index = ui->editCommandComboBox->itemData(ui->editCommandComboBox->currentIndex()).toInt();
MAV_CMD command = static_cast<MAV_CMD>(index);
int confirm = (ui->editConfirmationCheckBox->isChecked()) ? 1 : 0;
float param1 = ui->editParam1SpinBox->value();
float param2 = ui->editParam2SpinBox->value();
float param3 = ui->editParam3SpinBox->value();
float param4 = ui->editParam4SpinBox->value();
int component = ui->editComponentSpinBox->value();
QGCToolWidgetItem::uas->executeCommand(command, confirm, param1, param2, param3, param4, component);
}
else
{
qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
}
}
void QGCCommandButton::setCommandButtonName(QString text)
{
ui->commandButton->setText(text);
}
void QGCCommandButton::startEditMode()
{
// Hide elements
ui->commandButton->hide();
ui->nameLabel->hide();
ui->editCommandComboBox->show();
ui->editFinishButton->show();
ui->editNameLabel->show();
ui->editButtonName->show();
ui->editConfirmationCheckBox->show();
ui->editComponentSpinBox->show();
ui->editParamsVisibleCheckBox->show();
ui->editParam1SpinBox->show();
ui->editParam2SpinBox->show();
ui->editParam3SpinBox->show();
ui->editParam4SpinBox->show();
ui->editLine1->show();
ui->editLine2->show();
//setStyleSheet("QGroupBox { border: 1px solid #66666B; border-radius: 3px; padding: 10px 0px 0px 0px; background: #111122; }");
isInEditMode = true;
}
void QGCCommandButton::endEditMode()
{
ui->editCommandComboBox->hide();
ui->editFinishButton->hide();
ui->editNameLabel->hide();
ui->editButtonName->hide();
ui->editConfirmationCheckBox->hide();
ui->editComponentSpinBox->hide();
ui->editParamsVisibleCheckBox->hide();
ui->editLine1->hide();
ui->editLine2->hide();
if (!ui->editParamsVisibleCheckBox->isChecked())
{
ui->editParam1SpinBox->hide();
ui->editParam2SpinBox->hide();
ui->editParam3SpinBox->hide();
ui->editParam4SpinBox->hide();
}
ui->commandButton->show();
ui->nameLabel->show();
// Write to settings
emit editingFinished();
//setStyleSheet("");
isInEditMode = false;
}
void QGCCommandButton::writeSettings(QSettings& settings)
{
settings.setValue("TYPE", "COMMANDBUTTON");
settings.setValue("QGC_ACTION_BUTTON_DESCRIPTION", ui->nameLabel->text());
settings.setValue("QGC_ACTION_BUTTON_BUTTONTEXT", ui->commandButton->text());
settings.setValue("QGC_ACTION_BUTTON_ACTIONID", ui->editCommandComboBox->currentIndex());
settings.setValue("QGC_COMMAND_BUTTON_PARAMS_VISIBLE", ui->editParamsVisibleCheckBox->isChecked());
settings.sync();
}
void QGCCommandButton::readSettings(const QSettings& settings)
{
ui->editNameLabel->setText(settings.value("QGC_ACTION_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString());
ui->editButtonName->setText(settings.value("QGC_ACTION_BUTTON_BUTTONTEXT", "UNKNOWN").toString());
ui->editCommandComboBox->setCurrentIndex(settings.value("QGC_ACTION_BUTTON_ACTIONID", 0).toInt());
ui->nameLabel->setText(settings.value("QGC_ACTION_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString());
ui->commandButton->setText(settings.value("QGC_ACTION_BUTTON_BUTTONTEXT", "UNKNOWN").toString());
ui->editCommandComboBox->setCurrentIndex(settings.value("QGC_ACTION_BUTTON_ACTIONID", 0).toInt());
ui->editParamsVisibleCheckBox->setChecked(settings.value("QGC_COMMAND_BUTTON_PARAMS_VISIBLE").toBool());
if (ui->editParamsVisibleCheckBox->isChecked())
{
ui->editParam1SpinBox->show();
ui->editParam2SpinBox->show();
ui->editParam3SpinBox->show();
ui->editParam4SpinBox->show();
}
else
{
ui->editParam1SpinBox->hide();
ui->editParam2SpinBox->hide();
ui->editParam3SpinBox->hide();
ui->editParam4SpinBox->hide();
}
qDebug() << "DONE READING SETTINGS";
}
#ifndef QGCCOMMANDBUTTON_H
#define QGCCOMMANDBUTTON_H
#include "QGCToolWidgetItem.h"
namespace Ui {
class QGCCommandButton;
}
class UASInterface;
class QGCCommandButton : public QGCToolWidgetItem
{
Q_OBJECT
public:
explicit QGCCommandButton(QWidget *parent = 0);
~QGCCommandButton();
public slots:
void sendCommand();
void setCommandButtonName(QString text);
void startEditMode();
void endEditMode();
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
private:
Ui::QGCCommandButton *ui;
UASInterface* uas;
};
#endif // QGCCOMMANDBUTTON_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCCommandButton</class>
<widget class="QWidget" name="QGCCommandButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>882</width>
<height>430</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="100,0,0,0">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="7" column="0" colspan="3">
<widget class="QComboBox" name="editCommandComboBox"/>
</item>
<item row="7" column="3">
<widget class="QPushButton" name="editFinishButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="editButtonName">
<property name="text">
<string>&lt;Button Label&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string>&lt;Button Description Label (in front of button)&gt;</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="commandButton">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Unnamed</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QSpinBox" name="editComponentSpinBox">
<property name="prefix">
<string>Component ID: </string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QCheckBox" name="editConfirmationCheckBox">
<property name="toolTip">
<string>Set the confirm flag for this button. Some commands require that first one command is sent without confirm flag and then a second, equal command with confirm flag. This ensures safety.</string>
</property>
<property name="text">
<string>Set CONFIRM flag</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="editParam1SpinBox">
<property name="toolTip">
<string>PARAM1 Value as defined in MAV_CMD list</string>
</property>
<property name="statusTip">
<string>PARAM1 Value as defined in MAV_CMD list</string>
</property>
<property name="prefix">
<string>P1 </string>
</property>
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="editParam2SpinBox">
<property name="toolTip">
<string>PARAM2 Value as defined in MAV_CMD list</string>
</property>
<property name="statusTip">
<string>PARAM2 Value as defined in MAV_CMD list</string>
</property>
<property name="prefix">
<string>P2: </string>
</property>
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="editParam3SpinBox">
<property name="toolTip">
<string>PARAM3 Value as defined in MAV_CMD list</string>
</property>
<property name="statusTip">
<string>PARAM3 Value as defined in MAV_CMD list</string>
</property>
<property name="prefix">
<string>P3: </string>
</property>
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="editParam4SpinBox">
<property name="toolTip">
<string>PARAM4 Value as defined in MAV_CMD list</string>
</property>
<property name="statusTip">
<string>PARAM4 Value as defined in MAV_CMD list</string>
</property>
<property name="prefix">
<string>P4: </string>
</property>
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="editParamsVisibleCheckBox">
<property name="text">
<string>Keep parameters visible</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="Line" name="editLine1">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<widget class="Line" name="editLine2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>editNameLabel</sender>
<signal>textChanged(QString)</signal>
<receiver>nameLabel</receiver>
<slot>setText(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>114</x>
<y>22</y>
</hint>
<hint type="destinationlabel">
<x>114</x>
<y>55</y>
</hint>
</hints>
</connection>
</connections>
</ui>
This diff is collapsed.
......@@ -27,9 +27,18 @@ public slots:
/** @brief Set the slider value as parameter value */
void setSliderValue(int sliderValue);
/** @brief Update the UI with the new parameter value */
void setParameterValue(int uas, int component, QString parameterName, float value);
void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, float value);
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
void refreshParamList();
void setActiveUAS(UASInterface *uas);
void selectComponent(int componentIndex);
void selectParameter(int paramIndex);
void setParamValue(double value);
protected slots:
/** @brief Request the parameter of this widget from the MAV */
void requestParameter();
protected:
QString parameterName; ///< Key/Name of the parameter
......@@ -38,6 +47,7 @@ protected:
float parameterMin;
float parameterMax;
int component; ///< ID of the MAV component to address
int parameterIndex;
double scaledInt;
void changeEvent(QEvent *e);
......
......@@ -6,103 +6,244 @@
<rect>
<x>0</x>
<y>0</y>
<width>499</width>
<height>173</height>
<width>789</width>
<height>155</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout" columnstretch="100,0,0,0,0,0,0,0,0">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>12</number>
</property>
<item row="1" column="1" colspan="5">
<widget class="QLineEdit" name="editNameLabel">
<property name="text">
<string>Informal Name..</string>
<string>&lt;Parameter Name / Label&gt;</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="editMinLabel">
<item row="2" column="1">
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Min</string>
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QLabel" name="editMaxLabel">
<property name="text">
<string>Max</string>
<item row="2" column="5" colspan="2">
<widget class="QSlider" name="valueSlider">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="nameLabel">
<item row="5" column="1" colspan="6">
<widget class="QLabel" name="editStatusLabel">
<property name="text">
<string>Name</string>
<string>Please click first on refresh to update selection menus..</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="valueLabel">
<property name="text">
<string>0.00</string>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="editSelectComponentComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Select component</string>
</property>
<property name="statusTip">
<string>Select component</string>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="QDoubleSpinBox" name="editMinSpinBox"/>
</item>
<item row="2" column="5">
<widget class="QSlider" name="valueSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="3" column="4" colspan="3">
<widget class="QComboBox" name="editSelectParamComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Select parameter</string>
</property>
<property name="statusTip">
<string>Select parameter</string>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QDoubleSpinBox" name="editMaxSpinBox"/>
</item>
<item row="0" column="0" colspan="7">
<widget class="QLabel" name="editInstructionsLabel">
<item row="2" column="8">
<widget class="QPushButton" name="readButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Read the current parameter value on the system</string>
</property>
<property name="statusTip">
<string>Read the current parameter value on the system</string>
</property>
<property name="text">
<string>Please configure the parameter slider now:</string>
<string>R</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="6">
<widget class="QLabel" name="editStatusLabel">
<item row="3" column="8">
<widget class="QPushButton" name="editRefreshParamsButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
<string>Refresh</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QComboBox" name="editSelectComponentComboBox"/>
</item>
<item row="5" column="6">
<item row="5" column="8">
<widget class="QPushButton" name="editDoneButton">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
<item row="3" column="6">
<widget class="QPushButton" name="editRefreshParamsButton">
<property name="enabled">
<bool>true</bool>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="valueSpinBox">
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="7">
<widget class="QPushButton" name="writeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Transmit the current slider value to the system</string>
</property>
<property name="statusTip">
<string>Transmit the current slider value to the system</string>
</property>
<property name="text">
<string>Refresh</string>
<string>W</string>
</property>
</widget>
</item>
<item row="3" column="4" colspan="2">
<widget class="QComboBox" name="editSelectParamComboBox">
<item>
<property name="text">
<string>Select Parameter..</string>
</property>
</item>
<item row="0" column="0" colspan="9">
<widget class="Line" name="editLine1">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0" colspan="9">
<widget class="Line" name="editLine2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QDoubleSpinBox" name="editMinSpinBox">
<property name="prefix">
<string>MIN: </string>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="7" colspan="2">
<widget class="QDoubleSpinBox" name="editMaxSpinBox">
<property name="prefix">
<string>MAX: </string>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
......
#ifndef QGCPARAMSLIDERPLUGIN_H
#define QGCPARAMSLIDERPLUGIN_H
#include <QtDesigner/QDesignerCustomWidgetInterface>
class QGCParamSliderPlugin : public QObject,
public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
explicit QGCParamSliderPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool initialized;
};
#endif // QGCPARAMSLIDERPLUGIN_H
......@@ -10,6 +10,7 @@
#include "QGCParamSlider.h"
#include "QGCActionButton.h"
#include "QGCCommandButton.h"
#include "UASManager.h"
QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
......@@ -23,6 +24,7 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
createActions();
toolLayout = ui->toolLayout;
toolLayout->setAlignment(Qt::AlignTop);
toolLayout->setSpacing(8);
QDockWidget* dock = dynamic_cast<QDockWidget*>(this->parentWidget());
if (dock)
......@@ -105,6 +107,16 @@ QList<QGCToolWidget*> QGCToolWidget::createWidgetsFromSettings(QWidget* parent)
item = new QGCActionButton(newWidgets.at(i));
qDebug() << "CREATED BUTTON";
}
else if (type == "COMMANDBUTTON")
{
item = new QGCCommandButton(newWidgets.at(i));
qDebug() << "CREATED COMMANDBUTTON";
}
else if (type == "SLIDER")
{
item = new QGCParamSlider(newWidgets.at(i));
qDebug() << "CREATED PARAM SLIDER";
}
if (item)
{
......@@ -175,10 +187,12 @@ void QGCToolWidget::addUAS(UASInterface* uas)
void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
{
QMenu menu(this);
//menu.addAction(addParamAction);
menu.addAction(addButtonAction);
menu.addAction(addParamAction);
menu.addAction(addCommandAction);
menu.addAction(setTitleAction);
menu.addAction(deleteAction);
menu.addSeparator();
menu.addAction(addButtonAction);
menu.exec(event->globalPos());
}
......@@ -188,9 +202,9 @@ void QGCToolWidget::createActions()
addParamAction->setStatusTip(tr("Add a parameter setting slider widget to the tool"));
connect(addParamAction, SIGNAL(triggered()), this, SLOT(addParam()));
addButtonAction = new QAction(tr("New MAV &Action Button"), this);
addButtonAction->setStatusTip(tr("Add a new action button to the tool"));
connect(addButtonAction, SIGNAL(triggered()), this, SLOT(addAction()));
addCommandAction = new QAction(tr("New MAV &Command Button"), this);
addCommandAction->setStatusTip(tr("Add a new action button to the tool"));
connect(addCommandAction, SIGNAL(triggered()), this, SLOT(addCommand()));
setTitleAction = new QAction(tr("Set Widget Title"), this);
setTitleAction->setStatusTip(tr("Set the title caption of this tool widget"));
......@@ -199,6 +213,18 @@ void QGCToolWidget::createActions()
deleteAction = new QAction(tr("Delete this widget"), this);
deleteAction->setStatusTip(tr("Delete this widget permanently"));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteWidget()));
exportAction = new QAction(tr("Export this widget"), this);
exportAction->setStatusTip(tr("Export this widget to be reused by others"));
connect(exportAction, SIGNAL(triggered()), this, SLOT(exportWidget()));
importAction = new QAction(tr("Import widget"), this);
importAction->setStatusTip(tr("Import this widget from a file (current content will be removed)"));
connect(exportAction, SIGNAL(triggered()), this, SLOT(importWidget()));
addButtonAction = new QAction(tr("New MAV Action Button (Deprecated)"), this);
addButtonAction->setStatusTip(tr("Add a new action button to the tool"));
connect(addButtonAction, SIGNAL(triggered()), this, SLOT(addAction()));
}
QMap<QString, QGCToolWidget*>* QGCToolWidget::instances()
......@@ -239,6 +265,18 @@ void QGCToolWidget::addAction()
button->startEditMode();
}
void QGCToolWidget::addCommand()
{
QGCCommandButton* button = new QGCCommandButton(this);
if (ui->hintLabel)
{
ui->hintLabel->deleteLater();
ui->hintLabel = NULL;
}
toolLayout->addWidget(button);
button->startEditMode();
}
void QGCToolWidget::addToolWidget(QGCToolWidgetItem* widget)
{
if (ui->hintLabel)
......@@ -249,6 +287,16 @@ void QGCToolWidget::addToolWidget(QGCToolWidgetItem* widget)
toolLayout->addWidget(widget);
}
void QGCToolWidget::exportWidget()
{
}
void QGCToolWidget::importWidget(const QString& fileName)
{
}
const QString QGCToolWidget::getTitle()
{
QDockWidget* parent = dynamic_cast<QDockWidget*>(this->parentWidget());
......
......@@ -32,6 +32,10 @@ public slots:
void addUAS(UASInterface* uas);
/** @brief Delete this widget */
void deleteWidget();
/** @brief Export this widget to a file */
void exportWidget();
/** @brief Import settings for this widget from a file */
void importWidget(const QString& fileName);
/** @brief Store all widgets of this type to QSettings */
static void storeWidgetsToSettings();
......@@ -41,8 +45,11 @@ signals:
protected:
QAction* addParamAction;
QAction* addButtonAction;
QAction* addCommandAction;
QAction* setTitleAction;
QAction* deleteAction;
QAction* exportAction;
QAction* importAction;
QVBoxLayout* toolLayout;
UAS* mav;
QAction* mainMenuAction;
......@@ -56,7 +63,9 @@ protected:
protected slots:
void addParam();
/** @deprecated */
void addAction();
void addCommand();
void setTitle();
......
......@@ -14,6 +14,21 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="toolLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="hintLabel">
<property name="text">
......
......@@ -22,7 +22,7 @@ public slots:
virtual void setComponent(int comp) {_component = comp;}
virtual void writeSettings(QSettings& settings) = 0;
virtual void readSettings(const QSettings& settings) = 0;
void setActiveUAS(UASInterface *uas);
virtual void setActiveUAS(UASInterface *uas);
signals:
void editingFinished();
......
......@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>1105</width>
<width>1228</width>
<height>25</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="10,10,10,10,10,10,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="10,0,10,10,10,10,0,0">
<property name="spacing">
<number>5</number>
</property>
......
#include "QGCMissionConditionWidget.h"
#include "ui_QGCMissionConditionWidget.h"
QGCMissionConditionWidget::QGCMissionConditionWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCMissionConditionWidget)
{
ui->setupUi(this);
}
QGCMissionConditionWidget::~QGCMissionConditionWidget()
{
delete ui;
}
#ifndef QGCMISSIONCONDITIONWIDGET_H
#define QGCMISSIONCONDITIONWIDGET_H
#include <QWidget>
namespace Ui {
class QGCMissionConditionWidget;
}
class QGCMissionConditionWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCMissionConditionWidget(QWidget *parent = 0);
~QGCMissionConditionWidget();
private:
Ui::QGCMissionConditionWidget *ui;
};
#endif // QGCMISSIONCONDITIONWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCMissionConditionWidget</class>
<widget class="QWidget" name="QGCMissionConditionWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1260</width>
<height>31</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="conditionDelayTimeSpinBox">
<property name="prefix">
<string>delay: </string>
</property>
<property name="suffix">
<string> s</string>
</property>
<property name="maximum">
<double>50000.000000000000000</double>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="conditionChangeAltRateSpinBox">
<property name="prefix">
<string>rate: </string>
</property>
<property name="suffix">
<string> m/s</string>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="conditionChangeAltFinishAltitudeSpinBox">
<property name="prefix">
<string>finish altitude: </string>
</property>
<property name="suffix">
<string> m</string>
</property>
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="conditionDistanceSpinBox">
<property name="prefix">
<string>distance to next wp: </string>
</property>
<property name="suffix">
<string> m/s</string>
</property>
<property name="maximum">
<double>50000.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="conditionYawAngleSpinBox">
<property name="prefix">
<string>heading: </string>
</property>
<property name="suffix">
<string>°</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="conditionYawRateSpinBox">
<property name="prefix">
<string>turn rate: </string>
</property>
<property name="suffix">
<string>°/s</string>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value">
<double>15.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="conditionYawDirectionComboBox">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>left/counter-clockwise</string>
</property>
</item>
<item>
<property name="text">
<string>right/clockwise</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="conditionYawOffsetComboBox">
<item>
<property name="text">
<string>compass direction</string>
</property>
</item>
<item>
<property name="text">
<string>offset from current heading</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "QGCMissionDoWidget.h"
#include "ui_QGCMissionDoWidget.h"
QGCMissionDoWidget::QGCMissionDoWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCMissionDoWidget)
{
ui->setupUi(this);
}
QGCMissionDoWidget::~QGCMissionDoWidget()
{
delete ui;
}
#ifndef QGCMISSIONDOWIDGET_H
#define QGCMISSIONDOWIDGET_H
#include <QWidget>
namespace Ui {
class QGCMissionDoWidget;
}
class QGCMissionDoWidget : public QWidget
{
Q_OBJECT
public:
explicit QGCMissionDoWidget(QWidget *parent = 0);
~QGCMissionDoWidget();
private:
Ui::QGCMissionDoWidget *ui;
};
#endif // QGCMISSIONDOWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCMissionDoWidget</class>
<widget class="QWidget" name="QGCMissionDoWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>632</width>
<height>40</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QSpinBox" name="doJumpIndexSpinBox">
<property name="geometry">
<rect>
<x>170</x>
<y>10</y>
<width>201</width>
<height>25</height>
</rect>
</property>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string>list index to jump to: </string>
</property>
<property name="maximum">
<number>5000</number>
</property>
</widget>
<widget class="QSpinBox" name="doJumpRepeatSpinBox">
<property name="geometry">
<rect>
<x>380</x>
<y>10</y>
<width>121</width>
<height>25</height>
</rect>
</property>
<property name="suffix">
<string> times</string>
</property>
<property name="prefix">
<string>repeat </string>
</property>
<property name="maximum">
<number>1000</number>
</property>
</widget>
<widget class="QComboBox" name="doSetModeComboBox">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>111</width>
<height>26</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Subproject commit 49db98933d97766016c18b4dadd6e238eec6c8f7
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment