Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 361 → Rev 360

/QMK-Groundstation/trunk/Forms/dlg_Map.cpp
17,8 → 17,6
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "dlg_Map.h"
#include <QDomDocument>
#include <QFile>
 
dlg_Map::dlg_Map(QWidget *parent) : QDialog(parent)
{
46,13 → 44,7
connect(pb_Delete, SIGNAL(clicked()), this, SLOT(slot_DeleteWayPoints()));
connect(pb_Goto, SIGNAL(clicked()), this, SLOT(slot_GotoTarget()));
connect(pb_SendWaypoints, SIGNAL(clicked()), this, SLOT(slot_SendWayPoints()));
 
connect(pb_Load, SIGNAL(clicked()), this, SLOT(slot_LoadWayPoints()));
connect(pb_Save, SIGNAL(clicked()), this, SLOT(slot_SaveWayPoints()));
 
connect(cb_Maps, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_ChangeMap(int)));
connect(cb_ShowWPs, SIGNAL(toggled(bool)), this, SLOT(slot_ShowWayPoints(bool)));
 
connect(this, SIGNAL(rejected()), this, SLOT(slot_Close()));
 
o_Map = new MapControl(w_Map->size());
84,207 → 76,6
Pen[1]->setWidth(2);
}
 
QList<sWayPoint> dlg_Map::parse_WayPointKML(QString s_File)
{
QList<sWayPoint> tmp_WayPoints;
sWayPoint tmp_WayPoint;
 
QFile f_KML(s_File);
f_KML.open(QIODevice::ReadOnly | QIODevice::Text);
 
QByteArray s_KML;
 
while (!f_KML.atEnd())
{
s_KML.append(f_KML.readLine());
}
 
f_KML.close();
 
QDomDocument *UserXML;
UserXML = new QDomDocument;
 
UserXML->setContent(s_KML);
 
QDomElement Root = UserXML->firstChildElement("kml");
QDomElement Document = Root.firstChildElement("Document");
QDomElement Placemark = Document.firstChildElement("Placemark");
QDomElement Linestring = Placemark.firstChildElement("LineString");
 
QString Name = Placemark.firstChildElement("name").toElement().text();
 
QString Route = Linestring.firstChildElement("coordinates").toElement().text();
 
QStringList s_Points = Route.split(" ");
 
QStringList Position;
 
for (int z = 0; z < s_Points.count() - 1; z++)
{
if (z != 20)
{
Position = s_Points[z].split(",");
tmp_WayPoint.Longitude = Position[0].toDouble();
tmp_WayPoint.Latitude = Position[1].toDouble();
tmp_WayPoint.Altitude = Position[2].toDouble();
tmp_WayPoint.Time = sb_Time->value();
 
tmp_WayPoints.append(tmp_WayPoint);
}
else
{
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);
 
pb_Add->setEnabled(false);
 
z = s_Points.count();
}
}
return tmp_WayPoints;
}
 
QList<sWayPoint> dlg_Map::parse_WayPointMKW(QString s_File)
{
QList<sWayPoint> tmp_WayPoints;
sWayPoint tmp_WayPoint;
 
QFile f_MKW(s_File);
f_MKW.open(QIODevice::ReadOnly | QIODevice::Text);
 
QString s_MKW;
 
while (!f_MKW.atEnd())
{
s_MKW.append(f_MKW.readLine());
}
 
f_MKW.close();
 
QStringList s_Points = s_MKW.split(" ");
 
QStringList Position;
 
for (int z = 0; z < s_Points.count() - 1; z++)
{
if (z != 20)
{
Position = s_Points[z].split(",");
tmp_WayPoint.Longitude = Position[0].toDouble();
tmp_WayPoint.Latitude = Position[1].toDouble();
tmp_WayPoint.Altitude = Position[2].toDouble();
tmp_WayPoint.Time = Position[3].toInt();
 
tmp_WayPoints.append(tmp_WayPoint);
}
else
{
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);
 
pb_Add->setEnabled(false);
 
z = s_Points.count();
}
}
return tmp_WayPoints;
}
 
void dlg_Map::show_WayPoints(QList<sWayPoint> WayPoints)
{
Point* p_Point;
 
o_Route->removeGeometry(l_RouteWP);
p_RouteWP.clear();
l_WayPoints.clear();
 
l_WayPoints = WayPoints;
 
for (int z = 0; z < WayPoints.count(); z++)
{
p_Point = new Point(WayPoints[z].Longitude, WayPoints[z].Latitude);
 
p_RouteWP.append(p_Point);
}
 
l_RouteWP = new LineString(p_RouteWP, "", Pen[0]);
o_Route->addGeometry(l_RouteWP);
 
o_Map->setView(p_Point);
 
o_Map->updateRequestNew();
}
 
void dlg_Map::save_WayPointsMKW(QString s_File)
{
QFile *f_MKW = new QFile(s_File);
 
f_MKW->open(QIODevice::ReadWrite | QIODevice::Text);
 
QTextStream out(f_MKW);
 
out.setRealNumberPrecision(9);
 
for (int z = 0; z < l_WayPoints.count(); z++)
{
out << l_WayPoints[z].Longitude << "," << l_WayPoints[z].Latitude << "," << l_WayPoints[z].Altitude << "," << l_WayPoints[z].Time << " \n";
}
 
f_MKW->close();
}
 
void dlg_Map::slot_LoadWayPoints()
{
QString Filename = QFileDialog::getOpenFileName(this, "WayPoint-Route laden", o_Settings->DIR.Logging, "Mikrokopter WayPoints(*.mkw);;KML-Datei(*.kml);;Alle Dateien (*)");
 
if (!Filename.isEmpty())
{
if (Filename.endsWith(".kml", Qt::CaseInsensitive))
{
cb_ShowWPs->setChecked(true);
pb_SendWaypoints->setEnabled(true);
 
show_WayPoints(parse_WayPointKML(Filename));
}
if (Filename.endsWith(".mkw", Qt::CaseInsensitive))
{
cb_ShowWPs->setChecked(true);
pb_SendWaypoints->setEnabled(true);
 
show_WayPoints(parse_WayPointMKW(Filename));
}
}
}
 
void dlg_Map::slot_SaveWayPoints()
{
QString Filename = QFileDialog::getSaveFileName(this, "WayPoint-Route speichern", o_Settings->DIR.Logging, "Mikrokopter WayPoints(*.mkw);;Alle Dateien (*)");
 
if (!Filename.isEmpty())
{
if (!(Filename.endsWith(".mkw", Qt::CaseInsensitive)))
{
Filename = Filename + QString(".mkw");
}
 
save_WayPointsMKW(Filename);
}
}
 
void dlg_Map::slot_ShowWayPoints(bool Show)
{
if (Show == true)
{
qDebug("An");
o_Route->addGeometry(l_RouteWP);
o_Map->updateRequestNew();
}
else
{
qDebug("Aus");
o_Route->removeGeometry(l_RouteWP);
o_Map->updateRequestNew();
}
}
 
// Position zum Flug-Track hinzufügen
void dlg_Map::add_Position(double x, double y)
{
329,8 → 120,6
// Waypoint zur Liste hinzufügen
void dlg_Map::slot_AddWayPoint()
{
cb_ShowWPs->setChecked(true);
 
sWayPoint WayPoint;
 
WayPoint.Longitude = LastClick->longitude();
348,13 → 137,6
o_Map->updateRequestNew();
 
pb_SendWaypoints->setEnabled(true);
 
if (l_WayPoints.count() == 20)
{
QMessageBox::warning(this, QA_NAME,trUtf8("Wegpunkt-Liste ist voll. Es können maximal 20 Wegpunkte benutzt werden."), QMessageBox::Ok);
pb_Add->setEnabled(false);
}
 
}
 
// Waypoint-Liste löschen
364,8 → 146,6
p_RouteWP.clear();
l_WayPoints.clear();
o_Map->updateRequestNew();
 
pb_Add->setEnabled(pb_Goto->isEnabled());
}
 
void dlg_Map::slot_SendWayPoints()
404,15 → 184,13
{
if (o_Map->currentCoordinate() == MapCenter)
{
if (l_WayPoints.count() < 20)
{
pb_Add->setEnabled(true);
}
pb_Add->setEnabled(true);
pb_Goto->setEnabled(true);
 
o_Click->removeGeometry(ClickPoint);
 
ClickPoint = new CirclePoint(Coord.x(), Coord.y(), 6, "P1", Point::Middle, Pen[1]);
// LastPoint = P;
 
LastClick = new Point(Coord.x(), Coord.y());
 
/QMK-Groundstation/trunk/Forms/dlg_Map.h
67,13 → 67,6
QList<sWayPoint> l_WayPoints;
QList<sWayPoint> l_Track;
 
QList<sWayPoint> parse_WayPointKML(QString s_File);
QList<sWayPoint> parse_WayPointMKW(QString s_File);
 
void show_WayPoints(QList<sWayPoint> WayPoints);
 
void save_WayPointsMKW(QString s_File);
 
private slots:
void slot_Zoom(int t_Zoom);
void slot_ChangeMap(int);
82,14 → 75,10
void slot_AddWayPoint();
void slot_DeleteWayPoints();
void slot_SendWayPoints();
void slot_ShowWayPoints(bool);
 
void slot_GotoTarget();
void slot_Close();
 
void slot_LoadWayPoints();
void slot_SaveWayPoints();
 
protected:
virtual void resizeEvent ( QResizeEvent * event );
 
/QMK-Groundstation/trunk/Forms/dlg_Map.ui
7,7 → 7,7
<x>0</x>
<y>0</y>
<width>600</width>
<height>345</height>
<height>350</height>
</rect>
</property>
<property name="minimumSize">
35,20 → 35,7
</layout>
</widget>
</item>
<item row="0" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>2</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3" rowspan="6">
<item row="0" column="3" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
101,34 → 88,35
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<item row="6" column="0">
<widget class="QCheckBox" name="cb_ShowRoute">
<property name="text">
<string>Verweilzeit</string>
<string>geflogene
Route anzeigen</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="pb_Load">
<widget class="QCheckBox" name="cb_CenterPos">
<property name="text">
<string>Route laden</string>
<string>auf IST-Position
zentrieren</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QPushButton" name="pb_Save">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Route speichern</string>
<string>Verweilzeit</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
149,6 → 137,13
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Close">
<property name="text">
<string>Schließen</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
161,74 → 156,9
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_Close">
<property name="text">
<string>Schließen</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QFrame" name="More">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>428</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cb_ShowRoute">
<property name="text">
<string>geflogene
Route anzeigen</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="cb_ShowWPs">
<property name="text">
<string>ausgewählte
Route anzeigen</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="cb_CenterPos">
<property name="text">
<string>auf IST-Position
zentrieren</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="1">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
312,9 → 242,24
</item>
</layout>
</item>
<item row="0" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>2</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../MKTool.qrc"/>
</resources>
<connections>
<connection>
<sender>pb_Close</sender>
/QMK-Groundstation/trunk/Forms/dlg_Preferences.cpp
77,7 → 77,7
/////////////////////////////////
void dlg_Preferences::slot_DIR_CVS()
{
QString directory = QFileDialog::getExistingDirectory(this, trUtf8("Verzeichniss für Daten"), Settings->DIR.Logging, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);
QString directory = QFileDialog::getExistingDirectory(this, trUtf8("Verzeichniss für CSV-Logdateien"), Settings->DIR.Logging, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);
 
if ((!directory.isEmpty()) && (Settings->DIR.Logging != directory))
{
/QMK-Groundstation/trunk/Forms/dlg_Preferences.ui
131,7 → 131,7
<enum>QFrame::Box</enum>
</property>
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_4">
518,7 → 518,7
<item row="0" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Verzeichniss für Dateien (Datenrecorder, WayPoints ect.)</string>
<string>Verzeichniss für CVS-Dateien (Datenrecorder)</string>
</property>
</widget>
</item>
/QMK-Groundstation/trunk/global.h
56,7 → 56,7
static const int SLEEP = 500000;
 
static const QString QA_NAME = "QMK-Groundstation";
static const QString QA_VERSION_NR = "0.8.5";
static const QString QA_VERSION_NR = "0.8.2";
 
#ifdef _BETA_
static const QString QA_VERSION = QA_VERSION_NR + " (BETA)";
81,7 → 81,7
#endif
 
 
static const QString QA_DATE = "13.04.2009";
static const QString QA_DATE = "10.04.2009";
static const QString QA_YEAR = "2008-2009";
static const QString QA_AUTHOR = "Manuel Schrape";
static const QString QA_EMAIL = "manuel.schrape@gmx.de";
170,7 → 170,6
{
double Longitude;
double Latitude;
double Altitude;
int Time;
};
 
/QMK-Groundstation/trunk/global.pri
6,7 → 6,7
RCC_DIR = build/.rcc
DESTDIR = build/bin
 
QT *= gui core network xml
QT *= gui core network
 
CONFIG += warn_on thread qt