From 853d50a0fb1570c1d9a445fa6af399e691257042 Mon Sep 17 00:00:00 2001 From: Jeff Wheeler Date: Sun, 16 Jun 2024 23:50:33 -0700 Subject: [PATCH] Identify the drill symbol inside a `T1CPad` instance --- src/brd_gui/brdview.cpp | 6 +++--- src/lib/printing/printers.cpp | 32 ++++++++++++++++++++++---------- src/lib/structure/types.cpp | 6 +++--- src/lib/structure/types.h | 14 ++++++++++---- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/brd_gui/brdview.cpp b/src/brd_gui/brdview.cpp index 5544381..bcd0a90 100644 --- a/src/brd_gui/brdview.cpp +++ b/src/brd_gui/brdview.cpp @@ -182,13 +182,13 @@ void BrdView::drawX0C(const T0CDrillIndicator *inst, QPen *pen) { int32_t w = inst->coords[2], h = inst->coords[3]; QPointF center = QPointF(inst->coords[0] / factor, inst->coords[1] / factor); - if (inst->backdrill_id != DrillSymbol::NoSymbol) { + if (inst->drill_chart_symbol != DrillSymbol::NoSymbol) { QTransform t = QTransform() .translate(center.x(), center.y()) .rotate(inst->rotation / 1000.); QGraphicsItem *item = nullptr; - if (inst->backdrill_id == DrillSymbol::Circle || - inst->backdrill_id == DrillSymbol::RoundedRect) { + if (inst->drill_chart_symbol == DrillSymbol::Circle || + inst->drill_chart_symbol == DrillSymbol::RoundedRect) { item = scene->addEllipse((-w / 2.) / factor, (-h / 2.) / factor, w / factor, h / factor, *pen); } else { diff --git a/src/lib/printing/printers.cpp b/src/lib/printing/printers.cpp index 44006df..68f663f 100644 --- a/src/lib/printing/printers.cpp +++ b/src/lib/printing/printers.cpp @@ -803,9 +803,9 @@ void print_x0C(const void *untyped_inst, File *fs, const int d) { T0CDrillIndicator inst = fs->get_x0C(k); printf_d(d, "x0C: t=0x%04X subtype=%02X layer=%d k=0x%08X " - "label=\x1b[34m\"%s\"\x1b[0m backdrill_id=%08X\n", + "label=\x1b[34m\"%s\"\x1b[0m drill_chart_symbol=%08X\n", ntohl(inst.t), inst.subtype, inst.layer, ntohl(inst.k), inst.label, - ntohl(inst.backdrill_id)); + ntohl(inst.drill_chart_symbol)); if constexpr (!std::is_same_v) { printf_d(d + 1, "un2=%08X un4=%08X\n", ntohl(inst.un2), ntohl(inst.un4)); } @@ -814,8 +814,8 @@ void print_x0C(const void *untyped_inst, File *fs, const int d) { } printf_d(d + 1, "un1={%08X %08X}, un5=%08X, un6=0x%08X\n", ntohl(inst.un1[0]), ntohl(inst.un1[1]), ntohl(inst.un5), ntohl(inst.un6)); - printf_d(d + 1, "\x1b[2m(%d, %d, %d, %d, %0.1f deg)\x1b[0m\n", inst.coords[0], - inst.coords[1], inst.coords[2], inst.coords[3], + printf_d(d + 1, "\x1b[2m(%d, %d, w=%d, h=%d, %0.1f deg)\x1b[0m\n", + inst.coords[0], inst.coords[1], inst.coords[2], inst.coords[3], inst.rotation / 1000.); printf_d(d + 1, "group_ptr:"); @@ -993,17 +993,22 @@ void print_x11(const void *untyped_inst, File *fs, const int d) { exit(0); } - printf_d(d + 1, "ptr3 \x1b[3m(matching footprint pin)\x1b[0m:\n"); - if (fs->is_type(inst->ptr3, 0x08)) { - print_struct(inst->ptr3, *fs, d + 2); + printf_d(d + 1, "ptr3 \x1b[3m(matching footprint pin)\x1b[0m:"); + if (inst->ptr3 == 0) { + printf(" \x1b[2mnull\x1b[0m\n"); } else { - printf_d(d + 2, "ptr3 unrecognized: 0x%08X\n", ntohl(inst->ptr3)); - exit(0); + std::printf("\n"); + if (fs->is_type(inst->ptr3, 0x08)) { + print_struct(inst->ptr3, *fs, d + 2); + } else { + printf_d(d + 2, "ptr3 unrecognized: 0x%08X\n", ntohl(inst->ptr3)); + exit(0); + } } if (inst->un != 0) { printf_d(d + 1, "expected un to be 0, but = %08X\n", ntohl(inst->un)); - exit(1); + // exit(1); } } @@ -1442,6 +1447,11 @@ void print_x1C(const void *untyped_inst, File *fs, const int d) { padtype(inst.pad_info.pad_type).c_str(), inst.pad_info.pad_type, inst.pad_info.a, inst.pad_info.b, inst.pad_info.c, inst.pad_info.d, ntohl(inst.pad_str), str_lookup(inst.pad_str, *fs)); + printf_d(d + 1, + "drill_chart_symbol=%08X label=\x1b[34m\"%s\"\x1b[0m (symbol_w=%d, " + "symbol_h=%d)\n", + ntohl(inst.drill_chart_symbol), inst.drill_label, inst.symbol_w, + inst.symbol_h); printf_d(d + 1, "layer_count=%d len(parts)=%d\n", inst.layer_count, inst.parts.size()); @@ -2443,6 +2453,7 @@ void print_x32(const void *untyped_inst, File *fs, const int d) { } } + /* printf_d(d + 1, "next:\n"); if (fs->is_type(inst.next, 0x32)) { print_struct(inst.next, *fs, d + 2); @@ -2454,6 +2465,7 @@ void print_x32(const void *untyped_inst, File *fs, const int d) { printf_d(d + 2, "next unrecognized: 0x%08X\n", ntohl(inst.next)); exit(0); } + */ printf_d(d + 1, "ptr3 \x1b[3m(placed symbol)\x1b[0m:\n"); if (fs->is_type(inst.ptr3, 0x2D)) { diff --git a/src/lib/structure/types.cpp b/src/lib/structure/types.cpp index 496a827..1ce6251 100644 --- a/src/lib/structure/types.cpp +++ b/src/lib/structure/types.cpp @@ -202,7 +202,7 @@ T0CDrillIndicator::operator T0CDrillIndicator() const { new_inst.next = this->next; new_inst.un1[0] = this->un1[0]; new_inst.un1[1] = this->un1[1]; - new_inst.backdrill_id = this->backdrill_id; + new_inst.drill_chart_symbol = this->drill_chart_symbol; new_inst.un2 = 0; for (uint8_t i = 0; i < 4; i++) { new_inst.label[i] = this->label[i]; @@ -227,7 +227,7 @@ T0CDrillIndicator::operator T0CDrillIndicator() const { new_inst.next = this->next; new_inst.un1[0] = this->un1[0]; new_inst.un1[1] = this->un1[1]; - new_inst.backdrill_id = this->backdrill_id; + new_inst.drill_chart_symbol = this->drill_chart_symbol; new_inst.un2 = this->un2; new_inst.un4 = this->un4; for (uint8_t i = 0; i < 4; i++) { @@ -253,7 +253,7 @@ T0CDrillIndicator::operator T0CDrillIndicator() const { new_inst.next = this->next; new_inst.un1[0] = this->un1[0]; new_inst.un1[1] = this->un1[1]; - new_inst.backdrill_id = this->backdrill_id; + new_inst.drill_chart_symbol = this->drill_chart_symbol; new_inst.un2 = this->un2; for (uint8_t i = 0; i < 4; i++) { new_inst.label[i] = this->label[i]; diff --git a/src/lib/structure/types.h b/src/lib/structure/types.h index bb106ed..5d724a8 100644 --- a/src/lib/structure/types.h +++ b/src/lib/structure/types.h @@ -458,7 +458,7 @@ struct T0ADRC { static constexpr AllegroVersion versions[2] = {kA172, kA174}; }; -enum DrillSymbol : uint8_t { +enum DrillSymbol : uint32_t { NoSymbol = 0, Circle = 0x02, RoundedRect = 0x0B, @@ -474,7 +474,7 @@ struct T0CDrillIndicator { uint32_t k; uint32_t next; uint32_t un1[2]; // Typically (always?) null - uint32_t backdrill_id; // Each backdrill depth (e.g. 12-6) gets its own ID + DrillSymbol drill_chart_symbol; char label[4]; COND_FIELD(version >= kA172, uint32_t, un2); COND_FIELD(version >= kA172, uint32_t, un4); @@ -825,8 +825,13 @@ struct T1CPad { COND_FIELD(version < kA172, uint16_t, un6); uint16_t layer_count; COND_FIELD(version >= kA172, uint16_t, un7); - uint32_t un8[7]; - COND_FIELD(version >= kA172, uint32_t[28], un9); + uint32_t un8[3]; + COND_FIELD(version >= kA172, uint32_t[8], un9); + uint32_t symbol_w; + uint32_t symbol_h; + DrillSymbol drill_chart_symbol; + char drill_label[4]; + COND_FIELD(version >= kA172, uint32_t[20], un11); COND_FIELD(version == kA165 || version == kA166, uint32_t[8], un10); uint32_t TAIL; @@ -844,6 +849,7 @@ static_assert(offsetof(T1CPad, layer_count) == 50); static_assert(offsetof(T1CPad, layer_count) == 44); static_assert(offsetof(T1CPad, pad_info) == 44); static_assert(offsetof(T1CPad, pad_info) == 28); +static_assert(offsetof(T1CPad, drill_label) == 104); template struct x1D {