1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 // #include "../mapwidget/mapgraphicitem.h"
5 MainWindow::MainWindow(QWidget
*parent
) :
9 map
= new mapcontrol::OPMapWidget();
10 map
->SetShowUAV(true);
11 map
->SetShowHome(true);
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);
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()
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
);
51 // qDebug()<<itemm->Type;
52 if (itemm
->Type
== mapcontrol::WayPointItem::Type
) {
55 QLabel
*l
= new QLabel(this);
60 void MainWindow::changeEvent(QEvent
*e
)
62 QMainWindow::changeEvent(e
);
65 case QEvent::LanguageChange
:
66 ui
->retranslateUi(this);
73 void MainWindow::on_pushButtonZoomP_clicked()
75 double x
= map
->ZoomTotal();
76 double y
= ui
->doubleSpinBox
->value();
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);
102 // map->WPCreate(internals::PointLatLng(20,20),100);
105 void MainWindow::on_pushButtonRC_clicked()
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()
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()
147 // QLabel *x=new QLabel();
149 // x->setPixmap(QPixmap::fromImage(ima));