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