diff --git a/lib/QMapControl/src/googlesatmapadapter.cpp b/lib/QMapControl/src/googlesatmapadapter.cpp index a2e3edefbe1b4d3f1e273c56c37193210e86d65f..5692b29489c36eae9c9d44ef54ed0964b5dee94a 100644 --- a/lib/QMapControl/src/googlesatmapadapter.cpp +++ b/lib/QMapControl/src/googlesatmapadapter.cpp @@ -29,7 +29,7 @@ namespace qmapcontrol { GoogleSatMapAdapter::GoogleSatMapAdapter() - : TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 0, 18) + : TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 9, 21) { // // name = "googlesat"; // diff --git a/lib/QMapControl/src/mapcontrol.cpp b/lib/QMapControl/src/mapcontrol.cpp index 2872765dab8b14751d843c93fccfce9b839bcdca..c01a95e81b3f1161052edca18e3262958386849a 100644 --- a/lib/QMapControl/src/mapcontrol.cpp +++ b/lib/QMapControl/src/mapcontrol.cpp @@ -27,7 +27,7 @@ namespace qmapcontrol { MapControl::MapControl(QSize size, MouseMode mousemode) - : size(size), mymousemode(mousemode), scaleVisible(false), cursorPosVisible(false) + : size(size), mymousemode(mousemode), scaleVisible(false), cursorPosVisible(false), mapPen(Qt::black) { layermanager = new LayerManager(this, size); screen_middle = QPoint(size.width()/2, size.height()/2); @@ -126,6 +126,11 @@ namespace qmapcontrol } } + void MapControl::setPen(QPen pen) + { + this->mapPen = pen; + } + void MapControl::paintEvent(QPaintEvent* evnt) { QWidget::paintEvent(evnt); @@ -160,7 +165,7 @@ namespace qmapcontrol line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164; // draw the scale - painter.setPen(Qt::black); + painter.setPen(mapPen); QPoint p1(10,size.height()-20); QPoint p2((int)line,size.height()-20); painter.drawLine(p1,p2); @@ -209,7 +214,10 @@ namespace qmapcontrol // Draw the Lat and Lon if needed - if (cursorPosVisible) { + + // FIXME Mariano + if (cursorPosVisible && currentZoom() < 19) + { line = distanceList.at( currentZoom() ) / pow(2.0, 18-currentZoom() ) / 0.597164; QString str; @@ -336,6 +344,9 @@ namespace qmapcontrol void MapControl::setZoom(int zoomlevel) { layermanager->setZoom(zoomlevel); + + qDebug() << "MAPCONTROL: Set zoomlevel to:" << zoomlevel << "at " << __FILE__ << __LINE__; + update(); } int MapControl::currentZoom() const diff --git a/lib/QMapControl/src/mapcontrol.h b/lib/QMapControl/src/mapcontrol.h index d0d434e1bbe3bdb1a86787b1c149982ddcaf458b..db790f48fdec98bc4e310504a2e1a1d34463c0cf 100644 --- a/lib/QMapControl/src/mapcontrol.h +++ b/lib/QMapControl/src/mapcontrol.h @@ -222,6 +222,13 @@ namespace qmapcontrol */ void showCoord ( bool show ); + //! Set the pen for overlay text + /*! + * + * @param pen The new QPen + */ + void setPen(QPen pen); + private: LayerManager* layermanager; QPoint screen_middle; // middle of the widget (half size) @@ -239,6 +246,7 @@ namespace qmapcontrol MouseMode mymousemode; bool scaleVisible; bool cursorPosVisible; + QPen mapPen; bool m_loadingFlag; diff --git a/lib/QMapControl/src/mapnetwork.cpp b/lib/QMapControl/src/mapnetwork.cpp index 155d9202f1029ec00851f6d1e8cddbe2e3e41c2c..7fba8ae5306055e103de8e7508b644e97f8f89b5 100644 --- a/lib/QMapControl/src/mapnetwork.cpp +++ b/lib/QMapControl/src/mapnetwork.cpp @@ -98,6 +98,8 @@ namespace qmapcontrol // QGC FIXME Error is currently undetected // TODO Error is currently undetected //qDebug() << "NETWORK_PIXMAP_ERROR: " << ax; + qDebug() << "QMapControl external library: ERROR loading map:" << "width:" << pm.width() << "heigh:" << pm.height() << "at " << __FILE__ << __LINE__; + qDebug() << "HTML ERROR MESSAGE:" << ax << "at " << __FILE__ << __LINE__; } } diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 90c22ae57fe383cd2be7c465f694170a27e3e8b9..1fb7c7e5e7c968b1f153a65ef55db0d73dd3cdce 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -194,7 +194,7 @@ HUD::~HUD() QSize HUD::sizeHint() const { - return QSize(800, 600); + return QSize(width(), (width()*3.0f)/4); } void HUD::showEvent(QShowEvent* event) diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index c8165aea35e0cb3570a85358432334a3e21071a0..ebd66090415f8a76df209254a4bc495281d1dc0f 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -6,8 +6,8 @@ 0 0 - 1000 - 800 + 800 + 500 @@ -31,14 +31,27 @@ - + + + + 0 + 0 + + + + + 200 + 150 + + + 0 0 - 1000 - 22 + 800 + 25 diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index cda58c62dc871b06a42c75abdda6bfe93d1ba785..443ee5ff27442d0fdb7c026734319729a28f3d42 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -14,6 +14,7 @@ #include #include +#include "QGC.h" #include "MapWidget.h" #include "ui_MapWidget.h" #include "UASInterface.h" @@ -34,6 +35,19 @@ MapWidget::MapWidget(QWidget *parent) : m_ui(new Ui::MapWidget) { m_ui->setupUi(this); + mc = new qmapcontrol::MapControl(QSize(320, 240)); + + // VISUAL MAP STYLE + QString buttonStyle("QAbstractButton { background-color: rgba(20, 20, 20, 45%); border-color: rgba(10, 10, 10, 50%)}"); + mc->setPen(QGC::colorCyan.darker(400)); + + + + + + + + waypointIsDrag = false; @@ -41,7 +55,7 @@ MapWidget::MapWidget(QWidget *parent) : this->setFocusPolicy(Qt::StrongFocus); // create MapControl - mc = new qmapcontrol::MapControl(QSize(320, 240)); + mc->showScale(true); mc->showCoord(true); mc->enablePersistentCache(); @@ -126,32 +140,35 @@ MapWidget::MapWidget(QWidget *parent) : mapButton = new QPushButton(this); mapButton->setText("Map Source"); mapButton->setMenu(mapMenu); + mapButton->setStyleSheet(buttonStyle); // display the MapControl in the application QGridLayout* layout = new QGridLayout(this); layout->setMargin(0); - layout->setSpacing(2); - layout->addWidget(mc, 0, 0, 1, 2); - layout->addWidget(mapButton, 1, 0); - layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 1, 1); - layout->setRowStretch(0, 100); - layout->setRowStretch(1, 1); - layout->setColumnStretch(0, 1); - layout->setColumnStretch(1, 50); + layout->setSpacing(0); + layout->addWidget(mc, 0, 0); setLayout(layout); // create buttons to control the map (zoom, GPS tracking and WP capture) QPushButton* zoomin = new QPushButton(QIcon(":/images/actions/list-add.svg"), "", this); + zoomin->setStyleSheet(buttonStyle); QPushButton* zoomout = new QPushButton(QIcon(":/images/actions/list-remove.svg"), "", this); + zoomout->setStyleSheet(buttonStyle); createPath = new QPushButton(QIcon(":/images/actions/go-bottom.svg"), "", this); + createPath->setStyleSheet(buttonStyle); clearTracking = new QPushButton(QIcon(""), "", this); + clearTracking->setStyleSheet(buttonStyle); followgps = new QPushButton(QIcon(":/images/actions/system-lock-screen.svg"), "", this); + followgps->setStyleSheet(buttonStyle); + QPushButton* goToButton = new QPushButton(QIcon(""), "T", this); + goToButton->setStyleSheet(buttonStyle); zoomin->setMaximumWidth(30); zoomout->setMaximumWidth(30); createPath->setMaximumWidth(30); clearTracking->setMaximumWidth(30); followgps->setMaximumWidth(30); + goToButton->setMaximumWidth(30); // Set checkable buttons // TODO: Currently checked buttons are are very difficult to distinguish when checked. @@ -161,8 +178,8 @@ MapWidget::MapWidget(QWidget *parent) : // add buttons to control the map (zoom, GPS tracking and WP capture) QGridLayout* innerlayout = new QGridLayout(mc); - innerlayout->setMargin(5); - innerlayout->setSpacing(5); + innerlayout->setMargin(3); + innerlayout->setSpacing(3); innerlayout->addWidget(zoomin, 0, 0); innerlayout->addWidget(zoomout, 1, 0); innerlayout->addWidget(followgps, 2, 0); @@ -170,7 +187,9 @@ MapWidget::MapWidget(QWidget *parent) : innerlayout->addWidget(clearTracking, 4, 0); // Add spacers to compress buttons on the top left innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 5, 0); - innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 0, 1, 0, 6); + innerlayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 0, 1, 0, 7); + innerlayout->addWidget(mapButton, 0, 6); + innerlayout->addWidget(goToButton, 0, 7); innerlayout->setRowStretch(0, 1); innerlayout->setRowStretch(1, 100); mc->setLayout(innerlayout); @@ -183,6 +202,8 @@ MapWidget::MapWidget(QWidget *parent) : connect(zoomout, SIGNAL(clicked(bool)), mc, SLOT(zoomOut())); + connect(goToButton, SIGNAL(clicked()), this, SLOT(goTo())); + QList systems = UASManager::instance()->getUASList(); foreach(UASInterface* system, systems) { @@ -229,6 +250,31 @@ MapWidget::MapWidget(QWidget *parent) : radioCamera = 10; } +void MapWidget::goTo() +{ + bool ok; + QString text = QInputDialog::getText(this, tr("Please enter coordinates"), + tr("Coordinates (Lat,Lon):"), QLineEdit::Normal, + QString("%1,%2").arg(mc->currentCoordinate().x()).arg(mc->currentCoordinate().y()), &ok); + if (ok && !text.isEmpty()) + { + QStringList split = text.split(","); + if (split.length() == 2) + { + bool convert; + double latitude = split.first().toDouble(&convert); + ok &= convert; + double longitude = split.last().toDouble(&convert); + ok &= convert; + + if (ok) + { + mc->setView(QPointF(latitude, longitude)); + } + } + } +} + void MapWidget::mapproviderSelected(QAction* action) { diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index 53654331631c1020f0a4ce39ec0e05a20b0a51af..d8474cbf5c8bfebed1ee3f9da3ce2767519837c2 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -77,6 +77,8 @@ public slots: void clearPath(); void changeGlobalWaypointPositionBySpinBox(int index, float lat, float lon); void drawBorderCamAtMap(bool status); + /** @brief Bring up dialog to go to a specific location */ + void goTo(); protected: void changeEvent(QEvent* e); diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc index 5af21c83787511234fbba4be6f7cb7e62df9aa56..6164cfcf1891d4e039eb71a27124a771fc38ecae 100644 --- a/src/ui/designer/QGCParamSlider.cc +++ b/src/ui/designer/QGCParamSlider.cc @@ -22,7 +22,7 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ui->editDoneButton->show(); ui->editMaxLabel->show(); ui->editMinLabel->show(); - ui->editNameLineEdit->show(); + ui->editNameLabel->show(); ui->editInstructionsLabel->show(); ui->editRefreshParamsButton->show(); ui->editSelectParamComboBox->show(); @@ -30,7 +30,6 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) : ui->editStatusLabel->show(); ui->editMinSpinBox->show(); ui->editMaxSpinBox->show(); - ui->editTypeComboBox->show(); connect(ui->editDoneButton, SIGNAL(clicked()), this, SLOT(endEditMode())); } @@ -44,7 +43,7 @@ void QGCParamSlider::startEditMode() ui->editDoneButton->show(); ui->editMaxLabel->show(); ui->editMinLabel->show(); - ui->editNameLineEdit->show(); + ui->editNameLabel->show(); ui->editInstructionsLabel->show(); ui->editRefreshParamsButton->show(); ui->editSelectParamComboBox->show(); @@ -60,7 +59,7 @@ void QGCParamSlider::endEditMode() ui->editDoneButton->hide(); ui->editMaxLabel->hide(); ui->editMinLabel->hide(); - ui->editNameLineEdit->hide(); + ui->editNameLabel->hide(); ui->editInstructionsLabel->hide(); ui->editRefreshParamsButton->hide(); ui->editSelectParamComboBox->hide(); @@ -68,7 +67,6 @@ void QGCParamSlider::endEditMode() ui->editStatusLabel->hide(); ui->editMinSpinBox->hide(); ui->editMaxSpinBox->hide(); - ui->editTypeComboBox->hide(); isInEditMode = false; emit editingFinished(); } @@ -138,9 +136,9 @@ void QGCParamSlider::readSettings(const QSettings& settings) { ui->nameLabel->setText(settings.value("QGC_PARAM_SLIDER_DESCRIPTION").toString()); //settings.setValue("QGC_PARAM_SLIDER_BUTTONTEXT", ui->actionButton->text()); - ui->editSelectParamComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); - ui->editSelectComponentsComboBox->setCurrentText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); - ui->editMinSpinBox(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); - ui->editMaxSpinBox(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); + ui->editSelectParamComboBox->setEditText(settings.value("QGC_PARAM_SLIDER_PARAMID").toString()); + ui->editSelectComponentComboBox->setEditText(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toString()); + ui->editMinSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MIN").toFloat()); + ui->editMaxSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MAX").toFloat()); qDebug() << "DONE READING SETTINGS"; }