diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2019-07-18 09:22:27 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 09:22:27 -0300 |
commit | 8357c081eb75147bb8f94d8b6e367d88ea3898ed (patch) | |
tree | 9d9726fdcefb917475d6b33344d2b832d4e78ef8 /Project/GraphAutoLayout.h | |
parent | 295b775ad53eb1e128b705e6028f9690dc6fa640 (diff) | |
parent | 7f46d390b8cc1d5f37560f52b222198dbc5e1225 (diff) | |
download | PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.gz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.xz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.zip |
Merge pull request #50 from Thales1330/wip/induction-motor
Wip/induction motor
Diffstat (limited to 'Project/GraphAutoLayout.h')
-rw-r--r-- | Project/GraphAutoLayout.h | 46 |
1 files changed, 46 insertions, 0 deletions
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 <cmath> +//#include <vector> +#include <wx/gdicmn.h> +#include <wx/progdlg.h> + +// 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<ParseMatpower::BusData*> busData, std::vector<ParseMatpower::BranchData*> 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<GraphLayoutNode> m_nodes; + std::vector<GraphLayoutEdge> m_edges; + + std::vector<ParseMatpower::BusData*> m_busData; + std::vector<ParseMatpower::BranchData*> m_branchData; +}; + +#endif // GRAPHAUTOLAYOUT_H |