diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index f7cbd8f43d98af22e8a403dbac93becf2c066678..d526a260786c7e5630279d8ecf31dd2d196de17e 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -249,7 +249,8 @@ HEADERS += src/MG.h \ src/ui/SlugsHilSim.h \ src/ui/SlugsPIDControl.h \ src/ui/SlugsVideoCamControl.h \ - src/ui/SlugsPadCameraControl.h + src/ui/SlugsPadCameraControl.h \ + src/ui/QGCMainWindowAPConfigurator.h contains(DEPENDENCIES_PRESENT, osg) { message("Including headers for OpenSceneGraph") @@ -359,7 +360,8 @@ SOURCES += src/main.cc \ src/ui/SlugsHilSim.cc \ src/ui/SlugsPIDControl.cpp \ src/ui/SlugsVideoCamControl.cpp \ - src/ui/SlugsPadCameraControl.cpp + src/ui/SlugsPadCameraControl.cpp \ + src/ui/QGCMainWindowAPConfigurator.cc contains(DEPENDENCIES_PRESENT, osg) { message("Including sources for OpenSceneGraph") diff --git a/src/Core.cc b/src/Core.cc index d63bd0d919bda5645fbcd3f87a9e27aac3a393a5..e49a06c53cd57ec73c143533a3e849f4acff607d 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -157,6 +157,9 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) **/ Core::~Core() { + //mainWindow->storeSettings(); + mainWindow->hide(); + mainWindow->deleteLater(); // Delete singletons delete LinkManager::instance(); delete UASManager::instance(); diff --git a/src/QGC.h b/src/QGC.h index 1ea849a230599933f07ae20dbcd2c26714b81d24..4751cdda47404bea2c0d454f84ad560f51984ea7 100644 --- a/src/QGC.h +++ b/src/QGC.h @@ -14,6 +14,9 @@ namespace QGC /** @brief Get the current ground time in microseconds */ quint64 groundTimeUsecs(); + + const QString APPNAME = "QGROUNDCONTROL"; + const QString COMPANYNAME = "OPENMAV"; } #endif // QGC_H diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 76c4fde4c142de7e24b6655c863b4fd70b5106f2..802cf1741f7642efe92cfea223405ce301f7f88d 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project #include #include #include "LinkManager.h" +#include #include @@ -65,6 +66,7 @@ LinkManager::~LinkManager() void LinkManager::add(LinkInterface* link) { + if(!link) return; links.append(link); emit newLink(link); } @@ -73,6 +75,7 @@ void LinkManager::addProtocol(LinkInterface* link, ProtocolInterface* protocol) { // Connect link to protocol // the protocol will receive new bytes from the link + if(!link || !protocol) return; connect(link, SIGNAL(bytesReceived(LinkInterface*, QByteArray)), protocol, SLOT(receiveBytes(LinkInterface*, QByteArray))); // Store the connection information in the protocol links map protocolLinks.insertMulti(protocol, link); @@ -91,7 +94,8 @@ bool LinkManager::connectAll() foreach (LinkInterface* link, links) { - if(! link->connect()) allConnected = false; + if(!link) {} + else if(!link->connect()) allConnected = false; } return allConnected; @@ -103,7 +107,9 @@ bool LinkManager::disconnectAll() foreach (LinkInterface* link, links) { - if(! link->disconnect()) allDisconnected = false; + //static int i=0; + if(!link){} + else if(!link->disconnect()) allDisconnected = false; } return allDisconnected; @@ -111,14 +117,32 @@ bool LinkManager::disconnectAll() bool LinkManager::connectLink(LinkInterface* link) { + if(!link) return false; return link->connect(); } bool LinkManager::disconnectLink(LinkInterface* link) { + if(!link) return false; return link->disconnect(); } +bool LinkManager::removeLink(LinkInterface* link) +{ + if(link) + { + for (int i=0; i < QList(links).size(); i++) + { + if(link==links.at(i)) + { + links.removeAt(i); //remove from link list + } + } + return true; + } + return false; +} + /** * The access time is linear in the number of links. * diff --git a/src/comm/LinkManager.h b/src/comm/LinkManager.h index b1768758b2a356362c37d93ed85ca5c22c1ca3e9..8d283c3de0d3f1273bf41afdabdccd8724812d7a 100644 --- a/src/comm/LinkManager.h +++ b/src/comm/LinkManager.h @@ -67,6 +67,8 @@ public slots: void add(LinkInterface* link); void addProtocol(LinkInterface* link, ProtocolInterface* protocol); + bool removeLink(LinkInterface* link); + bool connectAll(); bool connectLink(LinkInterface* link); diff --git a/src/comm/MAVLinkSimulationLink.cc b/src/comm/MAVLinkSimulationLink.cc index 82eb080d5b08344db098fe02d1fbbb8b9d5d841d..f35a129467e2f05efbd0efbb0080ff234f6c49aa 100644 --- a/src/comm/MAVLinkSimulationLink.cc +++ b/src/comm/MAVLinkSimulationLink.cc @@ -559,16 +559,17 @@ void MAVLinkSimulationLink::mainloop() // Send controller states -// uint8_t attControl = 1; -// uint8_t posXYControl = 1; -// uint8_t posZControl = 0; -// uint8_t posYawControl = 1; -// uint8_t gpsLock = 2; -// uint8_t visLock = 3; - //uint8_t posLock = qMax(gpsLock, visLock); #ifdef MAVLINK_ENABLED_PIXHAWK + uint8_t attControl = 1; + uint8_t posXYControl = 1; + uint8_t posZControl = 0; + uint8_t posYawControl = 1; + + uint8_t gpsLock = 2; + uint8_t visLock = 3; + uint8_t posLock = qMax(gpsLock, visLock); messageSize = mavlink_msg_control_status_pack(systemId, componentId, &msg, posLock, visLock, gpsLock, attControl, posXYControl, posZControl, posYawControl); #endif diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index 1e9b74f9ab029a0e07cf8b859137ebe1c4195aa2..404a8dbfc8049ee7c56afa7191c207c40e58a731 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -30,10 +30,13 @@ This file is part of the QGROUNDCONTROL project #include #include +#include #include #include "SerialLink.h" #include "LinkManager.h" +#include "QGC.h" #include +#include #ifdef _WIN32 #include "windows.h" #endif @@ -54,12 +57,41 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P #endif // Set unique ID and add link to the list of links this->id = getNextLinkId(); - this->baudrate = baudrate; - this->flow = flow; - this->parity = parity; - this->dataBits = dataBits; - this->stopBits = stopBits; - this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all. + + // Load defaults from settings + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + settings.sync(); + if (settings.contains("SERIALLINK_COMM_PORT")) + { + this->porthandle = settings.value("SERIALLINK_COMM_PORT").toString(); + } + + // *nix (Linux, MacOS tested) serial port support + port = new QextSerialPort(porthandle, QextSerialPort::Polling); + //port = new QextSerialPort(porthandle, QextSerialPort::EventDriven); + + if (settings.contains("SERIALLINK_COMM_PORT")) + { + setBaudRate(settings.value("SERIALLINK_COMM_BAUD").toInt()); + setParityType(settings.value("SERIALLINK_COMM_PARITY").toInt()); + setStopBitsType(settings.value("SERIALLINK_COMM_STOPBITS").toInt()); + setDataBitsType(settings.value("SERIALLINK_COMM_DATABITS").toInt()); + } + else + { + this->baudrate = baudrate; + this->flow = flow; + this->parity = parity; + this->dataBits = dataBits; + this->stopBits = stopBits; + this->timeout = 1; ///< The timeout controls how long the program flow should wait for new serial bytes. As we're polling, we don't want to wait at all. + } + port->setTimeout(timeout); // Timeout of 0 ms, we don't want to wait for data, we just poll again next time + port->setBaudRate(baudrate); + port->setFlowControl(flow); + port->setParity(parity); + port->setDataBits(dataBits); + port->setStopBits(stopBits); // Set the port name if (porthandle == "") @@ -88,15 +120,7 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P //some other error occurred. Inform user. } #else - // *nix (Linux, MacOS tested) serial port support - port = new QextSerialPort(porthandle, QextSerialPort::Polling); - //port = new QextSerialPort(porthandle, QextSerialPort::EventDriven); - port->setTimeout(timeout); // Timeout of 0 ms, we don't want to wait for data, we just poll again next time - port->setBaudRate(baudrate); - port->setFlowControl(flow); - port->setParity(parity); - port->setDataBits(dataBits); - port->setStopBits(stopBits); + #endif // Link is setup, register it with link manager @@ -106,7 +130,7 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P SerialLink::~SerialLink() { disconnect(); - delete port; + if(port) delete port; port = NULL; } @@ -239,6 +263,8 @@ bool SerialLink::disconnect() port->close(); dataMutex.unlock(); + if(this->isRunning()) this->terminate(); //stop running the thread, restart it upon connect + bool closed = true; //port->isOpen(); @@ -298,6 +324,15 @@ bool SerialLink::hardwareConnect() if(connectionUp) { emit connected(); emit connected(true); + + // Store settings + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + settings.setValue("SERIALLINK_COMM_PORT", this->porthandle); + settings.setValue("SERIALLINK_COMM_BAUD", getBaudRate()); + settings.setValue("SERIALLINK_COMM_PARITY", getParityType()); + settings.setValue("SERIALLINK_COMM_STOPBITS", getStopBitsType()); + settings.setValue("SERIALLINK_COMM_DATABITS", getDataBitsType()); + settings.sync(); } return connectionUp; @@ -311,7 +346,14 @@ bool SerialLink::hardwareConnect() **/ bool SerialLink::isConnected() { - return port->isOpen(); + if (port) + { + return port->isOpen(); + } + else + { + return false; + } } int SerialLink::getId() @@ -516,7 +558,7 @@ bool SerialLink::setPortName(QString portName) this->porthandle = "\\\\.\\" + this->porthandle; } #endif - delete port; + if(port) delete port; port = new QextSerialPort(porthandle, QextSerialPort::Polling); port->setBaudRate(baudrate); @@ -707,9 +749,16 @@ bool SerialLink::setBaudRate(int rate) break; } - port->setBaudRate(this->baudrate); - if(reconnect) connect(); - return accepted; + if (port) + { + port->setBaudRate(this->baudrate); + if(reconnect) connect(); + return accepted; + } + else + { + return false; + } } bool SerialLink::setFlowType(int flow) diff --git a/src/input/Freenect.cc b/src/input/Freenect.cc index a599e2c9c50d14731f4bf5b0dd00568a793ff98b..1ac1bba5483e4f9bc8577685364246a9bcf54c6a 100644 --- a/src/input/Freenect.cc +++ b/src/input/Freenect.cc @@ -341,7 +341,7 @@ Freenect::readConfigFile(void) settings.value("transform/R33").toDouble(), settings.value("transform/Tz").toDouble(), 0.0, 0.0, 0.0, 1.0); - transformMatrix = transformMatrix.transposed(); + transformMatrix = transformMatrix.inverted(); baseline = settings.value("transform/baseline").toDouble(); disparityOffset = settings.value("transform/disparity_offset").toDouble(); diff --git a/src/uas/PxQuadMAV.cc b/src/uas/PxQuadMAV.cc index ba79d860ed9f7570ca105d26c6d31b74e5c7584d..2b9739ee4d9ed5108f0d1029410abc537b3855da 100644 --- a/src/uas/PxQuadMAV.cc +++ b/src/uas/PxQuadMAV.cc @@ -41,12 +41,12 @@ void PxQuadMAV::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; // Only compile this portion if matching MAVLink packets have been compiled #ifdef MAVLINK_ENABLED_PIXHAWK + mavlink_message_t* msg = &message; if (message.sysid == uasId) { diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 2eadd5be38c0f62146ed61b4d5cdc4edede7c464..95d941a07d6af8c8f1961e78e565d41109947291 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -95,6 +95,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), UAS::~UAS() { delete links; + links=NULL; } int UAS::getUASID() const @@ -126,6 +127,7 @@ void UAS::setSelected() void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) { + if (!link) return; if (!links->contains(link)) { addLink(link); @@ -371,11 +373,6 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) GAudioOutput::instance()->notifyPositive(); } positionLock = true; - - // Send to patch antenna - mavlink_message_t msg; - mavlink_msg_global_position_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, pos.usec, pos.lat, pos.lon, pos.alt, pos.vx, pos.vy, pos.vz); - sendMessage(msg); } break; case MAVLINK_MSG_ID_GPS_RAW: @@ -839,6 +836,7 @@ void UAS::sendMessage(mavlink_message_t message) void UAS::sendMessage(LinkInterface* link, mavlink_message_t message) { + if(!link) return; // Create buffer uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; // Write message into buffer, prepending start sign diff --git a/src/uas/UASManager.cc b/src/uas/UASManager.cc index 2af5a5fca38f5e5ac501bfe9a1c077eff0b38827..fabfec6ba1072d55fbf5101a2a710114d2631710 100644 --- a/src/uas/UASManager.cc +++ b/src/uas/UASManager.cc @@ -85,6 +85,11 @@ void UASManager::addUAS(UASInterface* uas) } } +QList UASManager::getUASList() +{ + return systems.values(); +} + UASInterface* UASManager::getActiveUAS() { if(!activeUAS) diff --git a/src/uas/UASManager.h b/src/uas/UASManager.h index c5ca03cc54e34a9850f5367170baaf71756a9d7e..b4d97789df578036d4b7a56d914a673ced3a159a 100644 --- a/src/uas/UASManager.h +++ b/src/uas/UASManager.h @@ -69,6 +69,8 @@ public: **/ UASInterface* getUASForId(int id); + QList getUASList(); + public slots: diff --git a/src/ui/CommConfigurationWindow.cc b/src/ui/CommConfigurationWindow.cc index 0708aeef9f3b0e32e42db0b216e323a058cac989..33e57ba2514c5bc6138ac22f3b9a228362158e88 100644 --- a/src/ui/CommConfigurationWindow.cc +++ b/src/ui/CommConfigurationWindow.cc @@ -47,6 +47,7 @@ This file is part of the QGROUNDCONTROL project #endif #include "MAVLinkProtocol.h" #include "MAVLinkSettingsWidget.h" +#include "LinkManager.h" CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolInterface* protocol, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) { @@ -58,6 +59,10 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn // add link types ui.linkType->addItem("Serial",QGC_LINK_SERIAL); ui.linkType->addItem("UDP",QGC_LINK_UDP); + ui.linkType->addItem("Simulation",QGC_LINK_SIMULATION); + ui.linkType->addItem("Serial Forwarding",QGC_LINK_FORWARDING); + + ui.connectionType->addItem("MAVLink", QGC_PROTOCOL_MAVLINK); // Create action to open this menu // Create configuration action for this link @@ -195,11 +200,20 @@ void CommConfigurationWindow::setLinkName(QString name) void CommConfigurationWindow::remove() { - link->disconnect(); - //delete link; - //delete action; + if(action) delete action; //delete action first since it has a pointer to link + action=NULL; + + if(link) + { + LinkManager::instance()->removeLink(link); //remove link from LinkManager list + link->disconnect(); //disconnect port, and also calls terminate() to stop the thread + if (link->isRunning()) link->terminate(); // terminate() the serial thread just in case it is still running + link->wait(); // wait() until thread is stoped before deleting + delete link; + } + link=NULL; + this->window()->close(); - qDebug() << "TODO: Link cannot be deleted: CommConfigurationWindow::remove() NOT IMPLEMENTED!"; } void CommConfigurationWindow::connectionState(bool connect) diff --git a/src/ui/CommConfigurationWindow.h b/src/ui/CommConfigurationWindow.h index fce37dbbe380be280ff7f347bfb78d4b2b0a99c7..93f1566aeceb26a15d5f080291402eaa40f470bc 100644 --- a/src/ui/CommConfigurationWindow.h +++ b/src/ui/CommConfigurationWindow.h @@ -42,7 +42,14 @@ This file is part of the QGROUNDCONTROL project enum qgc_link_t { QGC_LINK_SERIAL, - QGC_LINK_UDP + QGC_LINK_UDP, + QGC_LINK_SIMULATION, + QGC_LINK_FORWARDING +}; + +enum qgc_protocol_t +{ + QGC_PROTOCOL_MAVLINK }; #ifdef OPAL_RT diff --git a/src/ui/CommSettings.ui b/src/ui/CommSettings.ui index 8aec750ea97e720f99ae659f9a5c723cae78563f..71a4c30cd881d5eda30099d868921d2cd96e4d38 100644 --- a/src/ui/CommSettings.ui +++ b/src/ui/CommSettings.ui @@ -43,23 +43,7 @@ - - - - Serial Link - - - - - UDP - - - - - Simulation - - - + @@ -71,13 +55,8 @@ - 0 + -1 - - - MAVLink - - diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 872f2b9659566cffd36883cd97fe28a144768bda..c95107ea10545701aa35b8e4ef550167f9809258 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -165,6 +165,19 @@ HUD::~HUD() } +void HUD::showEvent(QShowEvent* event) +{ + Q_UNUSED(event); + if (isVisible()) + { + refreshTimer->start(); + } + else + { + refreshTimer->stop(); + } +} + void HUD::start() { refreshTimer->start(); diff --git a/src/ui/HUD.h b/src/ui/HUD.h index 9255ac788e720d6e99e7dc92306f6267cd43ce03..658054de3ce8a67bb096da831e8db85925c5565a 100644 --- a/src/ui/HUD.h +++ b/src/ui/HUD.h @@ -123,6 +123,8 @@ protected: float refLineWidthToPen(float line); /** @brief Rotate a polygon around a point clockwise */ void rotatePolygonClockWiseRad(QPolygonF& p, float angle, QPointF origin); + /** @brief Override base class show */ + virtual void showEvent(QShowEvent* event); QImage* image; ///< Double buffer image QImage glImage; ///< The background / camera image diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index d948fe88cf02eda2492a75d0b0feffac32b0a4cc..5bc657a0ba93deb08b2545c7d85e0a613fcbbdf0 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -16,6 +16,7 @@ #include #include "MG.h" +#include "QGC.h" #include "MAVLinkSimulationLink.h" #include "SerialLink.h" #include "UDPLink.h" @@ -82,6 +83,33 @@ MainWindow::MainWindow(QWidget *parent): // Adjust the size adjustSize(); + + // Load previous widget setup + + // FIXME WORK IN PROGRESS + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + + QList dockwidgets = qFindChildren(this); + if (dockwidgets.size()) + { + settings.beginGroup("mainwindow/dockwidgets"); + for (int i = 0; i < dockwidgets.size(); ++i) + { + QDockWidget *dockWidget = dockwidgets.at(i); + if (dockWidget->parentWidget() == this) + { + if (settings.contains(dockWidget->windowTitle())) + { + dockWidget->setVisible(settings.value(dockWidget->windowTitle(), dockWidget->isVisible()).toBool()); + } + } + } + settings.endGroup(); + } + + + + this->show(); } MainWindow::~MainWindow() @@ -127,6 +155,110 @@ void MainWindow::buildCommonWidgets() } +//======= +//void MainWindow::storeSettings() +//{ +// QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); + +// QList dockwidgets = qFindChildren(this); +// if (dockwidgets.size()) +// { +// settings.beginGroup("mainwindow/dockwidgets"); +// for (int i = 0; i < dockwidgets.size(); ++i) +// { +// QDockWidget *dockWidget = dockwidgets.at(i); +// if (dockWidget->parentWidget() == this) +// { +// settings.setValue(dockWidget->windowTitle(), QVariant(dockWidget->isVisible())); +// } +// } +// settings.endGroup(); +// } +// settings.sync(); +//} + +//QMenu* MainWindow::createCenterWidgetMenu() +//{ +// QMenu* menu = NULL; +// QStackedWidget* centerStack = dynamic_cast(centralWidget()); +// if (centerStack) +// { +// if (centerStack->count() > 0) +// { +// menu = new QMenu(this); +// for (int i = 0; i < centerStack->count(); ++i) +// { +// //menu->addAction(centerStack->widget(i)->actions()) +// } +// } +// } +// return menu; +//} + +//QMenu* MainWindow::createDockWidgetMenu() +//{ +// QMenu *menu = 0; +//#ifndef QT_NO_DOCKWIDGET +// QList dockwidgets = qFindChildren(this); +// if (dockwidgets.size()) +// { +// menu = new QMenu(this); +// for (int i = 0; i < dockwidgets.size(); ++i) +// { +// QDockWidget *dockWidget = dockwidgets.at(i); +// if (dockWidget->parentWidget() == this) +// { +// menu->addAction(dockwidgets.at(i)->toggleViewAction()); +// } +// } +// menu->addSeparator(); +// } +//#endif +// return menu; +//} + +////QList* MainWindow::getMainWidgets() +////{ + +////} + +////QMenu* QMainWindow::getDockWidgetMenu() +////{ +//// Q_D(QMainWindow); +//// QMenu *menu = 0; +////#ifndef QT_NO_DOCKWIDGET +//// QList dockwidgets = qFindChildren(this); +//// if (dockwidgets.size()) { +//// menu = new QMenu(this); +//// for (int i = 0; i < dockwidgets.size(); ++i) { +//// QDockWidget *dockWidget = dockwidgets.at(i); +//// if (dockWidget->parentWidget() == this +//// && d->layout->contains(dockWidget)) { +//// menu->addAction(dockwidgets.at(i)->toggleViewAction()); +//// } +//// } +//// menu->addSeparator(); +//// } +////#endif // QT_NO_DOCKWIDGET +////#ifndef QT_NO_TOOLBAR +//// QList toolbars = qFindChildren(this); +//// if (toolbars.size()) { +//// if (!menu) +//// menu = new QMenu(this); +//// for (int i = 0; i < toolbars.size(); ++i) { +//// QToolBar *toolBar = toolbars.at(i); +//// if (toolBar->parentWidget() == this +//// && d->layout->contains(toolBar)) { +//// menu->addAction(toolbars.at(i)->toggleViewAction()); +//// } +//// } +//// } +////#endif +//// Q_UNUSED(d); +//// return menu; +////} +//>>>>>>> master + void MainWindow::buildPxWidgets() { //FIXME: memory of acceptList will never be freed again @@ -172,6 +304,7 @@ void MainWindow::buildPxWidgets() #endif // Dock widgets + detectionDockWidget = new QDockWidget(tr("Object Recognition"), this); detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) ); addToToolsMenu (detectionDockWidget, tr("Object Recognition"), SLOT(showToolWidget()), MENU_DETECTION, Qt::RightDockWidgetArea); @@ -189,9 +322,53 @@ void MainWindow::buildPxWidgets() hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this); hsiDockWidget->setWidget( new HSIDisplay(this) ); addToToolsMenu (hsiDockWidget, tr("HSI"), SLOT(showToolWidget()), MENU_HSI, Qt::BottomDockWidgetArea); - - headDown1DockWidget = new QDockWidget(tr("Primary Flight Display"), this); +//======= +// controlDockWidget = new QDockWidget(tr("Control"), this); +// controlDockWidget->setWidget( new UASControlWidget(this) ); +// addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget); +// controlDockWidget->hide(); + +// infoDockWidget = new QDockWidget(tr("Status Details"), this); +// infoDockWidget->setWidget( new UASInfoWidget(this) ); +// addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget); +// //infoDockWidget->hide(); + +// listDockWidget = new QDockWidget(tr("Unmanned Systems"), this); +// listDockWidget->setWidget( new UASListWidget(this) ); +// addDockWidget(Qt::BottomDockWidgetArea, listDockWidget); +// listDockWidget->hide(); + +// waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this); +// waypointsDockWidget->setWidget( new WaypointList(this, NULL) ); +// addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget); +// waypointsDockWidget->hide(); + +// detectionDockWidget = new QDockWidget(tr("Object Recognition"), this); +// detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) ); +// addDockWidget(Qt::RightDockWidgetArea, detectionDockWidget); +// detectionDockWidget->hide(); + +// debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this); +// debugConsoleDockWidget->setWidget( new DebugConsole(this) ); +// addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget); + +// parametersDockWidget = new QDockWidget(tr("Onboard Parameters"), this); +// parametersDockWidget->setWidget( new ParameterInterface(this) ); +// addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget); + +// watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this); +// watchdogControlDockWidget->setWidget( new WatchdogControl(this) ); +// addDockWidget(Qt::RightDockWidgetArea, watchdogControlDockWidget); +// watchdogControlDockWidget->hide(); + +// hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this); +// hsiDockWidget->setWidget( new HSIDisplay(this) ); +// addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget); +//>>>>>>> master + + headDown1DockWidget = new QDockWidget(tr("System Stats"), this); headDown1DockWidget->setWidget( new HDDisplay(acceptList, this) ); + addToToolsMenu (headDown1DockWidget, tr("Flight Display"), SLOT(showToolWidget()), MENU_HDD_1, Qt::RightDockWidgetArea); headDown2DockWidget = new QDockWidget(tr("Payload Status"), this); @@ -201,6 +378,18 @@ void MainWindow::buildPxWidgets() rcViewDockWidget = new QDockWidget(tr("Radio Control"), this); rcViewDockWidget->setWidget( new QGCRemoteControlView(this) ); addToToolsMenu (rcViewDockWidget, tr("Radio Control"), SLOT(showToolWidget()), MENU_RC_VIEW, Qt::BottomDockWidgetArea); +//======= +// addDockWidget(Qt::RightDockWidgetArea, headDown1DockWidget); + +// headDown2DockWidget = new QDockWidget(tr("Payload Status"), this); +// headDown2DockWidget->setWidget( new HDDisplay(acceptList2, this) ); +// addDockWidget(Qt::RightDockWidgetArea, headDown2DockWidget); + +// rcViewDockWidget = new QDockWidget(tr("Radio Control"), this); +// rcViewDockWidget->setWidget( new QGCRemoteControlView(this) ); +// addDockWidget(Qt::BottomDockWidgetArea, rcViewDockWidget); +// rcViewDockWidget->hide(); +//>>>>>>> master headUpDockWidget = new QDockWidget(tr("HUD"), this); headUpDockWidget->setWidget( new HUD(320, 240, this)); @@ -234,16 +423,34 @@ void MainWindow::buildSlugsWidgets() slugsDataWidget->setWidget( new SlugsDataSensorView(this)); addToToolsMenu (slugsDataWidget, tr("Telemetry Data"), SLOT(showToolWidget()), MENU_SLUGS_DATA, Qt::RightDockWidgetArea); +//======= +// this->addDockWidget(Qt::LeftDockWidgetArea, headUpDockWidget); - slugsPIDControlWidget = new QDockWidget(tr("PID Control"), this); +// // SLUGS +// slugsDataWidget = new QDockWidget(tr("Slugs Data"), this); +// slugsDataWidget->setWidget( new SlugsDataSensorView(this)); +// addDockWidget(Qt::LeftDockWidgetArea, slugsDataWidget); +// slugsDataWidget->hide(); +//>>>>>>> master + + slugsPIDControlWidget = new QDockWidget(tr("Slugs PID Control"), this); slugsPIDControlWidget->setWidget(new SlugsPIDControl(this)); addToToolsMenu (slugsPIDControlWidget, tr("PID Configuration"), SLOT(showToolWidget()), MENU_SLUGS_PID, Qt::LeftDockWidgetArea); slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); slugsHilSimWidget->setWidget( new SlugsHilSim(this)); addToToolsMenu (slugsHilSimWidget, tr("HIL Sim Configuration"), SLOT(showToolWidget()), MENU_SLUGS_HIL, Qt::LeftDockWidgetArea); +//======= +// addDockWidget(Qt::BottomDockWidgetArea, slugsPIDControlWidget); +// slugsPIDControlWidget->hide(); - slugsCamControlWidget = new QDockWidget(tr("Video Camera Control"), this); +// slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); +// slugsHilSimWidget->setWidget( new SlugsHilSim(this)); +// addDockWidget(Qt::BottomDockWidgetArea, slugsHilSimWidget); +// slugsHilSimWidget->hide(); +//>>>>>>> master + + slugsCamControlWidget = new QDockWidget(tr("Slugs Video Camera Control"), this); slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this)); addToToolsMenu (slugsCamControlWidget, tr("Camera Control"), SLOT(showToolWidget()), MENU_SLUGS_CAMERA, Qt::BottomDockWidgetArea); @@ -475,6 +682,13 @@ void MainWindow::updateLocationSettings (Qt::DockWidgetArea location){ break; } } +//======= +// addDockWidget(Qt::BottomDockWidgetArea, slugsCamControlWidget); +// slugsCamControlWidget->hide(); + +// //FIXME: free memory in destructor +// joystick = new JoystickInput(); +//>>>>>>> master } /** @@ -505,10 +719,6 @@ void MainWindow::connectPxWidgets() { if (linechartWidget) { - connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), - linechartWidget, SLOT(addSystem(UASInterface*))); - connect(UASManager::instance(), SIGNAL(activeUASSet(int)), - linechartWidget, SLOT(selectSystem(int))); connect(linechartWidget, SIGNAL(logfileWritten(QString)), this, SLOT(loadDataView(QString))); } @@ -1006,7 +1216,8 @@ void MainWindow::clearView() if (dockWidget) { // Remove dock widget from main window - this->removeDockWidget(dockWidget); + //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? @@ -1048,6 +1259,14 @@ void MainWindow::loadMAVLinkView() currentView = VIEW_MAVLINK; presentView(); +//======= +// // Slugs Data View +// if (slugsHilSimWidget) +// { +// addDockWidget(Qt::LeftDockWidgetArea, slugsHilSimWidget); +// slugsHilSimWidget->show(); +// } +//>>>>>>> master } void MainWindow::presentView() { @@ -1224,12 +1443,18 @@ void MainWindow::presentView() { } - - - void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SECTIONS view){ bool tempVisible; QWidget* tempWidget = dockWidgets[centralWidget]; +//======= +// // ONBOARD PARAMETERS +// if (parametersDockWidget) +// { +// addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget); +// parametersDockWidget->show(); +// } +//} +//>>>>>>> master tempVisible = settings.value(buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view)).toBool(); qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible; @@ -1281,6 +1506,24 @@ void MainWindow::loadAllView() hdd->start(); } } +//<<<<<<< HEAD +//======= +//} + +//void MainWindow::loadOperatorView() +//{ +// clearView(); + +// // MAP +// if (mapWidget) +// { +// QStackedWidget *centerStack = dynamic_cast(centralWidget()); +// if (centerStack) +// { +// centerStack->setCurrentWidget(mapWidget); +// } +// } +//>>>>>>> master // UAS CONTROL if (controlDockWidget) @@ -1341,8 +1584,6 @@ void MainWindow::loadAllView() addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget); parametersDockWidget->show(); } - - this->show(); } void MainWindow::loadWidgets() @@ -1430,7 +1671,6 @@ void MainWindow::load3DMapView() } } #endif - this->show(); } void MainWindow::loadGoogleEarthView() @@ -1480,7 +1720,6 @@ void MainWindow::loadGoogleEarthView() hsiDockWidget->show(); } } - this->show(); #endif } @@ -1534,8 +1773,6 @@ void MainWindow::load3DView() } } #endif - this->show(); - } /* @@ -1586,15 +1823,26 @@ void MainWindow::buildWidgets() listDockWidget = new QDockWidget(tr("Unmanned Systems"), this); listDockWidget->setWidget( new UASListWidget(this) ); +<<<<<<< HEAD waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this); waypointsDockWidget->setWidget( new WaypointList(this, NULL) ); infoDockWidget = new QDockWidget(tr("Status Details"), this); infoDockWidget->setWidget( new UASInfoWidget(this) ); +======= + // RADIO CONTROL VIEW + if (rcViewDockWidget) + { + addDockWidget(Qt::BottomDockWidgetArea, rcViewDockWidget); + rcViewDockWidget->show(); + } +} +>>>>>>> master detectionDockWidget = new QDockWidget(tr("Object Recognition"), this); detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) ); +<<<<<<< HEAD debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this); debugConsoleDockWidget->setWidget( new DebugConsole(this) ); @@ -1635,6 +1883,16 @@ void MainWindow::buildWidgets() slugsCamControlWidget = new QDockWidget(tr("Video Camera Control"), this); slugsCamControlWidget->setWidget(new SlugsVideoCamControl(this)); +======= + if (protocolWidget) + { + QStackedWidget *centerStack = dynamic_cast(centralWidget()); + if (centerStack) + { + centerStack->setCurrentWidget(protocolWidget); + } + } +>>>>>>> master } void MainWindow::connectWidgets() @@ -1707,10 +1965,19 @@ void MainWindow::arrangeCenterStack() if (dataplotWidget) centerStack->addWidget(dataplotWidget); setCentralWidget(centerStack); +======= + // ONBOARD PARAMETERS + if (parametersDockWidget) + { + addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget); + parametersDockWidget->show(); + } +>>>>>>> master } void MainWindow::connectActions() { +<<<<<<< HEAD // Connect actions from ui connect(ui.actionAdd_Link, SIGNAL(triggered()), this, SLOT(addLink())); @@ -1763,6 +2030,9 @@ void MainWindow::connectActions() //GlobalOperatorView // connect(ui.actionGlobalOperatorView,SIGNAL(triggered()),waypointsDockWidget->widget(),SLOT()) +======= + //loadEngineerView(); +>>>>>>> master } */ diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 0ef75966a51544fe96102cb587abd580bd105359..be8b3184f1fdfa90a9ad7bc1458d150cee57c5fc 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -87,6 +87,9 @@ public: ~MainWindow(); public slots: +// /** @brief Store the mainwindow settings */ +// void storeSettings(); + /** * @brief Shows a status message on the bottom status bar * @@ -324,7 +327,6 @@ protected: void configureWindowName(); - // TODO Should be moved elsewhere, as the protocol does not belong to the UI MAVLinkProtocol* mavlink; AS4Protocol* as4link; @@ -367,6 +369,7 @@ protected: QPointer hsiDockWidget; QPointer rcViewDockWidget; + QPointer hudDockWidget; QPointer slugsDataWidget; QPointer slugsPIDControlWidget; QPointer slugsHilSimWidget; diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index 1593eee27e01f73ac8ee89cfd38f98c54bffd381..de35a73d547a73cb8896053fd51a32b07dcd0439 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -108,14 +108,7 @@ - - - TopToolBarArea - - - false - - + @@ -461,3 +454,5 @@ + + diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index 45fe505a366edb356ee33a2b1a8f262dcd3331cb..b95e7547086c6b559e69d3a1b6e09550063ed407 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -593,21 +593,12 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon, uasTrails.value(uas->getUASID())->addPoint(new qmapcontrol::Point(lat, lon, QString("lat: %1 lon: %2").arg(lat, lon))); } - // points.append(new CirclePoint(8.275145, 50.016992, 15, "Wiesbaden-Mainz-Kastel, Johannes-Goßner-Straße", Point::Middle, pointpen)); - // points.append(new CirclePoint(8.270476, 50.021426, 15, "Wiesbaden-Mainz-Kastel, Ruthof", Point::Middle, pointpen)); - // // "Blind" Points - // points.append(new Point(8.266445, 50.025913, "Wiesbaden-Mainz-Kastel, Mudra Kaserne")); - // points.append(new Point(8.260378, 50.030345, "Wiesbaden-Mainz-Amoneburg, Dyckerhoffstraße")); // Connect click events of the layer to this object // connect(osmLayer, SIGNAL(geometryClicked(Geometry*, QPoint)), // this, SLOT(geometryClicked(Geometry*, QPoint))); // Sets the view to the interesting area - //QList view; - //view.append(QPointF(8.24764, 50.0319)); - //view.append(QPointF(8.28412, 49.9998)); - // mc->setView(view); updatePosition(0, lat, lon); } } diff --git a/src/ui/ParameterInterface.cc b/src/ui/ParameterInterface.cc index f44e08389301787445e07e46c16ab4da9a2b8d34..d6a3a59aae206baa6f968cf0ec0641b2e79462f3 100644 --- a/src/ui/ParameterInterface.cc +++ b/src/ui/ParameterInterface.cc @@ -51,6 +51,15 @@ ParameterInterface::ParameterInterface(QWidget *parent) : // Setup UI connections connect(m_ui->vehicleComboBox, SIGNAL(activated(int)), this, SLOT(selectUAS(int))); + // Get current MAV list + QList systems = UASManager::instance()->getUASList(); + + // Add each of them + foreach (UASInterface* sys, systems) + { + addUAS(sys); + } + // Setup MAV connections connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); this->setVisible(false); diff --git a/src/ui/QGCMainWindowAPConfigurator.cc b/src/ui/QGCMainWindowAPConfigurator.cc new file mode 100644 index 0000000000000000000000000000000000000000..69da8c599ed6460879cd74c5d5f53df28802a93b --- /dev/null +++ b/src/ui/QGCMainWindowAPConfigurator.cc @@ -0,0 +1,6 @@ +#include "QGCMainWindowAPConfigurator.h" + +QGCMainWindowAPConfigurator::QGCMainWindowAPConfigurator(QObject *parent) : + QObject(parent) +{ +} diff --git a/src/ui/QGCMainWindowAPConfigurator.h b/src/ui/QGCMainWindowAPConfigurator.h new file mode 100644 index 0000000000000000000000000000000000000000..f4806f8202c7dee906868232fd013f3cf5980d78 --- /dev/null +++ b/src/ui/QGCMainWindowAPConfigurator.h @@ -0,0 +1,18 @@ +#ifndef QGCMAINWINDOWAPCONFIGURATOR_H +#define QGCMAINWINDOWAPCONFIGURATOR_H + +#include + +class QGCMainWindowAPConfigurator : public QObject +{ + Q_OBJECT +public: + explicit QGCMainWindowAPConfigurator(QObject *parent = 0); + +signals: + +public slots: + +}; + +#endif // QGCMAINWINDOWAPCONFIGURATOR_H diff --git a/src/ui/SerialConfigurationWindow.cc b/src/ui/SerialConfigurationWindow.cc index 5542bc93bd382ec0971c464a00c644c7e3303c9b..d85802706f1dc578cfeaf33546a37098a55d7490 100644 --- a/src/ui/SerialConfigurationWindow.cc +++ b/src/ui/SerialConfigurationWindow.cc @@ -33,6 +33,7 @@ This file is part of the QGROUNDCONTROL project #include #include #include +#include #include #ifdef _WIN32 #include @@ -509,12 +510,3 @@ void SerialConfigurationWindow::setLinkName(QString name) setWindowTitle(tr("Configuration of ") + link->getName()); } -void SerialConfigurationWindow::remove() -{ - link->disconnect(); - //delete link; - //delete action; - this->window()->close(); - qDebug() << "TODO: Link cannot be deleted: SerialConfigurationWindow::remove() NOT IMPLEMENTED!"; -} - diff --git a/src/ui/SerialConfigurationWindow.h b/src/ui/SerialConfigurationWindow.h index d71fb95e2aa5f415f1033c93cab511fa66e07805..abfa5c138c0ea3ba8ffb5e7c118ff26ab2ce86c5 100644 --- a/src/ui/SerialConfigurationWindow.h +++ b/src/ui/SerialConfigurationWindow.h @@ -60,12 +60,6 @@ public slots: void setParityEven(); void setPortName(QString port); void setLinkName(QString name); - /** - * @brief Remove this link - * - * Disconnects the associated link, removes it from all menus and closes the window. - */ - void remove(); void setupPortList(); protected slots: diff --git a/src/ui/XMLCommProtocolWidget.cc b/src/ui/XMLCommProtocolWidget.cc index 582c74ac639480592dfbd36dca607fb5db4c7b7c..c2ea91ea47901f644dedbb4b0cad98b76160ff8f 100644 --- a/src/ui/XMLCommProtocolWidget.cc +++ b/src/ui/XMLCommProtocolWidget.cc @@ -7,6 +7,7 @@ #include "ui_XMLCommProtocolWidget.h" #include "MAVLinkXMLParser.h" #include "MAVLinkSyntaxHighlighter.h" +#include "QGC.h" #include #include @@ -31,7 +32,7 @@ XMLCommProtocolWidget::XMLCommProtocolWidget(QWidget *parent) : void XMLCommProtocolWidget::selectXMLFile() { //QString fileName = QFileDialog::getOpenFileName(this, tr("Load Protocol Definition File"), ".", "*.xml"); - QSettings settings; + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); const QString mavlinkXML = "MAVLINK_XML_FILE"; QString dirPath = settings.value(mavlinkXML, QCoreApplication::applicationDirPath() + "../").toString(); QFileDialog dialog; @@ -56,6 +57,7 @@ void XMLCommProtocolWidget::selectXMLFile() setXML(instanceText); // Store filename for next time settings.setValue(mavlinkXML, QFileInfo(file).absoluteFilePath()); + settings.sync(); } else { @@ -92,7 +94,7 @@ void XMLCommProtocolWidget::setXML(const QString& xml) void XMLCommProtocolWidget::selectOutputDirectory() { - QSettings settings; + QSettings settings(QGC::COMPANYNAME, QGC::APPNAME); const QString mavlinkOutputDir = "MAVLINK_OUTPUT_DIR"; QString dirPath = settings.value(mavlinkOutputDir, QCoreApplication::applicationDirPath() + "../").toString(); QFileDialog dialog; @@ -110,7 +112,8 @@ void XMLCommProtocolWidget::selectOutputDirectory() { m_ui->outputDirNameLabel->setText(fileNames.first()); // Store directory for next time - settings.setValue(mavlinkOutputDir, fileNames.first()); + settings.setValue(mavlinkOutputDir, QFileInfo(fileNames.first()).absoluteFilePath()); + settings.sync(); //QFile file(fileName); } } diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index 7d1613845034a908f3978e9db2db6af1a78cd213..3a7cb0183279d73dc87ff51d98e2f9bea52e1f3c 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -56,7 +56,7 @@ maxInterval(MAX_STORAGE_INTERVAL), timeScaleStep(DEFAULT_SCALE_INTERVAL), // 10 seconds automaticScrollActive(false), m_active(true), -m_groundTime(false), +m_groundTime(true), d_data(NULL), d_curve(NULL) { diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index d3b17b27948e00595e03afc93dfea55885de52b7..03153e9acb6537b96bf75b740521664f92022058 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -159,7 +159,9 @@ void LinechartWidget::createLayout() QToolButton* timeButton = new QToolButton(this); timeButton->setText(tr("Ground Time")); timeButton->setCheckable(true); - timeButton->setChecked(false); + bool gTimeDefault = true; + if (activePlot) activePlot->enforceGroundTime(gTimeDefault); + timeButton->setChecked(gTimeDefault); layout->addWidget(timeButton, 1, 4); layout->setColumnStretch(4, 0); connect(timeButton, SIGNAL(clicked(bool)), activePlot, SLOT(enforceGroundTime(bool))); @@ -442,6 +444,12 @@ void LinechartWidget::removeCurve(QString curve) // Remove name } +void LinechartWidget::showEvent(QShowEvent* event) +{ + Q_UNUSED(event); + setActive(isVisible()); +} + void LinechartWidget::setActive(bool active) { if (activePlot) diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h index 26644f755d2ae76e3e15f10e7cf6dd939ca9cb4a..850b0aaa9f64caedc05d234b8799b110000b74a6 100644 --- a/src/ui/linechart/LinechartWidget.h +++ b/src/ui/linechart/LinechartWidget.h @@ -77,6 +77,8 @@ public slots: void setPlotWindowPosition(int scrollBarValue); void setPlotWindowPosition(quint64 position); void setPlotInterval(quint64 interval); + /** @brief Override base class show */ + virtual void showEvent(QShowEvent* event); void setActive(bool active); /** @brief Set the number of values to average over */ void setAverageWindow(int windowSize); diff --git a/src/ui/linechart/Linecharts.cc b/src/ui/linechart/Linecharts.cc index 2cfaf83ad5fd35daa9bba71d17a5000e86ee8675..b47ea71a7f5a32b0d2281b57f2a0a166d8378ee5 100644 --- a/src/ui/linechart/Linecharts.cc +++ b/src/ui/linechart/Linecharts.cc @@ -1,4 +1,5 @@ #include "Linecharts.h" +#include "UASManager.h" Linecharts::Linecharts(QWidget *parent) : QStackedWidget(parent), @@ -6,6 +7,18 @@ Linecharts::Linecharts(QWidget *parent) : active(true) { this->setVisible(false); + // Get current MAV list + QList systems = UASManager::instance()->getUASList(); + + // Add each of them + foreach (UASInterface* sys, systems) + { + addSystem(sys); + } + connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), + this, SLOT(addSystem(UASInterface*))); + connect(UASManager::instance(), SIGNAL(activeUASSet(int)), + this, SLOT(selectSystem(int))); } diff --git a/src/ui/map/MAV2DIcon.cc b/src/ui/map/MAV2DIcon.cc index 573149a853e851695af11d316bc059bd36f49ab8..a87962c052174e0c91b751a8b5f48ddd53a37b43 100644 --- a/src/ui/map/MAV2DIcon.cc +++ b/src/ui/map/MAV2DIcon.cc @@ -14,7 +14,10 @@ MAV2DIcon::MAV2DIcon(qreal x, qreal y, QString name, Alignment alignment, QPen* { int radius = 10; size = QSize(radius, radius); - drawIcon(pen); + if (pen) + { + drawIcon(pen); + } } MAV2DIcon::~MAV2DIcon() @@ -24,8 +27,11 @@ MAV2DIcon::~MAV2DIcon() void MAV2DIcon::setPen(QPen* pen) { - mypen = pen; - drawIcon(pen); + if (pen) + { + mypen = pen; + drawIcon(pen); + } } /** @@ -38,46 +44,49 @@ void MAV2DIcon::setYaw(float yaw) void MAV2DIcon::drawIcon(QPen* pen) { - mypixmap = new QPixmap(radius+1, radius+1); - mypixmap->fill(Qt::transparent); - QPainter painter(mypixmap); + if (pen) + { + mypixmap = new QPixmap(radius+1, radius+1); + mypixmap->fill(Qt::transparent); + QPainter painter(mypixmap); - // DRAW MICRO AIR VEHICLE - QPointF p(radius/2, radius/2); + // DRAW MICRO AIR VEHICLE + QPointF p(radius/2, radius/2); - float waypointSize = radius; - QPolygonF poly(3); - // Top point - poly.replace(0, QPointF(p.x(), p.y()+waypointSize/2.0f)); - // Right point - poly.replace(1, QPointF(p.x()-waypointSize/2.0f, p.y()-waypointSize/2.0f)); - // Left point - poly.replace(2, QPointF(p.x()+waypointSize/2.0f, p.y() + waypointSize/2.0f)); + float waypointSize = radius; + QPolygonF poly(3); + // Top point + poly.replace(0, QPointF(p.x(), p.y()+waypointSize/2.0f)); + // Right point + poly.replace(1, QPointF(p.x()-waypointSize/2.0f, p.y()-waypointSize/2.0f)); + // Left point + poly.replace(2, QPointF(p.x()+waypointSize/2.0f, p.y() + waypointSize/2.0f)); -// // Select color based on if this is the current waypoint -// if (list.at(i)->getCurrent()) -// { -// color = QGC::colorCyan;//uas->getColor(); -// pen.setWidthF(refLineWidthToPen(0.8f)); -// } -// else -// { -// color = uas->getColor(); -// pen.setWidthF(refLineWidthToPen(0.4f)); -// } + // // Select color based on if this is the current waypoint + // if (list.at(i)->getCurrent()) + // { + // color = QGC::colorCyan;//uas->getColor(); + // pen.setWidthF(refLineWidthToPen(0.8f)); + // } + // else + // { + // color = uas->getColor(); + // pen.setWidthF(refLineWidthToPen(0.4f)); + // } - //pen.setColor(color); - if (pen) - { - pen->setWidthF(2); - painter.setPen(*pen); - } - else - { - QPen pen2(Qt::yellow); - pen2.setWidth(2); - painter.setPen(pen2); + //pen.setColor(color); + if (pen) + { + pen->setWidthF(2); + painter.setPen(*pen); + } + else + { + QPen pen2(Qt::yellow); + pen2.setWidth(2); + painter.setPen(pen2); + } + painter.setBrush(Qt::NoBrush); + painter.drawPolygon(poly); } - painter.setBrush(Qt::NoBrush); - painter.drawPolygon(poly); } diff --git a/src/ui/map3D/GCManipulator.cc b/src/ui/map3D/GCManipulator.cc index 05c9b246c9328055016a96095541e1251b17892c..06a7527b4233a16cf945d7c95c173bf607adfd1b 100644 --- a/src/ui/map3D/GCManipulator.cc +++ b/src/ui/map3D/GCManipulator.cc @@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project */ #include "GCManipulator.h" +#include GCManipulator::GCManipulator() { @@ -254,10 +255,10 @@ GCManipulator::calcMovement(void) if (buttonMask == GUIEventAdapter::LEFT_MOUSE_BUTTON) { // rotate camera -#ifdef __WIN32__ - osg::Vec3 axis; -#else +#if ((OPENSCENEGRAPH_MAJOR_VERSION == 2) & (OPENSCENEGRAPH_MINOR_VERSION > 8)) | (OPENSCENEGRAPH_MAJOR_VERSION > 2) osg::Vec3d axis; +#else + osg::Vec3 axis; #endif float angle; diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc index 2754dc6aadddd4023679a052c65add3e907e3b14..5762082ea545f1722c2ed6a7cbaf9534fdadd7a9 100644 --- a/src/ui/map3D/QGCGoogleEarthView.cc +++ b/src/ui/map3D/QGCGoogleEarthView.cc @@ -16,9 +16,11 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : QWidget(parent), updateTimer(new QTimer(this)), + refreshRateMs(200), mav(NULL), followCamera(true), trailEnabled(true), + webViewInitialized(false), #if (defined Q_OS_MAC) webViewMac(new QWebView(this)), #endif @@ -34,22 +36,14 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : #endif ui->setupUi(this); - #if (defined Q_OS_MAC) ui->webViewLayout->addWidget(webViewMac); - webViewMac->setPage(new QGCWebPage(webViewMac)); - webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - webViewMac->load(QUrl("earth.html")); -#endif - -#if (defined Q_OS_WIN) & !(defined __MINGW32__) - webViewWin->load(QUrl("earth.html")); #endif #if ((defined Q_OS_MAC) | ((defined Q_OS_WIN) & !(defined __MINGW32__))) connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState())); - updateTimer->start(200); + updateTimer->start(refreshRateMs); #endif // Follow checkbox @@ -94,53 +88,82 @@ void QGCGoogleEarthView::follow(bool follow) followCamera = follow; } -void QGCGoogleEarthView::updateState() +void QGCGoogleEarthView::hide() { -#ifdef Q_OS_MAC - if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) + updateTimer->stop(); + QWidget::hide(); +} + +void QGCGoogleEarthView::show() +{ + if (!webViewInitialized) { - static bool initialized = false; - if (!initialized) - { - webViewMac->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);"); - initialized = true; - } - int uasId = 0; - double lat = 22.679833; - double lon = 8.549444; - double alt = 470.0; +#if (defined Q_OS_MAC) + webViewMac->setPage(new QGCWebPage(webViewMac)); + webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + webViewMac->load(QUrl("earth.html")); +#endif - float roll = 0.0f; - float pitch = 0.0f; - float yaw = 0.0f; +#if (defined Q_OS_WIN) & !(defined __MINGW32__) + webViewWin->load(QUrl("earth.html")); +#endif + webViewInitialized = true; + } + updateTimer->start(); + QWidget::show(); +} - if (mav) - { - uasId = mav->getUASID(); - lat = mav->getLatitude(); - lon = mav->getLongitude(); - alt = mav->getAltitude(); - roll = mav->getRoll(); - pitch = mav->getPitch(); - yaw = mav->getYaw(); - } - webViewMac->page()->currentFrame()->evaluateJavaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);") - .arg(uasId) - .arg(lat) - .arg(lon) - .arg(alt+500) - .arg(roll) - .arg(pitch) - .arg(yaw)); - - if (followCamera) +void QGCGoogleEarthView::updateState() +{ +#ifdef Q_OS_MAC + if (isVisible()) + { + if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) { - webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()")); + static bool initialized = false; + if (!initialized) + { + webViewMac->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);"); + initialized = true; + } + int uasId = 0; + double lat = 22.679833; + double lon = 8.549444; + double alt = 470.0; + + float roll = 0.0f; + float pitch = 0.0f; + float yaw = 0.0f; + + if (mav) + { + uasId = mav->getUASID(); + lat = mav->getLatitude(); + lon = mav->getLongitude(); + alt = mav->getAltitude(); + roll = mav->getRoll(); + pitch = mav->getPitch(); + yaw = mav->getYaw(); + } + webViewMac->page()->currentFrame()->evaluateJavaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);") + .arg(uasId) + .arg(lat) + .arg(lon) + .arg(alt+500) + .arg(roll) + .arg(pitch) + .arg(yaw)); + + if (followCamera) + { + webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()")); + } } } #endif } + void QGCGoogleEarthView::changeEvent(QEvent *e) { QWidget::changeEvent(e); diff --git a/src/ui/map3D/QGCGoogleEarthView.h b/src/ui/map3D/QGCGoogleEarthView.h index f0f4aed073777a1efbfb6b7eb251c03f6ed98110..8ecf5d8f412c05ef228eef46b649f02169141a38 100644 --- a/src/ui/map3D/QGCGoogleEarthView.h +++ b/src/ui/map3D/QGCGoogleEarthView.h @@ -62,13 +62,19 @@ public slots: void showWaypoints(bool state); /** @brief Follow the aircraft during flight */ void follow(bool follow); + /** @brief Hide and deactivate */ + void hide(); + /** @brief Show and activate */ + void show(); protected: void changeEvent(QEvent *e); QTimer* updateTimer; + int refreshRateMs; UASInterface* mav; bool followCamera; bool trailEnabled; + bool webViewInitialized; #if (defined Q_OS_WIN) && !(defined __MINGW32__) WebAxWidget* webViewWin; #endif diff --git a/src/ui/map3D/QMap3D.cc b/src/ui/map3D/QMap3D.cc index 83ff90179ab0be7bfda1b1eb7c49616a897892e3..f5d7ffb8e5932903602f610677d6b066adca6a4f 100644 --- a/src/ui/map3D/QMap3D.cc +++ b/src/ui/map3D/QMap3D.cc @@ -38,8 +38,13 @@ This file is part of the QGROUNDCONTROL project QMap3D::QMap3D(QWidget * parent, const char * name, WindowFlags f) : QWidget(parent,f) { + Q_UNUSED(name); setupUi(this); +#if ((OPENSCENEGRAPH_MAJOR_VERSION == 2) & (OPENSCENEGRAPH_MINOR_VERSION > 8)) | (OPENSCENEGRAPH_MAJOR_VERSION > 2) graphicsView->setCameraManipulator(new osgEarth::Util::EarthManipulator); +#else + graphicsView->setCameraManipulator(new osgEarthUtil::EarthManipulator); +#endif graphicsView->setSceneData(new osg::Group); graphicsView->updateCamera(); show(); diff --git a/src/ui/uas/UASControlWidget.cc b/src/ui/uas/UASControlWidget.cc index d638e1cc3c73171c62f9d176db75c3beeb46adff..a007e7c96c0ee3bd9df2969ec93d210723cc23c1 100644 --- a/src/ui/uas/UASControlWidget.cc +++ b/src/ui/uas/UASControlWidget.cc @@ -50,7 +50,7 @@ This file is part of the PIXHAWK project #define CONTROL_MODE_TEST2 "MODE TEST2" #define CONTROL_MODE_TEST3 "MODE TEST3" #define CONTROL_MODE_READY "MODE TEST3" -#define CONTROL_MODE_RC_TRAINING "MODE RC TRAINING" +#define CONTROL_MODE_RC_TRAINING "RC SIMULATION" #define CONTROL_MODE_LOCKED_INDEX 1 #define CONTROL_MODE_MANUAL_INDEX 2