Browse Source

First semi-usable version with new menu layout based on autopilot. Still very experimental. Current Bug: Linecharts do not work. Need to find out why

QGC4.4
Mariano Lizarraga 15 years ago
parent
commit
870ad6de68
  1. 22
      src/comm/MAVLinkProtocol.cc
  2. 4
      src/comm/MAVLinkSimulationLink.cc
  3. 2
      src/comm/SerialLink.cc
  4. 767
      src/ui/MainWindow.cc
  5. 128
      src/ui/MainWindow.h
  6. 1
      src/ui/MapWidget.cc

22
src/comm/MAVLinkProtocol.cc

@ -162,10 +162,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -162,10 +162,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
uas = new UAS(this, message.sysid);
// Set the autopilot type
uas->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object
connect(this, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), uas, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
break;
@ -173,10 +169,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -173,10 +169,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
{
// Fixme differentiate between quadrotor and coaxial here
PxQuadMAV* mav = new PxQuadMAV(this, message.sysid);
// Set the autopilot type
//mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
@ -188,10 +180,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -188,10 +180,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
case MAV_AUTOPILOT_SLUGS:
{
SlugsMAV* mav = new SlugsMAV(this, message.sysid);
// Set the autopilot type
mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
@ -203,10 +191,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -203,10 +191,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
case MAV_AUTOPILOT_ARDUPILOTMEGA:
{
ArduPilotMegaMAV* mav = new ArduPilotMegaMAV(this, message.sysid);
// Set the autopilot type
mav->setAutopilotType((int)heartbeat.autopilot);
// Connect this robot to the UAS object
// it is IMPORTANT here to use the right object type,
// else the slot of the parent object is called (and thus the special
@ -229,12 +213,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) @@ -229,12 +213,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
// Now add UAS to "official" list, which makes the whole application aware of it
UASManager::instance()->addUAS(uas);
qDebug() << "++===============================";
qDebug() << uas->getAutopilotType();
qDebug() << "++===============================";
}
// Only count message if UAS exists for this message

4
src/comm/MAVLinkSimulationLink.cc

@ -837,9 +837,9 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) @@ -837,9 +837,9 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
}
unsigned char v=data[i];
fprintf(stderr,"%02x ", v);
//fprintf(stderr,"%02x ", v);
}
fprintf(stderr,"\n");
//fprintf(stderr,"\n");
readyBufferMutex.lock();
for (int i = 0; i < streampointer; i++)

2
src/comm/SerialLink.cc

@ -170,7 +170,7 @@ void SerialLink::writeBytes(const char* data, qint64 size) @@ -170,7 +170,7 @@ void SerialLink::writeBytes(const char* data, qint64 size)
{
unsigned char v=data[i];
fprintf(stderr,"%02x ", v);
//fprintf(stderr,"%02x ", v);
}
}
}

767
src/ui/MainWindow.cc

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
*
* @see QMainWindow::show()
**/
MainWindow::MainWindow(QWidget *parent) :
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent),
toolsMenuActions(),
currentView(VIEW_MAVLINK),
@ -90,8 +90,6 @@ MainWindow::~MainWindow() @@ -90,8 +90,6 @@ MainWindow::~MainWindow()
statusBar = NULL;
}
void MainWindow::buildCommonWidgets()
{
//TODO: move protocol outside UI
@ -128,6 +126,7 @@ void MainWindow::buildCommonWidgets() @@ -128,6 +126,7 @@ void MainWindow::buildCommonWidgets()
}
void MainWindow::buildPxWidgets()
{
//FIXME: memory of acceptList will never be freed again
@ -146,18 +145,30 @@ void MainWindow::buildPxWidgets() @@ -146,18 +145,30 @@ void MainWindow::buildPxWidgets()
// Center widgets
linechartWidget = new Linecharts(this);
addToCentralWidgetsMenu(linechartWidget, "Line Plots", SLOT(showCentralWidget()), CENTRAL_LINECHART);
hudWidget = new HUD(320, 240, this);
addToCentralWidgetsMenu(hudWidget, "HUD", SLOT(showCentralWidget()), CENTRAL_HUD);
dataplotWidget = new QGCDataPlot2D(this);
addToCentralWidgetsMenu(dataplotWidget, "Data Plots", SLOT(showCentralWidget()), CENTRAL_DATA_PLOT);
#ifdef QGC_OSG_ENABLED
_3DWidget = Q3DWidgetFactory::get("PIXHAWK");
addToCentralWidgetsMenu(_3DWidget, "Local 3D", SLOT(showCentralWidget()), CENTRAL_3D_LOCAL);
#endif
#ifdef QGC_OSGEARTH_ENABLED
_3DMapWidget = Q3DWidgetFactory::get("MAP3D");
addToCentralWidgetsMenu(_3DMapWidget, "OSG Earth 3D", SLOT(showCentralWidget()), CENTRAL_OSGEARTH);
#endif
#if (defined Q_OS_WIN) | (defined Q_OS_MAC)
gEarthWidget = new QGCGoogleEarthView(this);
addToCentralWidgetsMenu(gEarthWidget, "Google Earth", SLOT(showCentralWidget()), CENTRAL_GOOGLE_EARTH);
#endif
// Dock widgets
@ -244,10 +255,12 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget, @@ -244,10 +255,12 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
TOOLS_WIDGET_NAMES centralWidget){
QAction* tempAction;
// Add the separator that will separate tools from central Widgets
if (!toolsMenuActions[CENTRAL_SEPARATOR]){
tempAction = ui.menuTools->addSeparator();
toolsMenuActions[CENTRAL_SEPARATOR] = tempAction;
tempAction->setData(CENTRAL_SEPARATOR);
}
tempAction = ui.menuTools->addAction(title);
@ -264,9 +277,10 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget, @@ -264,9 +277,10 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
if (!settings.contains(chKey)){
settings.setValue(chKey,false);
tempAction->setChecked(false);
} else {
tempAction->setChecked(settings.value(chKey).toBool());
}
// else {
// tempAction->setChecked(settings.value(chKey).toBool());
// }
// connect the action
connect(tempAction,SIGNAL(triggered()),this, slotName);
@ -279,14 +293,16 @@ void MainWindow::showCentralWidget(){ @@ -279,14 +293,16 @@ void MainWindow::showCentralWidget(){
int tool = senderAction->data().toInt();
QString chKey;
// check the current action
if (senderAction && dockWidgets[tool]){
// uncheck all central widget actions
QHashIterator<int, QAction*> i(toolsMenuActions);
while (i.hasNext()) {
i.next();
if (i.value()->data().toInt() >= 255){
i.next();
qDebug() << "shCW" << i.key() << "read";
if (i.value() && i.value()->data().toInt() > 255){
i.value()->setChecked(false);
// update the settings
@ -296,6 +312,7 @@ void MainWindow::showCentralWidget(){ @@ -296,6 +312,7 @@ void MainWindow::showCentralWidget(){
}
// check the current action
qDebug() << senderAction->text();
senderAction->setChecked(true);
// update the central widget
@ -304,6 +321,8 @@ void MainWindow::showCentralWidget(){ @@ -304,6 +321,8 @@ void MainWindow::showCentralWidget(){
// store the selected central widget
chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(tool), currentView);
settings.setValue(chKey,true);
presentView();
}
}
@ -315,6 +334,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget, @@ -315,6 +334,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
QAction* tempAction;
QString posKey, chKey;
if (toolsMenuActions[CENTRAL_SEPARATOR]){
tempAction = new QAction(title, this);
ui.menuTools->insertAction(toolsMenuActions[CENTRAL_SEPARATOR],
@ -329,6 +349,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget, @@ -329,6 +349,7 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
// populate the Hashes
toolsMenuActions[tool] = tempAction;
dockWidgets[tool] = widget;
qDebug() << widget;
posKey = buildMenuKey (SUB_SECTION_LOCATION,tool, currentView);
@ -351,14 +372,55 @@ void MainWindow::addToToolsMenu ( QWidget* widget, @@ -351,14 +372,55 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
// connect the action
connect(tempAction,SIGNAL(triggered()),this, slotName);
connect(static_cast <QDockWidget *>(dockWidgets[tool]),
connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool)));
connect(static_cast <QDockWidget *>(dockWidgets[tool]),
connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(updateLocationSettings(Qt::DockWidgetArea)));
}
void MainWindow::showToolWidget(){
QAction* temp = qobject_cast<QAction *>(sender());
int tool = temp->data().toInt();
if (temp && dockWidgets[tool]){
if (temp->isChecked()){
addDockWidget(dockWidgetLocations[tool], qobject_cast<QDockWidget *> (dockWidgets[tool]));
qobject_cast<QDockWidget *>(dockWidgets[tool])->show();
} else {
removeDockWidget(qobject_cast<QDockWidget *>(dockWidgets[tool]));
}
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(tool), currentView);
settings.setValue(chKey,temp->isChecked());
}
}
void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view){
bool tempVisible;
Qt::DockWidgetArea tempLocation;
QDockWidget* tempWidget = static_cast <QDockWidget *>(dockWidgets[widget]);
tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,widget,view)).toBool();
if (tempWidget){
toolsMenuActions[widget]->setChecked(tempVisible);
}
//qDebug() << buildMenuKey (SUB_SECTION_CHECKED,widget,view) << tempVisible;
tempLocation = static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,widget, view)).toInt());
if (tempWidget && tempVisible){
addDockWidget(tempLocation, tempWidget);
tempWidget->show();
}
}
QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES tool, VIEW_SECTIONS view){
// Key is built as follows: autopilot_type/section_menu/view/tool/section
int apType;
@ -374,24 +436,6 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t @@ -374,24 +436,6 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t
QString::number(section) + "/" );
}
void MainWindow::showToolWidget(){
QAction* temp = qobject_cast<QAction *>(sender());
int tool = temp->data().toInt();
if (temp && dockWidgets[tool]){
if (temp->isChecked()){
addDockWidget(dockWidgetLocations[tool], static_cast <QDockWidget *> (dockWidgets[tool]));
static_cast <QDockWidget *>(dockWidgets[tool])->show();
} else {
removeDockWidget(static_cast <QDockWidget *>(dockWidgets[tool]));
}
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(tool), currentView);
settings.setValue(chKey,temp->isChecked());
}
}
void MainWindow::updateVisibilitySettings (bool vis){
Q_UNUSED(vis);
@ -974,359 +1018,109 @@ void MainWindow::clearView() @@ -974,359 +1018,109 @@ void MainWindow::clearView()
}
}
void MainWindow::loadSlugsView()
void MainWindow::loadEngineerView()
{
clearView();
// Engineer view, used in EMAV2009
// LINE CHART
if (linechartWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
linechartWidget->setActive(true);
centerStack->setCurrentWidget(linechartWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// UAS STATUS
if (infoDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
infoDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// DEBUG CONSOLE
if (debugConsoleDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget);
debugConsoleDockWidget->show();
}
clearView();
// Slugs Data View
if (slugsDataWidget)
{
addDockWidget(Qt::RightDockWidgetArea, slugsDataWidget);
slugsDataWidget->show();
}
currentView = VIEW_ENGINEER;
// Slugs Data View
if (slugsHilSimWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, slugsHilSimWidget);
slugsHilSimWidget->show();
}
this->show();
presentView();
}
void MainWindow::loadPixhawkEngineerView()
void MainWindow::loadOperatorView()
{
clearView();
currentView = VIEW_OPERATOR;
presentView();
}
void MainWindow::loadDataView()
void MainWindow::loadPilotView()
{
clearView();
// DATAPLOT
if (dataplotWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
centerStack->setCurrentWidget(dataplotWidget);
}
currentView = VIEW_PILOT;
presentView();
}
void MainWindow::loadDataView(QString fileName)
void MainWindow::loadMAVLinkView()
{
clearView();
// DATAPLOT
if (dataplotWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(dataplotWidget);
dataplotWidget->loadFile(fileName);
}
}
currentView = VIEW_MAVLINK;
presentView();
}
void MainWindow::presentView() {
#ifdef QGC_OSG_ENABLED
// 3D map
if (_3DWidget)
{
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DWidget);
}
}
#endif
qDebug() << "LC";
if (linechartWidget){
qDebug () << buildMenuKey (SUB_SECTION_CHECKED,CENTRAL_LINECHART,currentView) <<
settings.value(buildMenuKey (SUB_SECTION_CHECKED,CENTRAL_LINECHART,currentView)).toBool() ;
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,CENTRAL_LINECHART,currentView)).toBool()){
if (centerStack) {
linechartWidget->setActive(true);
centerStack->setCurrentWidget(linechartWidget);
}
} else {
linechartWidget->setActive(false);
}
}
void MainWindow::loadSlugsEngineerView()
{
}
void MainWindow::load3DMapView()
{
#ifdef QGC_OSGEARTH_ENABLED
clearView();
// MAP
qDebug() << "MAP";
showTheCentralWidget(CENTRAL_MAP, currentView);
// 3D map
if (_3DMapWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DMapWidget);
}
}
// PROTOCOL
qDebug() << "CP";
showTheCentralWidget(CENTRAL_PROTOCOL, currentView);
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// HEAD UP DISPLAY
qDebug() << "HUD";
if (hudWidget){
qDebug() << buildMenuKey(SUB_SECTION_CHECKED,CENTRAL_HUD,currentView) <<
settings.value(buildMenuKey (SUB_SECTION_CHECKED,CENTRAL_HUD,currentView)).toBool();
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,CENTRAL_HUD,currentView)).toBool()){
if (centerStack) {
centerStack->setCurrentWidget(hudWidget);
hudWidget->start();
}
} else {
hudWidget->stop();
}
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// Show docked widgets based on current view and autopilot type
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// UAS CONTROL
showTheWidget(MENU_UAS_CONTROL, currentView);
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
#endif
this->show();
}
// UAS LIST
showTheWidget(MENU_UAS_LIST, currentView);
void MainWindow::loadGoogleEarthView()
{
#if (defined Q_OS_WIN) | (defined Q_OS_MAC)
clearView();
// WAYPOINT LIST
showTheWidget(MENU_WAYPOINTS, currentView);
// 3D map
if (gEarthWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(gEarthWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
this->show();
#endif
}
void MainWindow::load3DView()
{
#ifdef QGC_OSG_ENABLED
clearView();
// 3D map
if (_3DWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
#endif
this->show();
}
void MainWindow::loadEngineerView()
{
clearView();
currentView = VIEW_ENGINEER;
presentView();
}
void MainWindow::loadOperatorView()
{
clearView();
currentView = VIEW_OPERATOR;
presentView();
}
void MainWindow::loadPilotView()
{
clearView();
currentView = VIEW_PILOT;
presentView();
}
void MainWindow::loadMAVLinkView()
{
clearView();
currentView = VIEW_MAVLINK;
presentView();
}
void MainWindow::presentView() {
#ifdef QGC_OSG_ENABLED
// 3D map
if (_3DWidget)
{
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DWidget);
}
}
#else
showCentralWidget(CENTRAL_LINECHART, currentView);
#endif
// MAP
showCentralWidget(CENTRAL_MAP, currentView);
// PROTOCOL
showCentralWidget(CENTRAL_PROTOCOL, currentView);
// HEAD UP DISPLAY
if (hudWidget &&
settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HSI,currentView)).toBool()){
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(hudWidget);
hudWidget->start();
}
}
// Show docked widgets based on current view and autopilot type
// UAS CONTROL
showTheWidget(MENU_UAS_CONTROL, currentView);
// UAS LIST
showTheWidget(MENU_UAS_LIST, currentView);
// WAYPOINT LIST
showTheWidget(MENU_WAYPOINTS, currentView);
// UAS STATUS
showTheWidget(MENU_STATUS, currentView);
// UAS STATUS
showTheWidget(MENU_STATUS, currentView);
// DETECTION
showTheWidget(MENU_DETECTION, currentView);
@ -1342,6 +1136,22 @@ void MainWindow::presentView() { @@ -1342,6 +1136,22 @@ void MainWindow::presentView() {
// HUD
showTheWidget(MENU_HUD, currentView);
if (headUpDockWidget)
{
HUD* tmpHud = dynamic_cast<HUD*>( headUpDockWidget->widget() );
if (tmpHud){
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HUD,currentView)).toBool()){
tmpHud->start();
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HUD, currentView)).toInt()),
hsiDockWidget);
headUpDockWidget->show();
} else {
tmpHud->stop();
headUpDockWidget->hide();
}
}
}
// RC View
showTheWidget(MENU_RC_VIEW, currentView);
@ -1359,45 +1169,56 @@ void MainWindow::presentView() { @@ -1359,45 +1169,56 @@ void MainWindow::presentView() {
showTheWidget(MENU_SLUGS_CAMERA, currentView);
// HORIZONTAL SITUATION INDICATOR
showTheWidget(MENU_HSI, currentView);
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi &&
settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HSI,currentView)).toBool())
{
if (hsi){
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HSI,currentView)).toBool()){
hsi->start();
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HSI, currentView)).toInt()),
hsiDockWidget);
hsiDockWidget->show();
} else {
hsi->stop();
hsiDockWidget->hide();
}
}
}
// HEAD DOWN 1
showTheWidget(MENU_HDD_1, currentView);
if (headDown1DockWidget)
{
HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown1DockWidget->widget());
if (hdd &&
settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HDD_1,currentView)).toBool())
{
if (hdd) {
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HDD_1,currentView)).toBool()) {
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HDD_1, currentView)).toInt()),
headDown1DockWidget);
headDown1DockWidget->show();
hdd->start();
} else {
headDown1DockWidget->hide();;
hdd->stop();
}
}
}
// HEAD DOWN 2
showTheWidget(MENU_HDD_2, currentView);
if (headDown2DockWidget)
{
HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown2DockWidget->widget());
if (hdd &&
settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HDD_2,currentView)).toBool())
{
if (hdd){
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HDD_2,currentView)).toBool()){
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HDD_2, currentView)).toInt()),
headDown2DockWidget);
headDown2DockWidget->show();
hdd->start();
} else {
headDown2DockWidget->hide();
hdd->stop();
}
}
}
@ -1407,36 +1228,13 @@ void MainWindow::presentView() { @@ -1407,36 +1228,13 @@ void MainWindow::presentView() {
void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view){
bool tempVisible;
Qt::DockWidgetArea tempLocation;
QDockWidget* tempWidget = static_cast <QDockWidget *>(dockWidgets[widget]);
tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,widget,view)).toBool();
if (toolsMenuActions[widget]){
toolsMenuActions[widget]->setChecked(tempVisible);
}
qDebug() << buildMenuKey (SUB_SECTION_CHECKED,widget,view) << tempVisible;
tempLocation = static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,widget, view)).toInt());
if (tempWidget && tempVisible){
addDockWidget(tempLocation, tempWidget);
tempWidget->show();
}
}
void MainWindow::showCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view){
void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view){
bool tempVisible;
QWidget* tempWidget = dockWidgets[centralWidget];
tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view)).toBool();
qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible;
if (toolsMenuActions[centralWidget]){
toolsMenuActions[centralWidget]->setChecked(tempVisible);
}
@ -1446,6 +1244,20 @@ void MainWindow::showCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTI @@ -1446,6 +1244,20 @@ void MainWindow::showCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTI
}
}
/*
==========================================================
Potentially Deprecated
==========================================================
*/
void MainWindow::loadPixhawkEngineerView()
{
}
void MainWindow::loadAllView()
{
clearView();
@ -1459,7 +1271,7 @@ void MainWindow::loadAllView() @@ -1459,7 +1271,7 @@ void MainWindow::loadAllView()
headDown1DockWidget->show();
hdd->start();
}
}
if (headDown2DockWidget)
{
@ -1542,6 +1354,191 @@ void MainWindow::loadWidgets() @@ -1542,6 +1354,191 @@ void MainWindow::loadWidgets()
//loadPilotView();
}
void MainWindow::loadDataView()
{
clearView();
// DATAPLOT
if (dataplotWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
centerStack->setCurrentWidget(dataplotWidget);
}
}
void MainWindow::loadDataView(QString fileName)
{
clearView();
// DATAPLOT
if (dataplotWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(dataplotWidget);
dataplotWidget->loadFile(fileName);
}
}
}
void MainWindow::load3DMapView()
{
#ifdef QGC_OSGEARTH_ENABLED
clearView();
// 3D map
if (_3DMapWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DMapWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
#endif
this->show();
}
void MainWindow::loadGoogleEarthView()
{
#if (defined Q_OS_WIN) | (defined Q_OS_MAC)
clearView();
// 3D map
if (gEarthWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(gEarthWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
this->show();
#endif
}
void MainWindow::load3DView()
{
#ifdef QGC_OSG_ENABLED
clearView();
// 3D map
if (_3DWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DWidget);
}
}
// UAS CONTROL
if (controlDockWidget)
{
addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
controlDockWidget->show();
}
// UAS LIST
if (listDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
listDockWidget->show();
}
// WAYPOINT LIST
if (waypointsDockWidget)
{
addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
waypointsDockWidget->show();
}
// HORIZONTAL SITUATION INDICATOR
if (hsiDockWidget)
{
HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
if (hsi)
{
hsi->start();
addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
hsiDockWidget->show();
}
}
#endif
this->show();
}
/*
==================================

128
src/ui/MainWindow.h

@ -119,20 +119,9 @@ public slots: @@ -119,20 +119,9 @@ public slots:
void loadEngineerView();
/** @brief Load view for operator */
void loadOperatorView();
/** @brief Load 3D view */
void load3DView();
/** @brief Load 3D Google Earth view */
void loadGoogleEarthView();
/** @brief Load 3D map view */
void load3DMapView();
/** @brief Load view with all widgets */
void loadAllView();
/** @brief Load MAVLink XML generator view */
void loadMAVLinkView();
/** @brief Load data view, allowing to plot flight data */
void loadDataView();
/** @brief Load data view, allowing to plot flight data */
void loadDataView(QString fileName);
/** @brief Show the online help for users */
void showHelp();
/** @brief Show the authors / credits */
@ -140,22 +129,63 @@ public slots: @@ -140,22 +129,63 @@ public slots:
/** @brief Show the project roadmap */
void showRoadMap();
// Fixme find a nicer solution that scales to more AP types
void loadSlugsView();
void loadPixhawkEngineerView();
void loadSlugsEngineerView();
/** @brief Shows the widgets based on configuration and current view and autopilot */
void presentView();
/** @brief Reload the CSS style sheet */
void reloadStylesheet();
/*
==========================================================
Potentially Deprecated
==========================================================
*/
void loadPixhawkEngineerView();
/** @brief Load view with all widgets */
void loadAllView();
void loadWidgets();
/** @brief Load data view, allowing to plot flight data */
void loadDataView();
/** @brief Load data view, allowing to plot flight data */
void loadDataView(QString fileName);
/** @brief Load 3D map view */
void load3DMapView();
/** @brief Load 3D Google Earth view */
void loadGoogleEarthView();
/** @brief Load 3D view */
void load3DView();
/**
* @brief Shows a Docked Widget based on the action sender
*
* This slot is written to be used in conjunction with the addToToolsMenu function
* It shows the QDockedWidget based on the action sender
*
*/
void showToolWidget();
/**
* @brief Shows a Widget from the center stack based on the action sender
*
* This slot is written to be used in conjunction with the addToCentralWidgetsMenu function
* It shows the Widget based on the action sender
*
*/
void showCentralWidget();
/** @brief Updates a QDockWidget's checked status based on its visibility */
void updateVisibilitySettings (bool vis);
/** @brief Updates a QDockWidget's location */
void updateLocationSettings (Qt::DockWidgetArea location);
protected:
// These defines are used to save the settings when selecting with
@ -182,15 +212,17 @@ protected: @@ -182,15 +212,17 @@ protected:
MENU_SLUGS_PID,
MENU_SLUGS_HIL,
MENU_SLUGS_CAMERA,
CENTRAL_LINECHART = 255, // do not change
CENTRAL_SEPARATOR= 255, // do not change
CENTRAL_LINECHART,
CENTRAL_PROTOCOL,
CENTRAL_MAP,
CENTRAL_3D_LOCAL,
CENTRAL_3D_MAP,
CENTRAL_OSGEARTH,
CENTRAL_GOOGLE_EARTH,
CENTRAL_HUD,
CENTRAL_DATA_PLOT,
CENTRAL_SEPARATOR,
}TOOLS_WIDGET_NAMES;
typedef enum _SETTINGS_SECTIONS {
@ -211,19 +243,65 @@ protected: @@ -211,19 +243,65 @@ protected:
QHash<int, QWidget*> dockWidgets; // Holds ptr to the Actual Dock widget
QHash<int, Qt::DockWidgetArea> dockWidgetLocations; // Holds the location
/**
* @brief Adds an already instantiated QDockedWidget to the Tools Menu
*
* This function does all the hosekeeping to have a QDockedWidget added to the
* tools menu and connects the QMenuAction to a slot that shows the widget and
* checks/unchecks the tools menu item
*
* @param widget The QDockedWidget being added
* @param title The entry that will appear in the Menu and in the QDockedWidget title bar
* @param slotName The slot to which the triggered() signal of the menu action will be connected.
* @param tool The ENUM defined in MainWindow.h that is associated to the widget
* @param location The default location for the QDockedWidget in case there is no previous key in the settings
*/
void addToToolsMenu (QWidget* widget, const QString title, const char * slotName, TOOLS_WIDGET_NAMES tool, Qt::DockWidgetArea location);
/**
* @brief Determines if a QDockWidget needs to be show and if so, shows it
*
* Based on the the autopilot and the current view it queries the settings and shows the
* widget if necessary
*
* @param widget The QDockWidget requested to be shown
* @param view The view for which the QDockWidget is requested
*/
void showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view = VIEW_MAVLINK);
void showCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view);
/**
* @brief Adds an already instantiated QWidget to the center stack
*
* This function does all the hosekeeping to have a QWidget added to the tools menu
* tools menu and connects the QMenuAction to a slot that shows the widget and
* checks/unchecks the tools menu item. This is used for all the central widgets (those in
* the center stack.
*
* @param widget The QWidget being added
* @param title The entry that will appear in the Menu
* @param slotName The slot to which the triggered() signal of the menu action will be connected.
* @param centralWidget The ENUM defined in MainWindow.h that is associated to the widget
*/
void addToCentralWidgetsMenu ( QWidget* widget, const QString title,const char * slotName, TOOLS_WIDGET_NAMES centralWidget);
/**
* @brief Determines if a QWidget needs to be show and if so, shows it
*
* Based on the the autopilot and the current view it queries the settings and shows the
* widget if necessary
*
* @param centralWidget The QWidget requested to be shown
* @param view The view for which the QWidget is requested
*/
void showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view);
/** @brief Keeps track of the current view */
VIEW_SECTIONS currentView;
int aboutToQuit;
//QHash<int, QString> settingsSections;
QStatusBar* statusBar;
QStatusBar* createStatusBar();
void loadWidgets();
void clearView();

1
src/ui/MapWidget.cc

@ -562,6 +562,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon, @@ -562,6 +562,7 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
// Icon
QPen* pointpen = new QPen(uasColor);
qDebug() << uas->getUASName();
MAV2DIcon* p = new MAV2DIcon(lat, lon, 20, uas->getUASName(), qmapcontrol::Point::Middle, pointpen);
uasIcons.insert(uas->getUASID(), p);
geomLayer->addGeometry(p);

Loading…
Cancel
Save