Changeset View
Changeset View
Standalone View
Standalone View
src/part/graphsubgraph.h
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #ifndef GRAPH_SUBGRAPH_H | 23 | #ifndef GRAPH_SUBGRAPH_H | ||
24 | #define GRAPH_SUBGRAPH_H | 24 | #define GRAPH_SUBGRAPH_H | ||
25 | 25 | | |||
26 | #include <QMap> | 26 | #include <QMap> | ||
27 | #include <QTextStream> | 27 | #include <QTextStream> | ||
28 | 28 | | |||
29 | #include "dotgrammar.h" | 29 | #include "dotgrammar.h" | ||
30 | #include "graphelement.h" | | |||
31 | #include "dotrenderop.h" | 30 | #include "dotrenderop.h" | ||
31 | #include "graphelement.h" | ||||
32 | 32 | | |||
33 | #include <graphviz/gvc.h> | 33 | #include <graphviz/gvc.h> | ||
34 | 34 | | |||
35 | namespace KGraphViewer | 35 | namespace KGraphViewer | ||
36 | { | 36 | { | ||
37 | | ||||
38 | | ||||
39 | class CanvasSubgraph; | 37 | class CanvasSubgraph; | ||
40 | class GraphSubgraph; | 38 | class GraphSubgraph; | ||
41 | 39 | | |||
42 | typedef QMap<QString, GraphSubgraph*> GraphSubgraphMap; | 40 | typedef QMap<QString, GraphSubgraph *> GraphSubgraphMap; | ||
43 | 41 | | |||
44 | | ||||
45 | /** | 42 | /** | ||
46 | * Colors and styles are DOT names | 43 | * Colors and styles are DOT names | ||
47 | */ | 44 | */ | ||
48 | class GraphSubgraph : public GraphElement | 45 | class GraphSubgraph : public GraphElement | ||
49 | { | 46 | { | ||
50 | Q_OBJECT | 47 | Q_OBJECT | ||
51 | public: | 48 | public: | ||
52 | GraphSubgraph(); | 49 | GraphSubgraph(); | ||
53 | explicit GraphSubgraph(graph_t* sg); | 50 | explicit GraphSubgraph(graph_t *sg); | ||
54 | 51 | | |||
55 | ~GraphSubgraph() override {} | 52 | ~GraphSubgraph() override | ||
53 | { | ||||
54 | } | ||||
56 | 55 | | |||
57 | inline const GraphSubgraphMap& subgraphs() const {return m_subgraphsMap;} | 56 | inline const GraphSubgraphMap &subgraphs() const | ||
58 | inline GraphSubgraphMap& subgraphs() {return m_subgraphsMap;} | 57 | { | ||
58 | return m_subgraphsMap; | ||||
59 | } | ||||
60 | inline GraphSubgraphMap &subgraphs() | ||||
61 | { | ||||
62 | return m_subgraphsMap; | ||||
63 | } | ||||
59 | 64 | | |||
60 | void updateWithSubgraph(const GraphSubgraph& subgraph); | 65 | void updateWithSubgraph(const GraphSubgraph &subgraph); | ||
61 | void updateWithSubgraph(graph_t* subgraph); | 66 | void updateWithSubgraph(graph_t *subgraph); | ||
62 | 67 | | |||
63 | CanvasSubgraph* canvasSubgraph() { return (CanvasSubgraph*)canvasElement(); } | 68 | CanvasSubgraph *canvasSubgraph() | ||
64 | void setCanvasSubgraph(CanvasSubgraph* cs) { setCanvasElement((CanvasElement*)cs); } | 69 | { | ||
70 | return (CanvasSubgraph *)canvasElement(); | ||||
71 | } | ||||
72 | void setCanvasSubgraph(CanvasSubgraph *cs) | ||||
73 | { | ||||
74 | setCanvasElement((CanvasElement *)cs); | ||||
75 | } | ||||
65 | 76 | | |||
66 | QString backColor() const override; | 77 | QString backColor() const override; | ||
67 | 78 | | |||
68 | inline const QList<GraphElement*>& content() const {return m_content;} | 79 | inline const QList<GraphElement *> &content() const | ||
69 | inline QList<GraphElement*>& content() {return m_content;} | 80 | { | ||
70 | inline void setContent(QList<GraphElement*>& c) {m_content=c;} | 81 | return m_content; | ||
82 | } | ||||
83 | inline QList<GraphElement *> &content() | ||||
84 | { | ||||
85 | return m_content; | ||||
86 | } | ||||
87 | inline void setContent(QList<GraphElement *> &c) | ||||
88 | { | ||||
89 | m_content = c; | ||||
90 | } | ||||
71 | 91 | | |||
72 | void removeElement(GraphElement* element); | 92 | void removeElement(GraphElement *element); | ||
73 | 93 | | |||
74 | /// Recursively walk through this subgraph and its subsubgraphs to find an element named id | 94 | /// Recursively walk through this subgraph and its subsubgraphs to find an element named id | ||
75 | /// @return the node found or 0 if there is no such node | 95 | /// @return the node found or 0 if there is no such node | ||
76 | GraphElement* elementNamed(const QString& id); | 96 | GraphElement *elementNamed(const QString &id); | ||
77 | 97 | | |||
78 | | ||||
79 | /// Recursively walk through this subgraph and its subsubgraphs to make | 98 | /// Recursively walk through this subgraph and its subsubgraphs to make | ||
80 | /// the given element selected or not depending on the selectValue parameter | 99 | /// the given element selected or not depending on the selectValue parameter | ||
81 | /// and unselect other elements depending on the unselect others parameter | 100 | /// and unselect other elements depending on the unselect others parameter | ||
82 | /// @return true if the given node was found | 101 | /// @return true if the given node was found | ||
83 | virtual bool setElementSelected( | 102 | virtual bool setElementSelected(GraphElement *element, bool selectValue, bool unselectOthers); | ||
84 | GraphElement* element, | | |||
85 | bool selectValue, | | |||
86 | bool unselectOthers); | | |||
87 | 103 | | |||
88 | void retrieveSelectedElementsIds(QList<QString> selection); | 104 | void retrieveSelectedElementsIds(QList<QString> selection); | ||
89 | 105 | | |||
90 | private: | 106 | private: | ||
91 | QList<GraphElement*> m_content; | 107 | QList<GraphElement *> m_content; | ||
92 | GraphSubgraphMap m_subgraphsMap; | 108 | GraphSubgraphMap m_subgraphsMap; | ||
93 | }; | 109 | }; | ||
94 | 110 | | |||
95 | QTextStream& operator<<(QTextStream& stream, const GraphSubgraph& s); | 111 | QTextStream &operator<<(QTextStream &stream, const GraphSubgraph &s); | ||
96 | 112 | | |||
97 | } | 113 | } | ||
98 | 114 | | |||
99 | #endif | 115 | #endif | ||
100 | | ||||
101 | | ||||
102 | |