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_highlights(const std::set<UUID> &pkgs);
19  void add_widget(Gtk::Widget *w);
20 
21  void set_solder_mask_color(const Gdk::RGBA &c);
22  Gdk::RGBA get_solder_mask_color();
23 
24  void set_silkscreen_color(const Gdk::RGBA &c);
25  Gdk::RGBA get_silkscreen_color();
26 
27  void set_substrate_color(const Gdk::RGBA &c);
28  Gdk::RGBA get_substrate_color();
29 
30  class Canvas3D &get_canvas()
31  {
32  return *canvas;
33  }
34 
35  void apply_preferences(const class Preferences &prefs);
36 
37  typedef sigc::signal<void> type_signal_request_update;
38  type_signal_request_update signal_request_update()
39  {
40  return s_signal_request_update;
41  }
42  type_signal_request_update signal_present_imp()
43  {
44  return s_signal_present_imp;
45  }
46 
47  typedef sigc::signal<void, UUID> type_signal_package_select;
48  type_signal_package_select signal_package_select();
49 
50 private:
51  class Canvas3D *canvas = nullptr;
52  const class Board &board;
53  class IPool &pool;
54  const Mode mode;
55  Gtk::Box *main_box = nullptr;
56  Gtk::Revealer *model_loading_revealer = nullptr;
57  Gtk::Spinner *model_loading_spinner = nullptr;
58  Gtk::ProgressBar *model_loading_progress = nullptr;
59 
60  Gtk::ColorButton *background_top_color_button = nullptr;
61  Gtk::ColorButton *background_bottom_color_button = nullptr;
62  Gtk::ColorButton *solder_mask_color_button = nullptr;
63  Gtk::ColorButton *silkscreen_color_button = nullptr;
64  Gtk::ColorButton *substrate_color_button = nullptr;
65  Gtk::ComboBoxText *background_color_preset_combo = nullptr;
66  bool setting_background_color_from_preset = false;
67 
68  Gtk::RadioButton *proj_persp_rb = nullptr;
69  Gtk::RadioButton *proj_ortho_rb = nullptr;
70 
71  Gtk::Revealer *hud_revealer = nullptr;
72  Gtk::Label *hud_label = nullptr;
73  void hud_set_package(const UUID &uu);
74 
75  using FnSetColor = void (Canvas3D::*)(const Color &color);
76  void bind_color_button(Gtk::ColorButton *color_button, FnSetColor fn_set, std::function<void(void)> extra_fn);
77 
78  WindowStateStore state_store;
79 
80  std::map<ActionID, ActionConnection> action_connections;
81  ActionConnection &connect_action(ActionID action_id, std::function<void(const ActionConnection &)> cb);
82  bool handle_action_key(const GdkEventKey *ev);
83  KeySequence keys_current;
84  void trigger_action(ActionID action);
85 
86  void handle_pan_action(const ActionConnection &c);
87  void handle_zoom_action(const ActionConnection &c);
88  void handle_rotate_action(const ActionConnection &c);
89  void handle_view_action(const ActionConnection &c);
90  void handle_proj_action(const ActionConnection &c);
91 
92  type_signal_request_update s_signal_request_update;
93  type_signal_request_update s_signal_present_imp;
94 };
95 } // namespace horizon
Definition: action.hpp:87
Definition: board.hpp:43
Definition: canvas3d.hpp:16
Definition: changeable.hpp:5
Definition: common.hpp:267
Definition: ipool.hpp:14
Definition: preferences.hpp:136
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