添加了关系图片展示
This commit is contained in:
parent
b5cab7f821
commit
ca59dd7c78
|
@ -6,9 +6,9 @@
|
|||
<LocalDebuggerCommandArguments>-path D:\Projects\Cpp\WsNovelParser\x64\test_file</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:18:59.8731740Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:46.2857569Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.1378580Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:46.5528331Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -421,3 +421,47 @@ void tools_printer::volumes_anchors_define(const QList<std::shared_ptr<StoryVolu
|
|||
refers_refresh(it->elements(), page_address);
|
||||
}
|
||||
}
|
||||
|
||||
QString printer::tools_printer::storylines_paint(const QList<std::shared_ptr<StoryLine>> lines) {
|
||||
auto get_node_name = [](const std::shared_ptr<Access> item){
|
||||
return u8"node_" + QString::number((qulonglong)item->accessPeers()->element().get());
|
||||
};
|
||||
|
||||
QHash<QString, std::shared_ptr<Access>> node_records;
|
||||
QString nodes_description;
|
||||
for (auto& story : lines) {
|
||||
auto story_elem = std::dynamic_pointer_cast<const example_novel::StoryDefine>(story->accessPeers()->element());
|
||||
node_records[story_elem->signature()] = story;
|
||||
nodes_description += get_node_name(story) + QString(u8"[label=\"%1\",shape=\"cds\"]\n").arg(story_elem->name());
|
||||
|
||||
for (auto frag : story->elements()) {
|
||||
auto fragment_peers = frag->accessPeers()->element();
|
||||
if (fragment_peers->typeMark() == (int)example_novel::NovelNode::FragmentDefine) {
|
||||
auto fragment_elem = std::dynamic_pointer_cast<const example_novel::FragmentDefine>(fragment_peers);
|
||||
node_records[fragment_elem->signature()] = frag;
|
||||
nodes_description += get_node_name(frag) + QString(u8"[label=\"%1\",shape=\"rect\"]\n").arg(fragment_elem->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString arrows_link;
|
||||
for (auto &story : lines) {
|
||||
auto story_elem = std::dynamic_pointer_cast<const example_novel::StoryDefine>(story->accessPeers()->element());
|
||||
|
||||
QString previous_node = get_node_name(story);
|
||||
for (auto &frag : story->elements()) {
|
||||
if (example_novel::NovelNode::FragmentDefine == (example_novel::NovelNode) frag->accessPeers()->element()->typeMark()) {
|
||||
arrows_link += previous_node + u8"->" + get_node_name(frag) + u8"\n";
|
||||
previous_node = get_node_name(frag);
|
||||
}
|
||||
else if (example_novel::NovelNode::FragmentRefer == (example_novel::NovelNode)frag->accessPeers()->element()->typeMark()) {
|
||||
auto frag_refer = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(frag->accessPeers()->element());
|
||||
auto frag_src = node_records[frag_refer->referSignature()];
|
||||
arrows_link += previous_node + u8"->" + get_node_name(frag_src) + u8"\n";
|
||||
previous_node = get_node_name(frag_src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QString(u8"digraph{ rankdir = LR \n %1\n %2 }").arg(nodes_description).arg(arrows_link);
|
||||
}
|
||||
|
|
|
@ -153,5 +153,7 @@ namespace printer {
|
|||
void fragments_anchors_define(const QList<std::shared_ptr<Fragment>> &list, const QDir &destdir);
|
||||
void storylines_anchors_define(const QList<std::shared_ptr<StoryLine>> &list, const QDir &destdir);
|
||||
void volumes_anchors_define(const QList<std::shared_ptr<StoryVolume>> &list, const QDir &destdir);
|
||||
|
||||
QString storylines_paint(const QList<std::shared_ptr<StoryLine>> lines);
|
||||
};
|
||||
}
|
|
@ -66,7 +66,14 @@ int main(int argc, char* argv[]) {
|
|||
for (auto& node : tool.volume_defines)
|
||||
html_output(node);
|
||||
|
||||
|
||||
auto dot_src = tool.storylines_paint(tool.storyline_defines.values());
|
||||
QFile dot_file(QDir::current().filePath(u8"relates.dot"));
|
||||
if (dot_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream txt(&dot_file);
|
||||
txt.setCodec(u8"UTF-8");
|
||||
txt << dot_src;
|
||||
txt.flush();
|
||||
}
|
||||
|
||||
std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_print =
|
||||
[&](std::shared_ptr<const ast_gen::ElementAccess> node, int intend) {
|
||||
|
@ -103,7 +110,7 @@ int main(int argc, char* argv[]) {
|
|||
dom_storyline.appendChild(dom_line);
|
||||
|
||||
auto line_href = doc_inst.createElement("a");
|
||||
line_href.setAttribute(u8"href", u8"file:///"+inst_line->pageRefers());
|
||||
line_href.setAttribute(u8"href", u8"file:///" + inst_line->pageRefers());
|
||||
line_href.appendChild(doc_inst.createTextNode(inst_line->accessPeers()->element()->signature()));
|
||||
dom_line.appendChild(line_href);
|
||||
}
|
||||
|
@ -130,7 +137,7 @@ int main(int argc, char* argv[]) {
|
|||
dom_fragment.appendChild(dom_fragment_title);
|
||||
body.appendChild(dom_fragment);
|
||||
|
||||
for (auto &inst_frag : tool.fragment_defines) {
|
||||
for (auto& inst_frag : tool.fragment_defines) {
|
||||
auto dom_fragment_ref = doc_inst.createElement("p");
|
||||
dom_fragment.appendChild(dom_fragment_ref);
|
||||
|
||||
|
@ -140,12 +147,23 @@ int main(int argc, char* argv[]) {
|
|||
dom_fragment_ref.appendChild(frag_href);
|
||||
}
|
||||
|
||||
auto dom_relate = doc_inst.createElement(u8"div");
|
||||
auto dom_relate_title = doc_inst.createElement(u8"h2");
|
||||
dom_relate_title.appendChild(doc_inst.createTextNode(u8"<EFBFBD><EFBFBD>ϵͼ"));
|
||||
dom_relate.appendChild(dom_fragment_title);
|
||||
body.appendChild(dom_relate);
|
||||
|
||||
auto img = doc_inst.createElement(u8"img");
|
||||
img.setAttribute(u8"src", u8"file:///" + QDir::current().filePath(u8"relates.svg"));
|
||||
dom_relate.appendChild(img);
|
||||
|
||||
QTextStream tout(&tfile);
|
||||
doc_inst.save(tout, 2);
|
||||
tout.flush();
|
||||
}
|
||||
}
|
||||
|
||||
system("dot -Tsvg relates.dot -o relates.svg");
|
||||
tnode_print(novel_accesstree, 0);
|
||||
}
|
||||
catch (lib_syntax::SyntaxException* e) {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.3474812Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:47.1986642Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.4450682Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:47.3829821Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -5,9 +5,9 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.1942518Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:46.6414549Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.2951725Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:47.0693524Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -2,9 +2,9 @@
|
|||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.4973995Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:47.4685693Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtLastBackgroundBuild>2024-04-05T16:19:00.6479589Z</QtLastBackgroundBuild>
|
||||
<QtLastBackgroundBuild>2024-04-16T12:53:47.6504183Z</QtLastBackgroundBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue