Horizon
Loading...
Searching...
No Matches
airwire_filter_window.hpp
1#pragma once
2#include <gtkmm.h>
3#include "util/uuid.hpp"
4#include "util/changeable.hpp"
5#include "common/common.hpp"
6#include <set>
7#include "nlohmann/json.hpp"
8
9namespace horizon {
10using json = nlohmann::json;
11
12class AirwireFilterWindow : public Gtk::Window, public Changeable {
13public:
14 static AirwireFilterWindow *create(Gtk::Window *p, const class Board &b);
15 AirwireFilterWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, const class Board &b);
16
17 void update_from_board();
18 void update_nets();
19 bool airwire_is_visible(const UUID &net) const;
20 bool get_filtered() const;
21 void set_all(bool v);
22 void set_only(const std::set<UUID> &nets);
23
24 typedef sigc::signal<void, std::set<UUID>> type_signal_selection_changed;
25 type_signal_selection_changed signal_selection_changed()
26 {
27 return s_signal_selection_changed;
28 }
29 const std::map<UUID, ColorI> &get_net_colors() const
30 {
31 return net_colors;
32 }
33
34 json serialize();
35 void load_from_json(const json &j);
36
37private:
38 const class Board &brd;
39 const class Block &block;
40 std::map<UUID, bool> airwires_visible;
41 std::map<UUID, ColorI> net_colors;
42
43 class ListColumns : public Gtk::TreeModelColumnRecord {
44 public:
45 ListColumns()
46 {
47 Gtk::TreeModelColumnRecord::add(net);
48 Gtk::TreeModelColumnRecord::add(net_name);
49 Gtk::TreeModelColumnRecord::add(net_class);
50 Gtk::TreeModelColumnRecord::add(net_class_name);
51 Gtk::TreeModelColumnRecord::add(airwires_visible);
52 Gtk::TreeModelColumnRecord::add(n_airwires);
53 Gtk::TreeModelColumnRecord::add(color);
54 }
55 Gtk::TreeModelColumn<UUID> net;
56 Gtk::TreeModelColumn<Glib::ustring> net_name;
57 Gtk::TreeModelColumn<UUID> net_class;
58 Gtk::TreeModelColumn<Glib::ustring> net_class_name;
59 Gtk::TreeModelColumn<bool> airwires_visible;
60 Gtk::TreeModelColumn<unsigned int> n_airwires;
61 Gtk::TreeModelColumn<Gdk::RGBA> color;
62 };
63 ListColumns list_columns;
64
65 Glib::RefPtr<Gtk::ListStore> store;
66 Glib::RefPtr<Gtk::TreeModelFilter> store_filtered;
67 Glib::RefPtr<Gtk::TreeModelSort> store_sorted;
68 Gtk::TreeView *treeview = nullptr;
69 Gtk::Button *all_on_button = nullptr;
70 Gtk::Button *all_off_button = nullptr;
71
72 Gtk::ToggleButton *search_button = nullptr;
73 Gtk::ToggleButton *airwires_button = nullptr;
74 Gtk::Revealer *search_revealer = nullptr;
75 Gtk::Revealer *airwires_revealer = nullptr;
76 Gtk::ComboBoxText *netclass_combo = nullptr;
77 UUID netclass_filter;
78
79 Gtk::SearchEntry *search_entry = nullptr;
80 std::optional<Glib::PatternSpec> search_spec;
81
82 Gtk::CheckButton *airwires_only_cb = nullptr;
83
84 Gtk::Menu context_menu;
85 enum class MenuOP { CHECK, UNCHECK, TOGGLE, SET_COLOR, CLEAR_COLOR };
86 void append_context_menu_item(const std::string &name, MenuOP op);
87
88 type_signal_selection_changed s_signal_selection_changed;
89};
90
91} // namespace horizon
Definition airwire_filter_window.hpp:12
A block is one level of hierarchy in the netlist.
Definition block.hpp:29
Definition board.hpp:47
Definition changeable.hpp:5
This class encapsulates a UUID and allows it to be uses as a value type.
Definition uuid.hpp:16
a class to store JSON values
Definition json.hpp:177
basic_json<> json
default JSON class
Definition json_fwd.hpp:62