Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/credits in a browser.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::showRoadMap()
{
if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/roadmap")))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open roadmap in browser");
msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/roadmap in a browser.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
{
joystickWidget = new JoystickWidget(joystick, this);
}
{
SerialLink* link = new SerialLink();
// TODO This should be only done in the dialog itself
LinkManager::instance()->addProtocol(link, mavlink);
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
ui.menuNetwork->addAction(commWidget->getAction());
commWidget->show();
}
void MainWindow::addLink(LinkInterface *link)
{
LinkManager::instance()->addProtocol(link, mavlink);
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
ui.menuNetwork->addAction(commWidget->getAction());
// Special case for simulationlink
MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim)
{
//connect(sim, SIGNAL(valueChanged(int,QString,double,quint64)), linechart, SLOT(appendData(int,QString,double,quint64)));
connect(ui.actionSimulate, SIGNAL(triggered(bool)), sim, SLOT(connectLink(bool)));
}
}
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
if (uas != NULL)
{
QIcon icon;
// Set matching icon
switch (uas->getSystemType())
{
case 0:
icon = QIcon(":/images/mavs/generic.svg");
break;
case 1:
icon = QIcon(":/images/mavs/fixed-wing.svg");
break;
case 2:
icon = QIcon(":/images/mavs/quadrotor.svg");
break;
case 3:
icon = QIcon(":/images/mavs/coaxial.svg");
break;
case 4:
icon = QIcon(":/images/mavs/helicopter.svg");
break;
case 5:
icon = QIcon(":/images/mavs/groundstation.svg");
break;
default:
icon = QIcon(":/images/mavs/unknown.svg");
break;
}
ui.menuConnected_Systems->addAction(icon, tr("Select %1 for control").arg(uas->getUASName()), uas, SLOT(setSelected()));
// FIXME Should be not inside the mainwindow
if (debugConsoleDockWidget)
{
DebugConsole *debugConsole = dynamic_cast<DebugConsole*>(debugConsoleDockWidget->widget());
if (debugConsole)
{
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)),
debugConsole, SLOT(receiveTextMessage(int,int,int,QString)));
}
// Health / System status indicator
if (infoDockWidget)
{
UASInfoWidget *infoWidget = dynamic_cast<UASInfoWidget*>(infoDockWidget->widget());
if (infoWidget)
{
infoWidget->addUAS(uas);
}
// UAS List
if (listDockWidget)
{
UASListWidget *listWidget = dynamic_cast<UASListWidget*>(listDockWidget->widget());
if (listWidget)
{
listWidget->addUAS(uas);
}
// Camera view
//camera->addUAS(uas);
// Revalidate UI
// TODO Stylesheet reloading should in theory not be necessary
reloadStylesheet();
Mariano Lizarraga
committed
{
case (MAV_AUTOPILOT_SLUGS):
{
// Build Slugs Widgets
buildSlugsWidgets();
// Connect Slugs Widgets
connectSlugsWidgets();
// Arrange Slugs Centerstack
arrangeSlugsCenterStack();
// Connect Slugs Actions
connectSlugsActions();
// FIXME: This type checking might be redundant
// if (slugsDataWidget) {
// SlugsDataSensorView* dataWidget = dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget());
// if (dataWidget) {
// SlugsMAV* mav2 = dynamic_cast<SlugsMAV*>(uas);
// if (mav2) {
Mariano Lizarraga
committed
(dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget()))->addUAS(uas);
// //loadSlugsView();
// loadGlobalOperatorView();
// }
// }
// }
Mariano Lizarraga
committed
}
break;
default:
case (MAV_AUTOPILOT_GENERIC):
case (MAV_AUTOPILOT_ARDUPILOTMEGA):
case (MAV_AUTOPILOT_PIXHAWK):
{
// Build Pixhawk Widgets
buildPxWidgets();
// Connect Pixhawk Widgets
connectPxWidgets();
// Arrange Pixhawk Centerstack
arrangePxCenterStack();
// Connect Pixhawk Actions
connectPxActions();
Mariano Lizarraga
committed
// Change the view only if this is the first UAS
Mariano Lizarraga
committed
// If this is the first connected UAS, it is both created as well as
// the currently active UAS
if (UASManager::instance()->getActiveUAS() == uas)
{
qDebug() << "UPDATING THE VIEW SINCE THIS IS THE FIRST CONNECTED SYSTEM";
Mariano Lizarraga
committed
// Load last view if setting is present
if (settings.contains("VIEW_ON_APPLICATION_CLOSE"))
int view = settings.value("VIEW_ON_APPLICATION_CLOSE").toInt();
currentView = (VIEW_SECTIONS) view;
presentView();
Mariano Lizarraga
committed
}
Mariano Lizarraga
committed
/**
* Clears the current view completely
*/
// Remove all dock widgets from main window
QObjectList childList( this->children() );
QObjectList::iterator i;
QDockWidget* dockWidget;
for (i = childList.begin(); i != childList.end(); ++i)
dockWidget = dynamic_cast<QDockWidget*>(*i);
if (dockWidget)
// Remove dock widget from main window
//this->removeDockWidget(dockWidget);
dockWidget->setVisible(false);
// Deletion of dockWidget would also delete all child
// widgets of dockWidget
// Is there a way to unset a widget from QDockWidget?
Mariano Lizarraga
committed
void MainWindow::loadEngineerView()
Mariano Lizarraga
committed
clearView();
Mariano Lizarraga
committed
currentView = VIEW_ENGINEER;
Mariano Lizarraga
committed
presentView();
Mariano Lizarraga
committed
void MainWindow::loadOperatorView()
Mariano Lizarraga
committed
clearView();
currentView = VIEW_OPERATOR;
Mariano Lizarraga
committed
presentView();
Mariano Lizarraga
committed
void MainWindow::loadPilotView()
Mariano Lizarraga
committed
currentView = VIEW_PILOT;
presentView();
Mariano Lizarraga
committed
void MainWindow::loadMAVLinkView()
{
clearView();
Mariano Lizarraga
committed
currentView = VIEW_MAVLINK;
presentView();
}
Mariano Lizarraga
committed
Mariano Lizarraga
committed
qDebug() << "LC";
showTheCentralWidget(CENTRAL_LINECHART, currentView);
Mariano Lizarraga
committed
// MAP
qDebug() << "MAP";
showTheCentralWidget(CENTRAL_MAP, currentView);
Mariano Lizarraga
committed
// PROTOCOL
qDebug() << "CP";
showTheCentralWidget(CENTRAL_PROTOCOL, currentView);
Mariano Lizarraga
committed
// HEAD UP DISPLAY
showTheCentralWidget(CENTRAL_HUD, currentView);
// GOOGLE EARTH
showTheCentralWidget(CENTRAL_GOOGLE_EARTH, currentView);
// LOCAL 3D VIEW
showTheCentralWidget(CENTRAL_3D_LOCAL, currentView);
// GLOBAL 3D VIEW
showTheCentralWidget(CENTRAL_3D_MAP, currentView);
Mariano Lizarraga
committed
// Show docked widgets based on current view and autopilot type
Mariano Lizarraga
committed
// UAS CONTROL
showTheWidget(MENU_UAS_CONTROL, currentView);
Mariano Lizarraga
committed
// UAS LIST
showTheWidget(MENU_UAS_LIST, currentView);
Mariano Lizarraga
committed
// WAYPOINT LIST
showTheWidget(MENU_WAYPOINTS, currentView);
Mariano Lizarraga
committed
// UAS STATUS
showTheWidget(MENU_STATUS, currentView);
Mariano Lizarraga
committed
// DETECTION
showTheWidget(MENU_DETECTION, currentView);
// DEBUG CONSOLE
showTheWidget(MENU_DEBUG_CONSOLE, currentView);
// ONBOARD PARAMETERS
showTheWidget(MENU_PARAMETERS, currentView);
// WATCHDOG
showTheWidget(MENU_WATCHDOG, currentView);
// HUD
showTheWidget(MENU_HUD, currentView);
Mariano Lizarraga
committed
if (headUpDockWidget)
{
HUD* tmpHud = dynamic_cast<HUD*>( headUpDockWidget->widget() );
if (tmpHud){
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HUD,currentView)).toBool()){
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HUD, currentView)).toInt()),
headUpDockWidget);
Mariano Lizarraga
committed
headUpDockWidget->show();
} else {
headUpDockWidget->hide();
}
}
}
Mariano Lizarraga
committed
// RC View
showTheWidget(MENU_RC_VIEW, currentView);
// SLUGS DATA
showTheWidget(MENU_SLUGS_DATA, currentView);
// SLUGS PID
showTheWidget(MENU_SLUGS_PID, currentView);
// SLUGS HIL
showTheWidget(MENU_SLUGS_HIL, currentView);
// SLUGS CAMERA
showTheWidget(MENU_SLUGS_CAMERA, currentView);
// HORIZONTAL SITUATION INDICATOR
Mariano Lizarraga
committed
showTheWidget(MENU_HSI, currentView);
// if (hsiDockWidget)
// {
// HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
// if (hsi){
// if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HSI,currentView)).toBool()){
// addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HSI, currentView)).toInt()),
// hsiDockWidget);
// }
// }
// }
Mariano Lizarraga
committed
// HEAD DOWN 1
Mariano Lizarraga
committed
showTheWidget(MENU_HDD_1, currentView);
// if (headDown1DockWidget)
// {
// HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown1DockWidget->widget());
// 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();
// }
// }
// }
Mariano Lizarraga
committed
// HEAD DOWN 2
Mariano Lizarraga
committed
showTheWidget(MENU_HDD_2, currentView);
// if (headDown2DockWidget)
// {
// HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown2DockWidget->widget());
// 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();
// }
// }
// }
Mariano Lizarraga
committed
this->show();
Mariano Lizarraga
committed
pixhawk
committed
}
void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view)
{
Mariano Lizarraga
committed
bool tempVisible;
QWidget* tempWidget = dockWidgets[centralWidget];
tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view)).toBool();
Mariano Lizarraga
committed
// qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible;
Mariano Lizarraga
committed
toolsMenuActions[centralWidget]->setChecked(tempVisible);
}
if (centerStack && tempWidget && tempVisible)
Mariano Lizarraga
committed
centerStack->setCurrentWidget(tempWidget);
}
}
loadOperatorView();
//loadMAVLinkView();
Mariano Lizarraga
committed
Mariano Lizarraga
committed
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
void MainWindow::loadDataView(QString fileName)
{
// 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);
}
}
#endif
}
void MainWindow::loadGoogleEarthView()
{
#if (defined _MSC_VER) | (defined Q_OS_MAC)
Mariano Lizarraga
committed
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
clearView();
// 3D map
if (gEarthWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(gEarthWidget);
}
}
#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);
}
}