MapApp.hpp 2.05 KB
Newer Older
Martin Kröning's avatar
Martin Kröning committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include "DrawableJunction.hpp"
#include "DrawableRoad.hpp"
#include "DrawableVehicle.hpp"
#include "MapArea.hpp"
#include "glibmm/refptr.h"
#include <chrono>
#include <gtkmm/window.h>
#include <map>
#include <string>
#include <thread>
#include <valarray>
#include <vector>
namespace Gtk {
class Application;
class ComboBoxText;
class Label;
class ListBox;
class ListBoxRow;
} // namespace Gtk

class MapApp {
public:
25
  MapApp(std::string windowTitle);
Martin Kröning's avatar
Martin Kröning committed
26
27
28
29
  virtual ~MapApp();
  void addJunction(double x, double y);
  void addRoad(std::string laneThereName, std::string laneBackName,
               std::vector<std::valarray<double>> coordinates);
30
  void addOrReplaceBicycle(const std::string &vehicleName,
Martin Kröning's avatar
Martin Kröning committed
31
                           const std::string &laneName, double positionOnLane,
32
33
34
35
                           double speed);
  void addOrReplaceCar(const std::string &vehicleName,
                       const std::string &laneName, double positionOnLane,
                       double speed, double remainingFuel);
Martin Kröning's avatar
Martin Kröning committed
36
37
38
39
  void setDurationLabel(std::chrono::minutes minutes);

private:
  static const std::vector<std::string> zoomLevels;
40
41
42
43
  void addOrReplaceVehicle(const std::string &vehicleName,
                           const std::string &laneName, double positionOnLane,
                           double speed, double remainingFuel, double red,
                           double green, double blue);
Martin Kröning's avatar
Martin Kröning committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  void onZoomEntryActivate();
  void onZoomSelectionChanged();
  void onVehicleRowSelected(Gtk::ListBoxRow *row);
  void refreshVehicleLabels(const DrawableVehicle &vehicle);
  void refreshArea(int x, int y, int width, int height);
  Glib::RefPtr<Gtk::Application> app;
  std::thread thread;
  MapArea mapArea;
  Gtk::Window win;
  Gtk::ListBox *listBox;
  Gtk::Label *durationLabel;
  Gtk::Label *laneLabel;
  Gtk::Label *lanePositionPercentageLabel;
  Gtk::Label *speedLabel;
  Gtk::Label *remainingFuelLabel;
  Gtk::ComboBoxText *zoomComboBoxText;
  std::vector<DrawableJunction> junctions;
  std::vector<DrawableRoad> roads;
  std::map<std::string, DrawableVehicle> nameVehicleMap;
};