Debian Codegraph @

src/Gui/SoFCDB.h

raw
1 /***************************************************************************
2 * Copyright (c) 2005 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_SOFCDB_H
24 #define GUI_SOFCDB_H
25
26 #include <iosfwd>
27 #include <map>
28 #include <string>
29 #include <Inventor/C/basic.h>
30
31 #include <FCGlobal.h>
32
33 class SoNode;
34 class SoGroup;
35 class SoVRMLGroup;
36
37 namespace Gui
38 {
39 /**
40 * The FreeCAD database class to initialize all our own Inventor nodes.
41 * @author Werner Mayer
42 */
43 class GuiExport SoFCDB
44 {
45 public:
46 static SbBool isInitialized();
47 static void init();
48 static void finish();
49 static SoNode* replaceSwitches(SoNode* node);
50 /// helper to apply a SoWriteAction to a node and write it to a string
51 static const std::string& writeNodesToString(SoNode* root);
52 static bool writeToVRML(SoNode* node, const char* filename, bool binary);
53 static void writeToVRML(SoNode* node, std::string& buffer);
54 static bool writeToX3D(SoNode* node, const char* filename, bool binary);
55 static bool writeToX3D(SoNode* node, bool exportViewpoints, std::string& buffer);
56 static bool writeToX3DOM(SoNode* node, std::string& buffer);
57 // Write to Inventor, VRML, X3D or XHTML (based on X3DOM) file
58 static bool writeToFile(SoNode* node, const char* filename, bool binary);
59 /*! container for app lifetime storage. See SoTransformDragger for details
60 * on why this is needed.
61 */
62 static SoGroup* getStorage();
63
64 private:
65 static void writeX3D(SoVRMLGroup* node, bool exportViewpoints, std::ostream& out);
66 static void writeX3DChild(
67 SoNode* node,
68 std::map<SoNode*, std::string>& nodeMap,
69 int& numDEF,
70 int spaces,
71 std::ostream& out
72 );
73 static void writeX3DFields(
74 SoNode* node,
75 std::map<SoNode*, std::string>& nodeMap,
76 bool isRoot,
77 int& numDEF,
78 int spaces,
79 std::ostream& out
80 );
81 };
82
83 } // namespace Gui
84
85 #endif // GUI_SOFCDB_H