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
10namespace horizon {
11
12namespace CSV {
13class Csv;
14}
15
16class PartWizard : public Gtk::Window {
17 friend class PadEditor;
18 friend class GateEditorWizard;
19
20public:
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,
25 std::vector<std::string> get_files_saved() const;
26 void reload();
27
29
30private:
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 class PreviewCanvas *canvas = nullptr;
44 Gtk::Allocation canvas_alloc;
45
46 Gtk::ListBox *pads_lb = nullptr;
47 Gtk::ToolButton *button_link_pads = nullptr;
48 Gtk::ToolButton *button_unlink_pads = nullptr;
49 Gtk::ToolButton *button_import_pads = nullptr;
50
51 Glib::RefPtr<Gtk::SizeGroup> sg_name;
52 Gtk::Box *page_assign = nullptr;
53 Gtk::Box *page_edit = nullptr;
54 Gtk::Box *edit_left_box = nullptr;
55
56 Gtk::Entry *entity_name_entry = nullptr;
57 Gtk::Button *entity_name_from_mpn_button = nullptr;
58 Gtk::Entry *entity_prefix_entry = nullptr;
59 class TagEntry *entity_tags_entry = nullptr;
60
61 Gtk::Entry *part_mpn_entry = nullptr;
62 Gtk::Entry *part_value_entry = nullptr;
63 Gtk::Entry *part_manufacturer_entry = nullptr;
64 Gtk::Entry *part_datasheet_entry = nullptr;
65 Gtk::Entry *part_description_entry = nullptr;
66 class TagEntry *part_tags_entry = nullptr;
67 Gtk::Button *part_autofill_button = nullptr;
68
69 class LocationEntry *entity_location_entry = nullptr;
70 class LocationEntry *part_location_entry = nullptr;
71
72 Gtk::Grid *steps_grid = nullptr;
73
74 Part part;
75 Entity entity;
76
77 class ListColumns : public Gtk::TreeModelColumnRecord {
78 public:
79 ListColumns()
80 {
81 Gtk::TreeModelColumnRecord::add(name);
82 }
83 Gtk::TreeModelColumn<Glib::ustring> name;
84 };
85 ListColumns list_columns;
86
87 Glib::RefPtr<Gtk::ListStore> gate_name_store;
88 void update_gate_names();
89 void update_pin_warnings();
90 std::map<std::pair<std::string, std::string>, std::set<class PadEditor *>> get_pin_names();
91 void handle_link();
92 void handle_unlink();
93 void handle_import();
94 void update_part();
95
96 class PadImportItem {
97 public:
98 std::string pin;
99 std::string gate = "Main";
100 struct AltName {
101 std::string name;
102 Pin::Direction direction = Pin::Direction::INPUT;
103 };
104 std::vector<AltName> alt;
105 Pin::Direction direction = Pin::Direction::INPUT;
106 };
107 void import_pads(const json &j);
108 void import_pads(CSV::Csv &csv);
109 void import_pads(const std::map<std::string, PadImportItem> &items);
110
111 void create_pad_editors();
112 void autolink_pads();
113 void link_pads(const std::deque<class PadEditor *> &eds);
114 bool frozen = false;
115
116 enum class Mode { PACKAGE, ASSIGN, EDIT };
117
118 void handle_next();
119 void handle_back();
120 void handle_finish();
121 void handle_select();
122 void finish();
123
124 std::string get_rel_part_filename();
125 void update_can_finish();
126 void autofill();
127 void update_steps();
128 bool valid = false;
129 bool mpn_valid = false;
130 bool part_filename_valid = false;
131 bool gates_valid = false;
132 std::vector<std::string> get_filenames();
133 std::vector<std::string> files_saved;
134
135 Mode mode = Mode::ASSIGN;
136 void set_mode(Mode mo);
137 void prepare_edit();
138 std::map<std::string, Unit> units;
139 std::map<UUID, UUID> symbols; // unit UUID -> symbol UUID
140 std::map<UUID, unsigned int> symbol_pins_mapped; // unit UUID -> pins mapped
141 void update_symbol_pins_mapped();
142
143 std::map<std::string, class PoolProjectManagerProcess *> processes;
144 std::set<UUID> symbols_open;
145
147
148 class LocationEntry *pack_location_entry(const Glib::RefPtr<Gtk::Builder> &x, const std::string &w,
149 Gtk::Button **button_other = nullptr);
150
151 WindowStateStore state_store;
152};
153} // namespace horizon
Definition: csv.hpp:30
Definition: entity.hpp:13
Definition: gate_editor.hpp:10
Definition: location_entry.hpp:6
Definition: package.hpp:29
Definition: pad_editor.hpp:9
Definition: part_wizard.hpp:16
Definition: part.hpp:14
Definition: pool_browser_package.hpp:5
Definition: pool-prj-mgr-app_win.hpp:22
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:22
Definition: preview_canvas.hpp:7
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:25
a class to store JSON values
Definition: json.hpp:177
Definition: part_wizard.hpp:100