From 2771fff79ac9c3c09b70f4668e7142b2e944d1f2 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Thu, 25 Apr 2019 01:25:41 -0300 Subject: Matpower Importer and power quality calculation Power quality in implementation --- Project/GraphAutoLayout.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Project/GraphAutoLayout.h (limited to 'Project/GraphAutoLayout.h') diff --git a/Project/GraphAutoLayout.h b/Project/GraphAutoLayout.h new file mode 100644 index 0000000..4d42752 --- /dev/null +++ b/Project/GraphAutoLayout.h @@ -0,0 +1,46 @@ +// Code based in: "Weighted graphs: generate a layout in C++" +// https://rodic.fr/blog/c-weighted-graph-layout-fruchterman-reingold/ + +#ifndef GRAPHAUTOLAYOUT_H +#define GRAPHAUTOLAYOUT_H + +#include +//#include +#include +#include + +// class ParseMatpower; +#include "ImportForm.h" + +class GraphAutoLayout +{ + public: + struct GraphLayoutNode { + wxRealPoint position; + wxRealPoint displacement; + }; + + struct GraphLayoutEdge { + GraphLayoutNode &node1; + GraphLayoutNode &node2; + float weight; + }; + + GraphAutoLayout(); + GraphAutoLayout(std::vector busData, std::vector branchData); + ~GraphAutoLayout(); + + void CalculatePositions(int iterations, double scale); + + protected: + void AddLink(size_t index1, size_t index2, float weight = 1.f); + void Compute(size_t iterations); + + std::vector m_nodes; + std::vector m_edges; + + std::vector m_busData; + std::vector m_branchData; +}; + +#endif // GRAPHAUTOLAYOUT_H -- cgit