Merge branch 'feature/step' into 'feature/Path'

Feature/step

See merge request p2406187/sae201!2
This commit is contained in:
LEBLOND MALO p2405951 2025-06-18 13:13:32 +00:00
commit 7722dde604
4 changed files with 64 additions and 2 deletions

View File

@ -3,11 +3,14 @@
#include "path.h"
#include <QApplication>
#include <step.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -11,11 +11,13 @@ CONFIG += c++17
SOURCES += \
main.cpp \
mainwindow.cpp \
path.cpp
step.cpp \
path.cpp \
HEADERS += \
mainwindow.h \
path.h
step.h \
path.h \
FORMS += \
mainwindow.ui

35
step.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "step.h"
Step::Step() {
latitude = 0.0;
longitude = 0.0;
response = 0;
}
Step::Step(QTextStream &in)
{
int stepNumber;
in >> stepNumber;
in.readLine();
title = in.readLine();
QChar latDir, lonDir;
int latDeg, lonDeg;
float latMin, lonMin;
in >> latDir >> latDeg >> latMin >> lonDir >> lonDeg >> lonMin;
setLatitude(latDeg, latMin, latDir);
setLongitude(lonDeg, lonMin, lonDir);
in >> response;
in.readLine();
}
void Step::setLatitude(int degree, float minute, QChar NS)
{
latitude = degree + minute / 60.0;
if (NS.toUpper() == 'S')
latitude = -latitude;
}
void Step::setLongitude(int degree, float minute, QChar EW)
{
longitude = degree + minute / 60.0;
if (EW.toUpper() == 'W')
longitude = -longitude;
}

22
step.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef STEP_H
#define STEP_H
#include <QString>
#include <QTextStream>
class Step
{
private:
QString title;
float latitude;
float longitude;
QString text;
int response;
public:
Step();
Step(QTextStream &in);
void setLatitude(int degree,float minute,QChar NS);
void setLongitude(int degree,float minute,QChar EW);
};
#endif // STEP_H