Code

Fixed messed up transformations because of a missing cairo_restore() and removed...
[inkscape.git] / src / extension / internal / pov-out.h
index 7e71d121cf921884d25dd58839260c944e95abfa..18aad56d190d52b239c2f7cf3cc3ff9ee55698b9 100644 (file)
 #include <glib.h>
 #include "extension/implementation/implementation.h"
 
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
+namespace Inkscape
+{
+namespace Extension
+{
+namespace Internal
+{
 
+
+
+/**
+ * Output bezier splines in POVRay format.
+ * 
+ * For information, @see:  
+ * http://www.povray.org 
+ */ 
 class PovOutput : public Inkscape::Extension::Implementation::Implementation
 {
 
-    public:
 
+/**
+ * Our internal String definition
+ */ 
+typedef Glib::ustring String;
+
+
+public:
+
+    /**
+     * Check whether we can actually output using this module
+     */
        bool check (Inkscape::Extension::Extension * module);
 
-       void          save  (Inkscape::Extension::Output *mod,
-                            SPDocument *doc,
-                            const gchar *uri);
+    /**
+     * API call to perform the output to a file
+     */
+       void save (Inkscape::Extension::Output *mod,
+                  SPDocument *doc, const gchar *uri);
 
-       static void   init  (void);
+    /**
+     * Inkscape runtime startup call.
+     */
+       static void init(void);
        
+    /**
+     * Reset variables to initial state
+     */
+       void reset();
+       
+private:
+
+       /**
+        * Format text to our output buffer
+        */             
+       void out(char const *fmt, ...) G_GNUC_PRINTF(2,3);
+
+    /**
+     * Output a 2d vector
+     */
+    void vec2(double a, double b);
+
+    /**
+     * Output a 3d vector
+     */
+    void vec3(double a, double b, double c);
+
+    /**
+     * Output a 4d vector
+     */
+    void vec4(double a, double b, double c, double d);
+
+    /**
+     * Output an rgbf color vector
+     */
+    void rgbf(double r, double g, double b, double f);
+
+    /**
+     * Output one bezier's start, start-control, 
+     *      end-control, and end nodes
+     */
+    void segment(int segNr, double a0, double a1,
+                            double b0, double b1,
+                            double c0, double c1,
+                            double d0, double d1);
+
+
+    /**
+     * Output the file header
+     */
+    void doHeader();
+
+    /**
+     * Output the file footer
+     */
+    void doTail();
+
+    /**
+     * Output the SVG document's curve data as POV curves
+     */
+    void doCurves(SPDocument *doc);
+
+    /**
+     * Actual method to save document
+     */
+       void saveDocument(SPDocument *doc, const gchar *uri);
+
+
+    /**
+     * used for saving information about shapes
+     */
+    class PovShapeInfo
+    {
+    public:
+        PovShapeInfo()
+            {}
+        PovShapeInfo(const PovShapeInfo &other)
+            { assign(other); }
+        PovShapeInfo operator=(const PovShapeInfo &other)
+            { assign(other); return *this; }
+        virtual ~PovShapeInfo()
+            {}
+        String id;
+        String color;
+
+    private:
+        void assign(const PovShapeInfo &other)
+            {
+            id    = other.id;
+            color = other.color;
+            }
+    };
+
+    //A list for saving information about the shapes
+    std::vector<PovShapeInfo> povShapes;
+    
+    //For formatted output
+       String outbuf;
+
+    //For statistics
+    int nrNodes;
+    int nrSegments;
+    int nrShapes;
 
 };
 
 
 
 
-}  //namespace Internal
-}  //namespace Extension
-}  //namespace Inkscape
+}  // namespace Internal
+}  // namespace Extension
+}  // namespace Inkscape