Horizon
part_wizard.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "common/common.hpp"
4 #include "pool/unit.hpp"
5 #include "pool/part.hpp"
6 #include "pool/entity.hpp"
7 #include "../pool_notebook.hpp" //for processes
8 #include "util/window_state_store.hpp"
9 
10 namespace horizon {
11 
12 namespace CSV {
13 class Csv;
14 }
15 
16 class PartWizard : public Gtk::Window {
17  friend class PadEditor;
18  friend class GateEditorWizard;
19 
20 public:
21  PartWizard(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const UUID &pkg_uuid,
22  const std::string &bp, class Pool &po, class PoolProjectManagerAppWindow *aw);
23  static PartWizard *create(const UUID &pkg_uuid, const std::string &pool_base_path, class Pool &po,
24  class PoolProjectManagerAppWindow *aw);
25  std::vector<std::string> get_files_saved() const;
26  void reload();
27 
28  ~PartWizard();
29 
30 private:
31  const class Package *pkg = nullptr;
32  void set_pkg(const Package *p);
33  std::string pool_base_path;
34  class Pool &pool;
35 
36  Gtk::HeaderBar *header = nullptr;
37  Gtk::Button *button_back = nullptr;
38  Gtk::Button *button_next = nullptr;
39  Gtk::Button *button_finish = nullptr;
40  Gtk::Button *button_select = nullptr;
41  Gtk::Stack *stack = nullptr;
42  class PoolBrowserPackage *browser_package = nullptr;
43 
44  Gtk::ListBox *pads_lb = nullptr;
45  Gtk::ToolButton *button_link_pads = nullptr;
46  Gtk::ToolButton *button_unlink_pads = nullptr;
47  Gtk::ToolButton *button_import_pads = nullptr;
48 
49  Glib::RefPtr<Gtk::SizeGroup> sg_name;
50  Gtk::Box *page_assign = nullptr;
51  Gtk::Box *page_edit = nullptr;
52  Gtk::Box *edit_left_box = nullptr;
53 
54  Gtk::Entry *entity_name_entry = nullptr;
55  Gtk::Button *entity_name_from_mpn_button = nullptr;
56  Gtk::Entry *entity_prefix_entry = nullptr;
57  class TagEntry *entity_tags_entry = nullptr;
58 
59  Gtk::Entry *part_mpn_entry = nullptr;
60  Gtk::Entry *part_value_entry = nullptr;
61  Gtk::Entry *part_manufacturer_entry = nullptr;
62  Gtk::Entry *part_datasheet_entry = nullptr;
63  Gtk::Entry *part_description_entry = nullptr;
64  class TagEntry *part_tags_entry = nullptr;
65  Gtk::Button *part_autofill_button = nullptr;
66 
67  class LocationEntry *entity_location_entry = nullptr;
68  class LocationEntry *part_location_entry = nullptr;
69 
70  Gtk::Grid *steps_grid = nullptr;
71 
72  Part part;
73  Entity entity;
74 
75  class ListColumns : public Gtk::TreeModelColumnRecord {
76  public:
77  ListColumns()
78  {
79  Gtk::TreeModelColumnRecord::add(name);
80  }
81  Gtk::TreeModelColumn<Glib::ustring> name;
82  };
83  ListColumns list_columns;
84 
85  Glib::RefPtr<Gtk::ListStore> gate_name_store;
86  void update_gate_names();
87  void update_pin_warnings();
88  std::map<std::pair<std::string, std::string>, std::set<class PadEditor *>> get_pin_names();
89  void handle_link();
90  void handle_unlink();
91  void handle_import();
92  void update_part();
93 
94  class PadImportItem {
95  public:
96  std::string pin;
97  std::string gate = "Main";
98  std::vector<std::string> alt;
99  Pin::Direction direction = Pin::Direction::INPUT;
100  };
101  void import_pads(const json &j);
102  void import_pads(CSV::Csv &csv);
103  void import_pads(const std::map<std::string, PadImportItem> &items);
104 
105  void create_pad_editors();
106  void autolink_pads();
107  void link_pads(const std::deque<class PadEditor *> &eds);
108  bool frozen = false;
109 
110  enum class Mode { PACKAGE, ASSIGN, EDIT };
111 
112  void handle_next();
113  void handle_back();
114  void handle_finish();
115  void handle_select();
116  void finish();
117 
118  std::string get_rel_part_filename();
119  void update_can_finish();
120  void autofill();
121  void update_steps();
122  bool valid = false;
123  bool mpn_valid = false;
124  bool part_filename_valid = false;
125  bool gates_valid = false;
126  std::vector<std::string> get_filenames();
127  std::vector<std::string> files_saved;
128 
129  Mode mode = Mode::ASSIGN;
130  void set_mode(Mode mo);
131  void prepare_edit();
132  std::map<std::string, Unit> units;
133  std::map<UUID, UUID> symbols; // unit UUID -> symbol UUID
134  std::map<UUID, unsigned int> symbol_pins_mapped; // unit UUID -> pins mapped
135  void update_symbol_pins_mapped();
136 
137  std::map<std::string, class PoolProjectManagerProcess *> processes;
138  std::set<UUID> symbols_open;
139 
141 
142  class LocationEntry *pack_location_entry(const Glib::RefPtr<Gtk::Builder> &x, const std::string &w,
143  Gtk::Button **button_other = nullptr);
144 
145  WindowStateStore state_store;
146 };
147 } // namespace horizon
Definition: csv.hpp:30
Definition: entity.hpp:14
Definition: gate_editor.hpp:10
Definition: location_entry.hpp:6
Definition: package.hpp:29
Definition: pad_editor.hpp:8
Definition: part_wizard.hpp:16
Definition: part.hpp:14
Definition: pool_browser_package.hpp:5
Definition: pool-prj-mgr-app_win.hpp:21
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:23
Definition: tag_entry.hpp:9
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: window_state_store.hpp:20
a class to store JSON values
Definition: json.hpp:166