Horizon
pool_notebook.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <memory>
4 #include "util/uuid.hpp"
5 #include "pool/part.hpp"
6 #include "pool/unit.hpp"
7 #include "pool/entity.hpp"
8 #include "pool/symbol.hpp"
9 #include "pool/package.hpp"
10 #include "pool/padstack.hpp"
11 
12 #include "pool/pool.hpp"
13 #include "pool/pool_parametric.hpp"
14 #include "util/editor_process.hpp"
15 #include "pool-update/pool-update.hpp"
16 #include <zmq.hpp>
17 #ifdef G_OS_WIN32
18 #undef ERROR
19 #undef DELETE
20 #undef DUPLICATE
21 #endif
22 
23 namespace horizon {
24 class PoolNotebook : public Gtk::Notebook {
25  friend class PoolRemoteBox;
26  friend class PoolGitBox;
27 
28 public:
29  PoolNotebook(const std::string &bp, class PoolProjectManagerAppWindow *aw);
30  void populate();
31  bool get_close_prohibited() const;
32  void prepare_close();
33  void pool_update(std::function<void()> cb = nullptr, const std::vector<std::string> &filenames = {});
34  bool get_needs_save() const;
35  void save();
36  void go_to(ObjectType type, const UUID &uu);
37  const UUID &get_pool_uuid() const;
38  ~PoolNotebook();
39 
40 private:
41  const std::string base_path;
42  Pool pool;
43  PoolParametric pool_parametric;
44  class PoolProjectManagerAppWindow *appwin;
45  std::map<ObjectType, class PoolBrowser *> browsers;
46  std::map<std::string, class PoolBrowserParametric *> browsers_parametric;
47  class PartWizard *part_wizard = nullptr;
48  class KiCadSymbolImportWizard *kicad_symbol_import_wizard = nullptr;
49  class DuplicateWindow *duplicate_window = nullptr;
50  bool closing = false;
51 
52  Glib::Dispatcher pool_update_dispatcher;
53  bool in_pool_update_handler = false;
54  std::mutex pool_update_status_queue_mutex;
55  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_status_queue;
56  std::deque<std::tuple<PoolUpdateStatus, std::string, std::string>> pool_update_error_queue;
57  bool pool_updating = false;
58  void pool_updated(bool success);
59  void reload();
60  std::string pool_update_last_file;
61  unsigned int pool_update_n_files = 0;
62  unsigned int pool_update_n_files_last = 0;
63  std::function<void()> pool_update_done_cb = nullptr;
64  std::vector<std::string> pool_update_filenames;
65 
66  void pool_update_thread();
67 
68  void show_duplicate_window(ObjectType ty, const UUID &uu);
69 
70  void construct_units();
71  void handle_create_unit();
72  void handle_edit_unit(const UUID &uu);
73  void handle_create_symbol_for_unit(const UUID &uu);
74  void handle_create_entity_for_unit(const UUID &uu);
75  void handle_duplicate_unit(const UUID &uu);
76 
77  void construct_symbols();
78  void handle_edit_symbol(const UUID &uu);
79  void handle_create_symbol();
80  void handle_duplicate_symbol(const UUID &uu);
81 
82  void construct_entities();
83  void handle_edit_entity(const UUID &uu);
84  void handle_create_entity();
85  void handle_duplicate_entity(const UUID &uu);
86 
87  void construct_padstacks();
88  void handle_edit_padstack(const UUID &uu);
89  void handle_create_padstack();
90  void handle_duplicate_padstack(const UUID &uu);
91 
92  void construct_packages();
93  void handle_edit_package(const UUID &uu);
94  void handle_create_package();
95  void handle_create_padstack_for_package(const UUID &uu);
96  void handle_duplicate_package(const UUID &uu);
97  void handle_part_wizard();
98  void handle_kicad_symbol_import_wizard();
99 
100  void construct_parts();
101  void handle_edit_part(const UUID &uu);
102  void handle_create_part();
103  void handle_create_part_from_part(const UUID &uu);
104  void handle_duplicate_part(const UUID &uu);
105 
106  void construct_frames();
107  void handle_edit_frame(const UUID &uu);
108  void handle_create_frame();
109  void handle_duplicate_frame(const UUID &uu);
110 
111  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, sigc::slot0<void>);
112  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, class PoolBrowser *br,
113  sigc::slot1<void, UUID>);
114  void add_preview_stack_switcher(Gtk::Box *bbox, Gtk::Stack *stack);
115 
116  void handle_delete(ObjectType ty, const UUID &uu);
117  void handle_copy_path(ObjectType ty, const UUID &uu);
118  void add_context_menu(class PoolBrowser *br);
119 
120  void install_search_once(Gtk::Widget *page, PoolBrowser *browser);
121  bool widget_is_visible(Gtk::Widget *widget);
122 
123  std::string remote_repo;
124  class PoolRemoteBox *remote_box = nullptr;
125  class PoolSettingsBox *settings_box = nullptr;
126  class PoolGitBox *git_box = nullptr;
127 
128  UUID pool_uuid;
129 };
130 } // namespace horizon
horizon::PoolRemoteBox
Definition: pool_remote_box.hpp:15
horizon::PoolBrowser
Definition: pool_browser.hpp:11
horizon::KiCadSymbolImportWizard
Definition: kicad_symbol_import_wizard.hpp:14
horizon::PoolNotebook
Definition: pool_notebook.hpp:24
horizon::PoolSettingsBox
Definition: pool_settings_box.hpp:13
horizon::DuplicateWindow
Definition: duplicate_window.hpp:7
horizon::PartWizard
Definition: part_wizard.hpp:16
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::PoolGitBox
Definition: pool_git_box.hpp:15
horizon::PoolParametric
Definition: pool_parametric.hpp:10
horizon::PoolProjectManagerAppWindow
Definition: pool-prj-mgr-app_win.hpp:25