Rev 750 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 750 | Rev 801 | ||
---|---|---|---|
1 | /*************************************************************************** |
1 | /*************************************************************************** |
2 | * Copyright (C) 2009 by Manuel Schrape * |
2 | * Copyright (C) 2009 by Manuel Schrape * |
3 | * manuel.schrape@gmx.de * |
3 | * manuel.schrape@gmx.de * |
4 | * * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License. * |
7 | * the Free Software Foundation; either version 2 of the License. * |
8 | * * |
8 | * * |
9 | * This program is distributed in the hope that it will be useful, * |
9 | * This program is distributed in the hope that it will be useful, * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * GNU General Public License for more details. * |
12 | * GNU General Public License for more details. * |
13 | * * |
13 | * * |
14 | * You should have received a copy of the GNU General Public License * |
14 | * You should have received a copy of the GNU General Public License * |
15 | * along with this program; if not, write to the * |
15 | * along with this program; if not, write to the * |
16 | * Free Software Foundation, Inc., * |
16 | * Free Software Foundation, Inc., * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | ***************************************************************************/ |
18 | ***************************************************************************/ |
19 | 19 | ||
20 | #include <QCryptographicHash> |
20 | #include <QCryptographicHash> |
21 | #include <QMessageBox> |
21 | #include <QMessageBox> |
22 | #include <QDomDocument> |
22 | #include <QDomDocument> |
23 | #include <QFile> |
23 | #include <QFile> |
24 | 24 | ||
25 | #include "dlg_Main.h" |
25 | #include "dlg_Main.h" |
26 | #include "dlg_MapPos.h" |
26 | #include "dlg_MapPos.h" |
27 | 27 | ||
28 | // Konstruktor Main-Form |
28 | // Konstruktor Main-Form |
29 | dlg_Main::dlg_Main() |
29 | dlg_Main::dlg_Main() |
30 | { |
30 | { |
31 | setupUi(this); |
31 | setupUi(this); |
32 | 32 | ||
33 | o_Settings = new cSettings(); |
33 | o_Settings = new cSettings(); |
34 | 34 | ||
35 | wg_Connection->set_Client(ID_MAPS, QA_NAME + " " + QA_VERSION, DataFields); |
35 | wg_Connection->set_Client(ID_MAPS, QA_NAME + " " + QA_VERSION, DataFields); |
36 | 36 | ||
37 | o_Map = new MapControl(QSize(25,25)); |
37 | o_Map = new MapControl(QSize(25,25)); |
38 | l_RouteWP = new LineString(); |
38 | l_RouteWP = new LineString(); |
39 | init_Directorys(); |
39 | init_Directorys(); |
40 | init_GUI(); |
40 | init_GUI(); |
41 | init_Connections(); |
41 | init_Connections(); |
42 | } |
42 | } |
43 | 43 | ||
44 | // Grafische Oberfläche initialisieren |
44 | // Grafische Oberfläche initialisieren |
45 | void dlg_Main::init_GUI() |
45 | void dlg_Main::init_GUI() |
46 | { |
46 | { |
47 | setWindowTitle(QA_NAME + " " + QA_VERSION); |
47 | setWindowTitle(QA_NAME + " " + QA_VERSION); |
48 | 48 | ||
49 | resize(o_Settings->GUI.Size); |
49 | resize(o_Settings->GUI.Size); |
50 | move(o_Settings->GUI.Point); |
50 | move(o_Settings->GUI.Point); |
51 | 51 | ||
52 | if (o_Settings->GUI.isMax) |
52 | if (o_Settings->GUI.isMax) |
53 | { |
53 | { |
54 | showMaximized(); |
54 | showMaximized(); |
55 | } |
55 | } |
56 | 56 | ||
57 | wg_Connection->set_SelectVisible(false); |
57 | wg_Connection->set_SelectVisible(false); |
58 | 58 | ||
59 | cb_CenterPos->setChecked(o_Settings->CONFIG.cb_CenterPos); |
59 | cb_CenterPos->setChecked(o_Settings->CONFIG.cb_CenterPos); |
60 | cb_ShowRoute->setChecked(o_Settings->CONFIG.cb_ShowRoute); |
60 | cb_ShowRoute->setChecked(o_Settings->CONFIG.cb_ShowRoute); |
61 | cb_ShowWPs->setChecked(o_Settings->CONFIG.cb_ShowWPs); |
61 | cb_ShowWPs->setChecked(o_Settings->CONFIG.cb_ShowWPs); |
62 | cb_Goto->setChecked(o_Settings->CONFIG.cb_Goto); |
62 | cb_Goto->setChecked(o_Settings->CONFIG.cb_Goto); |
63 | 63 | ||
64 | tb_More->addWidget(cb_Maps); |
64 | // tb_More->addWidget(cb_Maps); |
65 | cb_Maps->setVisible(false); |
65 | cb_Maps->setVisible(false); |
66 | 66 | ||
67 | ac_Toolbar->setChecked(o_Settings->GUI.Toolbar); |
67 | ac_Toolbar->setChecked(o_Settings->GUI.Toolbar); |
68 | 68 | ||
69 | if (ac_Toolbar->isChecked()) |
69 | if (ac_Toolbar->isChecked()) |
70 | { |
70 | { |
71 | wg_Connection->set_ButtonVisible(false); |
71 | wg_Connection->set_ButtonVisible(false); |
72 | } |
72 | } |
73 | else |
73 | else |
74 | { |
74 | { |
75 | ToolBar->setVisible(false); |
75 | ToolBar->setVisible(false); |
76 | tb_More->setVisible(false); |
76 | tb_More->setVisible(false); |
77 | } |
77 | } |
78 | } |
78 | } |
79 | 79 | ||
80 | // Signale mit Slots verbinden |
80 | // Signale mit Slots verbinden |
81 | void dlg_Main::init_Connections() |
81 | void dlg_Main::init_Connections() |
82 | { |
82 | { |
83 | connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect())); |
83 | connect(ac_Connect, SIGNAL(triggered()), wg_Connection, SLOT(slot_btn_Connect())); |
84 | connect(ac_Toolbar, SIGNAL(triggered()), this, SLOT(slot_ac_Toolbar())); |
84 | connect(ac_Toolbar, SIGNAL(triggered()), this, SLOT(slot_ac_Toolbar())); |
85 | 85 | ||
86 | connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
86 | connect(sl_Zoom, SIGNAL(valueChanged(int)), this, SLOT(slot_Zoom(int))); |
87 | connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
87 | connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int))); |
88 | 88 | ||
89 | connect(cb_ShowWPs, SIGNAL(toggled(bool)), this, SLOT(slot_ShowWayPoints(bool))); |
89 | connect(cb_ShowWPs, SIGNAL(toggled(bool)), this, SLOT(slot_ShowWayPoints(bool))); |
90 | 90 | ||
91 | connect(btn_WPAdd, SIGNAL(clicked()), this, SLOT(slot_btn_WPAdd())); |
91 | connect(btn_WPAdd, SIGNAL(clicked()), this, SLOT(slot_btn_WPAdd())); |
92 | connect(btn_WPFly, SIGNAL(clicked()), this, SLOT(slot_btn_WPFly())); |
92 | connect(btn_WPFly, SIGNAL(clicked()), this, SLOT(slot_btn_WPFly())); |
93 | connect(btn_WPDelete, SIGNAL(clicked()), this, SLOT(slot_btn_WPDelete())); |
93 | connect(btn_WPDelete, SIGNAL(clicked()), this, SLOT(slot_btn_WPDelete())); |
94 | 94 | ||
95 | connect(ac_LoadRoute, SIGNAL(triggered()), this, SLOT(slot_ac_LoadWayPoints())); |
95 | connect(ac_LoadRoute, SIGNAL(triggered()), this, SLOT(slot_ac_LoadWayPoints())); |
96 | connect(ac_SaveRoute, SIGNAL(triggered()), this, SLOT(slot_ac_SaveRoute())); |
96 | connect(ac_SaveRoute, SIGNAL(triggered()), this, SLOT(slot_ac_SaveRoute())); |
97 | 97 | ||
98 | connect(ac_LoadMap, SIGNAL(triggered()), this, SLOT(slot_ac_LoadMapPic())); |
98 | connect(ac_LoadMap, SIGNAL(triggered()), this, SLOT(slot_ac_LoadMapPic())); |
99 | connect(ac_Record, SIGNAL(triggered()), this, SLOT(slot_ac_Record())); |
99 | connect(ac_Record, SIGNAL(triggered()), this, SLOT(slot_ac_Record())); |
100 | connect(ac_RouteDelete, SIGNAL(triggered()), this, SLOT(slot_ac_RouteDelete())); |
100 | connect(ac_RouteDelete, SIGNAL(triggered()), this, SLOT(slot_ac_RouteDelete())); |
101 | 101 | ||
102 | // About QMK-Kernel & About-QT Dialog einfügen |
102 | // About QMK-Kernel & About-QT Dialog einfügen |
103 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
103 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
104 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
104 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
105 | 105 | ||
106 | connect(wg_Connection, SIGNAL(sig_Status(int)), this, SLOT(slot_ConnectionStatus(int))); |
106 | connect(wg_Connection, SIGNAL(sig_Status(int)), this, SLOT(slot_ConnectionStatus(int))); |
107 | connect(wg_Connection, SIGNAL(sig_MK_Version(s_Hardware)), this, SLOT(slot_MK_Version(s_Hardware))); |
107 | connect(wg_Connection, SIGNAL(sig_MK_Version(s_Hardware)), this, SLOT(slot_MK_Version(s_Hardware))); |
108 | connect(wg_Connection, SIGNAL(sig_MK_NaviData(s_MK_NaviData)), this, SLOT(slot_MK_NaviData(s_MK_NaviData))); |
108 | connect(wg_Connection, SIGNAL(sig_MK_NaviData(s_MK_NaviData)), this, SLOT(slot_MK_NaviData(s_MK_NaviData))); |
109 | connect(wg_Connection, SIGNAL(sig_MK_WayPoint(int)), this, SLOT(slot_MK_WayPoint(int))); |
109 | connect(wg_Connection, SIGNAL(sig_MK_WayPoint(int)), this, SLOT(slot_MK_WayPoint(int))); |
110 | } |
110 | } |
111 | 111 | ||
112 | void dlg_Main::init_Directorys() |
112 | void dlg_Main::init_Directorys() |
113 | { |
113 | { |
114 | QDir *t_Dir = new QDir(); |
114 | QDir *t_Dir = new QDir(); |
115 | 115 | ||
116 | s_Dir.MainData = QDir::homePath() + "/QMK-Data"; |
116 | s_Dir.MainData = QDir::homePath() + "/QMK-Data"; |
117 | if (!t_Dir->exists(s_Dir.MainData)) |
117 | if (!t_Dir->exists(s_Dir.MainData)) |
118 | { |
118 | { |
119 | t_Dir->mkdir(s_Dir.MainData); |
119 | t_Dir->mkdir(s_Dir.MainData); |
120 | } |
120 | } |
121 | 121 | ||
122 | s_Dir.MapCache = s_Dir.MainData + "/Map-Cache"; |
122 | s_Dir.MapCache = s_Dir.MainData + "/Map-Cache"; |
123 | if (!t_Dir->exists(s_Dir.MapCache)) |
123 | if (!t_Dir->exists(s_Dir.MapCache)) |
124 | { |
124 | { |
125 | t_Dir->mkdir(s_Dir.MapCache); |
125 | t_Dir->mkdir(s_Dir.MapCache); |
126 | } |
126 | } |
127 | 127 | ||
128 | s_Dir.WPRoutes = s_Dir.MainData + "/WP-Routes"; |
128 | s_Dir.WPRoutes = s_Dir.MainData + "/WP-Routes"; |
129 | if (!t_Dir->exists(s_Dir.WPRoutes)) |
129 | if (!t_Dir->exists(s_Dir.WPRoutes)) |
130 | { |
130 | { |
131 | t_Dir->mkdir(s_Dir.WPRoutes); |
131 | t_Dir->mkdir(s_Dir.WPRoutes); |
132 | } |
132 | } |
133 | 133 | ||
134 | s_Dir.MapPics = s_Dir.MainData + "/Map-Pics"; |
134 | s_Dir.MapPics = s_Dir.MainData + "/Map-Pics"; |
135 | if (!t_Dir->exists(s_Dir.MapPics)) |
135 | if (!t_Dir->exists(s_Dir.MapPics)) |
136 | { |
136 | { |
137 | t_Dir->mkdir(s_Dir.MapPics); |
137 | t_Dir->mkdir(s_Dir.MapPics); |
138 | } |
138 | } |
139 | 139 | ||
140 | s_Dir.Flights = s_Dir.MainData + "/Flights"; |
140 | s_Dir.Flights = s_Dir.MainData + "/Flights"; |
141 | if (!t_Dir->exists(s_Dir.Flights)) |
141 | if (!t_Dir->exists(s_Dir.Flights)) |
142 | { |
142 | { |
143 | t_Dir->mkdir(s_Dir.Flights); |
143 | t_Dir->mkdir(s_Dir.Flights); |
144 | } |
144 | } |
145 | } |
145 | } |
146 | 146 | ||
147 | /////////////////////////////////////////////////////////////////// |
147 | /////////////////////////////////////////////////////////////////// |
148 | // QMK-Maps // |
148 | // QMK-Maps // |
149 | /////////////////////////////////////////////////////////////////// |
149 | /////////////////////////////////////////////////////////////////// |
150 | 150 | ||
151 | void dlg_Main::create_Map() |
151 | void dlg_Main::create_Map() |
152 | { |
152 | { |
153 | o_Map->resize(w_Map->size() - QSize(25,50)); |
153 | o_Map->resize(w_Map->size() - QSize(25,50)); |
154 | o_Map->enablePersistentCache(s_Dir.MapCache); |
154 | o_Map->enablePersistentCache(s_Dir.MapCache); |
155 | o_Map->showScale(true); |
155 | o_Map->showScale(true); |
156 | 156 | ||
157 | o_Adapter = new OSMMapAdapter(); |
157 | o_Adapter = new OSMMapAdapter(); |
158 | 158 | ||
159 | o_Layer = new MapLayer("MapLayer", o_Adapter); |
159 | o_Layer = new MapLayer("MapLayer", o_Adapter); |
160 | o_Click = new GeometryLayer("Click", o_Adapter); |
160 | o_Click = new GeometryLayer("Click", o_Adapter); |
161 | o_Info = new GeometryLayer("Poute", o_Adapter); |
161 | o_Info = new GeometryLayer("Poute", o_Adapter); |
162 | o_RouteWP = new GeometryLayer("Route-WayPoint", o_Adapter); |
162 | o_RouteWP = new GeometryLayer("Route-WayPoint", o_Adapter); |
163 | o_RouteFL = new GeometryLayer("Route-Flight", o_Adapter); |
163 | o_RouteFL = new GeometryLayer("Route-Flight", o_Adapter); |
164 | 164 | ||
165 | o_Map->addLayer(o_Layer); |
165 | o_Map->addLayer(o_Layer); |
166 | o_Map->addLayer(o_Click); |
166 | o_Map->addLayer(o_Click); |
167 | o_Map->addLayer(o_Info); |
167 | o_Map->addLayer(o_Info); |
168 | o_Map->addLayer(o_RouteWP); |
168 | o_Map->addLayer(o_RouteWP); |
169 | o_Map->addLayer(o_RouteFL); |
169 | o_Map->addLayer(o_RouteFL); |
170 | 170 | ||
171 | o_Map->setZoom(17); |
171 | o_Map->setZoom(17); |
172 | // o_Map->setView(QPointF(o_Settings->NAVI.Longitude,o_Settings->NAVI.Latitude)); |
172 | o_Map->setView(QPointF(o_Settings->NAVI.Longitude,o_Settings->NAVI.Latitude)); |
173 | // o_Map->setView(QPointF(13.5,52.5)); |
173 | // o_Map->setView(QPointF(13.5,52.5)); |
174 | o_Map->setView(QPointF(13.419805,52.431787)); |
174 | // o_Map->setView(QPointF(13.419805,52.431787)); |
175 | connect(o_Map, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(slot_Click(const QMouseEvent*, const QPointF))); |
175 | connect(o_Map, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(slot_Click(const QMouseEvent*, const QPointF))); |
176 | 176 | ||
177 | l_Map->addWidget(o_Map); |
177 | l_Map->addWidget(o_Map); |
178 | 178 | ||
179 | sl_Zoom->setValue(17); |
179 | sl_Zoom->setValue(17); |
180 | 180 | ||
181 | // Flight |
181 | // Flight |
182 | Pen[0] = new QPen(QColor(0,0,255,255)); |
182 | Pen[0] = new QPen(QColor(0,0,255,255)); |
183 | Pen[0]->setWidth(2); |
183 | Pen[0]->setWidth(2); |
184 | Pen[1] = new QPen(QColor(0,0,255,255)); |
184 | Pen[1] = new QPen(QColor(0,0,255,255)); |
185 | Pen[1]->setWidth(1); |
185 | Pen[1]->setWidth(1); |
186 | // WayPoint |
186 | // WayPoint |
187 | Pen[2] = new QPen(QColor(255,0,0,255)); |
187 | Pen[2] = new QPen(QColor(255,0,0,255)); |
188 | Pen[2]->setWidth(2); |
188 | Pen[2]->setWidth(2); |
189 | Pen[3] = new QPen(QColor(255,0,0,255)); |
189 | Pen[3] = new QPen(QColor(255,0,0,255)); |
190 | Pen[3]->setWidth(1); |
190 | Pen[3]->setWidth(1); |
191 | // Info |
191 | // Info |
192 | Pen[4] = new QPen(QColor(0,128,128,255)); |
192 | Pen[4] = new QPen(QColor(0,128,128,255)); |
193 | Pen[4]->setWidth(2); |
193 | Pen[4]->setWidth(2); |
194 | Pen[5] = new QPen(QColor(0,128,128,255)); |
194 | Pen[5] = new QPen(QColor(0,128,128,255)); |
195 | Pen[5]->setWidth(1); |
195 | Pen[5]->setWidth(1); |
196 | } |
196 | } |
197 | 197 | ||
198 | // auf Veränderung der Fenstergröße reagieren |
198 | // auf Veränderung der Fenstergröße reagieren |
199 | void dlg_Main::resizeEvent ( QResizeEvent * event ) |
199 | void dlg_Main::resizeEvent ( QResizeEvent * event ) |
200 | { |
200 | { |
201 | event = event; |
201 | event = event; |
202 | o_Map->resize(w_Map->size() - QSize(25,25)); |
202 | o_Map->resize(w_Map->size() - QSize(25,25)); |
203 | } |
203 | } |
204 | 204 | ||
205 | void dlg_Main::wheelEvent(QWheelEvent *event) |
205 | void dlg_Main::wheelEvent(QWheelEvent *event) |
206 | { |
206 | { |
207 | int zoomValue = sl_Zoom->value(); |
207 | int zoomValue = sl_Zoom->value(); |
208 | int numDegrees = event->delta() / 8; |
208 | int numDegrees = event->delta() / 8; |
209 | int numSteps = numDegrees / 15; |
209 | int numSteps = numDegrees / 15; |
210 | zoomValue += numSteps; |
210 | zoomValue += numSteps; |
211 | if (zoomValue < 0) { zoomValue = 0;} |
211 | if (zoomValue < 0) { zoomValue = 0;} |
212 | if (zoomValue > 17) { zoomValue = 17;} |
212 | if (zoomValue > 18) { zoomValue = 18;} |
213 | sl_Zoom->setValue(zoomValue); |
213 | sl_Zoom->setValue(zoomValue); |
214 | } |
214 | } |
215 | 215 | ||
216 | QList<sWayPoint> dlg_Main::parse_WayPointKML(QString s_File) |
216 | QList<sWayPoint> dlg_Main::parse_WayPointKML(QString s_File) |
217 | { |
217 | { |
218 | QList<sWayPoint> tmp_WayPoints; |
218 | QList<sWayPoint> tmp_WayPoints; |
219 | sWayPoint tmp_WayPoint; |
219 | sWayPoint tmp_WayPoint; |
220 | 220 | ||
221 | QFile f_KML(s_File); |
221 | QFile f_KML(s_File); |
222 | f_KML.open(QIODevice::ReadOnly | QIODevice::Text); |
222 | f_KML.open(QIODevice::ReadOnly | QIODevice::Text); |
223 | 223 | ||
224 | QByteArray s_KML; |
224 | QByteArray s_KML; |
225 | 225 | ||
226 | while (!f_KML.atEnd()) |
226 | while (!f_KML.atEnd()) |
227 | { |
227 | { |
228 | s_KML.append(f_KML.readLine()); |
228 | s_KML.append(f_KML.readLine()); |
229 | } |
229 | } |
230 | 230 | ||
231 | f_KML.close(); |
231 | f_KML.close(); |
232 | 232 | ||
233 | QDomDocument *UserXML; |
233 | QDomDocument *UserXML; |
234 | UserXML = new QDomDocument; |
234 | UserXML = new QDomDocument; |
235 | 235 | ||
236 | UserXML->setContent(s_KML); |
236 | UserXML->setContent(s_KML); |
237 | 237 | ||
238 | QDomElement Root = UserXML->firstChildElement("kml"); |
238 | QDomElement Root = UserXML->firstChildElement("kml"); |
239 | QDomElement Document = Root.firstChildElement("Document"); |
239 | QDomElement Document = Root.firstChildElement("Document"); |
240 | QDomElement Placemark = Document.firstChildElement("Placemark"); |
240 | QDomElement Placemark = Document.firstChildElement("Placemark"); |
241 | QDomElement Linestring = Placemark.firstChildElement("LineString"); |
241 | QDomElement Linestring = Placemark.firstChildElement("LineString"); |
242 | 242 | ||
243 | QString Name = Placemark.firstChildElement("name").toElement().text(); |
243 | QString Name = Placemark.firstChildElement("name").toElement().text(); |
244 | 244 | ||
245 | QString Route = Linestring.firstChildElement("coordinates").toElement().text(); |
245 | QString Route = Linestring.firstChildElement("coordinates").toElement().text(); |
246 | 246 | ||
247 | QStringList s_Points = Route.split(" "); |
247 | QStringList s_Points = Route.split(" "); |
248 | 248 | ||
249 | QStringList Position; |
249 | QStringList Position; |
250 | 250 | ||
251 | for (int z = 0; z < s_Points.count() - 1; z++) |
251 | for (int z = 0; z < s_Points.count() - 1; z++) |
252 | { |
252 | { |
253 | if (z != 20) |
253 | if (z != 20) |
254 | { |
254 | { |
255 | Position = s_Points[z].split(","); |
255 | Position = s_Points[z].split(","); |
256 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
256 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
257 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
257 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
258 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
258 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
259 | tmp_WayPoint.Time = sb_Time->value(); |
259 | tmp_WayPoint.Time = sb_Time->value(); |
260 | 260 | ||
261 | tmp_WayPoints.append(tmp_WayPoint); |
261 | tmp_WayPoints.append(tmp_WayPoint); |
262 | } |
262 | } |
263 | else |
263 | else |
264 | { |
264 | { |
265 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
265 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
266 | 266 | ||
267 | btn_WPAdd->setEnabled(false); |
267 | btn_WPAdd->setEnabled(false); |
268 | 268 | ||
269 | z = s_Points.count(); |
269 | z = s_Points.count(); |
270 | } |
270 | } |
271 | } |
271 | } |
272 | return tmp_WayPoints; |
272 | return tmp_WayPoints; |
273 | } |
273 | } |
274 | 274 | ||
275 | QList<sWayPoint> dlg_Main::parse_WayPointMKW(QString s_File) |
275 | QList<sWayPoint> dlg_Main::parse_WayPointMKW(QString s_File) |
276 | { |
276 | { |
277 | QList<sWayPoint> tmp_WayPoints; |
277 | QList<sWayPoint> tmp_WayPoints; |
278 | sWayPoint tmp_WayPoint; |
278 | sWayPoint tmp_WayPoint; |
279 | 279 | ||
280 | QFile f_MKW(s_File); |
280 | QFile f_MKW(s_File); |
281 | f_MKW.open(QIODevice::ReadOnly | QIODevice::Text); |
281 | f_MKW.open(QIODevice::ReadOnly | QIODevice::Text); |
282 | 282 | ||
283 | QString s_MKW; |
283 | QString s_MKW; |
284 | 284 | ||
285 | while (!f_MKW.atEnd()) |
285 | while (!f_MKW.atEnd()) |
286 | { |
286 | { |
287 | s_MKW.append(f_MKW.readLine()); |
287 | s_MKW.append(f_MKW.readLine()); |
288 | } |
288 | } |
289 | 289 | ||
290 | f_MKW.close(); |
290 | f_MKW.close(); |
291 | 291 | ||
292 | QStringList s_Points = s_MKW.split(" "); |
292 | QStringList s_Points = s_MKW.split(" "); |
293 | 293 | ||
294 | QStringList Position; |
294 | QStringList Position; |
295 | 295 | ||
296 | for (int z = 0; z < s_Points.count() - 1; z++) |
296 | for (int z = 0; z < s_Points.count() - 1; z++) |
297 | { |
297 | { |
298 | if (z != 20) |
298 | if (z != 20) |
299 | { |
299 | { |
300 | Position = s_Points[z].split(","); |
300 | Position = s_Points[z].split(","); |
301 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
301 | tmp_WayPoint.Longitude = Position[0].toDouble(); |
302 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
302 | tmp_WayPoint.Latitude = Position[1].toDouble(); |
303 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
303 | tmp_WayPoint.Altitude = Position[2].toDouble(); |
304 | tmp_WayPoint.Time = Position[3].toInt(); |
304 | tmp_WayPoint.Time = Position[3].toInt(); |
305 | 305 | ||
306 | tmp_WayPoints.append(tmp_WayPoint); |
306 | tmp_WayPoints.append(tmp_WayPoint); |
307 | } |
307 | } |
308 | else |
308 | else |
309 | { |
309 | { |
310 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
310 | QMessageBox::warning(this, QA_NAME,trUtf8("Die Wegpunkt-Liste umfasst mehr als 20 Einträge. Es werden nur die ersten 20 Einträge übernommen."), QMessageBox::Ok); |
311 | 311 | ||
312 | btn_WPAdd->setEnabled(false); |
312 | btn_WPAdd->setEnabled(false); |
313 | 313 | ||
314 | z = s_Points.count(); |
314 | z = s_Points.count(); |
315 | } |
315 | } |
316 | } |
316 | } |
317 | return tmp_WayPoints; |
317 | return tmp_WayPoints; |
318 | } |
318 | } |
319 | 319 | ||
320 | // Waypoint-Route anzeigen in Karte |
320 | // Waypoint-Route anzeigen in Karte |
321 | void dlg_Main::show_WayPoints(QList<sWayPoint> WayPoints) |
321 | void dlg_Main::show_WayPoints(QList<sWayPoint> WayPoints) |
322 | { |
322 | { |
323 | Point* p_Point; |
323 | Point* p_Point; |
324 | 324 | ||
325 | o_RouteWP->removeGeometry(l_RouteWP); |
325 | o_RouteWP->removeGeometry(l_RouteWP); |
326 | p_RouteWP.clear(); |
326 | p_RouteWP.clear(); |
327 | l_WayPoints.clear(); |
327 | l_WayPoints.clear(); |
328 | 328 | ||
329 | l_WayPoints = WayPoints; |
329 | l_WayPoints = WayPoints; |
330 | 330 | ||
331 | for (int z = 0; z < WayPoints.count(); z++) |
331 | for (int z = 0; z < WayPoints.count(); z++) |
332 | { |
332 | { |
333 | p_Point = new Point(WayPoints[z].Longitude, WayPoints[z].Latitude); |
333 | p_Point = new Point(WayPoints[z].Longitude, WayPoints[z].Latitude); |
334 | 334 | ||
335 | p_RouteWP.append(p_Point); |
335 | p_RouteWP.append(p_Point); |
336 | } |
336 | } |
337 | 337 | ||
338 | l_RouteWP = new LineString(p_RouteWP, "", Pen[3]); |
338 | l_RouteWP = new LineString(p_RouteWP, "", Pen[3]); |
339 | o_RouteWP->addGeometry(l_RouteWP); |
339 | o_RouteWP->addGeometry(l_RouteWP); |
340 | 340 | ||
341 | o_Map->setView(p_Point); |
341 | o_Map->setView(p_Point); |
342 | 342 | ||
343 | o_Map->updateRequestNew(); |
343 | o_Map->updateRequestNew(); |
344 | } |
344 | } |
345 | 345 | ||
346 | // Waypoint-Liste speichern |
346 | // Waypoint-Liste speichern |
347 | void dlg_Main::save_WayPointsMKW(QString s_File) |
347 | void dlg_Main::save_WayPointsMKW(QString s_File) |
348 | { |
348 | { |
349 | QFile *f_MKW = new QFile(s_File); |
349 | QFile *f_MKW = new QFile(s_File); |
350 | 350 | ||
351 | f_MKW->open(QIODevice::ReadWrite | QIODevice::Text); |
351 | f_MKW->open(QIODevice::ReadWrite | QIODevice::Text); |
352 | 352 | ||
353 | QTextStream out(f_MKW); |
353 | QTextStream out(f_MKW); |
354 | 354 | ||
355 | out.setRealNumberPrecision(9); |
355 | out.setRealNumberPrecision(9); |
356 | 356 | ||
357 | for (int z = 0; z < l_WayPoints.count(); z++) |
357 | for (int z = 0; z < l_WayPoints.count(); z++) |
358 | { |
358 | { |
359 | out << l_WayPoints[z].Longitude << "," << l_WayPoints[z].Latitude << "," << l_WayPoints[z].Altitude << "," << l_WayPoints[z].Time << " \n"; |
359 | out << l_WayPoints[z].Longitude << "," << l_WayPoints[z].Latitude << "," << l_WayPoints[z].Altitude << "," << l_WayPoints[z].Time << " \n"; |
360 | } |
360 | } |
361 | 361 | ||
362 | f_MKW->close(); |
362 | f_MKW->close(); |
363 | } |
363 | } |
364 | 364 | ||
365 | // Aktuelle MK-Position hinzufügen |
365 | // Aktuelle MK-Position hinzufügen |
366 | void dlg_Main::add_Position(s_MK_NaviData t_NaviData) |
366 | void dlg_Main::add_Position(s_MK_NaviData t_NaviData) |
367 | { |
367 | { |
368 | sWayPoint WayPoint; |
368 | sWayPoint WayPoint; |
369 | 369 | ||
370 | WayPoint.Longitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Longitude, 7); |
370 | WayPoint.Longitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Longitude, 7); |
371 | WayPoint.Latitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Latitude, 7); |
371 | WayPoint.Latitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Latitude, 7); |
372 | WayPoint.Altitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Altitude, 3); |
372 | WayPoint.Altitude = HandlerMK::Int2Double(t_NaviData.CurrentPosition.Altitude, 3); |
373 | 373 | ||
374 | o_Settings->NAVI.Latitude = WayPoint.Latitude; |
374 | o_Settings->NAVI.Latitude = WayPoint.Latitude; |
375 | o_Settings->NAVI.Longitude = WayPoint.Longitude; |
375 | o_Settings->NAVI.Longitude = WayPoint.Longitude; |
376 | 376 | ||
377 | l_Track.append(WayPoint); |
377 | l_Track.append(WayPoint); |
378 | 378 | ||
379 | o_RouteFL->removeGeometry(l_RouteFL); |
379 | o_RouteFL->removeGeometry(l_RouteFL); |
380 | p_RouteFL.append(new Point(WayPoint.Longitude, WayPoint.Latitude)); |
380 | p_RouteFL.append(new Point(WayPoint.Longitude, WayPoint.Latitude)); |
381 | 381 | ||
382 | o_Click->removeGeometry(LastPos); |
382 | o_Click->removeGeometry(LastPos); |
383 | 383 | ||
384 | Point* P = new CirclePoint(WayPoint.Longitude, WayPoint.Latitude, "P1", Point::Middle, Pen[0]); |
384 | Point* P = new CirclePoint(WayPoint.Longitude, WayPoint.Latitude, "P1", Point::Middle, Pen[0]); |
385 | LastPos = P; |
385 | LastPos = P; |
386 | // P->setBaselevel(17); |
386 | // P->setBaselevel(17); |
387 | o_Click->addGeometry(P); |
387 | o_Click->addGeometry(P); |
388 | 388 | ||
389 | // Target anzeigen |
389 | // Target anzeigen |
390 | o_Click->removeGeometry(Target); |
390 | o_Click->removeGeometry(Target); |
391 | 391 | ||
392 | Target = new ImagePoint( HandlerMK::Int2Double(t_NaviData.TargetPosition.Longitude, 7), HandlerMK::Int2Double(t_NaviData.TargetPosition.Latitude, 7), ":/Flags/Global/Images/Flags/Target.png", "Start"); |
392 | Target = new ImagePoint( HandlerMK::Int2Double(t_NaviData.TargetPosition.Longitude, 7), HandlerMK::Int2Double(t_NaviData.TargetPosition.Latitude, 7), ":/Flags/Global/Images/Flags/Target.png", "Start"); |
393 | Target->setBaselevel(o_Adapter->adaptedZoom()); |
393 | Target->setBaselevel(o_Adapter->adaptedZoom()); |
394 | o_Click->addGeometry(Target); |
394 | o_Click->addGeometry(Target); |
395 | 395 | ||
396 | if (cb_CenterPos->isChecked()) |
396 | if (cb_CenterPos->isChecked()) |
397 | { |
397 | { |
398 | o_Map->setView(QPointF(WayPoint.Longitude, WayPoint.Latitude)); |
398 | o_Map->setView(QPointF(WayPoint.Longitude, WayPoint.Latitude)); |
399 | } |
399 | } |
400 | 400 | ||
401 | if (cb_ShowRoute->isChecked()) |
401 | if (cb_ShowRoute->isChecked()) |
402 | { |
402 | { |
403 | l_RouteFL = new LineString(p_RouteFL, "", Pen[1]); |
403 | l_RouteFL = new LineString(p_RouteFL, "", Pen[1]); |
404 | 404 | ||
405 | o_RouteFL->addGeometry(l_RouteFL); |
405 | o_RouteFL->addGeometry(l_RouteFL); |
406 | } |
406 | } |
407 | o_Map->updateRequestNew(); |
407 | o_Map->updateRequestNew(); |
408 | 408 | ||
409 | if (ac_Record->isChecked()) |
409 | if (ac_Record->isChecked()) |
410 | { |
410 | { |
411 | QTextStream Out(o_Record); |
411 | QTextStream Out(o_Record); |
412 | 412 | ||
413 | Out.setRealNumberPrecision(9); |
413 | Out.setRealNumberPrecision(9); |
414 | 414 | ||
415 | Out << WayPoint.Longitude << ", " << WayPoint.Latitude << ", " << WayPoint.Altitude << "\n"; |
415 | Out << WayPoint.Longitude << ", " << WayPoint.Latitude << ", " << WayPoint.Altitude << "\n"; |
416 | } |
416 | } |
417 | } |
417 | } |
418 | 418 | ||
419 | // Ein Ziel anfliegen. |
419 | // Ein Ziel anfliegen. |
420 | // TODO: Check auf Entfernung zur IST-Position. |
420 | // TODO: Check auf Entfernung zur IST-Position. |
421 | void dlg_Main::send_Target(Point *t_Target) |
421 | void dlg_Main::send_Target(Point *t_Target) |
422 | { |
422 | { |
423 | if (l_Track.count() > 0) |
423 | if (l_Track.count() > 0) |
424 | { |
424 | { |
425 | s_MK_WayPoint s_WayPoint; |
425 | s_MK_WayPoint s_WayPoint; |
426 | 426 | ||
427 | s_WayPoint.Position.Latitude = int32_t(t_Target->latitude() * 10000000+0.5); |
427 | s_WayPoint.Position.Latitude = int32_t(t_Target->latitude() * 10000000+0.5); |
428 | s_WayPoint.Position.Longitude = int32_t(t_Target->longitude() * 10000000+0.5); |
428 | s_WayPoint.Position.Longitude = int32_t(t_Target->longitude() * 10000000+0.5); |
429 | s_WayPoint.Position.Altitude = 0; |
429 | s_WayPoint.Position.Altitude = 0; |
430 | s_WayPoint.Position.Status = NEWDATA; |
430 | s_WayPoint.Position.Status = NEWDATA; |
431 | s_WayPoint.Heading = -1; |
431 | s_WayPoint.Heading = -1; |
432 | s_WayPoint.ToleranceRadius = 5; |
432 | s_WayPoint.ToleranceRadius = 5; |
433 | s_WayPoint.HoldTime = sb_Time->value(); |
433 | s_WayPoint.HoldTime = sb_Time->value(); |
434 | s_WayPoint.Event_Flag = 0; |
434 | s_WayPoint.Event_Flag = 0; |
- | 435 | s_WayPoint.Index = 1; |
|
435 | s_WayPoint.reserve[0] = 0; // reserve |
436 | s_WayPoint.reserve[0] = 0; // reserve |
436 | s_WayPoint.reserve[1] = 0; // reserve |
437 | s_WayPoint.reserve[1] = 0; // reserve |
437 | s_WayPoint.reserve[2] = 0; // reserve |
438 | s_WayPoint.reserve[2] = 0; // reserve |
438 | s_WayPoint.reserve[3] = 0; |
439 | s_WayPoint.reserve[3] = 0; |
439 | 440 | ||
440 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
441 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
441 | wg_Connection->send_Data(HandlerMK::make_Frame('s', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data()); |
442 | wg_Connection->send_Data(HandlerMK::make_Frame('s', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data()); |
442 | } |
443 | } |
443 | else |
444 | else |
444 | { |
445 | { |
445 | QMessageBox::warning(this, QA_NAME,tr("Es wurden noch keine aktuellen Positionsdaten vom Mikrokopter empfangen."), QMessageBox::Ok); |
446 | QMessageBox::warning(this, QA_NAME,tr("Es wurden noch keine aktuellen Positionsdaten vom Mikrokopter empfangen."), QMessageBox::Ok); |
446 | } |
447 | } |
447 | } |
448 | } |
448 | 449 | ||
449 | //Waypoint-Liste zum MK senden |
450 | //Waypoint-Liste zum MK senden |
450 | void dlg_Main::send_WayPoints(QList<sWayPoint> t_WayPoints, int t_Pos) |
451 | void dlg_Main::send_WayPoints(QList<sWayPoint> t_WayPoints, int t_Pos) |
451 | { |
452 | { |
452 | s_MK_WayPoint s_WayPoint; |
453 | s_MK_WayPoint s_WayPoint; |
453 | double Longitude, Latitude; |
454 | double Longitude, Latitude; |
454 | 455 | ||
455 | if (t_Pos == 0) |
456 | if (t_Pos == 0) |
456 | { // Waypoint-Liste löschen |
457 | { // Waypoint-Liste löschen |
457 | s_WayPoint.Position.Status = INVALID; |
458 | s_WayPoint.Position.Status = INVALID; |
458 | 459 | ||
459 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
460 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
460 | wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
461 | wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
461 | } |
462 | } |
462 | else |
463 | else |
463 | { |
464 | { |
464 | int z = t_Pos - 1; |
465 | int z = t_Pos - 1; |
465 | Longitude = t_WayPoints[z].Longitude; |
466 | Longitude = t_WayPoints[z].Longitude; |
466 | Latitude = t_WayPoints[z].Latitude; |
467 | Latitude = t_WayPoints[z].Latitude; |
467 | 468 | ||
468 | if (Longitude < 100) |
469 | if (Longitude < 100) |
469 | Longitude *= 10000000+0.5; |
470 | Longitude *= 10000000+0.5; |
470 | 471 | ||
471 | if (Latitude < 100) |
472 | if (Latitude < 100) |
472 | Latitude *= 10000000+0.5; |
473 | Latitude *= 10000000+0.5; |
473 | 474 | ||
474 | //fülle Wegpunkt-Daten |
475 | //fülle Wegpunkt-Daten |
475 | s_WayPoint.Position.Altitude = 0; |
476 | s_WayPoint.Position.Altitude = 0; |
476 | s_WayPoint.Position.Longitude = int32_t(Longitude); |
477 | s_WayPoint.Position.Longitude = int32_t(Longitude); |
477 | s_WayPoint.Position.Latitude = int32_t(Latitude); |
478 | s_WayPoint.Position.Latitude = int32_t(Latitude); |
478 | s_WayPoint.Position.Status = NEWDATA; |
479 | s_WayPoint.Position.Status = NEWDATA; |
479 | s_WayPoint.Heading = -1; |
480 | s_WayPoint.Heading = -1; |
480 | s_WayPoint.ToleranceRadius = 5; |
481 | s_WayPoint.ToleranceRadius = 5; |
481 | s_WayPoint.HoldTime = t_WayPoints[z].Time; |
482 | s_WayPoint.HoldTime = t_WayPoints[z].Time; |
482 | s_WayPoint.Event_Flag = 0; |
483 | s_WayPoint.Event_Flag = 0; |
- | 484 | s_WayPoint.Index = t_Pos; |
|
483 | s_WayPoint.reserve[0] = 0; // reserve |
485 | s_WayPoint.reserve[0] = 0; // reserve |
484 | s_WayPoint.reserve[1] = 0; // reserve |
486 | s_WayPoint.reserve[1] = 0; // reserve |
485 | s_WayPoint.reserve[2] = 0; // reserve |
487 | s_WayPoint.reserve[2] = 0; // reserve |
486 | s_WayPoint.reserve[3] = 0; // reserve |
488 | s_WayPoint.reserve[3] = 0; // reserve |
487 | 489 | ||
488 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
490 | memcpy((unsigned char *)&c_Data, (unsigned char *)&s_WayPoint, sizeof(s_WayPoint)); |
489 | wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
491 | wg_Connection->send_Data(HandlerMK::make_Frame('w', ADDRESS_NC, c_Data, sizeof(s_WayPoint)).toLatin1().data(), DATA_WRITE_WAYPOINT); |
490 | } |
492 | } |
491 | } |
493 | } |
492 | 494 | ||
493 | /////////// |
495 | /////////// |
494 | // Slots // |
496 | // Slots // |
495 | /////////// |
497 | /////////// |
496 | 498 | ||
497 | // About-Dialog |
499 | // About-Dialog |
498 | void dlg_Main::slot_ac_About() |
500 | void dlg_Main::slot_ac_About() |
499 | { |
501 | { |
500 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
502 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
501 | } |
503 | } |
502 | 504 | ||
503 | void dlg_Main::slot_ac_Toolbar() |
505 | void dlg_Main::slot_ac_Toolbar() |
504 | { |
506 | { |
505 | if (ac_Toolbar->isChecked()) |
507 | if (ac_Toolbar->isChecked()) |
506 | { |
508 | { |
507 | wg_Connection->set_ButtonVisible(false); |
509 | wg_Connection->set_ButtonVisible(false); |
508 | ToolBar->setVisible(true); |
510 | ToolBar->setVisible(true); |
509 | tb_More->setVisible(true); |
511 | tb_More->setVisible(true); |
510 | } |
512 | } |
511 | else |
513 | else |
512 | { |
514 | { |
513 | wg_Connection->set_ButtonVisible(true); |
515 | wg_Connection->set_ButtonVisible(true); |
514 | ToolBar->setVisible(false); |
516 | ToolBar->setVisible(false); |
515 | tb_More->setVisible(false); |
517 | tb_More->setVisible(false); |
516 | } |
518 | } |
517 | } |
519 | } |
518 | 520 | ||
519 | void dlg_Main::slot_ConnectionStatus(int li_Status) |
521 | void dlg_Main::slot_ConnectionStatus(int li_Status) |
520 | { |
522 | { |
521 | if (li_Status) |
523 | if (li_Status) |
522 | { |
524 | { |
523 | ac_Connect->setChecked(true); |
525 | ac_Connect->setChecked(true); |
524 | ac_Connect->setText(tr("Trennen")); |
526 | ac_Connect->setText(tr("Trennen")); |
525 | } |
527 | } |
526 | else |
528 | else |
527 | { |
529 | { |
528 | ac_Connect->setChecked(false); |
530 | ac_Connect->setChecked(false); |
529 | ac_Connect->setText(tr("Verbinden")); |
531 | ac_Connect->setText(tr("Verbinden")); |
530 | } |
532 | } |
531 | } |
533 | } |
532 | 534 | ||
533 | void dlg_Main::slot_MK_Version(s_Hardware ls_Version) |
535 | void dlg_Main::slot_MK_Version(s_Hardware ls_Version) |
534 | { |
536 | { |
535 | gs_Version = ls_Version; |
537 | gs_Version = ls_Version; |
536 | setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version); |
538 | setWindowTitle(QA_NAME + " " + QA_VERSION + " - " + ls_Version.Hardware + " " + ls_Version.Version); |
537 | } |
539 | } |
538 | 540 | ||
539 | void dlg_Main::slot_MK_NaviData(s_MK_NaviData ps_MK_NaviData) |
541 | void dlg_Main::slot_MK_NaviData(s_MK_NaviData ps_MK_NaviData) |
540 | { |
542 | { |
541 | QString Mode = "NC-Flags : "; |
543 | QString Mode = "NC-Flags : "; |
542 | if (ps_MK_NaviData.NCFlags & 0x08) {le_Mode->setText(tr("Range Limit")); Mode += "R";} |
544 | if (ps_MK_NaviData.NCFlags & 0x08) {le_Mode->setText(tr("Range Limit")); Mode += "R";} |
543 | if (ps_MK_NaviData.NCFlags & 0x10) {le_Mode->setText(tr("Serial Error")); Mode += "S";} |
545 | if (ps_MK_NaviData.NCFlags & 0x10) {le_Mode->setText(tr("Serial Error")); Mode += "S";} |
544 | if (ps_MK_NaviData.NCFlags & 0x20) {le_Mode->setText(tr("Target reached")); Mode += "T";} |
546 | if (ps_MK_NaviData.NCFlags & 0x20) {le_Mode->setText(tr("Target reached")); Mode += "T";} |
545 | if (ps_MK_NaviData.NCFlags & 0x40) {le_Mode->setText(tr("Manual Control")); Mode += "M";} |
547 | if (ps_MK_NaviData.NCFlags & 0x40) {le_Mode->setText(tr("Manual Control")); Mode += "M";} |
546 | if (ps_MK_NaviData.NCFlags & 0x01) {le_Mode->setText(tr("Free")); Mode += "F";} |
548 | if (ps_MK_NaviData.NCFlags & 0x01) {le_Mode->setText(tr("Free")); Mode += "F";} |
547 | if (ps_MK_NaviData.NCFlags & 0x02) {le_Mode->setText(tr("Position Hold")); Mode += "P";} |
549 | if (ps_MK_NaviData.NCFlags & 0x02) {le_Mode->setText(tr("Position Hold")); Mode += "P";} |
548 | if (ps_MK_NaviData.NCFlags & 0x04) {le_Mode->setText(tr("Coming Home")); Mode += "C";} |
550 | if (ps_MK_NaviData.NCFlags & 0x04) {le_Mode->setText(tr("Coming Home")); Mode += "C";} |
549 | 551 | ||
550 | le_WP->setText(QString("%1/").arg(ps_MK_NaviData.WaypointIndex) + QString("%1").arg(ps_MK_NaviData.WaypointNumber)); |
552 | le_WP->setText(QString("%1/").arg(ps_MK_NaviData.WaypointIndex) + QString("%1").arg(ps_MK_NaviData.WaypointNumber)); |
551 | le_WPTime->setText(QString("%1:").arg(ps_MK_NaviData.TargetHoldTime / 60) + (QString("%1").arg(ps_MK_NaviData.TargetHoldTime % 60)).rightJustified(2, '0')); |
553 | le_WPTime->setText(QString("%1:").arg(ps_MK_NaviData.TargetHoldTime / 60) + (QString("%1").arg(ps_MK_NaviData.TargetHoldTime % 60)).rightJustified(2, '0')); |
552 | le_WPDist->setText(QString("%1m").arg(ps_MK_NaviData.TargetPositionDeviation.Distance / 10)); |
554 | le_WPDist->setText(QString("%1m").arg(ps_MK_NaviData.TargetPositionDeviation.Distance / 10)); |
553 | le_HomeDist->setText(QString("%1m").arg(ps_MK_NaviData.HomePositionDeviation.Distance / 10)); |
555 | le_HomeDist->setText(QString("%1m").arg(ps_MK_NaviData.HomePositionDeviation.Distance / 10)); |
- | 556 | le_Sats->setText(QString("%1").arg(ps_MK_NaviData.SatsInUse)); |
|
554 | 557 | ||
555 | add_Position(ps_MK_NaviData); |
558 | add_Position(ps_MK_NaviData); |
556 | } |
559 | } |
557 | 560 | ||
558 | void dlg_Main::slot_MK_WayPoint(int pi_WayPointID) |
561 | void dlg_Main::slot_MK_WayPoint(int pi_WayPointID) |
559 | { |
562 | { |
560 | if (pi_WayPointID < l_WayPoints.count()) |
563 | if (pi_WayPointID < l_WayPoints.count()) |
561 | { |
564 | { |
562 | send_WayPoints(l_WayPoints, pi_WayPointID + 1); |
565 | send_WayPoints(l_WayPoints, pi_WayPointID + 1); |
563 | } |
566 | } |
564 | } |
567 | } |
565 | /////////////////////////////////////////////////////////////////// |
568 | /////////////////////////////////////////////////////////////////// |
566 | // QMK-Maps // |
569 | // QMK-Maps // |
567 | /////////////////////////////////////////////////////////////////// |
570 | /////////////////////////////////////////////////////////////////// |
568 | 571 | ||
569 | // Zoom der Karte ändern |
572 | // Zoom der Karte ändern |
570 | void dlg_Main::slot_Zoom(int t_Zoom) |
573 | void dlg_Main::slot_Zoom(int t_Zoom) |
571 | { |
574 | { |
572 | o_Map->setZoom(t_Zoom); |
575 | o_Map->setZoom(t_Zoom); |
573 | } |
576 | } |
574 | 577 | ||
575 | // Karte wechseln |
578 | // Karte wechseln |
576 | void dlg_Main::slot_ChangeMap(int t_Set) |
579 | void dlg_Main::slot_ChangeMap(int t_Set) |
577 | { |
580 | { |
578 | int zoom = o_Adapter->adaptedZoom(); |
581 | int zoom = o_Adapter->adaptedZoom(); |
579 | QPointF a = o_Map->currentCoordinate(); |
582 | QPointF a = o_Map->currentCoordinate(); |
580 | 583 | ||
581 | o_Map->setZoom(0); |
584 | o_Map->setZoom(0); |
582 | 585 | ||
583 | switch(t_Set) |
586 | switch(t_Set) |
584 | { |
587 | { |
585 | case 0 : // OpenStreetMap |
588 | case 0 : // OpenStreetMap |
586 | { |
589 | { |
587 | o_Adapter = new OSMMapAdapter(); |
590 | o_Adapter = new OSMMapAdapter(); |
588 | } |
591 | } |
589 | break; |
592 | break; |
590 | case 1 : // Yahoo Sat |
593 | case 1 : // Yahoo Sat |
591 | { |
594 | { |
592 | o_Adapter = new TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17); |
595 | o_Adapter = new TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17); |
593 | } |
596 | } |
594 | break; |
597 | break; |
595 | case 2 : // Google Maps |
598 | case 2 : // Google Maps |
596 | { |
599 | { |
597 | o_Adapter = new GoogleMapAdapter(); |
600 | o_Adapter = new GoogleMapAdapter(); |
598 | } |
601 | } |
599 | break; |
602 | break; |
600 | case 3 : // Google Sat |
603 | case 3 : // Google Sat |
601 | { |
604 | { |
602 | o_Adapter = new GoogleSatMapAdapter(); |
605 | o_Adapter = new GoogleSatMapAdapter(); |
603 | } |
606 | } |
604 | break; |
607 | break; |
605 | case 4 : // Yahoo Maps |
608 | case 4 : // Yahoo Maps |
606 | { |
609 | { |
607 | o_Adapter = new YahooMapAdapter(); |
610 | o_Adapter = new YahooMapAdapter(); |
608 | } |
611 | } |
609 | break; |
612 | break; |
610 | case 5 : // Yahoo Sat |
613 | case 5 : // Yahoo Sat |
611 | { |
614 | { |
612 | o_Adapter = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1"); |
615 | o_Adapter = new YahooMapAdapter("us.maps3.yimg.com", "/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1"); |
613 | } |
616 | } |
614 | break; |
617 | break; |
615 | } |
618 | } |
616 | 619 | ||
617 | o_Layer->setMapAdapter(o_Adapter); |
620 | o_Layer->setMapAdapter(o_Adapter); |
618 | o_Click->setMapAdapter(o_Adapter); |
621 | o_Click->setMapAdapter(o_Adapter); |
619 | o_Info->setMapAdapter(o_Adapter); |
622 | o_Info->setMapAdapter(o_Adapter); |
620 | o_RouteWP->setMapAdapter(o_Adapter); |
623 | o_RouteWP->setMapAdapter(o_Adapter); |
621 | o_RouteFL->setMapAdapter(o_Adapter); |
624 | o_RouteFL->setMapAdapter(o_Adapter); |
622 | 625 | ||
623 | o_Map->updateRequestNew(); |
626 | o_Map->updateRequestNew(); |
624 | o_Map->setZoom(zoom); |
627 | o_Map->setZoom(zoom); |
625 | } |
628 | } |
626 | 629 | ||
627 | // Click in die Karte |
630 | // Click in die Karte |
628 | void dlg_Main::slot_Click(const QMouseEvent* Event, const QPointF Coord) |
631 | void dlg_Main::slot_Click(const QMouseEvent* Event, const QPointF Coord) |
629 | { |
632 | { |
630 | if ((Event->type() == QEvent::MouseButtonPress) && ((Event->button() == Qt::RightButton) || (Event->button() == Qt::MidButton))) |
633 | if ((Event->type() == QEvent::MouseButtonPress) && ((Event->button() == Qt::RightButton) || (Event->button() == Qt::MidButton))) |
631 | { |
634 | { |
632 | sl_Zoom->setValue(o_Adapter->adaptedZoom()); |
635 | sl_Zoom->setValue(o_Adapter->adaptedZoom()); |
633 | } |
636 | } |
634 | 637 | ||
635 | // Überwachen ob Karte verschoben wird |
638 | // Überwachen ob Karte verschoben wird |
636 | if ((Event->type() == QEvent::MouseButtonPress) && (Event->button() == Qt::LeftButton)) |
639 | if ((Event->type() == QEvent::MouseButtonPress) && (Event->button() == Qt::LeftButton)) |
637 | { |
640 | { |
638 | MapCenter = o_Map->currentCoordinate(); |
641 | MapCenter = o_Map->currentCoordinate(); |
639 | } |
642 | } |
640 | 643 | ||
641 | // Nur wenn nicht Verschoben dann einen Punkt setzen |
644 | // Nur wenn nicht Verschoben dann einen Punkt setzen |
642 | if ((Event->type() == QEvent::MouseButtonRelease) && (Event->button() == Qt::LeftButton)) |
645 | if ((Event->type() == QEvent::MouseButtonRelease) && (Event->button() == Qt::LeftButton)) |
643 | { |
646 | { |
644 | if (o_Map->currentCoordinate() == MapCenter) |
647 | if (o_Map->currentCoordinate() == MapCenter) |
645 | { |
648 | { |
646 | if (l_WayPoints.count() < 20) |
649 | if (l_WayPoints.count() < 20) |
647 | { |
650 | { |
648 | btn_WPAdd->setEnabled(true); |
651 | btn_WPAdd->setEnabled(true); |
649 | } |
652 | } |
650 | 653 | ||
651 | o_Click->removeGeometry(ClickPoint); |
654 | o_Click->removeGeometry(ClickPoint); |
652 | 655 | ||
653 | ClickPoint = new CirclePoint(Coord.x(), Coord.y(), 6, "P1", Point::Middle, Pen[2]); |
656 | ClickPoint = new CirclePoint(Coord.x(), Coord.y(), 6, "P1", Point::Middle, Pen[2]); |
654 | 657 | ||
655 | 658 | ||
656 | LastClick = new Point(Coord.x(), Coord.y()); |
659 | LastClick = new Point(Coord.x(), Coord.y()); |
657 | 660 | ||
658 | ClickPoint->setBaselevel(o_Adapter->adaptedZoom()); |
661 | ClickPoint->setBaselevel(o_Adapter->adaptedZoom()); |
659 | o_Click->addGeometry(ClickPoint); |
662 | o_Click->addGeometry(ClickPoint); |
660 | 663 | ||
661 | // o_Click->removeGeometry(Flag); |
664 | // o_Click->removeGeometry(Flag); |
662 | // Flag = new ImagePoint(Coord.x(), Coord.y(), ":/Flags/Global/Images/Flags/Target.png", "Start"); |
665 | // Flag = new ImagePoint(Coord.x(), Coord.y(), ":/Flags/Global/Images/Flags/Target.png", "Start"); |
663 | // Flag->setBaselevel(o_Adapter->adaptedZoom()); |
666 | // Flag->setBaselevel(o_Adapter->adaptedZoom()); |
664 | // o_Click->addGeometry(Flag); |
667 | // o_Click->addGeometry(Flag); |
665 | 668 | ||
666 | 669 | ||
667 | if (cb_Goto->isChecked()) |
670 | if (cb_Goto->isChecked()) |
668 | { |
671 | { |
669 | send_Target(LastClick); |
672 | send_Target(LastClick); |
670 | } |
673 | } |
671 | } |
674 | } |
672 | } |
675 | } |
673 | 676 | ||
674 | o_Map->updateRequestNew(); |
677 | o_Map->updateRequestNew(); |
675 | // qDebug(QString("%1").arg(Coord.x()).toLatin1().data()); |
678 | // qDebug(QString("%1").arg(Coord.x()).toLatin1().data()); |
676 | // qDebug(QString("%1").arg(Coord.y()).toLatin1().data()); |
679 | // qDebug(QString("%1").arg(Coord.y()).toLatin1().data()); |
677 | } |
680 | } |
678 | 681 | ||
679 | // WayPoint zur Liste hinzufügen |
682 | // WayPoint zur Liste hinzufügen |
680 | void dlg_Main::slot_btn_WPAdd() |
683 | void dlg_Main::slot_btn_WPAdd() |
681 | { |
684 | { |
682 | cb_ShowWPs->setChecked(true); |
685 | cb_ShowWPs->setChecked(true); |
683 | 686 | ||
684 | sWayPoint WayPoint; |
687 | sWayPoint WayPoint; |
685 | 688 | ||
686 | WayPoint.Longitude = LastClick->longitude(); |
689 | WayPoint.Longitude = LastClick->longitude(); |
687 | WayPoint.Latitude = LastClick->latitude(); |
690 | WayPoint.Latitude = LastClick->latitude(); |
688 | WayPoint.Time = sb_Time->value(); |
691 | WayPoint.Time = sb_Time->value(); |
689 | 692 | ||
690 | l_WayPoints.append(WayPoint); |
693 | l_WayPoints.append(WayPoint); |
691 | 694 | ||
692 | o_RouteWP->removeGeometry(l_RouteWP); |
695 | o_RouteWP->removeGeometry(l_RouteWP); |
693 | 696 | ||
694 | p_RouteWP.append(LastClick); |
697 | p_RouteWP.append(LastClick); |
695 | l_RouteWP = new LineString(p_RouteWP, "", Pen[3]); |
698 | l_RouteWP = new LineString(p_RouteWP, "", Pen[3]); |
696 | 699 | ||
697 | o_RouteWP->addGeometry(l_RouteWP); |
700 | o_RouteWP->addGeometry(l_RouteWP); |
698 | o_Map->updateRequestNew(); |
701 | o_Map->updateRequestNew(); |
699 | 702 | ||
700 | btn_WPFly->setEnabled(true); |
703 | btn_WPFly->setEnabled(true); |
701 | 704 | ||
702 | if (l_WayPoints.count() == 20) |
705 | if (l_WayPoints.count() == 20) |
703 | { |
706 | { |
704 | QMessageBox::warning(this, QA_NAME,trUtf8("Wegpunkt-Liste ist voll. Es können maximal 20 Wegpunkte benutzt werden."), QMessageBox::Ok); |
707 | QMessageBox::warning(this, QA_NAME,trUtf8("Wegpunkt-Liste ist voll. Es können maximal 20 Wegpunkte benutzt werden."), QMessageBox::Ok); |
705 | btn_WPAdd->setEnabled(false); |
708 | btn_WPAdd->setEnabled(false); |
706 | } |
709 | } |
707 | } |
710 | } |
708 | 711 | ||
709 | // WayPoint-Liste übertragen |
712 | // WayPoint-Liste übertragen |
710 | void dlg_Main::slot_btn_WPFly() |
713 | void dlg_Main::slot_btn_WPFly() |
711 | { |
714 | { |
712 | send_WayPoints(l_WayPoints, 0); |
715 | send_WayPoints(l_WayPoints, 0); |
713 | } |
716 | } |
714 | 717 | ||
715 | // WayPpoint-Liste löschen |
718 | // WayPpoint-Liste löschen |
716 | void dlg_Main::slot_btn_WPDelete() |
719 | void dlg_Main::slot_btn_WPDelete() |
717 | { |
720 | { |
718 | p_RouteWP.clear(); |
721 | p_RouteWP.clear(); |
719 | l_WayPoints.clear(); |
722 | l_WayPoints.clear(); |
720 | o_RouteWP->clearGeometries(); |
723 | o_RouteWP->clearGeometries(); |
721 | l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
724 | l_RouteWP = new LineString(p_RouteWP, "", Pen[0]); |
722 | // o_RouteWP->addGeometry(l_RouteWP); |
725 | // o_RouteWP->addGeometry(l_RouteWP); |
723 | // o_RouteWP->removeGeometry(l_RouteWP); |
726 | // o_RouteWP->removeGeometry(l_RouteWP); |
724 | 727 | ||
725 | o_Map->updateRequestNew(); |
728 | o_Map->updateRequestNew(); |
726 | 729 | ||
727 | btn_WPFly->setEnabled(false); |
730 | btn_WPFly->setEnabled(false); |
728 | btn_WPAdd->setEnabled(true); |
731 | btn_WPAdd->setEnabled(true); |
729 | } |
732 | } |
730 | 733 | ||
731 | // WayPoint-Liste laden |
734 | // WayPoint-Liste laden |
732 | void dlg_Main::slot_ac_LoadWayPoints() |
735 | void dlg_Main::slot_ac_LoadWayPoints() |
733 | { |
736 | { |
734 | QString Filename = QFileDialog::getOpenFileName(this, "WayPoint-Route laden", s_Dir.WPRoutes, "Mikrokopter WayPoints(*.mkw);;KML-Datei(*.kml);;Alle Dateien (*)"); |
737 | QString Filename = QFileDialog::getOpenFileName(this, "WayPoint-Route laden", s_Dir.WPRoutes, "Mikrokopter WayPoints(*.mkw);;KML-Datei(*.kml);;Alle Dateien (*)"); |
735 | 738 | ||
736 | if (!Filename.isEmpty()) |
739 | if (!Filename.isEmpty()) |
737 | { |
740 | { |
738 | if (Filename.endsWith(".kml", Qt::CaseInsensitive)) |
741 | if (Filename.endsWith(".kml", Qt::CaseInsensitive)) |
739 | { |
742 | { |
740 | cb_ShowWPs->setChecked(true); |
743 | cb_ShowWPs->setChecked(true); |
741 | btn_WPFly->setEnabled(true); |
744 | btn_WPFly->setEnabled(true); |
742 | 745 | ||
743 | show_WayPoints(parse_WayPointKML(Filename)); |
746 | show_WayPoints(parse_WayPointKML(Filename)); |
744 | } |
747 | } |
745 | if (Filename.endsWith(".mkw", Qt::CaseInsensitive)) |
748 | if (Filename.endsWith(".mkw", Qt::CaseInsensitive)) |
746 | { |
749 | { |
747 | cb_ShowWPs->setChecked(true); |
750 | cb_ShowWPs->setChecked(true); |
748 | btn_WPFly->setEnabled(true); |
751 | btn_WPFly->setEnabled(true); |
749 | 752 | ||
750 | show_WayPoints(parse_WayPointMKW(Filename)); |
753 | show_WayPoints(parse_WayPointMKW(Filename)); |
751 | } |
754 | } |
752 | } |
755 | } |
753 | } |
756 | } |
754 | 757 | ||
755 | // WayPoint-Liste speichern |
758 | // WayPoint-Liste speichern |
756 | void dlg_Main::slot_ac_SaveRoute() |
759 | void dlg_Main::slot_ac_SaveRoute() |
757 | { |
760 | { |
758 | QString Filename = QFileDialog::getSaveFileName(this, "WayPoint-Route speichern", s_Dir.WPRoutes, "Mikrokopter WayPoints(*.mkw);;Alle Dateien (*)"); |
761 | QString Filename = QFileDialog::getSaveFileName(this, "WayPoint-Route speichern", s_Dir.WPRoutes, "Mikrokopter WayPoints(*.mkw);;Alle Dateien (*)"); |
759 | 762 | ||
760 | if (!Filename.isEmpty()) |
763 | if (!Filename.isEmpty()) |
761 | { |
764 | { |
762 | if (!(Filename.endsWith(".mkw", Qt::CaseInsensitive))) |
765 | if (!(Filename.endsWith(".mkw", Qt::CaseInsensitive))) |
763 | { |
766 | { |
764 | Filename = Filename + QString(".mkw"); |
767 | Filename = Filename + QString(".mkw"); |
765 | } |
768 | } |
766 | 769 | ||
767 | save_WayPointsMKW(Filename); |
770 | save_WayPointsMKW(Filename); |
768 | } |
771 | } |
769 | } |
772 | } |
770 | 773 | ||
771 | // Route anzeigen / ausblenden |
774 | // Route anzeigen / ausblenden |
772 | void dlg_Main::slot_ShowWayPoints(bool Show) |
775 | void dlg_Main::slot_ShowWayPoints(bool Show) |
773 | { |
776 | { |
774 | if (Show == true) |
777 | if (Show == true) |
775 | { |
778 | { |
776 | if (l_RouteWP->hasPoints()) |
779 | if (l_RouteWP->hasPoints()) |
777 | { |
780 | { |
778 | o_RouteWP->addGeometry(l_RouteWP); |
781 | o_RouteWP->addGeometry(l_RouteWP); |
779 | o_Map->updateRequestNew(); |
782 | o_Map->updateRequestNew(); |
780 | } |
783 | } |
781 | } |
784 | } |
782 | else |
785 | else |
783 | { |
786 | { |
784 | o_RouteWP->removeGeometry(l_RouteWP); |
787 | o_RouteWP->removeGeometry(l_RouteWP); |
785 | o_Map->updateRequestNew(); |
788 | o_Map->updateRequestNew(); |
786 | } |
789 | } |
787 | } |
790 | } |
788 | 791 | ||
789 | // Bilddatei als Karteladen. |
792 | // Bilddatei als Karteladen. |
790 | void dlg_Main::slot_ac_LoadMapPic() |
793 | void dlg_Main::slot_ac_LoadMapPic() |
791 | { |
794 | { |
792 | QString Filename = QFileDialog::getOpenFileName(this, "Bild als Karte", s_Dir.MapPics, "Bilddatei(*.jpg *.png *.gif);;Alle Dateien (*)"); |
795 | QString Filename = QFileDialog::getOpenFileName(this, "Bild als Karte", s_Dir.MapPics, "Bilddatei(*.jpg *.png *.gif);;Alle Dateien (*)"); |
793 | 796 | ||
794 | if (!Filename.isEmpty()) |
797 | if (!Filename.isEmpty()) |
795 | { |
798 | { |
796 | QFile *f_Points = new QFile(Filename + ".pos"); |
799 | QFile *f_Points = new QFile(Filename + ".pos"); |
797 | 800 | ||
798 | if (f_Points->exists()) |
801 | if (f_Points->exists()) |
799 | { |
802 | { |
800 | f_Points->open(QIODevice::ReadOnly | QIODevice::Text); |
803 | f_Points->open(QIODevice::ReadOnly | QIODevice::Text); |
801 | 804 | ||
802 | QString s_Points; |
805 | QString s_Points; |
803 | 806 | ||
804 | while (!f_Points->atEnd()) |
807 | while (!f_Points->atEnd()) |
805 | { |
808 | { |
806 | s_Points.append(f_Points->readLine()); |
809 | s_Points.append(f_Points->readLine()); |
807 | } |
810 | } |
808 | 811 | ||
809 | f_Points->close(); |
812 | f_Points->close(); |
810 | 813 | ||
811 | QStringList s_Pos = s_Points.split(","); |
814 | QStringList s_Pos = s_Points.split(","); |
812 | 815 | ||
813 | FixedImageOverlay* fip = new FixedImageOverlay(s_Pos[0].toDouble(), s_Pos[1].toDouble(), s_Pos[2].toDouble(), s_Pos[3].toDouble(), Filename); |
816 | FixedImageOverlay* fip = new FixedImageOverlay(s_Pos[0].toDouble(), s_Pos[1].toDouble(), s_Pos[2].toDouble(), s_Pos[3].toDouble(), Filename); |
814 | 817 | ||
815 | o_Layer->addGeometry(fip); |
818 | o_Layer->addGeometry(fip); |
816 | o_Map->setView(QPointF(((s_Pos[0].toDouble() + s_Pos[2].toDouble()) / 2),((s_Pos[1].toDouble() + s_Pos[3].toDouble()) / 2))); |
819 | o_Map->setView(QPointF(((s_Pos[0].toDouble() + s_Pos[2].toDouble()) / 2),((s_Pos[1].toDouble() + s_Pos[3].toDouble()) / 2))); |
817 | 820 | ||
818 | o_Map->updateRequestNew(); |
821 | o_Map->updateRequestNew(); |
819 | } |
822 | } |
820 | else |
823 | else |
821 | { |
824 | { |
822 | dlg_MapPos *f_MapPos = new dlg_MapPos(this); |
825 | dlg_MapPos *f_MapPos = new dlg_MapPos(this); |
823 | 826 | ||
824 | if (f_MapPos->exec()==QDialog::Accepted) |
827 | if (f_MapPos->exec()==QDialog::Accepted) |
825 | { |
828 | { |
826 | QString Data = f_MapPos->get_Data(); |
829 | QString Data = f_MapPos->get_Data(); |
827 | 830 | ||
828 | f_Points->open(QIODevice::ReadWrite | QIODevice::Text); |
831 | f_Points->open(QIODevice::ReadWrite | QIODevice::Text); |
829 | 832 | ||
830 | QTextStream out(f_Points); |
833 | QTextStream out(f_Points); |
831 | 834 | ||
832 | out.setRealNumberPrecision(9); |
835 | out.setRealNumberPrecision(9); |
833 | 836 | ||
834 | out << Data << "\n"; |
837 | out << Data << "\n"; |
835 | 838 | ||
836 | f_Points->close(); |
839 | f_Points->close(); |
837 | 840 | ||
838 | QStringList s_Pos = Data.split(","); |
841 | QStringList s_Pos = Data.split(","); |
839 | 842 | ||
840 | FixedImageOverlay* fip = new FixedImageOverlay(s_Pos[0].toDouble(), s_Pos[1].toDouble(), s_Pos[2].toDouble(), s_Pos[3].toDouble(), Filename); |
843 | FixedImageOverlay* fip = new FixedImageOverlay(s_Pos[0].toDouble(), s_Pos[1].toDouble(), s_Pos[2].toDouble(), s_Pos[3].toDouble(), Filename); |
841 | 844 | ||
842 | o_Layer->addGeometry(fip); |
845 | o_Layer->addGeometry(fip); |
843 | o_Map->updateRequestNew(); |
846 | o_Map->updateRequestNew(); |
844 | } |
847 | } |
845 | 848 | ||
846 | } |
849 | } |
847 | } |
850 | } |
848 | } |
851 | } |
849 | 852 | ||
850 | // Flug als KML aufzeichnen |
853 | // Flug als KML aufzeichnen |
851 | void dlg_Main::slot_ac_Record() |
854 | void dlg_Main::slot_ac_Record() |
852 | { |
855 | { |
853 | if (ac_Record->isChecked()) |
856 | if (ac_Record->isChecked()) |
854 | { |
857 | { |
855 | QString f_Name = s_Dir.Flights + "/" + QDate::currentDate().toString(("yyyy-MM-dd")) + "_" + QTime::currentTime().toString("hh-mm"); |
858 | QString f_Name = s_Dir.Flights + "/" + QDate::currentDate().toString(("yyyy-MM-dd")) + "_" + QTime::currentTime().toString("hh-mm"); |
856 | 859 | ||
857 | ac_Record->setText(tr("Stoppen")); |
860 | ac_Record->setText(tr("Stoppen")); |
858 | 861 | ||
859 | o_Record = new QFile(f_Name + ".kml"); |
862 | o_Record = new QFile(f_Name + ".kml"); |
860 | o_Record->open(QIODevice::Append | QIODevice::Text); |
863 | o_Record->open(QIODevice::Append | QIODevice::Text); |
861 | 864 | ||
862 | QTextStream Out(o_Record); |
865 | QTextStream Out(o_Record); |
863 | Out << HandlerKML::get_Header(tr("Mikrokopter Flugaufzeichnung")) << "\n"; |
866 | Out << HandlerKML::get_Header(tr("Mikrokopter Flugaufzeichnung")) << "\n"; |
864 | 867 | ||
865 | } |
868 | } |
866 | else |
869 | else |
867 | { |
870 | { |
868 | QTextStream Out(o_Record); |
871 | QTextStream Out(o_Record); |
869 | Out << HandlerKML::get_Footer() << "\n"; |
872 | Out << HandlerKML::get_Footer() << "\n"; |
870 | o_Record->close(); |
873 | o_Record->close(); |
871 | ac_Record->setText(tr("Aufzeichnen")); |
874 | ac_Record->setText(tr("Aufzeichnen")); |
872 | } |
875 | } |
873 | } |
876 | } |
874 | 877 | ||
875 | // WayPpoint-Liste löschen |
878 | // WayPpoint-Liste löschen |
876 | void dlg_Main::slot_ac_RouteDelete() |
879 | void dlg_Main::slot_ac_RouteDelete() |
877 | { |
880 | { |
878 | p_RouteFL.clear(); |
881 | p_RouteFL.clear(); |
879 | l_Track.clear(); |
882 | l_Track.clear(); |
880 | o_RouteFL->clearGeometries(); |
883 | o_RouteFL->clearGeometries(); |
881 | l_RouteFL = new LineString(p_RouteFL, "", Pen[0]); |
884 | l_RouteFL = new LineString(p_RouteFL, "", Pen[0]); |
882 | // o_RouteFL->removeGeometry(l_RouteFL); |
885 | // o_RouteFL->removeGeometry(l_RouteFL); |
883 | 886 | ||
884 | o_Map->updateRequestNew(); |
887 | o_Map->updateRequestNew(); |
885 | } |
888 | } |
886 | 889 | ||
887 | // Programm Ende |
890 | // Programm Ende |
888 | dlg_Main::~dlg_Main() |
891 | dlg_Main::~dlg_Main() |
889 | { |
892 | { |
890 | o_Settings->GUI.isMax = isMaximized(); |
893 | o_Settings->GUI.isMax = isMaximized(); |
891 | o_Settings->GUI.Size = size(); |
894 | o_Settings->GUI.Size = size(); |
892 | o_Settings->GUI.Point = pos(); |
895 | o_Settings->GUI.Point = pos(); |
893 | o_Settings->GUI.Toolbar = ac_Toolbar->isChecked(); |
896 | o_Settings->GUI.Toolbar = ac_Toolbar->isChecked(); |
894 | 897 | ||
895 | o_Settings->CONFIG.cb_CenterPos = cb_CenterPos->isChecked(); |
898 | o_Settings->CONFIG.cb_CenterPos = cb_CenterPos->isChecked(); |
896 | o_Settings->CONFIG.cb_ShowRoute = cb_ShowRoute->isChecked(); |
899 | o_Settings->CONFIG.cb_ShowRoute = cb_ShowRoute->isChecked(); |
897 | o_Settings->CONFIG.cb_ShowWPs = cb_ShowWPs->isChecked(); |
900 | o_Settings->CONFIG.cb_ShowWPs = cb_ShowWPs->isChecked(); |
898 | o_Settings->CONFIG.cb_Goto = cb_Goto->isChecked(); |
901 | o_Settings->CONFIG.cb_Goto = cb_Goto->isChecked(); |
899 | 902 | ||
900 | o_Settings->NAVI.StayTime = sb_Time->value(); |
903 | o_Settings->NAVI.StayTime = sb_Time->value(); |
901 | 904 | ||
902 | o_Settings->write_Settings(); |
905 | o_Settings->write_Settings(); |
903 | 906 | ||
904 | // qDebug("Ende."); |
907 | // qDebug("Ende."); |
905 | } |
908 | } |
906 | 909 |