Debian Codegraph @

src/Gui/GraphvizView.h

raw
1 /***************************************************************************
2 * Copyright (c) 2014 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_GRAPHVIZVIEW_H
24 #define GUI_GRAPHVIZVIEW_H
25
26 #include "MDIView.h"
27
28
29 class QGraphicsScene;
30 class QGraphicsView;
31 class QSvgRenderer;
32 class QGraphicsSvgItem;
33 class GraphicsViewZoom;
34
35 namespace Gui
36 {
37
38 class GraphvizWorker;
39
40 class GuiExport GraphvizView: public MDIView
41 {
42 Q_OBJECT
43
44 public:
45 explicit GraphvizView(App::Document& _doc, QWidget* parent = nullptr);
46 ~GraphvizView() override;
47
48 QByteArray exportGraph(const QString& filter);
49
50 /// Message handler
51 bool onMsg(const char* pMsg, const char** ppReturn) override;
52 /// Message handler test
53 bool onHasMsg(const char* pMsg) const override;
54 /** @name Printing */
55 //@{
56 void print(QPrinter* printer) override;
57 /** Print content of view */
58 void print() override;
59 /** Print to PDF file */
60 void printPdf() override;
61 /** Show a preview dialog */
62 void printPreview() override;
63 //@}
64
65 private Q_SLOTS:
66 void svgFileRead(const QByteArray& data);
67 void error();
68 void done();
69
70 private:
71 void updateSvgItem(const App::Document& doc);
72 void disconnectSignals();
73
74 const App::Document& doc;
75 std::string graphCode;
76 QGraphicsScene* scene;
77 QGraphicsView* view;
78 GraphicsViewZoom* zoomer;
79 QGraphicsSvgItem* svgItem;
80 QSvgRenderer* renderer;
81 GraphvizWorker* thread;
82 int nPending;
83
84 using Connection = boost::signals2::scoped_connection;
85 Connection recomputeConnection;
86 Connection undoConnection;
87 Connection redoConnection;
88 };
89
90 } // namespace Gui
91
92 #endif // GUI_GRAPHVIZVIEW_H