1 /******************************************************************************
2 
3   This source file is part of the Avogadro project.
4 
5   Copyright 2014 Kitware, Inc.
6 
7   This source code is released under the New BSD License, (the "License").
8 
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14 
15 ******************************************************************************/
16 
17 #ifndef AVOGADRO_RENDERING_POVRAYVISITOR_H
18 #define AVOGADRO_RENDERING_POVRAYVISITOR_H
19 
20 #include "visitor.h"
21 
22 #include "avogadrorendering.h"
23 #include "camera.h"
24 #include <string>
25 
26 namespace Avogadro {
27 namespace Rendering {
28 
29 /**
30  * @class POVRayVisitor povrayvisitor.h <avogadro/rendering/povrayvisitor.h>
31  * @brief Visitor that visits scene elements and creates a POV-Ray input file.
32  *
33  * This visitor will render elements in the scene to a text file that contains
34  * elements that can be rendered by POV-Ray.
35  */
36 
37 class AVOGADRORENDERING_EXPORT POVRayVisitor : public Visitor
38 {
39 public:
40   POVRayVisitor(const Camera& camera);
41   ~POVRayVisitor() override;
42 
43   void begin();
44   std::string end();
45 
46   /**
47    * The overloaded visit functions, the base versions of which do nothing.
48    */
visit(Node &)49   void visit(Node&) override { return; }
visit(GroupNode &)50   void visit(GroupNode&) override { return; }
visit(GeometryNode &)51   void visit(GeometryNode&) override { return; }
52   void visit(Drawable&) override;
53   void visit(SphereGeometry&) override;
54   void visit(AmbientOcclusionSphereGeometry&) override;
55   void visit(CylinderGeometry&) override;
56   void visit(MeshGeometry&) override;
visit(TextLabel2D &)57   void visit(TextLabel2D&) override { return; }
visit(TextLabel3D &)58   void visit(TextLabel3D&) override { return; }
59   void visit(LineStripGeometry& geometry) override;
60 
setCamera(const Camera & c)61   void setCamera(const Camera& c) { m_camera = c; }
camera()62   Camera camera() const { return m_camera; }
63 
setBackgroundColor(const Vector3ub & c)64   void setBackgroundColor(const Vector3ub& c) { m_backgroundColor = c; }
setAmbientColor(const Vector3ub & c)65   void setAmbientColor(const Vector3ub& c) { m_ambientColor = c; }
setAspectRatio(float ratio)66   void setAspectRatio(float ratio) { m_aspectRatio = ratio; }
67 
68 private:
69   Camera m_camera;
70   Vector3ub m_backgroundColor;
71   Vector3ub m_ambientColor;
72   float m_aspectRatio;
73   std::string m_sceneData;
74 };
75 
76 } // End namespace Rendering
77 } // End namespace Avogadro
78 
79 #endif // AVOGADRO_RENDERING_POVRAYVISITOR_H
80