Blender  V2.93
ScenePrettyPrinter.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include <fstream>
25 #include <iostream>
26 #include <string>
27 
28 #include "SceneVisitor.h"
29 
30 using namespace std;
31 
32 namespace Freestyle {
33 
35  public:
36  ScenePrettyPrinter(const string filename = "SceneLog.txt") : SceneVisitor()
37  {
38  if (!filename.empty()) {
39  _ofs.open(filename.c_str());
40  }
41  if (!_ofs.is_open()) {
42  cerr << "Warning, unable to open file \"" << filename << "\"" << endl;
43  }
44  _space = "";
45  }
46 
48  {
49  if (_ofs.is_open()) {
50  _ofs.close();
51  }
52  }
53 
54  //
55  // visitClass methods
56  //
58 
65 
71 
72  virtual void visitNodeShapeBefore(NodeShape &);
73  virtual void visitNodeShapeAfter(NodeShape &);
74  virtual void visitNodeGroupBefore(NodeGroup &);
75  virtual void visitNodeGroupAfter(NodeGroup &);
76  virtual void visitNodeDrawingStyleBefore(NodeDrawingStyle &);
77  virtual void visitNodeDrawingStyleAfter(NodeDrawingStyle &);
78  virtual void visitNodeTransformBefore(NodeTransform &);
79  virtual void visitNodeTransformAfter(NodeTransform &);
80 
81  protected:
83  {
84  _space += " ";
85  }
86 
88  {
89  _space.erase(0, 2);
90  }
91 
92  private:
93  ofstream _ofs;
94  string _space;
95 };
96 
97 } /* namespace Freestyle */
Class to visit (without doing anything) a scene graph structure.
ScenePrettyPrinter(const string filename="SceneLog.txt")
VISIT_DECL(NodeDrawingStyle)
inherits from class Rep
Definition: AppCanvas.cpp:32