Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
// SlugsDataSensorView* dataWidget = dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget());
// if (dataWidget) {
// SlugsMAV* mav2 = dynamic_cast<SlugsMAV*>(uas);
// if (mav2) {
(dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget()))->addUAS(uas);
// //loadSlugsView();
// loadGlobalOperatorView();
// }
// }
// }
}
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();
}
break;
}
// Change the view only if this is the first UAS
// 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";
// 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();
}
else
{
loadEngineerView();
}
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
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();
}
qDebug() << "LC";
showTheCentralWidget(CENTRAL_LINECHART, currentView);
// MAP
qDebug() << "MAP";
showTheCentralWidget(CENTRAL_MAP, currentView);
// PROTOCOL
qDebug() << "CP";
showTheCentralWidget(CENTRAL_PROTOCOL, currentView);
// 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);
// 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);
Mariano Lizarraga
committed
// DETECTION
showTheWidget(MENU_DETECTION, currentView);
Mariano Lizarraga
committed
// DEBUG CONSOLE
showTheWidget(MENU_DEBUG_CONSOLE, currentView);
Mariano Lizarraga
committed
// ONBOARD PARAMETERS
showTheWidget(MENU_PARAMETERS, currentView);
Mariano Lizarraga
committed
// WATCHDOG
showTheWidget(MENU_WATCHDOG, currentView);
Mariano Lizarraga
committed
// 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()){
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HUD, currentView)).toInt()),
hsiDockWidget);
headUpDockWidget->show();
} else {
headUpDockWidget->hide();
}
Mariano Lizarraga
committed
}
Mariano Lizarraga
committed
Mariano Lizarraga
committed
// RC View
showTheWidget(MENU_RC_VIEW, currentView);
Mariano Lizarraga
committed
// SLUGS DATA
showTheWidget(MENU_SLUGS_DATA, currentView);
Mariano Lizarraga
committed
// SLUGS PID
showTheWidget(MENU_SLUGS_PID, currentView);
Mariano Lizarraga
committed
// SLUGS HIL
showTheWidget(MENU_SLUGS_HIL, currentView);
Mariano Lizarraga
committed
// SLUGS CAMERA
showTheWidget(MENU_SLUGS_CAMERA, currentView);
Mariano Lizarraga
committed
// HORIZONTAL SITUATION INDICATOR
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);
// }
// }
// }
// HEAD DOWN 1
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();
// }
// }
// }
// HEAD DOWN 2
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();
// }
// }
// }
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);
if (centerStack && tempWidget && tempVisible)
centerStack->setCurrentWidget(tempWidget);
loadOperatorView();
//loadMAVLinkView();
Mariano Lizarraga
committed
Mariano Lizarraga
committed
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
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
Mariano Lizarraga
committed
// 3D map
if (_3DMapWidget)
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DMapWidget);
}
}
Mariano Lizarraga
committed
#endif
}
void MainWindow::loadGoogleEarthView()
{
#if (defined _MSC_VER) | (defined Q_OS_MAC)
Mariano Lizarraga
committed
{
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
centerStack->setCurrentWidget(gEarthWidget);
Mariano Lizarraga
committed
}
Mariano Lizarraga
committed
{
#ifdef QGC_OSG_ENABLED
Mariano Lizarraga
committed
QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
if (centerStack)
{
//map3DWidget->setActive(true);
centerStack->setCurrentWidget(_3DWidget);
}