Skip to content

Commit 4f84530

Browse files
imp board: add display keepouts in outline mode by default
add option for filled display closes #622
1 parent 83797cf commit 4f84530

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

Diff for: Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ SRC_CANVAS = \
188188
src/canvas/bitmap_font_util.cpp\
189189
src/canvas/picture_renderer.cpp\
190190
src/util/warp_cursor.cpp\
191+
src/canvas/layer_display.cpp\
191192

192193
SRC_IMP = \
193194
src/imp/imp_main.cpp \

Diff for: src/canvas/layer_display.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "layer_display.hpp"
2+
#include "triangle.hpp"
3+
4+
namespace horizon {
5+
static const uint32_t types_visible_default = ~(1 << static_cast<uint32_t>(TriangleInfo::Type::KEEPOUT_FILL));
6+
7+
LayerDisplay::LayerDisplay() : types_visible(types_visible_default)
8+
{
9+
}
10+
11+
LayerDisplay::LayerDisplay(bool vi, Mode mo) : visible(vi), mode(mo), types_visible(types_visible_default)
12+
{
13+
}
14+
} // namespace horizon

Diff for: src/canvas/layer_display.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ class LayerDisplay {
66
public:
77
// also used in shaders
88
enum class Mode { OUTLINE = 0, HATCH = 1, FILL = 2, FILL_ONLY = 3, DOTTED = 4, N_MODES };
9-
LayerDisplay(bool vi, Mode mo) : visible(vi), mode(mo)
10-
{
11-
}
12-
LayerDisplay()
13-
{
14-
}
9+
LayerDisplay(bool vi, Mode mo);
10+
LayerDisplay();
1511

1612
bool visible = true;
1713
Mode mode = Mode::FILL;

Diff for: src/canvas/render.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,9 @@ void Canvas::render(const Polygon &ipoly, bool interactive, ColorP co)
836836
object_ref_pop();
837837
}
838838
else { // normal polygon
839+
const bool is_keepout = dynamic_cast<Keepout *>(poly.usage.ptr);
839840
begin_group(poly.layer);
840-
if (poly_is_rect(poly)) {
841+
if (poly_is_rect(poly) && !is_keepout) {
841842
const Coordf p0 = (poly.get_vertex(0).position + poly.get_vertex(1).position) / 2;
842843
const Coordf p1 = (poly.get_vertex(2).position + poly.get_vertex(3).position) / 2;
843844
const float width = (poly.get_vertex(0).position - poly.get_vertex(1).position).magd();
@@ -860,13 +861,20 @@ void Canvas::render(const Polygon &ipoly, bool interactive, ColorP co)
860861
TPPLPartition part;
861862
po.SetOrientation(TPPL_ORIENTATION_CCW);
862863
part.Triangulate_EC(&po, &outpolys);
864+
if (is_keepout) {
865+
assert(triangle_type_current == TriangleInfo::Type::NONE);
866+
triangle_type_current = TriangleInfo::Type::KEEPOUT_FILL;
867+
}
863868
for (auto &tri : outpolys) {
864869
assert(tri.GetNumPoints() == 3);
865870
Coordf p0 = transform.transform(coordf_from_pt(tri[0]));
866871
Coordf p1 = transform.transform(coordf_from_pt(tri[1]));
867872
Coordf p2 = transform.transform(coordf_from_pt(tri[2]));
868873
add_triangle(poly.layer, p0, p1, p2, co);
869874
}
875+
if (is_keepout) {
876+
triangle_type_current = TriangleInfo::Type::NONE;
877+
}
870878
for (size_t i = 0; i < poly.vertices.size(); i++) {
871879
draw_line(poly.vertices[i].position, poly.vertices[(i + 1) % poly.vertices.size()].position, co,
872880
poly.layer);

Diff for: src/canvas/triangle.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Triangle {
2626

2727
class TriangleInfo {
2828
public:
29-
enum class Type : uint8_t { NONE, TEXT, GRAPHICS, PLANE_FILL, PAD };
29+
enum class Type : uint8_t { NONE, TEXT, GRAPHICS, PLANE_FILL, KEEPOUT_FILL, PAD };
3030

3131
TriangleInfo(Type ty, uint8_t flg) : type(ty), flags(flg)
3232
{

Diff for: src/widgets/board_display_options.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,38 @@ class LayerOptionsCopper : public LayerOptionsExp {
103103
{
104104
cb_planes_outline = add_checkbutton("Don't fill planes");
105105
cb_planes_outline->signal_toggled().connect(sigc::mem_fun(*this, &LayerOptionsCopper::emit));
106+
107+
cb_keepouts_outline = add_checkbutton("Don't fill keepouts");
108+
cb_keepouts_outline->set_active(true);
109+
cb_keepouts_outline->signal_toggled().connect(sigc::mem_fun(*this, &LayerOptionsCopper::emit));
106110
}
107111

108112
json serialize() override
109113
{
110114
json j;
111115
j["planes_outline"] = cb_planes_outline->get_active();
116+
j["keepouts_outline"] = cb_keepouts_outline->get_active();
112117
return j;
113118
}
114119

115120
virtual void load_from_json(const json &j) override
116121
{
117-
if (j.count("planes_outline"))
118-
cb_planes_outline->set_active(j.at("planes_outline").get<bool>());
122+
cb_planes_outline->set_active(j.value("planes_outline", false));
123+
cb_keepouts_outline->set_active(j.value("keepouts_outline", true));
119124
}
120125

121126
private:
122127
Gtk::CheckButton *cb_planes_outline = nullptr;
128+
Gtk::CheckButton *cb_keepouts_outline = nullptr;
123129
void emit()
124130
{
125131
LayerDisplay ld;
126132
if (cb_planes_outline->get_active()) {
127133
ld.types_visible &= ~(1 << static_cast<int>(TriangleInfo::Type::PLANE_FILL));
128134
}
135+
if (!cb_keepouts_outline->get_active()) {
136+
ld.types_visible |= (1 << static_cast<int>(TriangleInfo::Type::KEEPOUT_FILL));
137+
}
129138
emit_layer_display(ld);
130139
}
131140
};

0 commit comments

Comments
 (0)