Changeset View
Changeset View
Standalone View
Standalone View
src/part/layoutagraphthread.h
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | 17 | | |||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef LAYOUTAGRAPHTHREAD_H | 20 | #ifndef LAYOUTAGRAPHTHREAD_H | ||
21 | #define LAYOUTAGRAPHTHREAD_H | 21 | #define LAYOUTAGRAPHTHREAD_H | ||
22 | 22 | | |||
23 | #include <QThread> | | |||
24 | #include <QSemaphore> | 23 | #include <QSemaphore> | ||
24 | #include <QThread> | ||||
25 | 25 | | |||
26 | #include <graphviz/gvc.h> | 26 | #include <graphviz/gvc.h> | ||
27 | 27 | | |||
28 | int threadsafe_wrap_gvLayout(GVC_t *gvc, graph_t *g, const char *engine); | 28 | int threadsafe_wrap_gvLayout(GVC_t *gvc, graph_t *g, const char *engine); | ||
29 | int threadsafe_wrap_gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out); | 29 | int threadsafe_wrap_gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out); | ||
30 | 30 | | |||
31 | class LayoutAGraphThread : public QThread | 31 | class LayoutAGraphThread : public QThread | ||
32 | { | 32 | { | ||
33 | Q_OBJECT | 33 | Q_OBJECT | ||
34 | public: | 34 | public: | ||
35 | LayoutAGraphThread(); | 35 | LayoutAGraphThread(); | ||
36 | ~LayoutAGraphThread() override; | 36 | ~LayoutAGraphThread() override; | ||
37 | void layoutGraph(graph_t* graph, const QString& layoutCommand); | 37 | void layoutGraph(graph_t *graph, const QString &layoutCommand); | ||
38 | inline graph_t* g() {return m_g;} | 38 | inline graph_t *g() | ||
39 | inline GVC_t* gvc() {return m_gvc;} | 39 | { | ||
40 | inline const QString& layoutCommand() const {return m_layoutCommand;} | 40 | return m_g; | ||
41 | void processed_finished() { sem.release(); } | 41 | } | ||
42 | inline GVC_t *gvc() | ||||
43 | { | ||||
44 | return m_gvc; | ||||
45 | } | ||||
46 | inline const QString &layoutCommand() const | ||||
47 | { | ||||
48 | return m_layoutCommand; | ||||
49 | } | ||||
50 | void processed_finished() | ||||
51 | { | ||||
52 | sem.release(); | ||||
53 | } | ||||
42 | 54 | | |||
43 | protected: | 55 | protected: | ||
44 | void run() override; | 56 | void run() override; | ||
45 | 57 | | |||
46 | private: | 58 | private: | ||
47 | QSemaphore sem; | 59 | QSemaphore sem; | ||
48 | QString m_layoutCommand; | 60 | QString m_layoutCommand; | ||
49 | graph_t* m_g; | 61 | graph_t *m_g; | ||
50 | GVC_t *m_gvc; | 62 | GVC_t *m_gvc; | ||
51 | }; | 63 | }; | ||
52 | 64 | | |||
53 | #endif // LAYOUTAGRAPHTHREAD_H | 65 | #endif // LAYOUTAGRAPHTHREAD_H |