Horizon
Loading...
Searching...
No Matches
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 std::shared_ptr<const class Package> pkg;
32 void set_pkg(std::shared_ptr<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_pad;
52 Glib::RefPtr<Gtk::SizeGroup> sg_pin_name;
53 Glib::RefPtr<Gtk::SizeGroup> sg_direction;
54 Glib::RefPtr<Gtk::SizeGroup> sg_alt_names;
55 Glib::RefPtr<Gtk::SizeGroup> sg_gate;
56
57 Gtk::Box *page_assign = nullptr;
58 Gtk::Box *page_edit = nullptr;
59 Gtk::Box *edit_left_box = nullptr;
60
61 Gtk::Entry *entity_name_entry = nullptr;
62 Gtk::Button *entity_name_from_mpn_button = nullptr;
63 Gtk::Entry *entity_prefix_entry = nullptr;
64 class TagEntry *entity_tags_entry = nullptr;
65
66 Gtk::Entry *part_mpn_entry = nullptr;
67 Gtk::Entry *part_value_entry = nullptr;
68 Gtk::Entry *part_manufacturer_entry = nullptr;
69 Gtk::Entry *part_datasheet_entry = nullptr;
70 Gtk::Entry *part_description_entry = nullptr;
71 class TagEntry *part_tags_entry = nullptr;
72 Gtk::Button *part_autofill_button = nullptr;
73
74 class LocationEntry *entity_location_entry = nullptr;
75 class LocationEntry *part_location_entry = nullptr;
76
77 Gtk::Grid *steps_grid = nullptr;
78
79 Part part;
80 std::shared_ptr<Entity> entity;
81
82 class ListColumns : public Gtk::TreeModelColumnRecord {
83 public:
84 ListColumns()
85 {
86 Gtk::TreeModelColumnRecord::add(name);
87 }
88 Gtk::TreeModelColumn<Glib::ustring> name;
89 };
90 ListColumns list_columns;
91
92 Glib::RefPtr<Gtk::ListStore> gate_name_store;
93 void update_gate_names();
94 void update_pin_warnings();
95 std::map<std::pair<std::string, std::string>, std::set<class PadEditor *>> get_pin_names();
96 void handle_link();
97 void handle_unlink();
98 void handle_import();
99 void update_part();
100
101 class PadImportItem {
102 public:
103 std::string pin;
104 std::string gate = "Main";
105 struct AltName {
106 std::string name;
107 Pin::Direction direction = Pin::Direction::INPUT;
108 };
109 std::vector<AltName> alt;
110 Pin::Direction direction = Pin::Direction::INPUT;
111 };
112 void import_pads(const json &j);
113 void import_pads(CSV::Csv &csv);
114 void import_pads(const std::map<std::string, PadImportItem> &items);
115
116 void create_pad_editors();
117 void autolink_pads();
118 void link_pads(const std::deque<class PadEditor *> &eds);
119 bool frozen = false;
120
121 enum class Mode { PACKAGE, ASSIGN, EDIT };
122
123 void handle_next();
124 void handle_back();
125 void handle_finish();
126 void handle_select();
127 void finish();
128
129 std::string get_rel_part_filename();
130 void update_can_finish();
131 void autofill();
132 void update_steps();
133 bool valid = false;
134 bool mpn_valid = false;
135 bool part_filename_valid = false;
136 bool gates_valid = false;
137 std::vector<std::string> get_filenames();
138 std::vector<std::string> files_saved;
139
140 Mode mode = Mode::ASSIGN;
141 void set_mode(Mode mo);
142 void prepare_edit();
143 std::map<std::string, std::shared_ptr<Unit>> units;
144 std::map<UUID, UUID> symbols; // unit UUID -> symbol UUID
145 std::map<UUID, unsigned int> symbol_pins_mapped; // unit UUID -> pins mapped
146 void update_symbol_pins_mapped();
147
148 std::map<std::string, class PoolProjectManagerProcess *> processes;
149 std::set<UUID> symbols_open;
150
152
153 class LocationEntry *pack_location_entry(const Glib::RefPtr<Gtk::Builder> &x, const std::string &w,
154 Gtk::Button **button_other = nullptr);
155
156 WindowStateStore state_store;
157};
158} // namespace horizon
Definition csv.hpp:30
Definition gate_editor.hpp:10
Definition location_entry.hpp:6
Definition pad_editor.hpp:9
Definition part_wizard.hpp:16
Definition part.hpp:15
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:105