Horizon
3d_view.hpp
1 #pragma once
2 #include "util/window_state_store.hpp"
3 #include "common/common.hpp"
4 #include "util/changeable.hpp"
5 #include "util/uuid.hpp"
6 #include "imp/action.hpp"
7 #include <gtkmm.h>
8 #include <set>
9 
10 namespace horizon {
11 class View3DWindow : public Gtk::Window, public Changeable {
12 public:
13  enum class Mode { BOARD, PACKAGE };
14  View3DWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const class Board &b, class IPool &p,
15  Mode mode, class Canvas3D *ca_custom);
16  static View3DWindow *create(const class Board &b, class IPool &p, Mode mode, class Canvas3D *ca_custom = nullptr);
17  void update(bool clear = false);
18  void set_needs_update();
19  void set_highlights(const std::set<UUID> &pkgs);
20  void add_widget(Gtk::Widget *w);
21 
22  void set_solder_mask_color(const Gdk::RGBA &c);
23  Gdk::RGBA get_solder_mask_color();
24 
25  void set_silkscreen_color(const Gdk::RGBA &c);
26  Gdk::RGBA get_silkscreen_color();
27 
28  void set_substrate_color(const Gdk::RGBA &c);
29  Gdk::RGBA get_substrate_color();
30 
31  class Canvas3D &get_canvas()
32  {
33  return *canvas;
34  }
35 
36  void apply_preferences(const class Preferences &prefs);
37 
38  typedef sigc::signal<void> type_signal_request_update;
39  type_signal_request_update signal_request_update()
40  {
41  return s_signal_request_update;
42  }
43  type_signal_request_update signal_present_imp()
44  {
45  return s_signal_present_imp;
46  }
47 
48  typedef sigc::signal<void, UUID> type_signal_package_select;
49  type_signal_package_select signal_package_select();
50 
51  void set_3d_title(const std::string &s);
52 
53 private:
54  class Canvas3D *canvas = nullptr;
55  const class Board &board;
56  class IPool &pool;
57  bool needs_update = true;
58  const Mode mode;
59  Gtk::Box *main_box = nullptr;
60 
61  Gtk::Button *update_button = nullptr;
62 
63  Gtk::Revealer *loading_revealer = nullptr;
64  Gtk::Spinner *loading_spinner = nullptr;
65 
66  Gtk::ProgressBar *model_loading_progress = nullptr;
67  Gtk::Box *model_loading_box = nullptr;
68  Gtk::ProgressBar *layer_loading_progress = nullptr;
69  Gtk::Box *layer_loading_box = nullptr;
70 
71  size_t model_loading_i = 0;
72  size_t model_loading_n = 0;
73  size_t layer_loading_i = 0;
74  size_t layer_loading_n = 0;
75 
76  void update_loading();
77 
78  Gtk::ColorButton *background_top_color_button = nullptr;
79  Gtk::ColorButton *background_bottom_color_button = nullptr;
80  Gtk::ColorButton *solder_mask_color_button = nullptr;
81  Gtk::ColorButton *silkscreen_color_button = nullptr;
82  Gtk::ColorButton *substrate_color_button = nullptr;
83  Gtk::ComboBoxText *background_color_preset_combo = nullptr;
84  bool setting_background_color_from_preset = false;
85 
86  Gtk::RadioButton *proj_persp_rb = nullptr;
87  Gtk::RadioButton *proj_ortho_rb = nullptr;
88 
89  Gtk::Revealer *hud_revealer = nullptr;
90  Gtk::Label *hud_label = nullptr;
91  void hud_set_package(const UUID &uu);
92 
93  using FnSetColor = void (Canvas3D::*)(const Color &color);
94  void bind_color_button(Gtk::ColorButton *color_button, FnSetColor fn_set, std::function<void(void)> extra_fn);
95 
96  WindowStateStore state_store;
97 
98  std::map<ActionID, ActionConnection> action_connections;
99  ActionConnection &connect_action(ActionID action_id, std::function<void(const ActionConnection &)> cb);
100  bool handle_action_key(const GdkEventKey *ev);
101  KeySequence keys_current;
102  void trigger_action(ActionID action);
103 
104  void handle_pan_action(const ActionConnection &c);
105  void handle_zoom_action(const ActionConnection &c);
106  void handle_rotate_action(const ActionConnection &c);
107  void handle_view_action(const ActionConnection &c);
108  void handle_proj_action(const ActionConnection &c);
109 
110  type_signal_request_update s_signal_request_update;
111  type_signal_request_update s_signal_present_imp;
112 
113  class MSDTuningWindow *msd_tuning_window = nullptr;
114 
115  std::vector<ActionID> spnav_buttons;
116 };
117 } // namespace horizon
Definition: action.hpp:87
Definition: board.hpp:47
Definition: canvas3d.hpp:19
Definition: changeable.hpp:5
Definition: common.hpp:278
Definition: ipool.hpp:14
Definition: msd_tuning_window.hpp:7
Definition: preferences.hpp:164
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: 3d_view.hpp:11
Definition: window_state_store.hpp:25