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 class PartWizard : public Gtk::Window {
13  friend class PadEditor;
14  friend class GateEditorWizard;
15 
16 public:
17  PartWizard(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const class Package *p,
18  const std::string &bp, class Pool *po);
19  static PartWizard *create(const class Package *p, const std::string &pool_base_path, class Pool *po);
20  bool get_has_finished() const;
21 
22  ~PartWizard();
23 
24 private:
25  const class Package *pkg;
26  std::string pool_base_path;
27  class Pool *pool;
28 
29  Gtk::Button *button_back = nullptr;
30  Gtk::Button *button_next = nullptr;
31  Gtk::Button *button_finish = nullptr;
32  Gtk::Stack *stack = nullptr;
33 
34  Gtk::ListBox *pads_lb = nullptr;
35  Gtk::ToolButton *button_link_pads = nullptr;
36  Gtk::ToolButton *button_unlink_pads = nullptr;
37  Gtk::ToolButton *button_import_pads = nullptr;
38 
39  Glib::RefPtr<Gtk::SizeGroup> sg_name;
40  Gtk::Box *page_assign = nullptr;
41  Gtk::Box *page_edit = nullptr;
42  Gtk::Box *edit_left_box = nullptr;
43 
44  Gtk::Entry *entity_name_entry = nullptr;
45  Gtk::Button *entity_name_from_mpn_button = nullptr;
46  Gtk::Entry *entity_prefix_entry = nullptr;
47  Gtk::Entry *entity_tags_entry = nullptr;
48 
49  Gtk::Entry *part_mpn_entry = nullptr;
50  Gtk::Entry *part_value_entry = nullptr;
51  Gtk::Entry *part_manufacturer_entry = nullptr;
52  Gtk::Entry *part_tags_entry = nullptr;
53  Gtk::Button *part_autofill_button = nullptr;
54 
55  class LocationEntry *entity_location_entry = nullptr;
56  class LocationEntry *part_location_entry = nullptr;
57 
58  Gtk::Grid *steps_grid = nullptr;
59 
60  Part part;
61  Entity entity;
62 
63  class ListColumns : public Gtk::TreeModelColumnRecord {
64  public:
65  ListColumns()
66  {
67  Gtk::TreeModelColumnRecord::add(name);
68  }
69  Gtk::TreeModelColumn<Glib::ustring> name;
70  };
71  ListColumns list_columns;
72 
73  Glib::RefPtr<Gtk::ListStore> gate_name_store;
74  void update_gate_names();
75  void update_pin_warnings();
76  std::map<std::pair<std::string, std::string>, std::set<class PadEditor *>> get_pin_names();
77  void handle_link();
78  void handle_unlink();
79  void handle_import();
80  void update_part();
81  void import_pads(const json &j);
82  void create_pad_editors();
83  void autolink_pads();
84  void link_pads(const std::deque<class PadEditor *> &eds);
85  bool frozen = true;
86 
87  enum class Mode { ASSIGN, EDIT };
88 
89  void handle_next();
90  void handle_back();
91  void handle_finish();
92  void finish();
93  bool has_finished = false;
94 
95  std::string get_rel_part_filename();
96  void update_can_finish();
97  void autofill();
98  void update_steps();
99  bool valid = false;
100  bool mpn_valid = false;
101  bool part_filename_valid = false;
102  bool gates_valid = false;
103  std::vector<std::string> get_filenames();
104 
105  Mode mode = Mode::ASSIGN;
106  void set_mode(Mode mo);
107  void prepare_edit();
108  std::map<std::string, Unit> units;
109  std::map<UUID, UUID> symbols;
110 
111  void spawn(PoolManagerProcess::Type type, const std::vector<std::string> &args);
112  std::map<std::string, PoolManagerProcess> processes;
113 
114  static class LocationEntry *pack_location_entry(const Glib::RefPtr<Gtk::Builder> &x, const std::string &w,
115  Gtk::Button **button_other = nullptr);
116 
117  WindowStateStore state_store;
118 };
119 } // namespace horizon
Definition: location_entry.hpp:6
a class to store JSON values
Definition: json.hpp:161
Definition: window_state_store.hpp:20
Definition: gate_editor.hpp:10
Definition: package.hpp:25
Definition: part_wizard.hpp:12
Definition: pad_editor.hpp:8
Definition: part.hpp:13
Definition: entity.hpp:13
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:18
Definition: block.cpp:7