Debian Codegraph @

src/Gui/SoFCVectorizeSVGAction.h

raw
1 /***************************************************************************
2 * Copyright (c) 2008 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_SOFCVECTORIZESVGACTION_H
24 #define GUI_SOFCVECTORIZESVGACTION_H
25
26 #include <Inventor/annex/HardCopy/SoVectorizeAction.h>
27 #include <Inventor/annex/HardCopy/SoVectorOutput.h>
28
29 #include <fstream>
30 #include <FCGlobal.h>
31
32
33 namespace Gui
34 {
35
36 class GuiExport SoSVGVectorOutput: public SoVectorOutput
37 {
38 public:
39 SoSVGVectorOutput();
40 ~SoSVGVectorOutput() override;
41
42 SbBool openFile(const char* filename) override;
43 void closeFile() override;
44 std::fstream& getFileStream();
45
46 private:
47 std::fstream file;
48 };
49
50 /**
51 * @author Werner Mayer
52 */
53 class SoFCVectorizeSVGActionP;
54 class GuiExport SoFCVectorizeSVGAction: public SoVectorizeAction
55 {
56 using inherited = SoReplacedElement;
57
58 SO_ACTION_HEADER(SoFCVectorizeSVGAction);
59
60 public:
61 SoFCVectorizeSVGAction();
62 ~SoFCVectorizeSVGAction() override;
63
64 static void initClass();
65 SoSVGVectorOutput* getSVGOutput() const;
66
67 virtual void setBackgroundState(bool b)
68 {
69 m_backgroundState = b;
70 }
71 virtual bool getBackgroundState() const
72 {
73 return m_backgroundState;
74 }
75 virtual void setLineWidth(double w)
76 {
77 m_lineWidth = w;
78 }
79 virtual double getLineWidth() const
80 {
81 return m_lineWidth;
82 }
83 virtual void setUseMM(bool b)
84 {
85 m_usemm = b;
86 }
87 virtual bool getUseMM() const
88 {
89 return m_usemm;
90 }
91
92 protected:
93 void printHeader() const override;
94 void printFooter() const override;
95 void printBackground() const override;
96 void printItem(const SoVectorizeItem* item) const override;
97 void printViewport() const override;
98
99 private:
100 SoFCVectorizeSVGActionP* p;
101 friend class SoFCVectorizeSVGActionP;
102 bool m_backgroundState {true};
103 double m_lineWidth {1.0};
104 bool m_usemm {false};
105 };
106
107 } // namespace Gui
108
109 #endif // GUI_SOFCVECTORIZESVGACTION_H