123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- #include "LayoutManager.h"
- LayoutManager::LayoutManager()
- {
- }
- SubGraph &LayoutManager::applyLayout(SubGraph &gMainGraph, const LayoutType &enLayoutType)
- {
- switch(enLayoutType)
- {
- case CircularLayout:
- {
- //Apply Circular Layout
- CircularLayoutGenerator CircularLayouter;
- LayoutEnum::VertexOrderCriteria enVertexOrder = LayoutEnum::DefaultOrder;
- // XXX enVertexOrder must be initialized -- fixed
- CircularLayouter.applyCircularLayout(gMainGraph, enVertexOrder);
- }
- break;
- case HierarchicalLayout:
- {
- //Apply Hierarchical Layout
- HierarchicalLayouter hierarchicalLayouter;
- hierarchicalLayouter.applyHierarchicalLayout(gMainGraph);
- }
- break;
- case RandomLayout:
- {
- //Apply random Layout
- RandomLayoutGenerator randomLayouter;
- randomLayouter.applyRandomLayout(gMainGraph);
- }
- break;
- case GridBasedLayout:
- {
- //Apply Grid Based Layout
- this->applyGridBasedLayout(&gMainGraph);
- }
- break;
- case ForceDirectedLayout:
- {
- //Apply Force Directed Layout
- applyForceDirectedLayout(&gMainGraph,iForceDirectedIterations);
- }
- break;
- default:
- // XXX huh?
- break;
- }
- return gMainGraph;
- }
- bool LayoutManager::applyLayout(LayoutType enLayoutType , QString strInputGraphmlPath,
- QString strOutputGraphMLPath)
- {
- LAYOUT_ASSERT(!strInputGraphmlPath.isEmpty() && !strOutputGraphMLPath.isEmpty(),
- LayoutException(__FUNCTION__
- ,LayoutExceptionEnum::REQUIRED_PARAMETER_NOT_SET
- ,"Input and Output graphml path"
- ,"applyLayout"));
- bool bLayoutStatus = false;
- //Read graphml
- QFile inFile(strInputGraphmlPath);
- GraphMLReader reader;
- SubGraph &gInGraph = reader.readGraphML(&inFile);
- //Initialize order property
- BoostGraphWrapper boostGraphWrapper;
- boostGraphWrapper.initGraphVertexOrderValues(gInGraph);
- //Apply layout
- SubGraph &gLaidoutGraph = applyLayout(gInGraph , enLayoutType);
- //Write back
- QFile outFile(strOutputGraphMLPath);
- if (!outFile.open(QFile::WriteOnly | QFile::Truncate))
- {
- //cout<<"Write path file could not be open. Exiting.\n";
- }
- else
- {
- GraphMLWriter writer;
- writer.writeGraphml(gLaidoutGraph , &outFile);
- bLayoutStatus = true;
- }
- return bLayoutStatus;
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyCircularLayout(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath, LayoutEnum::VertexOrderCriteria enVertexOrder)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enCircularLayoutErrorCode= GraphLayoutErrorCodes::LAYOUT_SUCCESS;
- if( (sInputGraphMLFilePath.isEmpty() == true))
- {
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::INVALID_FILE_NAME;
- }
- if((sInputGraphMLFilePath.trimmed().endsWith(GRAPHML, Qt::CaseInsensitive) == false)
- && (enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::UNSUPPORTED_FILE_FORMAT;
- }
- if((QFile::exists(sInputGraphMLFilePath) == false) && (enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- // create global graph pointer.
- SubGraph *gMainGraph = (SubGraph *)0;
- if(enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // read input GraphML file
- QFile inFile(sInputGraphMLFilePath);
- GraphMLReader reader;
- try
- {
- SubGraph &gInputGraph = reader.readGraphML(&inFile);
- gMainGraph = &(gInputGraph);
- inFile.close();
- }
- catch(LayoutFileIOException& eException)
- {
- inFile.close();
- //We return the file exception enums
- enCircularLayoutErrorCode = (GraphLayoutErrorCodes::LayoutErrorCode)eException.getErrorCode();
- }
- catch(...)
- {
- inFile.close();
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- // XXX gMainGraph can be NULL at this point -- fixed
- if(gMainGraph != (SubGraph *)0) {
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- return enCircularLayoutErrorCode;
- }
- if(enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // apply circular layout
- CircularLayoutGenerator circularLayoutGenerator;
- try
- {
- circularLayoutGenerator.applyCircularLayout(*gMainGraph, enVertexOrder);
- }
- catch(...)
- {
- DELETE_AND_SET_NULL(gMainGraph);
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- if(enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // write file to output path
- QFile outFile(sOutputGraphMLFilePath);
- if ((!outFile.open(QFile::WriteOnly | QFile::Truncate)))
- {
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- if(enCircularLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- GraphMLWriter writer;
- try
- {
- writer.writeGraphml(*gMainGraph , &outFile);
- outFile.close();
- }
- catch(...)
- {
- DELETE_AND_SET_NULL(gMainGraph);
- enCircularLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- outFile.close();
- }
- }
- }
- return enCircularLayoutErrorCode;
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyGridBasedLayout(QString sInputGraphMLFilePath,
- QString sOutputGraphMLFilePath)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enGridBasedLayoutErrorCode= GraphLayoutErrorCodes::LAYOUT_SUCCESS;
- //Read input file-------------------------------------------------------------------------------------------
- if( (sInputGraphMLFilePath.isEmpty() == true))
- {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::INVALID_FILE_NAME;
- }
- if((sInputGraphMLFilePath.trimmed().endsWith(GRAPHML, Qt::CaseInsensitive) == false)
- && (enGridBasedLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::UNSUPPORTED_FILE_FORMAT;
- }
- if((QFile::exists(sInputGraphMLFilePath) == false) && (enGridBasedLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- // create global graph pointer.
- SubGraph *gMainGraph = ( SubGraph *)0;
- if(enGridBasedLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // read input GraphML file
- QFile inFile(sInputGraphMLFilePath);
- GraphMLReader reader;
- try
- {
- SubGraph &gInputGraph = reader.readGraphML(&inFile);
- gMainGraph = &(gInputGraph);
- inFile.close();
- }
- catch(LayoutFileIOException& eException)
- {
- inFile.close();
- //We return the file exception enums
- enGridBasedLayoutErrorCode = (GraphLayoutErrorCodes::LayoutErrorCode)eException.getErrorCode();
- }
- catch(...)
- {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- //---------------------------------------------------------------------------------------------------------
- // XXX gMainGraph can be NULL -- fixed
- if(gMainGraph == ( SubGraph *)0) {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- return enGridBasedLayoutErrorCode;
- }
- this->applyGridBasedLayout(gMainGraph);
- //Write output file----------------------------------------------------------------------------------------
- if(enGridBasedLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- QFile outFile(sOutputGraphMLFilePath);
- if ((!outFile.open(QFile::WriteOnly | QFile::Truncate)))
- {
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- if(enGridBasedLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- GraphMLWriter writer;
- try
- {
- writer.writeGraphml(*gMainGraph , &outFile);
- outFile.close();
- }
- catch(...)
- {
- outFile.close();
- //DELETE_AND_SET_NULL(*gMainInputGraph);
- enGridBasedLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- }
- //---------------------------------------------------------------------------------------------------------
- return enGridBasedLayoutErrorCode;
- }
- void LayoutManager::applyGridBasedLayout(SubGraph * gMainInputGraph)
- {
- //FIND LAYOUT--------------------------------------------------------------------------------------------
- //Initialize cluster and vertex IDs, that will be used to identify which vertex is in which cluster
- MembershipInitializer membershipInitializer;
- membershipInitializer.initializeMembers(*gMainInputGraph);
- //Remove parallel edges
- int iInitialNumEdges = boost::num_edges(*gMainInputGraph);
- // XXX iInitialNumEdges is not used
- qDebug() << "iInitialNumEdges=" << iInitialNumEdges;
- GraphPreProcessor graphPreProcessor;
- std::vector<QString> oParallelEdgeIDs;
- graphPreProcessor.removeParallelEdges(*gMainInputGraph, m_oParallelEdges, oParallelEdgeIDs);
- // XXX compare of signed and unsigned -- obselete
- // LAYOUT_ASSERT(iInitialNumEdges == (boost::num_edges(*gMainInputGraph) + size(m_oParallelEdges)),
- // LayoutException("removeParallelEdges",
- // LayoutExceptionEnum::INCONSISTENT_DATASTRUCTURE,
- // "gMainInputGraph",
- // "after removeParallelEdges"));
- //Call gridLayouterForClusteredGraph()
- GridLayouter gridLayouter;
- gridLayouter.gridLayouterForClusteredGraph(*gMainInputGraph, *gMainInputGraph);
- // gridLayouter.gridLayouterForNonClusteredGraph(*gMainInputGraph);
- //Add parallel edges back
- // XXX unused - fixed
- int iIntermediateNumEdges = boost::num_edges(*gMainInputGraph);
- qDebug() << "iIntermediateNumEdges=" << iIntermediateNumEdges;
- graphPreProcessor.addParallelEdges(*gMainInputGraph, m_oParallelEdges, oParallelEdgeIDs);
- LAYOUT_ASSERT(boost::num_edges(*gMainInputGraph) == (iIntermediateNumEdges + size(m_oParallelEdges)),
- LayoutException("addParallelEdges",
- LayoutExceptionEnum::INCONSISTENT_DATASTRUCTURE,
- "gMainInputGraph",
- "after addParallelEdges"));
- //------------------------------------------------------------------------------------------------------
- //set default cluster size------------------------------------------------------------------------------
- BoostGraphWrapper boostGraphWrapper;
- int iDefaultGraphHeight = boostGraphWrapper.getGraphHeight(*gMainInputGraph);
- int iDefaultGraphWidth = boostGraphWrapper.getGraphWidth(*gMainInputGraph);
- boostGraphWrapper.setGraphHeight(iDefaultGraphHeight + 130, *gMainInputGraph);
- boostGraphWrapper.setGraphWidth(iDefaultGraphWidth + 130, *gMainInputGraph);
- int iDefaultGraphLeftTopX = boostGraphWrapper.getGraphLeftTopCoordX(*gMainInputGraph);
- int iDefaultGraphLeftTopY = boostGraphWrapper.getGraphLeftTopCoordY(*gMainInputGraph);
- boostGraphWrapper.setGraphLeftTopCoordX(iDefaultGraphLeftTopX - 65, *gMainInputGraph);
- boostGraphWrapper.setGraphLeftTopCoordY(iDefaultGraphLeftTopY - 65, *gMainInputGraph);
- //------------------------------------------------------------------------------------------------------
- //set NodeType and EdgeType-----------------------------------------------------------------------------
- VertexIterator itrVert, itrVertEnd;
- for(boost::tie(itrVert, itrVertEnd)=vertices(*gMainInputGraph); itrVert!=itrVertEnd; ++itrVert)
- {
- VertexDescriptor vCurrentVertex = *itrVert;
- //Enum::NodeType enNodeType = Enum::GraphNode;
- boostGraphWrapper.setVertexType(vCurrentVertex, *gMainInputGraph, LayoutEnum::GraphNode);
- }
- EdgeIterator itrEdge, itrEdgeEnd;
- for(boost::tie(itrEdge, itrEdgeEnd)=edges(*gMainInputGraph); itrEdge!=itrEdgeEnd; ++itrEdge)
- {
- EdgeDescriptor eCurrentEdge = *itrEdge;
- //Enum::EdgeType enEdgeType = Enum::GraphEdge;
- boostGraphWrapper.setEdgeType(eCurrentEdge, *gMainInputGraph, LayoutEnum::GraphEdge);
- }
- //------------------------------------------------------------------------------------------------------
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyHierarchicalLayout(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::LAYOUT_SUCCESS;
- if( (sInputGraphMLFilePath.isEmpty() == true))
- {
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::INVALID_FILE_NAME;
- }
- if((sInputGraphMLFilePath.trimmed().endsWith(GRAPHML, Qt::CaseInsensitive) == false)
- && (enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::UNSUPPORTED_FILE_FORMAT;
- }
- if((QFile::exists(sInputGraphMLFilePath) == false) && (enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- // create global graph pointer.
- SubGraph *gMainGraph = ( SubGraph *)0;
- if(enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // read input GraphML file
- QFile inFile(sInputGraphMLFilePath);
- GraphMLReader reader;
- try
- {
- SubGraph &gInputGraph = reader.readGraphML(&inFile);
- gMainGraph = &(gInputGraph);
- }
- catch(LayoutFileIOException& eException)
- {
- //We return the file exception enums
- enHierarchicalLayoutErrorCode = (GraphLayoutErrorCodes::LayoutErrorCode)eException.getErrorCode();
- }
- catch(...)
- {
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- // XXX gMainGraph can be NULL -- fixed
- if(gMainGraph == ( SubGraph *)0){
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- return enHierarchicalLayoutErrorCode;
- }
- if(enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // apply hierarchical layout
- HierarchicalLayouter hierarchicalLayouter;
- try
- {
- hierarchicalLayouter.applyHierarchicalLayout(*gMainGraph);
- }
- catch(...)
- {
- DELETE_AND_SET_NULL(gMainGraph);
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- if(enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // write file to output path
- QFile outFile(sOutputGraphMLFilePath);
- if ((!outFile.open(QFile::WriteOnly | QFile::Truncate)))
- {
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- if(enHierarchicalLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- GraphMLWriter writer;
- try
- {
- writer.writeGraphml(*gMainGraph , &outFile);
- outFile.flush();
- outFile.close();
- }
- catch(...)
- {
- DELETE_AND_SET_NULL(gMainGraph);
- enHierarchicalLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- }
- }
- return enHierarchicalLayoutErrorCode;
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyForceDirectedLayout(SubGraph *gMainInputGraph
- ,int iIterations)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enForceLayoutErrorCode = GraphLayoutErrorCodes::LAYOUT_SUCCESS;
- LAYOUT_ASSERT(iIterations != 0,LayoutException(__FUNCTION__
- ,LayoutExceptionEnum::INVALID_ATTRIBUTE_VALUE
- ,"ITERATIONS"
- ,"Iterations"));
- LAYOUT_ASSERT(iIterations < 5000,LayoutException(__FUNCTION__
- ,LayoutExceptionEnum::INVALID_ATTRIBUTE_VALUE
- ,"ITERATIONS"
- ,"Set Iteration less than 5000"));
- if(enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- try{
- // LAYOUT_ASSERT(num_vertices(*gMainInputGraph) != 0,LayoutException(__FUNCTION__
- // ,ExceptionEnum::INVALID_ATTRIBUTE_VALUE
- // ,"applyForceDirectedLayout"
- // ,"Number of vertices"));
- MembershipInitializer *memInit = new MembershipInitializer();
- memInit->initializeMembers(*gMainInputGraph);
- Reingold *reingold = new Reingold();
- // reingold->SetClusterCompartmentPropsNew(*gMainInputGraph);
- reingold->setCompartMentProps(*gMainInputGraph,10);
- ClusteredSpringEmbedder *clusteredSpring = new ClusteredSpringEmbedder();
- clusteredSpring->springForEachCluster(*gMainInputGraph,iIterations);
- // clusteredSpring->springTestRecursive(gMainInputGraph);
- // reingold->SetClusterCompartmentPropsNew(*gMainInputGraph);
- reingold->setCompartMentProps(*gMainInputGraph,10);
- }
- catch(boost::exception &eBoostException)
- {
- throw *boost::get_error_info<errmsg_info>(eBoostException);
- enForceLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- }
- catch(LayoutException &eLayoutException)
- {
- throw eLayoutException;
- }
- }
- // XXX must return here something
- return enForceLayoutErrorCode;
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyForceDirectedLayout(QString sInputGraphMLFilePath,
- QString sOutputGraphMLFilePath,
- int iIterations)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enForceLayoutErrorCode =
- GraphLayoutErrorCodes::LAYOUT_SUCCESS;
- if( (sInputGraphMLFilePath.isEmpty() == true))
- {
- enForceLayoutErrorCode = GraphLayoutErrorCodes::INVALID_FILE_NAME;
- }
- if((sInputGraphMLFilePath.trimmed().endsWith(GRAPHML, Qt::CaseInsensitive) == false)
- && (enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enForceLayoutErrorCode = GraphLayoutErrorCodes::UNSUPPORTED_FILE_FORMAT;
- }
- if((QFile::exists(sInputGraphMLFilePath) == false) && (enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS))
- {
- enForceLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- // create global graph pointer.
- SubGraph *gMainGraph = ( SubGraph *)0;
- if(enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // read input GraphML file
- QFile inFile(sInputGraphMLFilePath);
- GraphMLReader reader;
- try
- {
- SubGraph &gInputGraph = reader.readGraphML(&inFile);
- gMainGraph = &(gInputGraph);
- inFile.close();
- }
- catch(LayoutFileIOException& eException)
- {
- inFile.close();
- //We return the file exception enums
- enForceLayoutErrorCode = (GraphLayoutErrorCodes::LayoutErrorCode)eException.getErrorCode();
- }
- }
- // XXX gmaingraph can be NULL -- fixed
- if (gMainGraph == ( SubGraph *)0){
- enForceLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- return enForceLayoutErrorCode;
- }
- if(enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // apply Force Based layout
- applyForceDirectedLayout(gMainGraph,iIterations);
- }
- if(enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- // write file to output path
- QFile outFile(sOutputGraphMLFilePath);
- if ((!outFile.open(QFile::WriteOnly | QFile::Truncate)))
- {
- enForceLayoutErrorCode = GraphLayoutErrorCodes::FILE_NOT_FOUND;
- }
- if(enForceLayoutErrorCode == GraphLayoutErrorCodes::LAYOUT_SUCCESS)
- {
- GraphMLWriter writer;
- try
- {
- writer.writeGraphml(*gMainGraph , &outFile);
- outFile.flush();
- outFile.close();
- }
- catch(...)
- {
- outFile.close();
- DELETE_AND_SET_NULL(gMainGraph);
- enForceLayoutErrorCode = GraphLayoutErrorCodes::UNKNOWN_LAYOUT_EXCEPTION;
- outFile.close();
- }
- }
- }
- // XXX huh?
- //return gMainGraph;
- return enForceLayoutErrorCode;
- }
- GraphLayoutErrorCodes::LayoutErrorCode LayoutManager::applyVertexOverlapRemoval(QString sInputGraphMLFilePath,
- QString sOutputGraphMLFilePath)
- {
- GraphLayoutErrorCodes::LayoutErrorCode enVertexOVerlapErrorcode;
- VertexOverlapRemoval verOverlapRemoval;
- enVertexOVerlapErrorcode = verOverlapRemoval.removeOverlaps(sInputGraphMLFilePath
- ,sOutputGraphMLFilePath);
- return enVertexOVerlapErrorcode;
- }
- void LayoutManager::setNumberOfIterations(int iterations)
- {
- iForceDirectedIterations = iterations;
- }
|