diff --git a/src/brd_gui/brdview.cpp b/src/brd_gui/brdview.cpp index 2fbf445..c73a363 100644 --- a/src/brd_gui/brdview.cpp +++ b/src/brd_gui/brdview.cpp @@ -85,7 +85,7 @@ void BrdView::mouseReleaseEvent(QMouseEvent *event) { void BrdView::drawX01(const T01ArcSegment *inst, QPainterPath *path) { std::pair center = x01_center(inst); - double r = cfp_to_double(inst->r); + double r = static_cast(inst->r); /* scene->addEllipse( diff --git a/src/lib/printing/printers.cpp b/src/lib/printing/printers.cpp index e44a374..397bc14 100644 --- a/src/lib/printing/printers.cpp +++ b/src/lib/printing/printers.cpp @@ -194,7 +194,8 @@ void print_x01(const void *untyped_inst, File *fs, const int d) { " center=\x1b[2m(%.0f, %.0f)\x1b[0m" " r=%.0f width=%d\n", inst->bbox[0], inst->bbox[1], inst->bbox[2], inst->bbox[3], - center.first, center.second, cfp_to_double(inst->r), inst->width); + center.first, center.second, static_cast(inst->r), + inst->width); printf_d(d + 1, "next:\n"); if (fs->is_type(inst->next, 0x34)) { diff --git a/src/lib/structure/cadence_fp.cpp b/src/lib/structure/cadence_fp.cpp index 7c3c5fc..b686dfc 100644 --- a/src/lib/structure/cadence_fp.cpp +++ b/src/lib/structure/cadence_fp.cpp @@ -4,10 +4,8 @@ #include #include -auto cfp_to_double(CadenceDouble r) -> double { - CadenceDouble swapped; - swapped.x = r.y; - swapped.y = r.x; +CadenceDouble::operator double() const { + CadenceDouble swapped(this->y, this->x); double g; std::memcpy(&g, &swapped, 8); return g; diff --git a/src/lib/structure/cadence_fp.h b/src/lib/structure/cadence_fp.h index ea5e9e9..08ba9d9 100644 --- a/src/lib/structure/cadence_fp.h +++ b/src/lib/structure/cadence_fp.h @@ -9,10 +9,12 @@ * swap them. */ struct CadenceDouble { - uint32_t x; - uint32_t y; -}; + uint32_t x{}; + uint32_t y{}; -auto cfp_to_double(CadenceDouble r) -> double; + CadenceDouble() = default; + CadenceDouble(uint32_t x, uint32_t y) : x(x), y(y) {} + explicit operator double() const; +}; #endif diff --git a/src/lib/structure/types.cpp b/src/lib/structure/types.cpp index 52fb5c9..d647610 100644 --- a/src/lib/structure/types.cpp +++ b/src/lib/structure/types.cpp @@ -2,7 +2,7 @@ template <> T01ArcSegment::operator T01ArcSegment() const { - T01ArcSegment new_inst; + T01ArcSegment new_inst{}; new_inst.t = this->t; new_inst.un0 = this->un0; new_inst.subtype = this->subtype; diff --git a/src/lib/structure/utils.cpp b/src/lib/structure/utils.cpp index 17bcf80..4f95dff 100644 --- a/src/lib/structure/utils.cpp +++ b/src/lib/structure/utils.cpp @@ -3,7 +3,7 @@ #include auto x01_center(const T01ArcSegment* inst) -> std::pair { - return {cfp_to_double(inst->x), cfp_to_double(inst->y)}; + return {static_cast(inst->x), static_cast(inst->y)}; } auto ordered_stackup_materials(File& f)