LP-106 Setup Wizard refresh : Add dual servo setup (dual aileron or
[librepilot.git] / ground / gcs / src / experimental / finaltest / mainwindow.cpp
blob039df5ef9d695b28134d07e7a37da2ca78ab9043
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 // #include "../mapwidget/mapgraphicitem.h"
5 MainWindow::MainWindow(QWidget *parent) :
6 QMainWindow(parent),
7 ui(new Ui::MainWindow)
9 map = new mapcontrol::OPMapWidget();
10 map->SetShowUAV(true);
11 map->SetShowHome(true);
12 ui->setupUi(this);
13 ui->comboBox->addItems(mapcontrol::Helper::MapTypes());
14 ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
15 QHBoxLayout *layout = new QHBoxLayout(parent);
16 layout->addWidget(map);
17 layout->addWidget(ui->widget);
18 ui->centralWidget->setLayout(layout);
19 QTimer *timer = new QTimer;
20 timer->setInterval(500);
21 timer->start();
22 connect(map, SIGNAL(zoomChanged(double, double, double)), this, SLOT(zoomChanged(double, double, double)));
23 connect(map, SIGNAL(OnTilesStillToLoad(int)), this, SLOT(ttl(int)));
24 connect(timer, SIGNAL(timeout()), this, SLOT(time()));
25 map->WPCreate(internals::PointLatLng(38.42, -9.5), 0, "lisbon");
26 map->SetMouseWheelZoomType(internals::MouseWheelZoomType::MousePositionAndCenter);
29 MainWindow::~MainWindow()
31 delete ui;
32 delete map;
35 void MainWindow::ttl(int value)
37 ui->label_2->setText(QString::number(value));
40 void MainWindow::time()
42 internals::PointLatLng ll;
44 ll.SetLat(map->currentMousePosition().Lat());
45 ll.SetLng(map->currentMousePosition().Lng());
46 // map->UAV->SetUAVPos(ll,10);
47 ui->label_2->setText(map->currentMousePosition().ToString());
48 QGraphicsItem *itemm = map->itemAt(map->mapFromGlobal(QCursor::pos()));
49 mapcontrol::WayPointItem *w = qgraphicsitem_cast<mapcontrol::WayPointItem *>(itemm);
50 // if(w)
51 // qDebug()<<itemm->Type;
52 if (itemm->Type == mapcontrol::WayPointItem::Type) {
53 int x = itemm->Type;
54 int xx = x;
55 QLabel *l = new QLabel(this);
56 l->show();
60 void MainWindow::changeEvent(QEvent *e)
62 QMainWindow::changeEvent(e);
64 switch (e->type()) {
65 case QEvent::LanguageChange:
66 ui->retranslateUi(this);
67 break;
68 default:
69 break;
73 void MainWindow::on_pushButtonZoomP_clicked()
75 double x = map->ZoomTotal();
76 double y = ui->doubleSpinBox->value();
77 double z = x + y;
79 map->SetZoom(map->ZoomTotal() + ui->doubleSpinBox->value());
82 void MainWindow::on_pushButtonZoomM_clicked()
84 map->SetZoom(map->ZoomTotal() - ui->doubleSpinBox->value());
87 void MainWindow::on_checkBox_clicked(bool checked)
89 map->SetShowTileGridLines(checked);
91 void MainWindow::zoomChanged(double zoomt, double zoom, double zoomdigi)
93 ui->label_5->setText("CurrentZoom=" + QString::number(zoomt) + QString::number(zoom) + QString::number(zoomdigi));
96 void MainWindow::on_pushButtonRL_clicked()
98 map->UAV->DeleteTrail();
99 // map->UAV->SetUAVHeading(10);
100 // map->SetRotate(map->Rotate()-1);
101 // map->WPCreate();
102 // map->WPCreate(internals::PointLatLng(20,20),100);
105 void MainWindow::on_pushButtonRC_clicked()
107 map->SetRotate(0);
108 // wp=map->WPInsert(1);
111 void MainWindow::on_pushButtonRR_clicked()
113 map->SetRotate(map->Rotate() + 1);
114 // map->WPDeleteAll();
115 // map->WPDelete(wp);
116 // QList<mapcontrol::WayPointItem*> list= map->WPSelected();
117 // int x=list.at(0)->Number();
120 void MainWindow::on_pushButton_clicked()
122 map->ReloadMap();
125 void MainWindow::on_pushButtonGO_clicked()
127 core::GeoCoderStatusCode::Types x = map->SetCurrentPositionByKeywords(ui->lineEdit->text());
129 ui->label->setText(mapcontrol::Helper::StrFromGeoCoderStatusCode(x));
132 void MainWindow::on_checkBox_2_clicked(bool checked)
134 map->SetUseOpenGL(checked);
137 void MainWindow::on_comboBox_currentIndexChanged(QString value)
139 if (map->isStarted()) {
140 map->SetMapType(mapcontrol::Helper::MapTypeFromString(value));
144 void MainWindow::on_pushButton_2_clicked()
146 map->RipMap();
147 // QLabel *x=new QLabel();
148 // ima=map->X();
149 // x->setPixmap(QPixmap::fromImage(ima));
150 // x->show();