mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Minor new map user controls update
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@809 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
20fa15c24a
commit
c0ed4515f8
@ -128,6 +128,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonReload">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(160, 160, 160, 255), stop:1 rgba(180, 180, 180, 255));</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -329,6 +367,9 @@
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -358,6 +399,9 @@
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -394,6 +438,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelRotate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgba(255, 255, 255, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rotate</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonRL">
|
||||
<property name="sizePolicy">
|
||||
@ -427,6 +497,9 @@
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -503,43 +576,11 @@
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<property name="autoRepeat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonReload">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>OpenHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(160, 160, 160, 255), stop:1 rgba(180, 180, 180, 255));</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
<property name="autoRepeatInterval">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
@ -549,7 +590,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "opmapgadgetwidget.h"
|
||||
#include <QStringList>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
|
||||
#include "ui_opmap_controlpanel.h"
|
||||
@ -38,8 +39,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
// **************
|
||||
|
||||
map = NULL;
|
||||
controlpanel_ui = NULL;
|
||||
map = NULL;
|
||||
|
||||
follow_uav = false;
|
||||
|
||||
@ -56,6 +57,25 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
controlpanel_ui = new Ui::OPMapControlPanel();
|
||||
controlpanel_ui->setupUi(this);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
QWidget *dialog = new QWidget(this, Qt::Dialog);
|
||||
|
||||
controlpanel_ui = new Ui::OPMapControlPanel();
|
||||
controlpanel_ui->setupUi(dialog);
|
||||
|
||||
QHBoxLayout *d_layout = new QHBoxLayout(dialog);
|
||||
d_layout->setSpacing(0);
|
||||
d_layout->setContentsMargins(0, 0, 0, 0);
|
||||
d_layout->addWidget(controlpanel_ui->layoutWidget);
|
||||
dialog->setLayout(d_layout);
|
||||
|
||||
dialog->show();
|
||||
*/
|
||||
// **************
|
||||
// create the map display
|
||||
|
||||
@ -68,6 +88,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
|
||||
controlpanel_ui->comboBox->addItems(mapcontrol::Helper::MapTypes());
|
||||
controlpanel_ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
|
||||
controlpanel_ui->labelZoom->setText(" " + QString::number(map->Zoom()));
|
||||
controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate()));
|
||||
|
||||
// **************
|
||||
|
||||
@ -90,9 +112,15 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(controlpanel_ui->layoutWidget);
|
||||
// layout->addWidget(dialog);
|
||||
layout->addWidget(map);
|
||||
setLayout(layout);
|
||||
|
||||
// **************
|
||||
// create the user controls overlayed onto the map
|
||||
|
||||
createMapOverlayUserControls();
|
||||
|
||||
// **************
|
||||
|
||||
m_updateTimer = new QTimer();
|
||||
@ -204,6 +232,21 @@ void OPMapGadgetWidget::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
// *************************************************************************************
|
||||
|
||||
void OPMapGadgetWidget::zoomIn()
|
||||
{
|
||||
if (map)
|
||||
map->SetZoom(map->Zoom() + 1);
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::zoomOut()
|
||||
{
|
||||
if (map)
|
||||
map->SetZoom(map->Zoom() - 1);
|
||||
}
|
||||
|
||||
|
||||
// *************************************************************************************
|
||||
|
||||
void OPMapGadgetWidget::zoomChanged(double zoom)
|
||||
@ -242,19 +285,28 @@ void OPMapGadgetWidget::on_pushButtonReload_clicked()
|
||||
void OPMapGadgetWidget::on_pushButtonRL_clicked()
|
||||
{
|
||||
if (map)
|
||||
{
|
||||
map->SetRotate(map->Rotate() - 1);
|
||||
controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate()));
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::on_pushButtonRC_clicked()
|
||||
{
|
||||
if (map)
|
||||
{
|
||||
map->SetRotate(0);
|
||||
controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate()));
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::on_pushButtonRR_clicked()
|
||||
{
|
||||
if (map)
|
||||
{
|
||||
map->SetRotate(map->Rotate() + 1);
|
||||
controlpanel_ui->labelRotate->setText(" " + QString::number(map->Rotate()));
|
||||
}
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::on_pushButtonZoomP_clicked()
|
||||
@ -303,5 +355,72 @@ void OPMapGadgetWidget::on_pushButtonGeoFenceP_clicked()
|
||||
geo_fence_distance = controlpanel_ui->spinBoxGeoFenceDistance->value();
|
||||
}
|
||||
|
||||
// *************************************************************************************
|
||||
// create some user controls overlayed onto the map area
|
||||
|
||||
QPushButton * OPMapGadgetWidget::createTransparentButton(QWidget *parent, QString text, QString icon)
|
||||
{
|
||||
QPixmap pix;
|
||||
pix.load(icon);
|
||||
|
||||
QPushButton *but = new QPushButton(parent);
|
||||
|
||||
QColor transparent_color(0,0,0,0);
|
||||
QPalette but_pal(but->palette());
|
||||
|
||||
but_pal.setColor(QPalette::Button, transparent_color);
|
||||
but->setPalette(but_pal);
|
||||
|
||||
but->setIcon(pix);
|
||||
but->setText(text);
|
||||
but->setIconSize(pix.size());
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
void OPMapGadgetWidget::createMapOverlayUserControls()
|
||||
{
|
||||
QPushButton *zoomin = createTransparentButton(map, "", QString::fromUtf8(":/core/images/plus.png"));
|
||||
zoomin->setStyleSheet("");
|
||||
// QPushButton *zoomin = new QPushButton("");
|
||||
zoomin->setFixedSize(24, 24);
|
||||
zoomin->setToolTip(tr("Zoom in"));
|
||||
zoomin->setCursor(Qt::OpenHandCursor);
|
||||
// zoomin->setIcon(QIcon(QString::fromUtf8(":/core/images/plus.png")));
|
||||
zoomin->setIconSize(QSize(12, 12));
|
||||
connect(zoomin, SIGNAL(clicked(bool)), this, SLOT(zoomIn()));
|
||||
|
||||
QPushButton *zoomout = new QPushButton("");
|
||||
zoomout->setFixedSize(24, 24);
|
||||
zoomout->setToolTip(tr("Zoom out"));
|
||||
zoomout->setCursor(Qt::OpenHandCursor);
|
||||
zoomout->setIcon(QIcon(QString::fromUtf8(":/core/images/minus.png")));
|
||||
zoomout->setIconSize(QSize(12, 12));
|
||||
// zoomout->setWindowOpacity(0.7);
|
||||
// zoomout->setBackgroundRole(QPalette(QColor(0, 0, 0, 0)));
|
||||
connect(zoomout, SIGNAL(clicked(bool)), this, SLOT(zoomOut()));
|
||||
|
||||
// add zoom buttons to the layout of the MapControl
|
||||
QVBoxLayout* overlay_layout_v1 = new QVBoxLayout;
|
||||
overlay_layout_v1->setMargin(4);
|
||||
overlay_layout_v1->setSpacing(4);
|
||||
overlay_layout_v1->addSpacing(10);
|
||||
|
||||
QHBoxLayout* overlay_layout_h1 = new QHBoxLayout;
|
||||
overlay_layout_h1->setMargin(0);
|
||||
overlay_layout_h1->setSpacing(4);
|
||||
overlay_layout_h1->addSpacing(10);
|
||||
// overlay_layout_h1->addWidget(gcsButton);
|
||||
// overlay_layout_h1->addWidget(uavButton);
|
||||
// overlay_layout_h1->addSpacing(10);
|
||||
overlay_layout_h1->addWidget(zoomout);
|
||||
overlay_layout_h1->addWidget(zoomin);
|
||||
overlay_layout_h1->addStretch(0);
|
||||
|
||||
overlay_layout_v1->addLayout(overlay_layout_h1);
|
||||
overlay_layout_v1->addStretch(0);
|
||||
|
||||
map->setLayout(overlay_layout_v1);
|
||||
}
|
||||
|
||||
// *************************************************************************************
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#include "opmapcontrol/opmapcontrol.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include "uavobjects/positionactual.h"
|
||||
|
||||
@ -59,6 +58,9 @@ protected:
|
||||
private slots:
|
||||
void updatePosition();
|
||||
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
// control panel slots
|
||||
void on_checkBox_clicked(bool checked);
|
||||
void on_comboBox_currentIndexChanged(QString );
|
||||
@ -85,6 +87,10 @@ private:
|
||||
|
||||
Ui::OPMapControlPanel *controlpanel_ui;
|
||||
mapcontrol::OPMapWidget *map;
|
||||
|
||||
QPushButton * createTransparentButton(QWidget *parent, QString text, QString icon);
|
||||
void createMapOverlayUserControls();
|
||||
|
||||
};
|
||||
|
||||
#endif /* OPMAP_GADGETWIDGET_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user