Horizon
part_editor.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "common/common.hpp"
4 #include "pool/part.hpp"
5 #include "editor_interface.hpp"
6 
7 namespace horizon {
8 
9 class PartEditor : public Gtk::Box, public PoolEditorInterface {
10 public:
11  PartEditor(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, class Part &p, class IPool &po,
12  class PoolParametric &pp);
13  static PartEditor *create(class Part &p, class IPool &po, class PoolParametric &pp);
14  void reload() override;
15  void save() override;
16 
17  virtual ~PartEditor(){};
18 
19 private:
20  class Part &part;
21  class IPool &pool;
22  class PoolParametric &pool_parametric;
23 
24  class EntryWithInheritance *w_mpn = nullptr;
25  class EntryWithInheritance *w_value = nullptr;
26  class EntryWithInheritance *w_manufacturer = nullptr;
27  class EntryWithInheritance *w_description = nullptr;
28  class EntryWithInheritance *w_datasheet = nullptr;
29  std::map<Part::Attribute, class EntryWithInheritance *> attr_editors;
30 
31 
32  Gtk::Label *w_entity_label = nullptr;
33  Gtk::Label *w_package_label = nullptr;
34  Gtk::Label *w_base_label = nullptr;
35  Gtk::Button *w_change_package_button = nullptr;
36  Gtk::ComboBoxText *w_model_combo = nullptr;
37  Gtk::ToggleButton *w_model_inherit = nullptr;
38 
39  class TagEntry *w_tags = nullptr;
40  Gtk::Entry *w_tags_inherited = nullptr;
41  Gtk::ToggleButton *w_tags_inherit = nullptr;
42 
43  Gtk::TreeView *w_tv_pins = nullptr;
44  Gtk::TreeView *w_tv_pads = nullptr;
45  Gtk::Button *w_button_map = nullptr;
46  Gtk::Button *w_button_unmap = nullptr;
47  Gtk::Button *w_button_automap = nullptr;
48  Gtk::Button *w_button_select_pin = nullptr;
49  Gtk::Button *w_button_select_pads = nullptr;
50  Gtk::Button *w_button_copy_from_other = nullptr;
51  Gtk::Label *w_pin_stat = nullptr;
52  Gtk::Label *w_pad_stat = nullptr;
53 
54  Gtk::ComboBoxText *w_parametric_table_combo = nullptr;
55  Gtk::Box *w_parametric_box = nullptr;
56  Gtk::Button *w_parametric_from_base = nullptr;
57 
58  Gtk::Label *w_orderable_MPNs_label = nullptr;
59  Gtk::Button *w_orderable_MPNs_add_button = nullptr;
60  Gtk::Box *w_orderable_MPNs_box = nullptr;
61 
62  class PinListColumns : public Gtk::TreeModelColumnRecord {
63  public:
64  PinListColumns()
65  {
66  Gtk::TreeModelColumnRecord::add(gate_name);
67  Gtk::TreeModelColumnRecord::add(gate_uuid);
68  Gtk::TreeModelColumnRecord::add(pin_name);
69  Gtk::TreeModelColumnRecord::add(pin_uuid);
70  Gtk::TreeModelColumnRecord::add(mapped);
71  }
72  Gtk::TreeModelColumn<Glib::ustring> gate_name;
73  Gtk::TreeModelColumn<Glib::ustring> pin_name;
74  Gtk::TreeModelColumn<horizon::UUID> gate_uuid;
75  Gtk::TreeModelColumn<horizon::UUID> pin_uuid;
76  Gtk::TreeModelColumn<bool> mapped;
77  };
78  PinListColumns pin_list_columns;
79 
80  Glib::RefPtr<Gtk::ListStore> pin_store;
81 
82  class PadListColumns : public Gtk::TreeModelColumnRecord {
83  public:
84  PadListColumns()
85  {
86  Gtk::TreeModelColumnRecord::add(pad_name);
87  Gtk::TreeModelColumnRecord::add(pad_uuid);
88  Gtk::TreeModelColumnRecord::add(gate_name);
89  Gtk::TreeModelColumnRecord::add(gate_uuid);
90  Gtk::TreeModelColumnRecord::add(pin_name);
91  Gtk::TreeModelColumnRecord::add(pin_uuid);
92  }
93  Gtk::TreeModelColumn<Glib::ustring> pad_name;
94  Gtk::TreeModelColumn<horizon::UUID> pad_uuid;
95  Gtk::TreeModelColumn<Glib::ustring> gate_name;
96  Gtk::TreeModelColumn<Glib::ustring> pin_name;
97  Gtk::TreeModelColumn<horizon::UUID> gate_uuid;
98  Gtk::TreeModelColumn<horizon::UUID> pin_uuid;
99  };
100  PadListColumns pad_list_columns;
101 
102  Glib::RefPtr<Gtk::ListStore> pad_store;
103 
104  void update_orderable_MPNs_label();
105  void update_treeview();
106  void update_mapped();
107  void update_entries();
108  void change_package();
109  void populate_models();
110  void update_model_inherit();
111  void map_pin(Gtk::TreeModel::iterator it_pin);
112  void copy_from_other_part();
113  void update_map_buttons();
114 
115  class ParametricEditor *parametric_editor = nullptr;
116  void update_parametric_editor();
117  class OrderableMPNEditor *create_orderable_MPN_editor(const UUID &uu);
118 };
119 } // namespace horizon