MapApp.hpp 2.08 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);
36
  void setTimeLabel(std::chrono::minutes time);
Martin Kröning's avatar
Martin Kröning committed
37 38 39

private:
  static const std::vector<std::string> zoomLevels;
40 41
  static Glib::RefPtr<Gtk::Application> app;
  static std::thread thread;
42 43 44 45
  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
46 47 48 49 50
  void onZoomEntryActivate();
  void onZoomSelectionChanged();
  void onVehicleRowSelected(Gtk::ListBoxRow *row);
  void refreshVehicleLabels(const DrawableVehicle &vehicle);
  void refreshArea(int x, int y, int width, int height);
51
  void resizeWindow();
Martin Kröning's avatar
Martin Kröning committed
52 53 54
  MapArea mapArea;
  Gtk::Window win;
  Gtk::ListBox *listBox;
55
  Gtk::Label *timeLabel;
Martin Kröning's avatar
Martin Kröning committed
56 57 58 59 60 61 62 63 64
  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;
};