Horizon
Loading...
Searching...
No Matches
part_editor.hpp
1#pragma once
2#include <gtkmm.h>
3#include "common/common.hpp"
4#include "pool/part.hpp"
5#include "editor_base.hpp"
6#include "widgets/generic_combo_box.hpp"
7#include "pool/part.hpp"
8
9namespace horizon {
10
11class PartEditor : public Gtk::Box, public PoolEditorBase {
12public:
13 PartEditor(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const std::string &filename,
14 class IPool &po, class PoolParametric &pp);
15 static PartEditor *create(const std::string &filename, class IPool &po, class PoolParametric &pp);
16 void reload() override;
17
18 void save_as(const std::string &fn) override;
19 std::string get_name() const override;
20 const UUID &get_uuid() const override;
21 RulesCheckResult run_checks() const override;
22 const FileVersion &get_version() const override;
23 unsigned int get_required_version() const override;
24 ObjectType get_type() const override;
25
26 virtual ~PartEditor(){};
27
28private:
29 Part part;
30 class PoolParametric &pool_parametric;
31 void load();
32
33 class EntryWithInheritance *w_mpn = nullptr;
34 class EntryWithInheritance *w_value = nullptr;
35 class EntryWithInheritance *w_manufacturer = nullptr;
36 class EntryWithInheritance *w_description = nullptr;
37 class EntryWithInheritance *w_datasheet = nullptr;
38 std::map<Part::Attribute, class EntryWithInheritance *> attr_editors;
39
40
41 Gtk::Label *w_entity_label = nullptr;
42 Gtk::Label *w_package_label = nullptr;
43 Gtk::Label *w_base_label = nullptr;
44 Gtk::Button *w_change_package_button = nullptr;
45 Gtk::MenuItem *w_set_base_menu_item = nullptr;
46 Gtk::MenuItem *w_clear_base_menu_item = nullptr;
47 Gtk::MenuItem *w_create_base_menu_item = nullptr;
48 GenericComboBox<UUID> *w_model_combo = nullptr;
49 Gtk::ToggleButton *w_model_inherit = nullptr;
50
51 class TagEntry *w_tags = nullptr;
52 Gtk::Entry *w_tags_inherited = nullptr;
53 Gtk::ToggleButton *w_tags_inherit = nullptr;
54
55 Gtk::TreeView *w_tv_pins = nullptr;
56 Gtk::TreeView *w_tv_pads = nullptr;
57 Gtk::Button *w_button_map = nullptr;
58 Gtk::Button *w_button_unmap = nullptr;
59 Gtk::Button *w_button_automap = nullptr;
60 Gtk::Button *w_button_select_pin = nullptr;
61 Gtk::Button *w_button_select_pads = nullptr;
62 Gtk::Button *w_button_copy_from_other = nullptr;
63 Gtk::Label *w_pin_stat = nullptr;
64 Gtk::Label *w_pad_stat = nullptr;
65
66 Gtk::ComboBoxText *w_parametric_table_combo = nullptr;
67 Gtk::Box *w_parametric_box = nullptr;
68
69 Gtk::Label *w_orderable_MPNs_label = nullptr;
70 Gtk::Button *w_orderable_MPNs_add_button = nullptr;
71 Gtk::Box *w_orderable_MPNs_box = nullptr;
72
73 Gtk::Label *w_flags_label = nullptr;
74 Gtk::Grid *w_flags_grid = nullptr;
75
76 Gtk::RadioButton *w_override_prefix_inherit_button = nullptr;
77 Gtk::RadioButton *w_override_prefix_no_button = nullptr;
78 Gtk::RadioButton *w_override_prefix_yes_button = nullptr;
79 Gtk::Entry *w_override_prefix_entry = nullptr;
80 sigc::connection override_prefix_entry_connection;
81
82 class PinListColumns : public Gtk::TreeModelColumnRecord {
83 public:
84 PinListColumns()
85 {
86 Gtk::TreeModelColumnRecord::add(gate_name);
87 Gtk::TreeModelColumnRecord::add(gate_uuid);
88 Gtk::TreeModelColumnRecord::add(pin_name);
89 Gtk::TreeModelColumnRecord::add(pin_uuid);
90 Gtk::TreeModelColumnRecord::add(mapped);
91 }
92 Gtk::TreeModelColumn<Glib::ustring> gate_name;
93 Gtk::TreeModelColumn<Glib::ustring> pin_name;
94 Gtk::TreeModelColumn<horizon::UUID> gate_uuid;
95 Gtk::TreeModelColumn<horizon::UUID> pin_uuid;
96 Gtk::TreeModelColumn<bool> mapped;
97 };
98 PinListColumns pin_list_columns;
99
100 Glib::RefPtr<Gtk::ListStore> pin_store;
101
102 class PadListColumns : public Gtk::TreeModelColumnRecord {
103 public:
104 PadListColumns()
105 {
106 Gtk::TreeModelColumnRecord::add(pad_name);
107 Gtk::TreeModelColumnRecord::add(pad_uuid);
108 Gtk::TreeModelColumnRecord::add(gate_name);
109 Gtk::TreeModelColumnRecord::add(gate_uuid);
110 Gtk::TreeModelColumnRecord::add(pin_name);
111 Gtk::TreeModelColumnRecord::add(pin_uuid);
112 }
113 Gtk::TreeModelColumn<Glib::ustring> pad_name;
114 Gtk::TreeModelColumn<horizon::UUID> pad_uuid;
115 Gtk::TreeModelColumn<Glib::ustring> gate_name;
116 Gtk::TreeModelColumn<Glib::ustring> pin_name;
117 Gtk::TreeModelColumn<horizon::UUID> gate_uuid;
118 Gtk::TreeModelColumn<horizon::UUID> pin_uuid;
119 };
120 PadListColumns pad_list_columns;
121
122 Glib::RefPtr<Gtk::ListStore> pad_store;
123 void update_pad_map();
124
125 void update_orderable_MPNs_label();
126 void update_treeview();
127 void update_mapped();
128 void update_entries();
129 void change_package();
130 void set_package(std::shared_ptr<const Package> pkg);
131 void set_base(std::shared_ptr<const Part> part);
132 bool check_base(const UUID &new_base_uuid);
133 void change_base();
134 void clear_base();
135 void create_base();
136 void populate_models();
137 void update_model_inherit();
138 void map_pin(Gtk::TreeModel::iterator it_pin);
139 void copy_from_other_part();
140 void update_map_buttons();
141 void update_flags_label();
142 void update_prefix_entry();
143
144 std::map<Part::OverridePrefix, Gtk::RadioButton *> override_prefix_radio_buttons;
145
146 std::map<Part::Flag, class FlagEditor *> flag_editors;
147 class ParametricEditor *parametric_editor = nullptr;
148 void update_parametric_editor();
149 std::map<std::string, std::map<std::string, std::string>> parametric_data;
150 Glib::RefPtr<Gtk::SizeGroup> sg_parametric_label;
151
152 class OrderableMPNEditor *create_orderable_MPN_editor(const UUID &uu);
153
154 UUID pending_base_part;
155
156 std::unique_ptr<HistoryManager::HistoryItem> make_history_item(const std::string &comment) override;
157 void history_load(const HistoryManager::HistoryItem &it) override;
158};
159} // namespace horizon
Definition part_editor.cpp:21
Definition file_version.hpp:9
Definition generic_combo_box.hpp:5
Definition history_manager.hpp:10
Definition ipool.hpp:15
Definition part_editor.cpp:104
Definition parametric.hpp:11
Definition part_editor.hpp:11
Definition part.hpp:15
Definition editor_base.hpp:9
Definition pool_parametric.hpp:10
Definition rules.hpp:38
Definition tag_entry.hpp:9
This class encapsulates a UUID and allows it to be uses as a value type.
Definition uuid.hpp:16