2 #include "common/common.hpp"
3 #include "common/text.hpp"
4 #include "layer_display.hpp"
5 #include "selectables.hpp"
7 #include "triangle.hpp"
8 #include "object_ref.hpp"
9 #include "fragment_cache.hpp"
10 #include "util/placement.hpp"
11 #include "util/text_data.hpp"
12 #include "color_palette.hpp"
15 #include <unordered_map>
18 #include "picture.hpp"
19 #include "util/vector_pair.hpp"
24 friend class SelectionFilter;
25 friend class CanvasAnnotation;
33 void update(
const class Symbol &sym,
const Placement &transform = Placement(),
bool edit =
true);
34 void update(
const class Sheet &sheet);
35 void update(
const class Padstack &padstack,
bool edit =
true);
36 void update(
const class Package &pkg,
bool edit =
true);
37 void update(
const class Buffer &buf,
class LayerProvider *lp);
38 enum class PanelMode { INCLUDE, SKIP };
39 void update(
const class Board &brd, PanelMode mode = PanelMode::INCLUDE);
40 void update(
const class Frame &fr,
bool edit =
true);
41 void update(
const class Decal &dec,
bool edit =
true);
43 ObjectRef add_line(
const std::deque<Coordi> &pts,
int64_t width, ColorP color,
int layer);
44 void remove_obj(
const ObjectRef &r);
45 void hide_obj(
const ObjectRef &r);
46 void show_obj(
const ObjectRef &r);
47 void set_flags(
const ObjectRef &r,
uint8_t mask_set,
uint8_t mask_clear);
51 void set_color2(
const ObjectRef &r,
uint8_t color);
55 virtual void update_markers()
59 const LayerDisplay &get_layer_display(
int index)
const;
60 void set_layer_display(
int index,
const LayerDisplay &ld);
61 void set_layer_color(
int layer,
const Color &color);
63 bool layer_is_visible(
int layer)
const;
64 bool layer_is_visible(LayerRange layer)
const;
66 bool show_all_junctions_in_schematic =
false;
67 bool show_text_in_tracks =
false;
68 bool show_text_in_vias =
false;
70 virtual bool get_flip_view()
const
75 std::pair<Coordf, Coordf> get_bbox(
bool visible_only =
true)
const;
77 static const int first_overlay_layer = 30000;
80 std::map<int, vector_pair<Triangle, TriangleInfo>> triangles;
81 std::list<CanvasPicture> pictures;
82 void add_triangle(
int layer,
const Coordf &p0,
const Coordf &p1,
const Coordf &p2, ColorP co,
uint8_t flg = 0,
85 using ObjectRefIdx = std::map<int, std::pair<size_t, size_t>>;
86 std::unordered_map<ObjectRef, ObjectRefIdx> object_refs;
87 void begin_group(
int layer);
89 std::vector<ObjectRef> object_refs_current;
90 std::vector<ObjectRefIdx *> object_ref_idx;
91 void object_ref_push(
const ObjectRef &ref);
92 template <
typename... Args>
void object_ref_push(Args... args)
94 object_ref_push(ObjectRef(args...));
96 void object_ref_pop();
98 void render(
const class Symbol &sym,
bool on_sheet =
false,
bool smashed =
false, ColorP co = ColorP::FROM_LAYER);
99 void render(
const class Junction &junc,
bool interactive =
true, ObjectType mode = ObjectType::INVALID);
100 void render(
const class Line &line,
bool interactive =
true, ColorP co = ColorP::FROM_LAYER);
101 void render(
const class SymbolPin &pin,
bool interactive =
true, ColorP co = ColorP::FROM_LAYER);
102 void render(
const class Arc &arc,
bool interactive =
true, ColorP co = ColorP::FROM_LAYER);
103 void render(
const class Sheet &sheet);
104 void render(
const class SchematicSymbol &sym);
105 void render(
const class LineNet &line);
106 void render(
const class NetLabel &label);
107 void render(
const class BusLabel &label);
108 void render(
const class Warning &warn);
109 void render(
const class PowerSymbol &sym);
110 void render(
const class BusRipper &ripper);
111 void render(
const class Text &text,
bool interactive =
true, ColorP co = ColorP::FROM_LAYER);
112 void render(
const class Padstack &padstack,
bool interactive =
true);
113 void render(
const class Polygon &polygon,
bool interactive =
true, ColorP co = ColorP::FROM_LAYER);
114 void render(
const class Shape &shape,
bool interactive =
true);
115 void render(
const class Hole &hole,
bool interactive =
true);
116 void render(
const class Package &package,
bool interactive =
true,
bool smashed =
false,
117 bool omit_silkscreen =
false,
bool omit_outline =
false);
118 void render_pad_overlay(
const class Pad &pad);
119 void render(
const class Pad &pad);
120 void render(
const class Buffer &buf);
121 enum class OutlineMode { INCLUDE, OMIT };
122 void render(
const class Board &brd,
bool interactive =
true, PanelMode mode = PanelMode::INCLUDE,
123 OutlineMode outline_mode = OutlineMode::INCLUDE);
124 void render(
const class BoardPackage &pkg,
bool interactive =
true);
125 void render(
const class BoardHole &hole,
bool interactive =
true);
126 void render(
const class Track &track,
bool interactive =
true);
127 void render(
const class Via &via,
bool interactive =
true);
128 void render(
const class Dimension &dim);
129 void render(
const class Frame &frame,
bool on_sheet =
false);
130 void render(
const class ConnectionLine &line);
131 void render(
const class BoardPanel &panel);
132 void render(
const class Picture &pic);
133 void render(
const class Decal &decal,
bool interactive =
true);
134 void render(
const class BoardDecal &decal);
136 bool needs_push =
true;
137 virtual void request_push() = 0;
138 virtual void push() = 0;
140 void set_lod_size(
float size);
142 void draw_line(
const Coord<float> &a,
const Coord<float> &b, ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
143 bool tr =
true,
uint64_t width = 0);
144 void draw_cross(
const Coord<float> &o,
float size, ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
145 bool tr =
true,
uint64_t width = 0);
146 void draw_plus(
const Coord<float> &o,
float size, ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
147 bool tr =
true,
uint64_t width = 0);
148 void draw_box(
const Coord<float> &o,
float size, ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
149 bool tr =
true,
uint64_t width = 0);
150 void draw_arc(
const Coord<float> ¢er,
float radius,
float a0,
float a1, ColorP color = ColorP::FROM_LAYER,
151 int layer = 10000,
bool tr =
true,
uint64_t width = 0);
152 std::pair<Coordf, Coordf> draw_arc2(
const Coord<float> ¢er,
float radius0,
float a0,
float radius1,
float a1,
153 ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
bool tr =
true,
155 std::pair<Coordf, Coordf> draw_text0(
const Coordf &p,
float size,
const std::string &rtext,
int angle,
bool flip,
156 TextOrigin origin, ColorP color,
int layer = 10000,
uint64_t width = 0,
157 bool draw =
true, TextData::Font font = TextData::Font::SIMPLEX,
158 bool center =
false,
bool mirror =
false);
160 virtual void draw_bitmap_text(
const Coordf &p,
float scale,
const std::string &rtext,
int angle, ColorP color,
165 virtual std::pair<Coordf, Coordf> measure_bitmap_text(
const std::string &text)
const
167 return {{0, 0}, {0, 0}};
170 enum class TextBoxMode { FULL, LOWER, UPPER };
172 virtual void draw_bitmap_text_box(
const Placement &q,
float width,
float height,
const std::string &s, ColorP color,
173 int layer, TextBoxMode mode)
177 void draw_error(
const Coordf ¢er,
float scale,
const std::string &text,
bool tr =
true);
178 std::tuple<Coordf, Coordf, Coordi> draw_flag(
const Coordf &position,
const std::string &txt,
int64_t size,
179 Orientation orientation, ColorP color = ColorP::FROM_LAYER);
180 void draw_lock(
const Coordf ¢er,
float size, ColorP color = ColorP::FROM_LAYER,
int layer = 10000,
183 virtual void img_net(
const class Net *net)
186 virtual void img_polygon(
const Polygon &poly,
bool tr =
true)
189 virtual void img_padstack(
const Padstack &ps)
192 virtual void img_set_padstack(
bool v)
195 virtual void img_line(
const Coordi &p0,
const Coordi &p1,
const uint64_t width,
int layer = 10000,
bool tr =
true);
196 virtual void img_hole(
const Hole &hole)
199 virtual void img_patch_type(PatchType type)
202 virtual void img_text(
const Text &txt, std::pair<Coordf, Coordf> &extents)
205 virtual void img_draw_text(
const Coordf &p,
float size,
const std::string &rtext,
int angle,
bool flip,
206 TextOrigin origin,
int layer = 10000,
uint64_t width = 0,
207 TextData::Font font = TextData::Font::SIMPLEX,
bool center =
false,
bool mirror =
false)
210 bool img_mode =
false;
211 bool img_auto_line =
false;
214 void transform_save();
215 void transform_restore();
216 std::list<Placement> transforms;
218 Selectables selectables;
219 std::vector<Target> targets;
220 Target target_current;
222 const class LayerProvider *layer_provider =
nullptr;
223 std::map<int, Color> layer_colors;
224 Color get_layer_color(
int layer)
const;
226 std::map<int, LayerDisplay> layer_display;
228 UUID sheet_current_uuid;
230 TriangleInfo::Type triangle_type_current = TriangleInfo::Type::NONE;
232 std::map<std::pair<int, bool>,
int> overlay_layers;
233 int overlay_layer_current = first_overlay_layer;
234 int get_overlay_layer(
int layer,
bool ignore_flip =
false);
235 bool is_overlay_layer(
int overlay_layer,
int layer)
const;
237 FragmentCache fragment_cache;
243 vector_pair<Triangle, TriangleInfo> *group_tris =
nullptr;
244 size_t group_size = 0;