Recti 1.2.4
Loading...
Searching...
No Matches
svg_utils.hpp
Go to the documentation of this file.
1
5// include/recti/detail/svg_utils.hpp
6#pragma once
7
8#include <iosfwd>
10#include <vector>
11
12namespace recti::detail {
13
20 struct SvgParams {
21 int width;
22 int height;
23 int margin;
24 double scale;
25 int min_x;
26 int min_y;
27 };
28
29 // Declarations for functions moved to global_router.cpp
30 template <typename IntPoint>
31 SvgParams calculate_svg_params(const std::vector<RoutingNode<IntPoint>*>& nodes, int width,
32 int height, int margin);
33
34 template <> SvgParams calculate_svg_params<Point<int, int>>(
35 const std::vector<RoutingNode<Point<int, int>>*>& nodes, int width, int height, int margin);
36
37 template <> SvgParams calculate_svg_params<Point<Point<int, int>, int>>(
38 const std::vector<RoutingNode<Point<Point<int, int>, int>>*>& nodes, int width, int height,
39 int margin);
40
48 inline std::pair<double, double> scale_coords(int x, int y, const SvgParams& params) {
49 double sx = params.margin + (x - params.min_x) * params.scale;
50 double sy = params.margin + (y - params.min_y) * params.scale;
51 return {sx, sy};
52 }
53
54 template <typename IntPoint> void draw_node(std::ostringstream& svg,
55 const RoutingNode<IntPoint>* node,
56 const SvgParams& params);
57
58 template <> void draw_node<Point<int, int>>(std::ostringstream& svg,
59 const RoutingNode<Point<int, int>>* node,
60 const SvgParams& params);
61
62 template <> void draw_node<Point<Point<int, int>, int>>(
63 std::ostringstream& svg, const RoutingNode<Point<Point<int, int>, int>>* node,
64 const SvgParams& params);
65
66 void draw_legend(std::ostringstream& svg);
67
68 template <typename IntPoint>
69 void draw_stats(std::ostringstream& svg, const GlobalRoutingTree<IntPoint>& tree);
70
71 template <> void draw_stats<Point<int, int>>(std::ostringstream& svg,
73
74 template <> void draw_stats<Point<Point<int, int>, int>>(
75 std::ostringstream& svg, const GlobalRoutingTree<Point<Point<int, int>, int>>& tree);
76
77} // namespace recti::detail
Represents the entire global routing tree.
Definition global_router.hpp:165
Represents a node in the global routing tree.
Definition global_router.hpp:52
Data structures and algorithms for global routing in physical design.
Definition svg_utils.hpp:12
std::pair< double, double > scale_coords(int x, int y, const SvgParams &params)
Scale coordinates from data space to SVG canvas space.
Definition svg_utils.hpp:48
void draw_legend(std::ostringstream &svg)
SvgParams calculate_svg_params(const std::vector< RoutingNode< IntPoint > * > &nodes, int width, int height, int margin)
void draw_stats(std::ostringstream &svg, const GlobalRoutingTree< IntPoint > &tree)
void draw_node(std::ostringstream &svg, const RoutingNode< IntPoint > *node, const SvgParams &params)
SVG rendering parameters.
Definition svg_utils.hpp:20
int margin
Margin around the drawing area.
Definition svg_utils.hpp:23
int min_y
Minimum y-coordinate in the data.
Definition svg_utils.hpp:26
double scale
Scaling factor for coordinates.
Definition svg_utils.hpp:24
int width
Width of the SVG canvas.
Definition svg_utils.hpp:21
int height
Height of the SVG canvas.
Definition svg_utils.hpp:22
int min_x
Minimum x-coordinate in the data.
Definition svg_utils.hpp:25