LayoutManager.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #ifndef LAYOUTMANAGER_H
  2. #define LAYOUTMANAGER_H
  3. #include <QIODevice>
  4. #include <LayoutUtilities/LayoutTypes.h>
  5. #include <Common/BoostGraphWrapper.h>
  6. #include <GraphMLReader/GraphMLReader.h>
  7. #include <GraphMLWriter/GraphMLWriter.h>
  8. #include <GraphLayoutLibrary_global.h>
  9. #include <HierarchicalLayoutGenerator/HierarchicalLayouter.h>
  10. #include <CircularLayout/CircularLayoutGenerator.h>
  11. #include <GridBasedLayout/GridBasedLayout.h>
  12. #include <GridBasedLayout/GraphPreProcessor.h>
  13. #include <GridBasedLayout/GridLayouter.h>
  14. #include <RandomLayout/RandomLayoutGenerator.h>
  15. #include <Common/LayoutEnum.h>
  16. #include <QString>
  17. #include <LayoutManager/GraphLayoutErrorCodes.h>
  18. #include <ForceBasedLayout/SpringEmbedder.h>
  19. #include <ForceBasedLayout/Reingold.h>
  20. #include <ForceBasedLayout/ClusteredSpringEmbedder.h>
  21. #include <ForceBasedLayout/MembershipInitializer.h>
  22. #include <ForceBasedLayout/ForceBasedLayoutGenerator.h>
  23. #include <Common/LayoutUtility.h>
  24. #define SEPARATION 20
  25. //using namespace boost;
  26. /**
  27. * The LayoutManager class contains the main APIs of GraphLayoutLibrary. This is the starting poing for accessing the library.
  28. */
  29. class GRAPHLAYOUTLIBRARYSHARED_EXPORT LayoutManager
  30. {
  31. typedef std::vector< graph_traits< LayoutUtility::graph >::vertex_descriptor > CanonicalOrderStorage;
  32. public:
  33. /**
  34. * Constructs an object of LayoutManager
  35. *
  36. */
  37. LayoutManager();
  38. private:
  39. int iForceDirectedIterations; // iteration count received from client
  40. //CanonicalOrderStorage m_oCanonicalOrder;
  41. std::vector<int> m_oCanonicalOrder;
  42. std::vector< GridBasedLayout::Position > m_oVertexPossition;
  43. GraphPreProcessor::EdgeOrderType m_oDummyEdges, m_oNonPlanarEdges, m_oParallelEdges;
  44. GraphPreProcessor::VertexOrderType m_oDummyVertices;
  45. //GraphPreProcessor::CorrespondingEdgesType m_oCrossingEdges;
  46. std::vector<GraphPreProcessor::EdgePairType> m_oCrossingEdges;
  47. enum enumVertexType {ORIGINAL_VERTEX, NEW_VERTEX};
  48. struct Node_Type_Pair
  49. {
  50. VertexDescriptor vNode;
  51. enumVertexType vertexType;
  52. };
  53. typedef std::vector<Node_Type_Pair> edgeType;
  54. //To Do: Function to return list of errors
  55. /*API for Layout Library
  56. */
  57. SubGraph& applyLayout(SubGraph& gMainGraph, const LayoutType& enLayoutType);
  58. bool applyLayout(LayoutType enLayoutType , QString strInputGraphmlPath , QString strOutputGraphMLPath);
  59. public:
  60. /** @name Modifiers
  61. * The methods under this section are responsible for modifying
  62. * an instance of GraphCycleHandler.
  63. */
  64. //@{
  65. /**
  66. this method reads graphML file, apply circular layout on the input file data
  67. and writes the updated layout changes to the output file in the form of graphML file
  68. * @brief applyCircularLayoutProcess
  69. *
  70. * @pre sInputFileName.trimmed().isEmpty() != true
  71. *
  72. * @param sInputFileName
  73. *
  74. * @param sOutputFileName
  75. *
  76. * @param enVertexOrder
  77. *
  78. * @return GraphLayoutErrorCodes
  79. *
  80. * @throw none
  81. */
  82. GraphLayoutErrorCodes::LayoutErrorCode applyCircularLayout(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath, LayoutEnum::VertexOrderCriteria enVertexOrder = LayoutEnum::TopologicalOrder);
  83. /**
  84. this method reads graphML file, applies Hierarchical Layout on the input file data
  85. and writes the updated layout changes to the output file in the form of graphML file
  86. * @brief applyHierarchicalLayoutProcess
  87. *
  88. * @pre sInputFileName.trimmed().isEmpty() != true
  89. *
  90. * @param sInputFileName
  91. * input graphml file path
  92. *
  93. * @param sOutputFileName
  94. * output graphml file path
  95. *
  96. * @return GraphLayoutErrorCodes
  97. *
  98. * @throw none
  99. */
  100. GraphLayoutErrorCodes::LayoutErrorCode applyHierarchicalLayout(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath);
  101. /**
  102. This method reads graph from input file, applies grid based layout on the input graph data
  103. and writes the updated layout changes to the output file in the form of graphML file
  104. * @brief applyGridBasedLayoutProcess
  105. * applies Grid Based Layout algorithm to supplied graph
  106. * and writes the output to graphml file.
  107. *
  108. * @pre gMainInputGraph not empty, sOutputGraphMLFilePath is valid.
  109. *
  110. * @param sInputGraphMLFilePath
  111. * input file which contains graph on which Grid Based Layout algorithm is to be applied.
  112. *
  113. * @param sOutputGraphMLFilePath
  114. * output graphml file path where the output is to be written.
  115. *
  116. * @return GraphLayoutErrorCodes
  117. *
  118. * @throw LayoutException
  119. */
  120. GraphLayoutErrorCodes::LayoutErrorCode applyGridBasedLayout(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath);
  121. /**
  122. This method reads main input graph, applies grid based layout on the input graph data
  123. GraphLayoutErrorCodes::LayoutErrorCode applyForceDirectedLayout(SubGraph *gMaingraph,
  124. int iIterations);
  125. * and writes the output to graphml file.
  126. *
  127. * @pre gMainInputGraph not empty, sOutputGraphMLFilePath is valid.
  128. *
  129. * @param gMainInputGraph
  130. * input graph on which Grid Based Layout algorithm is to be applied.
  131. *
  132. * @return none
  133. *
  134. * @throw LayoutException
  135. */
  136. void applyGridBasedLayout(SubGraph *gMainInputGraph);
  137. /**
  138. this method reads Graph object, applies force directed layout.
  139. * @brief applyForceDirectedLayout
  140. *
  141. * @param gMainInputGraph
  142. * input graph.
  143. *
  144. * @param sInputGraphMLFilePath
  145. * input graph file path
  146. *
  147. * @param iIterations
  148. * number of iterations
  149. *
  150. * @return GraphLayoutErrorCodes::LayoutErrorCode
  151. *
  152. * @throw none
  153. */
  154. GraphLayoutErrorCodes::LayoutErrorCode applyForceDirectedLayout(SubGraph &gMainInputGraph,
  155. QString sInputGraphMLFilePath,
  156. int iIterations);
  157. /**
  158. this method reads Graph object, applies force directed layout.
  159. * @brief applyForceDirectedLayout
  160. *
  161. * @param gMainInputGraph
  162. * input graph.
  163. *
  164. * @param iIterations
  165. * number of iterations
  166. *
  167. * @return GraphLayoutErrorCodes::LayoutErrorCode
  168. *
  169. * @throw none
  170. */
  171. GraphLayoutErrorCodes::LayoutErrorCode applyForceDirectedLayout(SubGraph *gMainInputGraph
  172. ,int iIterations);
  173. /**
  174. this method reads Graph object, applies force directed layout.
  175. * @brief applyForceDirectedLayout
  176. *
  177. * @param sInputGraphMLFilePath
  178. * input graph file path
  179. *
  180. * @param sOutputGraphMLFilePath
  181. * output graph file path
  182. *
  183. * @param iIterations
  184. * number of iterations
  185. *
  186. * @return GraphLayoutErrorCodes::LayoutErrorCode
  187. *
  188. * @throw none
  189. */
  190. GraphLayoutErrorCodes::LayoutErrorCode applyForceDirectedLayout(QString sInputGraphMLFilePath,
  191. QString sOutputGraphMLFilePath,
  192. int iIterations);
  193. /**
  194. this method reads Graph Object, applies Force Directed on it.
  195. * @brief applyHierarchicalLayoutProcess
  196. *
  197. * @pre sInputFileName.trimmed().isEmpty() != true
  198. *
  199. * @pre gMainGraph != NULL
  200. *
  201. * @param gMainGraph
  202. * input graph object
  203. *
  204. * @param sInsputgraphPath
  205. * input graphML file path.
  206. *
  207. *
  208. * @param iIteration
  209. * number of iterations
  210. *
  211. *
  212. *
  213. * @return none
  214. *
  215. * @throw none
  216. */
  217. void setNumberOfIterations(int iterations);
  218. /**
  219. this method reads Graph from input file, removes vertex overlaps, writes the resulting graph to output file.
  220. * @brief applyVertexOverlapRemoval
  221. *
  222. * @pre sInputGraphMLFilePath.trimmed().isEmpty() != true
  223. *
  224. * @pre sOutputGraphMLFilePath.trimmed().isEmpty() != true
  225. *
  226. * @param sInsputgraphPath
  227. * input graphML file path.
  228. *
  229. * @param sOutputGraphMLFilePath
  230. * output graph file path
  231. *
  232. * @return GraphLayoutErrorCodes::LayoutErrorCode
  233. *
  234. * @throw none
  235. */
  236. GraphLayoutErrorCodes::LayoutErrorCode applyVertexOverlapRemoval(QString sInputGraphMLFilePath, QString sOutputGraphMLFilePath);
  237. //@}
  238. };
  239. #endif // LAYOUTMANAGER_H