MapWindowWrapper.cpp 1.77 KB
Newer Older
1 2 3
#include "MapWindowWrapper.hpp"
#include <pi2-view.h>
#include <string_view>
4
#include <type_traits>
5 6 7
#include <vector>

MapWindowWrapper::MapWindowWrapper(std::string_view windowTitle)
8 9
    : mapWindow(mapWindowCreate(windowTitle.data()),
                [](MapWindow *mapWindow) { mapWindowDestroy(mapWindow); }) {}
10 11

void MapWindowWrapper::addJunction(const double x, const double y) {
12
  mapWindowAddJunction(mapWindow.get(), x, y);
13 14 15 16 17
}

void MapWindowWrapper::addRoad(std::string_view laneThereName,
                               std::string_view laneBackName,
                               const std::vector<double> &coordinates) {
18
  mapWindowAddRoad(mapWindow.get(), laneThereName.data(), laneBackName.data(),
19 20 21 22 23 24 25
                   coordinates.data(), coordinates.size());
}

void MapWindowWrapper::addOrReplaceBicycle(std::string_view vehicleName,
                                           std::string_view laneName,
                                           const double positionOnLane,
                                           const double speed) {
26 27
  mapWindowAddOrReplaceBicycle(mapWindow.get(), vehicleName.data(),
                               laneName.data(), positionOnLane, speed);
28 29 30 31 32 33 34
}

void MapWindowWrapper::addOrReplaceCar(std::string_view vehicleName,
                                       std::string_view laneName,
                                       const double positionOnLane,
                                       const double speed,
                                       const double remainingFuel) {
35
  mapWindowAddOrReplaceCar(mapWindow.get(), vehicleName.data(), laneName.data(),
36 37 38 39
                           positionOnLane, speed, remainingFuel);
}

void MapWindowWrapper::setTimeLabel(const std::chrono::minutes time) {
40
  mapWindowSetTimeLabel(mapWindow.get(), time.count());
41
}