|
|
@ -79,6 +79,8 @@ void Graph::svg_demo(Analyse::track_data_t track_data) { |
|
|
|
|
|
|
|
if (ret.second) { // insert success
|
|
|
|
graph_layer[i - 1].emplace_back(&ret.first->second); |
|
|
|
} else { |
|
|
|
graph_data[src->code].next.emplace_back(graph_data[c->code].layer_index); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -95,23 +97,50 @@ void Graph::svg_demo(Analyse::track_data_t track_data) { |
|
|
|
uint64_t graph_width = CASE_WIDTH * max_width + CASE_GAP_X * (max_width + 1); |
|
|
|
uint64_t graph_height = CASE_HEIGHT * max_height + CASE_GAP_Y * (max_height + 1); |
|
|
|
|
|
|
|
|
|
|
|
auto case_address = [this, &graph_width, &graph_layer](uint32_t i, uint32_t j) -> Point { |
|
|
|
uint64_t case_top = CASE_GAP_Y * (i + 1) + CASE_HEIGHT * i; |
|
|
|
uint64_t offset = (graph_width - (CASE_GAP_X * (graph_layer[i].size() + 1) + CASE_WIDTH * graph_layer[i].size())) / 2; |
|
|
|
uint64_t case_left = offset + CASE_GAP_X * (j + 1) + CASE_WIDTH * j; |
|
|
|
|
|
|
|
return Point {case_left, case_top}; |
|
|
|
}; |
|
|
|
|
|
|
|
auto svg = SvgGraph(graph_width, graph_height); |
|
|
|
|
|
|
|
// std::cout << graph_layer[0][0]->next.size() << std::endl;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < graph_layer.size(); ++i) { |
|
|
|
// for (uint32_t i = 0; i < 1; ++i) {
|
|
|
|
|
|
|
|
uint64_t case_top = CASE_GAP_Y * (i + 1) + CASE_HEIGHT * i; |
|
|
|
// uint64_t case_top = CASE_GAP_Y * (i + 1) + CASE_HEIGHT * i;
|
|
|
|
|
|
|
|
uint64_t offset = (graph_width - (CASE_GAP_X * (graph_layer[i].size() + 1) + CASE_WIDTH * graph_layer[i].size())) / 2; |
|
|
|
// uint64_t offset = (graph_width - (CASE_GAP_X * (graph_layer[i].size() + 1) + CASE_WIDTH * graph_layer[i].size())) / 2;
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < graph_layer[i].size(); ++j) { |
|
|
|
uint64_t case_left = offset + CASE_GAP_X * (j + 1) + CASE_WIDTH * j; |
|
|
|
// uint64_t case_left = offset + CASE_GAP_X * (j + 1) + CASE_WIDTH * j;
|
|
|
|
|
|
|
|
auto g = GraphCase({case_left, case_top}, RawCode::unsafe_create(graph_layer[i][j]->code), BLOCK_GAP, BLOCK_LENGTH); |
|
|
|
// auto g = GraphCase({case_left, case_top}, graph_layer[i][j]->code, BLOCK_GAP, BLOCK_LENGTH);
|
|
|
|
auto g = GraphCase(case_address(i, j), graph_layer[i][j]->code, BLOCK_GAP, BLOCK_LENGTH); |
|
|
|
g.render(svg, skin); |
|
|
|
|
|
|
|
for (const auto next : graph_layer[i][j]->next) { |
|
|
|
|
|
|
|
auto s = case_address(i, j); |
|
|
|
auto e = case_address(i + 1, next); |
|
|
|
|
|
|
|
s.x += CASE_WIDTH / 2; |
|
|
|
s.y += CASE_HEIGHT + LINE_OFFSET; |
|
|
|
|
|
|
|
e.x += CASE_WIDTH / 2; |
|
|
|
e.y -= LINE_OFFSET; |
|
|
|
|
|
|
|
auto line = new SvgLine(s, e); |
|
|
|
svg.insert(line); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std::cout << svg.dump() << std::endl; |
|
|
|
|
|
|
|