forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodeGenerator.h
79 lines (58 loc) · 1.76 KB
/
NodeGenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
// Tell GCC to ignore implicitly declared copy methods as long as
// Qt is not compliant.
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-copy"
#endif
#include <QtWidgets/QGraphicsScene>
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#include <string>
#include "TreeNode.h"
#include "NodeOptions.h"
#include "Node.h"
#include "Edge.h"
#include "iostream"
#include "fstream"
#include "stack"
namespace Monitor {
class NodeGenerator {
public:
// calculate the layout based on options and number of nodes
void calcLayout(TreeNode *, int w, int h);
int getSceneWidth() { return sceneWidth_; }
int getSceneHeight() { return sceneHeight_; }
// generate the new graph
void draw(QGraphicsScene *);
NodeGenerator (TreeNode *, NodeOptionsData, bool honorDisplayFlag = false);
private:
TreeNode *root_;
NodeOptionsData nodeOpt_;
int sceneWidth_;
int sceneHeight_;
bool honorDisplayFlag_; // if true only graph treeNodes that have display flag set
std::vector<Edge *> edges_;
// find readers and writers
void findConnections(TreeNode *);
void connectNodes(QGraphicsScene *);
void generate(TreeNode *, QGraphicsScene *, int w, int h, Node* parent = 0);
// check to see if node is valid and populate node text
bool isNodeValid(TreeNode *t, QString &text);
std::string abbr(const std::string &);
std::ofstream fout;
// these are used for finding connections in the graphs
std::map<TreeNode *, Node *> nMap_;
std::map<TreeNode *, std::string> rMap_;
std::map<std::string, TreeNode *> wMap_;
};
}; // namespace Monitor