DependencyGraph: Show origins correctly

This commit is contained in:
Stefan Tröger
2017-01-29 22:38:34 +01:00
committed by wmayer
parent f08ab52724
commit e20aae688e

View File

@@ -107,6 +107,8 @@ recompute path. Also enables more complicated dependencies beyond trees.
#include "Application.h"
#include "Transactions.h"
#include "GeoFeatureGroupExtension.h"
#include "Origin.h"
#include "OriginGroupExtension.h"
using Base::Console;
using Base::streq;
@@ -371,13 +373,17 @@ void Document::exportGraphviz(std::ostream& out) const
//don't add objects twice
if(std::find(objects.begin(), objects.end(), docObj) != objects.end())
return;
return;
//find the correct graph to add the vertex too. Check first expressions graphs, afterwards
//the parent CS and origin graphs
Graph * sgraph = GraphList[docObj];
if(!sgraph) {
auto group = GeoFeatureGroupExtension::getGroupOfObject(docObj);
if(group)
sgraph = GraphList[group];
}
if(!sgraph) {
if(docObj->isDerivedFrom(OriginFeature::getClassTypeId()))
sgraph = GraphList[static_cast<OriginFeature*>(docObj)->getOrigin()];
}
@@ -453,13 +459,19 @@ void Document::exportGraphviz(std::ostream& out) const
void recursiveCSSubgraphs(DocumentObject* cs, DocumentObject* parent) {
auto graph = parent ? GraphList[parent] : &DepList;
auto& sub = graph->create_subgraph();
GraphList[cs] = &sub;
auto& sub = graph->create_subgraph();
GraphList[cs] = &sub;
get_property(sub, graph_name) = getClusterName(cs);
for(auto obj : cs->getOutList()) {
if(obj->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId()))
recursiveCSSubgraphs(obj, cs);
}
//setup the origin if available
if(cs->hasExtension(App::OriginGroupExtension::getExtensionClassTypeId())) {
auto origin = cs->getExtensionByType<OriginGroupExtension>()->Origin.getValue();
auto& osub = sub.create_subgraph();
GraphList[origin] = &osub;
get_property(osub, graph_name) = getClusterName(origin);
}
@@ -469,7 +481,7 @@ void Document::exportGraphviz(std::ostream& out) const
//first build up the coordinate system subgraphs
for (auto objectIt : d->objectArray) {
if (objectIt->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId()) && objectIt->getInList().empty())
if (objectIt->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId()) && objectIt->getInList().empty())
recursiveCSSubgraphs(objectIt, nullptr);
}
@@ -554,7 +566,15 @@ void Document::exportGraphviz(std::ostream& out) const
}
++j;
}
// Add edges between document objects
for (std::map<std::string, DocumentObject*>::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) {
//coordinate systems are represented by subgraphs
if(It->second->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId()))
continue;
//as well as origins
if(It->second->isDerivedFrom(Origin::getClassTypeId()))
continue;