Horizon
bom_export_window.hpp
1 #pragma once
2 #include <array>
3 #include <gtkmm.h>
4 #include <set>
5 #include "util/window_state_store.hpp"
6 #include "block/bom.hpp"
7 #include "util/changeable.hpp"
8 #include "util/export_file_chooser.hpp"
9 #include "pool/pool_parametric.hpp"
10 
11 namespace horizon {
12 
13 class BOMExportWindow : public Gtk::Window, public Changeable {
14  friend class OrderableMPNSelector;
15 
16 public:
17  BOMExportWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, class Block *block,
18  class BOMExportSettings *settings, class Pool &pool, const std::string &project_dir);
19  static BOMExportWindow *create(Gtk::Window *p, class Block *block, class BOMExportSettings *settings,
20  class Pool &pool, const std::string &project_dir);
21 
22  void set_can_export(bool v);
23  void generate();
24  void update_preview();
25  void update_orderable_MPNs();
26  void update();
27 
28 private:
29  class Block *block;
30  class BOMExportSettings *settings;
31  class Pool &pool;
32  PoolParametric pool_parametric;
33 
34  void update_concrete_parts();
35 
36  class MyExportFileChooser : public ExportFileChooser {
37  protected:
38  void prepare_chooser(Glib::RefPtr<Gtk::FileChooser> chooser) override;
39  void prepare_filename(std::string &filename) override;
40  };
41  MyExportFileChooser export_filechooser;
42 
43  Gtk::Button *export_button = nullptr;
44  Gtk::ComboBoxText *sort_column_combo = nullptr;
45  Gtk::ComboBoxText *sort_order_combo = nullptr;
46  Gtk::Revealer *done_revealer = nullptr;
47  Gtk::Label *done_label = nullptr;
48  Gtk::Entry *filename_entry = nullptr;
49  Gtk::Button *filename_button = nullptr;
50  Gtk::ListBox *orderable_MPNs_listbox = nullptr;
51 
52  Glib::RefPtr<Gtk::SizeGroup> sg_manufacturer;
53  Glib::RefPtr<Gtk::SizeGroup> sg_MPN;
54  Glib::RefPtr<Gtk::SizeGroup> sg_orderable_MPN;
55 
56  Gtk::TreeView *meta_parts_tv = nullptr;
57  Gtk::Label *concrete_parts_label = nullptr;
58 
59  class MetaPartsListColumns : public Gtk::TreeModelColumnRecord {
60  public:
61  MetaPartsListColumns()
62  {
63  Gtk::TreeModelColumnRecord::add(MPN);
64  Gtk::TreeModelColumnRecord::add(value);
65  Gtk::TreeModelColumnRecord::add(manufacturer);
66  Gtk::TreeModelColumnRecord::add(qty);
67  Gtk::TreeModelColumnRecord::add(uuid);
68  Gtk::TreeModelColumnRecord::add(concrete_MPN);
69  Gtk::TreeModelColumnRecord::add(concrete_value);
70  Gtk::TreeModelColumnRecord::add(concrete_manufacturer);
71  }
72  Gtk::TreeModelColumn<Glib::ustring> MPN;
73  Gtk::TreeModelColumn<Glib::ustring> value;
74  Gtk::TreeModelColumn<Glib::ustring> manufacturer;
75  Gtk::TreeModelColumn<UUID> uuid;
76  Gtk::TreeModelColumn<unsigned int> qty;
77 
78  Gtk::TreeModelColumn<Glib::ustring> concrete_MPN;
79  Gtk::TreeModelColumn<Glib::ustring> concrete_value;
80  Gtk::TreeModelColumn<Glib::ustring> concrete_manufacturer;
81  };
82  MetaPartsListColumns meta_parts_list_columns;
83 
84  Glib::RefPtr<Gtk::ListStore> meta_parts_store;
85 
86  Gtk::Box *param_browser_box = nullptr;
87  Gtk::RadioButton *rb_tol_10 = nullptr;
88  Gtk::RadioButton *rb_tol_1 = nullptr;
89  Gtk::Button *button_clear_similar = nullptr;
90  Gtk::Button *button_set_similar = nullptr;
91  class PoolBrowserParametric *browser_param = nullptr;
92  UUID meta_part_current;
93  void update_meta_mapping();
94  void handle_set_similar();
95  void update_similar_button_sensitivity();
96 
97  class ListColumns : public Gtk::TreeModelColumnRecord {
98  public:
99  ListColumns()
100  {
101  Gtk::TreeModelColumnRecord::add(name);
102  Gtk::TreeModelColumnRecord::add(column);
103  }
104  Gtk::TreeModelColumn<BOMColumn> column;
105  Gtk::TreeModelColumn<Glib::ustring> name;
106  };
107  ListColumns list_columns;
108 
109  Glib::RefPtr<Gtk::ListStore> columns_store;
110  Glib::RefPtr<Gtk::TreeModelFilter> columns_available;
111 
112  Glib::RefPtr<Gtk::ListStore> columns_store_included;
113 
114  Gtk::TreeView *cols_available_tv = nullptr;
115  Gtk::TreeView *cols_included_tv = nullptr;
116  Gtk::TreeView *preview_tv = nullptr;
117 
118  Gtk::Button *col_inc_button = nullptr;
119  Gtk::Button *col_excl_button = nullptr;
120  Gtk::Button *col_up_button = nullptr;
121  Gtk::Button *col_down_button = nullptr;
122 
123  WindowStateStore state_store;
124 
125  void incl_excl_col(bool incl);
126  void up_down_col(bool up);
127  void update_incl_excl_sensitivity();
128  void update_cols_included();
129 
130  void flash(const std::string &s);
131  sigc::connection flash_connection;
132 
133  class ListColumnsPreview : public Gtk::TreeModelColumnRecord {
134  public:
135  ListColumnsPreview()
136  {
137  Gtk::TreeModelColumnRecord::add(row);
138  }
139  Gtk::TreeModelColumn<BOMRow> row;
140  };
141  ListColumnsPreview list_columns_preview;
142 
143  Glib::RefPtr<Gtk::ListStore> bom_store;
144 };
145 } // namespace horizon
horizon::PoolBrowserParametric
Definition: pool_browser_parametric.hpp:7
horizon::ExportFileChooser
Definition: export_file_chooser.hpp:7
horizon::OrderableMPNSelector
Definition: bom_export_window.cpp:377
horizon::BOMExportWindow
Definition: bom_export_window.hpp:13
horizon::WindowStateStore
Definition: window_state_store.hpp:20
horizon::Changeable
Definition: changeable.hpp:5
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::BOMExportSettings
Definition: bom_export_settings.hpp:11
horizon::PoolParametric
Definition: pool_parametric.hpp:10