This commit is contained in:
parent
b24507a479
commit
207bdf845c
|
@ -49,11 +49,11 @@ std::shared_ptr<DAGLayerHelper> dags::DAGOrderHelper::layerNode() const {
|
||||||
return this->layer_bind;
|
return this->layer_bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DAGLayerHelper> dags::DAGOrderHelper::relateNode() const {
|
std::shared_ptr<DAGLayerHelper> dags::DAGOrderHelper::tailsNode() const {
|
||||||
return this->relate_bind;
|
return this->relate_bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DAGLayerHelper> dags::DAGOrderHelper::towardsNode() const {
|
std::shared_ptr<DAGLayerHelper> dags::DAGOrderHelper::headsNode() const {
|
||||||
return this->towards_to;
|
return this->towards_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ std::shared_ptr<DAGLayerHelper> DAGGraph::spawns_peak(QList<std::shared_ptr<DAGL
|
||||||
return std::shared_ptr<DAGLayerHelper>();
|
return std::shared_ptr<DAGLayerHelper>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DAGGraph::graph_recovery(const QList<std::shared_ptr<DAGLayerHelper>> &sort_seqs) {
|
void DAGGraph::graph_recovery(const QList<std::shared_ptr<DAGLayerHelper>>& sort_seqs) {
|
||||||
for (auto it : sort_seqs) {
|
for (auto it : sort_seqs) {
|
||||||
it->inputCount() = 0;
|
it->inputCount() = 0;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void DAGGraph::graph_recovery(const QList<std::shared_ptr<DAGLayerHelper>> &sort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DAGGraph::node_layering(const std::shared_ptr<DAGLayerHelper> &inst, int layer_current) {
|
int DAGGraph::node_layering(const std::shared_ptr<DAGLayerHelper>& inst, int layer_current) {
|
||||||
auto max_remains = layer_current;
|
auto max_remains = layer_current;
|
||||||
if (!layer_current || inst->layerValue() < layer_current) {
|
if (!layer_current || inst->layerValue() < layer_current) {
|
||||||
inst->setLayerValue(layer_current);
|
inst->setLayerValue(layer_current);
|
||||||
|
@ -228,7 +228,7 @@ QList<std::shared_ptr<DAGOrderHelper>> DAGGraph::tidy_graph_nodes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
void DAGGraph::graph_layer_nodes_sort(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>> &nodes) {
|
void DAGGraph::graph_layer_nodes_sort(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>>& nodes) {
|
||||||
QList<std::shared_ptr<DAGOrderHelper>> nodes_within_current_layer;
|
QList<std::shared_ptr<DAGOrderHelper>> nodes_within_current_layer;
|
||||||
for (auto n : nodes)
|
for (auto n : nodes)
|
||||||
if (n->layerNumber() == layer_index) {
|
if (n->layerNumber() == layer_index) {
|
||||||
|
@ -313,6 +313,36 @@ void dags::DAGGraph::above_nodes_sort(int layer_index, const QList<std::shared_p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dags::DAGGraph::graph_adjust_after_layout(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes)
|
||||||
|
{
|
||||||
|
int curr_layer = 0;
|
||||||
|
while (layer_adjust_after_layout(curr_layer++, total_nodes)) {
|
||||||
|
this->above_nodes_sort(curr_layer, total_nodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dags::DAGGraph::layer_adjust_after_layout(int curr_layer, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes)
|
||||||
|
{
|
||||||
|
QList<std::shared_ptr<DAGOrderHelper>> nodes_within_current_layer;
|
||||||
|
std::copy_if(total_nodes.begin(), total_nodes.end(), std::back_inserter(nodes_within_current_layer),
|
||||||
|
[&](std::shared_ptr<DAGOrderHelper> ins) { return ins->layerNumber() == curr_layer; });
|
||||||
|
|
||||||
|
if (!nodes_within_current_layer.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (auto node : nodes_within_current_layer) {
|
||||||
|
this->node_adjust_after_layout(node, total_nodes);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dags::DAGGraph::node_adjust_after_layout(std::shared_ptr<DAGOrderHelper> curr_node, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes)
|
||||||
|
{
|
||||||
|
auto next_data = curr_node->headsNode();
|
||||||
|
|
||||||
|
auto upstream_nodes = curr_node->getUpstreamNodes();
|
||||||
|
}
|
||||||
|
|
||||||
void dags::DAGGraph::graphLayout() {
|
void dags::DAGGraph::graphLayout() {
|
||||||
QList<std::shared_ptr<DAGLayerHelper>> sort_seqs;
|
QList<std::shared_ptr<DAGLayerHelper>> sort_seqs;
|
||||||
QList<std::shared_ptr<DAGLayerHelper>> refs;
|
QList<std::shared_ptr<DAGLayerHelper>> refs;
|
||||||
|
|
|
@ -54,8 +54,8 @@ namespace dags {
|
||||||
bool isFakeNode() const;
|
bool isFakeNode() const;
|
||||||
|
|
||||||
std::shared_ptr<DAGLayerHelper> layerNode() const;
|
std::shared_ptr<DAGLayerHelper> layerNode() const;
|
||||||
std::shared_ptr<DAGLayerHelper> relateNode() const;
|
std::shared_ptr<DAGLayerHelper> tailsNode() const;
|
||||||
std::shared_ptr<DAGLayerHelper> towardsNode() const;
|
std::shared_ptr<DAGLayerHelper> headsNode() const;
|
||||||
|
|
||||||
int layerNumber() const;
|
int layerNumber() const;
|
||||||
void setLayerNumber(int v);
|
void setLayerNumber(int v);
|
||||||
|
@ -88,5 +88,9 @@ namespace dags {
|
||||||
QList<std::shared_ptr<DAGOrderHelper>> tidy_graph_nodes();
|
QList<std::shared_ptr<DAGOrderHelper>> tidy_graph_nodes();
|
||||||
void graph_layer_nodes_sort(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>> &nodes);
|
void graph_layer_nodes_sort(int layer_index, const QList<std::shared_ptr<DAGOrderHelper>> &nodes);
|
||||||
void above_nodes_sort(int curr_layer, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
|
void above_nodes_sort(int curr_layer, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
|
||||||
|
|
||||||
|
void graph_adjust_after_layout(const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
|
||||||
|
bool layer_adjust_after_layout(int curr_layer, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
|
||||||
|
void node_adjust_after_layout(std::shared_ptr<DAGOrderHelper> curr_node, const QList<std::shared_ptr<DAGOrderHelper>>& total_nodes);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,8 +172,8 @@ QList<IGraphNode*> DAGActiveView::layer_nodes_construction(const QHash<IGraphNod
|
||||||
// 构建当前层次图形节点
|
// 构建当前层次图形节点
|
||||||
for (auto& data_node : current_layer_datas) {
|
for (auto& data_node : current_layer_datas) {
|
||||||
if (data_node->isFakeNode()) {
|
if (data_node->isFakeNode()) {
|
||||||
auto from = data_node->relateNode()->bindPoint().name();
|
auto from = data_node->tailsNode()->bindPoint().name();
|
||||||
auto to = data_node->towardsNode()->bindPoint().name();
|
auto to = data_node->headsNode()->bindPoint().name();
|
||||||
auto curr_gnode = new PenetrateNode(20, from, to);
|
auto curr_gnode = new PenetrateNode(20, from, to);
|
||||||
this->scene_bind.addItem(curr_gnode);
|
this->scene_bind.addItem(curr_gnode);
|
||||||
curr_gnode->setPos(prev_layer_end, data_node->sortNumber() * (this->node_span + this->font().pointSizeF()) * 7);
|
curr_gnode->setPos(prev_layer_end, data_node->sortNumber() * (this->node_span + this->font().pointSizeF()) * 7);
|
||||||
|
|
Loading…
Reference in New Issue