1010#include < cstdint>
1111#include < exception>
1212#include < filesystem>
13+ #include < functional>
1314#include < map>
1415#include < memory>
1516#include < mutex>
2627#include " clock_tree_report.h"
2728#include " color.h"
2829#include " drc_report.h"
29- #include " odb/3dblox.h"
3030#include " gui/descriptor_registry.h"
3131#include " gui/gui.h"
3232#include " gui/heatMap.h"
3333#include " hierarchy_report.h"
3434#include " json_builder.h"
35+ #include " odb/3dblox.h"
3536#include " odb/db.h"
3637#include " odb/dbTransform.h"
3738#include " odb/dbTypes.h"
@@ -192,7 +193,8 @@ int extract_int(const std::string& json, const std::string& key)
192193 pos++;
193194 }
194195 int result = 0 ;
195- auto [p, ec] = std::from_chars (json.data () + pos, json.data () + json.size (), result);
196+ auto [p, ec]
197+ = std::from_chars (json.data () + pos, json.data () + json.size (), result);
196198 if (ec == std::errc ()) {
197199 return result;
198200 }
@@ -228,8 +230,8 @@ float extract_float_or(const std::string& json,
228230 pos++;
229231 }
230232 float result = default_val;
231- auto [p, ec] = std::from_chars (
232- json.data () + pos, json.data () + json.size (), result);
233+ auto [p, ec]
234+ = std::from_chars ( json.data () + pos, json.data () + json.size (), result);
233235 if (ec == std::errc ()) {
234236 return result;
235237 }
@@ -396,8 +398,8 @@ static double extract_double_value(const std::string& json)
396398 pos++;
397399 }
398400 double result = 0.0 ;
399- auto [p, ec] = std::from_chars (
400- json.data () + pos, json.data () + json.size (), result);
401+ auto [p, ec]
402+ = std::from_chars ( json.data () + pos, json.data () + json.size (), result);
401403 if (ec == std::errc ()) {
402404 return result;
403405 }
@@ -586,7 +588,8 @@ WebSocketResponse dispatch_request(
586588 }
587589 case WebSocketRequest::TECH : {
588590 bool has_block = gen.getBlock () != nullptr ;
589- bool has_chip_insts = gen.getChip () != nullptr && !gen.getChip ()->getChipInsts ().empty ();
591+ bool has_chip_insts
592+ = gen.getChip () != nullptr && !gen.getChip ()->getChipInsts ().empty ();
590593 if (!has_block && !has_chip_insts) {
591594 resp.type = 2 ;
592595 const std::string err = " No block or chip with instances is loaded." ;
@@ -599,14 +602,14 @@ WebSocketResponse dispatch_request(
599602 builder.beginArray (" layers" );
600603 {
601604 static const int palette[][3 ] = {
602- { 70 , 130 , 210 }, // moderate blue
603- {200 , 50 , 50 }, // red
604- { 50 , 180 , 80 }, // green
605- {200 , 160 , 40 }, // amber
606- {160 , 60 , 200 }, // purple
607- { 40 , 190 , 190 }, // teal
608- {220 , 120 , 50 }, // orange
609- {180 , 70 , 150 }, // magenta
605+ {70 , 130 , 210 }, // moderate blue
606+ {200 , 50 , 50 }, // red
607+ {50 , 180 , 80 }, // green
608+ {200 , 160 , 40 }, // amber
609+ {160 , 60 , 200 }, // purple
610+ {40 , 190 , 190 }, // teal
611+ {220 , 120 , 50 }, // orange
612+ {180 , 70 , 150 }, // magenta
610613 };
611614 static constexpr int palette_size = 8 ;
612615 int idx = 0 ;
@@ -1288,12 +1291,22 @@ WebSocketResponse SelectHandler::handleGet3DData(const WebSocketRequest& req)
12881291 builder.beginObject ();
12891292 builder.beginArray (" chiplets" );
12901293
1291- auto processInst = [&](auto & self, odb::dbChipInst* inst, int offset_x, int offset_y, int offset_z, const std::string& parent_name) -> void {
1294+ auto processInst = [&](auto & self,
1295+ odb::dbChipInst* inst,
1296+ int offset_x,
1297+ int offset_y,
1298+ int offset_z,
1299+ const std::string& parent_name) -> void {
12921300 odb::dbChip* master_chip = inst->getMasterChip ();
12931301 if (master_chip && !master_chip->getChipInsts ().empty ()) {
12941302 for (odb::dbChipInst* child : master_chip->getChipInsts ()) {
12951303 odb::Point3D loc = inst->getLoc ();
1296- self (self, child, offset_x + loc.x (), offset_y + loc.y (), offset_z + loc.z (), parent_name + std::string (inst->getName ()) + " /" );
1304+ self (self,
1305+ child,
1306+ offset_x + loc.x (),
1307+ offset_y + loc.y (),
1308+ offset_z + loc.z (),
1309+ parent_name + std::string (inst->getName ()) + " /" );
12971310 }
12981311 } else {
12991312 builder.beginObject ();
@@ -2468,7 +2481,7 @@ WebSocketResponse DRCHandler::handleDRCHighlight(const WebSocketRequest& req,
24682481 }
24692482 }
24702483 if (found) {
2471- const Color red{255 , 50 , 50 , 200 };
2484+ const Color red{. r = 255 , . g = 50 , . b = 50 , . a = 200 };
24722485 for (const auto & rect : found->rects ) {
24732486 state.drc_rects .push_back ({rect, red, found->layer });
24742487 }
@@ -2506,13 +2519,17 @@ WebSocketResponse DRCHandler::handleDRCSetVisible(const WebSocketRequest& req,
25062519
25072520 if (!req.drc_visible_indexes .empty ()) {
25082521 const DRCReportResult result = drc_report_->getReport ();
2509- const Color red{255 , 50 , 50 , 200 };
2510-
2522+ const Color red{. r = 255 , . g = 50 , . b = 50 , . a = 200 };
2523+
25112524 for (const auto & cat : result.categories ) {
25122525 for (const auto & v : cat.violations ) {
2513- if (req.drc_visible_indexes .count (v.index ) > 0 ) {
2526+ if (req.drc_visible_indexes .contains (v.index )) {
25142527 for (const auto & rect : v.rects ) {
2515- state.drc_rects .push_back ({rect, red, v.layer , true }); // true for is_drc if we need to differentiate later
2528+ state.drc_rects .push_back (
2529+ {rect,
2530+ red,
2531+ v.layer ,
2532+ true }); // true for is_drc if we need to differentiate later
25162533 }
25172534 for (const auto & poly : v.polys ) {
25182535 state.drc_rects .push_back (
@@ -2546,24 +2563,29 @@ WebSocketResponse DRCHandler::handleDRCMarkVisited(const WebSocketRequest& req)
25462563 int index = 0 ;
25472564 odb::dbMarker* found_marker = nullptr ;
25482565 // Find marker by flat index (this matches drc_report.cpp logic)
2549- std::function<void (odb::dbMarkerCategory*)> search = [&](odb::dbMarkerCategory* cat) {
2550- for (odb::dbMarker* marker : cat->getMarkers ()) {
2551- if (index == req.drc_violation_index ) {
2552- found_marker = marker;
2553- return ;
2554- }
2555- index++;
2556- }
2557- for (odb::dbMarkerCategory* sub : cat->getMarkerCategories ()) {
2558- if (found_marker) return ;
2559- search (sub);
2560- }
2561- };
2566+ std::function<void (odb::dbMarkerCategory*)> search
2567+ = [&](odb::dbMarkerCategory* cat) {
2568+ for (odb::dbMarker* marker : cat->getMarkers ()) {
2569+ if (index == req.drc_violation_index ) {
2570+ found_marker = marker;
2571+ return ;
2572+ }
2573+ index++;
2574+ }
2575+ for (odb::dbMarkerCategory* sub : cat->getMarkerCategories ()) {
2576+ if (found_marker) {
2577+ return ;
2578+ }
2579+ search (sub);
2580+ }
2581+ };
25622582 for (odb::dbMarkerCategory* cat : chip->getMarkerCategories ()) {
2563- if (found_marker) break ;
2583+ if (found_marker) {
2584+ break ;
2585+ }
25642586 search (cat);
25652587 }
2566-
2588+
25672589 if (found_marker) {
25682590 found_marker->setVisited (true );
25692591 }
@@ -2596,13 +2618,9 @@ WebSocketResponse DRCHandler::handleDRCLoad(const WebSocketRequest& req)
25962618 }
25972619
25982620 odb::dbMarkerCategory* cat = nullptr ;
2599- const std::string ext = path.size () >= 5
2600- ? path.substr (path.size () - std::min (path.size (), size_t (5 )))
2601- : path;
26022621
26032622 // Determine format by extension (.json → JSON, else TritonRoute report)
2604- if (path.size () >= 5
2605- && path.compare (path.size () - 5 , 5 , " .json" ) == 0 ) {
2623+ if (path.size () >= 5 && path.compare (path.size () - 5 , 5 , " .json" ) == 0 ) {
26062624 auto cats = odb::dbMarkerCategory::fromJSON (chip, path);
26072625 if (!cats.empty ()) {
26082626 cat = *cats.begin ();
0 commit comments