高亮路径
This commit is contained in:
parent
bd472eea1e
commit
ddf9b01651
|
@ -311,6 +311,7 @@ void dags::DAGActiveView::refreshGraph()
|
||||||
// 헌뇜뎠품柬暠
|
// 헌뇜뎠품柬暠
|
||||||
this->scene_bind.clear();
|
this->scene_bind.clear();
|
||||||
this->total_graph_nodes.clear();
|
this->total_graph_nodes.clear();
|
||||||
|
this->highlight_nodelist.clear();
|
||||||
|
|
||||||
auto total_nodes = _layout_engine->nodeWithLayout();
|
auto total_nodes = _layout_engine->nodeWithLayout();
|
||||||
total_graph_nodes = this->layer_nodes_construction(QHash<IGraphNode*, std::shared_ptr<DAGOrderHelper>>(), total_nodes);
|
total_graph_nodes = this->layer_nodes_construction(QHash<IGraphNode*, std::shared_ptr<DAGOrderHelper>>(), total_nodes);
|
||||||
|
@ -331,7 +332,7 @@ void DAGActiveView::mousePressEvent(QMouseEvent* ev) {
|
||||||
auto type_item = dynamic_cast<IGraphNode*>(gitem);
|
auto type_item = dynamic_cast<IGraphNode*>(gitem);
|
||||||
if (type_item->nodeType() == GraphNodeType::ActivePresentNode) {
|
if (type_item->nodeType() == GraphNodeType::ActivePresentNode) {
|
||||||
auto node = static_cast<ActivePresentNode*>(type_item);
|
auto node = static_cast<ActivePresentNode*>(type_item);
|
||||||
emit this->nodeClicked(ev->pos(), QList<QString>() << node->nodeName());
|
emit this->nodeClicked(ev->pos(), node->nodeName());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace dags {
|
||||||
DAGGraph *const _layout_engine;
|
DAGGraph *const _layout_engine;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nodeClicked(const QPointF &pos, const QList<QString> &node_name);
|
void nodeClicked(const QPointF &pos, const QString &node_name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DAGActiveView(QWidget* parent = nullptr);
|
DAGActiveView(QWidget* parent = nullptr);
|
||||||
|
|
|
@ -20,7 +20,9 @@ StoryPresent::StoryPresent(QWidget* parent)
|
||||||
auto layout = mbar->addMenu(u8"²¼¾Öµ÷Õû");
|
auto layout = mbar->addMenu(u8"²¼¾Öµ÷Õû");
|
||||||
layout->addAction(u8"ÕýÏò²¼¾Ö", this, &StoryPresent::forwardLayout, Qt::CTRL + Qt::Key_F);
|
layout->addAction(u8"ÕýÏò²¼¾Ö", this, &StoryPresent::forwardLayout, Qt::CTRL + Qt::Key_F);
|
||||||
layout->addAction(u8"ÄæÏò²¼¾Ö", this, &StoryPresent::backwardLayout, Qt::CTRL + Qt::Key_B);
|
layout->addAction(u8"ÄæÏò²¼¾Ö", this, &StoryPresent::backwardLayout, Qt::CTRL + Qt::Key_B);
|
||||||
layout->addAction(u8"µ÷Õû²¼¾Ö", this, &StoryPresent::adjustLayout, Qt::CTRL+Qt::Key_A);
|
//layout->addAction(u8"µ÷Õû²¼¾Ö", this, &StoryPresent::adjustLayout, Qt::CTRL+Qt::Key_A);
|
||||||
|
|
||||||
|
connect(_story_present, &DAGActiveView::nodeClicked, this, &StoryPresent::nodeClickAccept);
|
||||||
}
|
}
|
||||||
|
|
||||||
StoryPresent::~StoryPresent()
|
StoryPresent::~StoryPresent()
|
||||||
|
@ -46,12 +48,14 @@ void StoryPresent::loadXAST(const QString& ast_path)
|
||||||
auto frag_temp = story_line->firstChild();
|
auto frag_temp = story_line->firstChild();
|
||||||
while (frag_temp) {
|
while (frag_temp) {
|
||||||
switch (frag_temp->type()) {
|
switch (frag_temp->type()) {
|
||||||
case SliceType::FragmentDefines: {
|
case SliceType::FragmentDefines:
|
||||||
|
{
|
||||||
auto arrow_tail = std::dynamic_pointer_cast<FragmentDefine>(frag_temp)->name() + u8"@" + story_line->name();
|
auto arrow_tail = std::dynamic_pointer_cast<FragmentDefine>(frag_temp)->name() + u8"@" + story_line->name();
|
||||||
arrows << graph_data::Arrow(arrow_start, arrow_tail);
|
arrows << graph_data::Arrow(arrow_start, arrow_tail);
|
||||||
arrow_start = arrow_tail;
|
arrow_start = arrow_tail;
|
||||||
}break;
|
}break;
|
||||||
case SliceType::FragmentRefers: {
|
case SliceType::FragmentRefers:
|
||||||
|
{
|
||||||
auto conv_refer = std::dynamic_pointer_cast<FragmentRefer>(frag_temp);
|
auto conv_refer = std::dynamic_pointer_cast<FragmentRefer>(frag_temp);
|
||||||
auto arrow_tail = conv_refer->fragmentRefer() + u8"@" + conv_refer->storyRefer();
|
auto arrow_tail = conv_refer->fragmentRefer() + u8"@" + conv_refer->storyRefer();
|
||||||
arrows << graph_data::Arrow(arrow_start, arrow_tail);
|
arrows << graph_data::Arrow(arrow_start, arrow_tail);
|
||||||
|
@ -67,6 +71,78 @@ void StoryPresent::loadXAST(const QString& ast_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
void StoryPresent::nodeClickAccept(const QPointF& pos, const QString& node_name)
|
||||||
|
{
|
||||||
|
// Æðʼ½Úµã
|
||||||
|
if (!node_name.contains(u8"@")) {
|
||||||
|
auto story_line = this->_story_graph[node_name];
|
||||||
|
|
||||||
|
QList<QString> node_names;
|
||||||
|
node_names << node_name;
|
||||||
|
|
||||||
|
auto temp_node = story_line->firstChild();
|
||||||
|
while (temp_node) {
|
||||||
|
switch (temp_node->type()) {
|
||||||
|
case SliceType::FragmentDefines:
|
||||||
|
{
|
||||||
|
auto fragm = std::dynamic_pointer_cast<FragmentDefine>(temp_node);
|
||||||
|
node_names << QString(u8"%1@%2").arg(fragm->name(), node_name);
|
||||||
|
}break;
|
||||||
|
case SliceType::FragmentRefers:
|
||||||
|
{
|
||||||
|
auto frefer = std::dynamic_pointer_cast<FragmentRefer>(temp_node);
|
||||||
|
node_names << QString(u8"%1@%2").arg(frefer->fragmentRefer(), frefer->storyRefer());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
temp_node = temp_node->nextSlice();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<graph_data::Arrow> arrows;
|
||||||
|
for (auto idx = 1; idx < node_names.size(); ++idx) {
|
||||||
|
auto from = node_names[idx - 1];
|
||||||
|
auto to = node_names[idx];
|
||||||
|
|
||||||
|
arrows << graph_data::Arrow(from, to);
|
||||||
|
}
|
||||||
|
this->_story_present->highlightGraphLink(arrows);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto splits = node_name.split(u8"@", QString::SkipEmptyParts);
|
||||||
|
auto story_line = this->_story_graph[splits.last()];
|
||||||
|
auto fragm_slice = story_line->getFragment(splits.first());
|
||||||
|
auto fragm_defn = std::dynamic_pointer_cast<FragmentDefine>(fragm_slice);
|
||||||
|
|
||||||
|
auto refers = fragm_defn->referSlices();
|
||||||
|
|
||||||
|
if (!refers.size()) {
|
||||||
|
this->nodeClickAccept(QPointF(), story_line->name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<std::shared_ptr<IElementSlice>> parent_slices;
|
||||||
|
std::transform(refers.begin(), refers.end(), std::back_inserter(parent_slices),
|
||||||
|
[](std::shared_ptr<IElementSlice> ins) { return ins->parentSlice().lock(); });
|
||||||
|
|
||||||
|
decltype(parent_slices) fliter_slices;
|
||||||
|
std::copy_if(parent_slices.begin(), parent_slices.end(), std::back_inserter(fliter_slices),
|
||||||
|
[](std::shared_ptr<IElementSlice> ins) { return ins->type() == SliceType::StoryDefines; });
|
||||||
|
|
||||||
|
QList<std::shared_ptr<StoryDefine>> lines = { story_line };
|
||||||
|
std::transform(fliter_slices.begin(), fliter_slices.end(), std::back_inserter(lines),
|
||||||
|
[](std::shared_ptr<IElementSlice> ins) { return std::dynamic_pointer_cast<StoryDefine>(ins); });
|
||||||
|
|
||||||
|
QMenu msep;
|
||||||
|
for (auto ln : lines) {
|
||||||
|
msep.addAction(ln->name(), [=](){
|
||||||
|
this->nodeClickAccept(QPointF(), ln->name());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
msep.exec(this->_story_present->mapToParent(pos.toPoint()));
|
||||||
|
}
|
||||||
|
}
|
||||||
void StoryPresent::bigger()
|
void StoryPresent::bigger()
|
||||||
{
|
{
|
||||||
_scale_value *= 1.1;
|
_scale_value *= 1.1;
|
||||||
|
|
|
@ -18,6 +18,8 @@ private:
|
||||||
dags::DAGActiveView *const _story_present;
|
dags::DAGActiveView *const _story_present;
|
||||||
QHash<QString, std::shared_ptr<xast_parse::StoryDefine>> _story_graph;
|
QHash<QString, std::shared_ptr<xast_parse::StoryDefine>> _story_graph;
|
||||||
|
|
||||||
|
void nodeClickAccept(const QPointF &pos, const QString &node_name);
|
||||||
|
|
||||||
void bigger();
|
void bigger();
|
||||||
void lesser();
|
void lesser();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue