Code

Filters. New Chromolitho custom predefined filter (experimental). Some UI (notebooks...
[inkscape.git] / src / extension / internal / pov-out.h
1 /*
2  * A simple utility for exporting Inkscape svg Shapes as PovRay bezier
3  * prisms.  Note that this is output-only, and would thus seem to be
4  * better placed as an 'export' rather than 'output'.  However, Export
5  * handles all or partial documents, while this outputs ALL shapes in
6  * the current SVG document.
7  *
8  * Authors:
9  *   Bob Jamison <ishmal@inkscape.org>
10  *
11  * Copyright (C) 2004-2008 Authors
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 #ifndef EXTENSION_INTERNAL_POV_OUT_H
17 #define EXTENSION_INTERNAL_POV_OUT_H
19 #include <glib.h>
20 #include "extension/implementation/implementation.h"
21 #include <sp-path.h>
24 namespace Inkscape
25 {
26 namespace Extension
27 {
28 namespace Internal
29 {
33 /**
34  * Output bezier splines in POVRay format.
35  * 
36  * For information, @see:  
37  * http://www.povray.org 
38  */ 
39 class PovOutput : public Inkscape::Extension::Implementation::Implementation
40 {
43 public:
45     /**
46      * Our internal String definition
47      */
48     typedef Glib::ustring String;
51     /**
52      * Check whether we can actually output using this module
53      */
54         bool check (Inkscape::Extension::Extension * module);
56     /**
57      * API call to perform the output to a file
58      */
59     void save(Inkscape::Extension::Output *mod,
60               SPDocument *doc, gchar const *filename);
62     /**
63      * Inkscape runtime startup call.
64      */
65         static void init(void);
66         
67     /**
68      * Reset variables to initial state
69      */
70         void reset();
71         
72 private:
74         /**
75          * Format text to our output buffer
76          */             
77         void out(const char *fmt, ...) G_GNUC_PRINTF(2,3);
79     /**
80      * Output a 2d vector
81      */
82     void vec2(double a, double b);
84     /**
85      * Output a 3d vector
86      */
87     void vec3(double a, double b, double c);
89     /**
90      * Output a 4d vector
91      */
92     void vec4(double a, double b, double c, double d);
94     /**
95      * Output an rgbf color vector
96      */
97     void rgbf(double r, double g, double b, double f);
99     /**
100      * Output one bezier's start, start-control, 
101      *      end-control, and end nodes
102      */
103     void segment(int segNr, double a0, double a1,
104                             double b0, double b1,
105                             double c0, double c1,
106                             double d0, double d1);
109     /**
110      * Output the file header
111      */
112     bool doHeader();
114     /**
115      * Output the file footer
116      */
117     bool doTail();
119     /**
120      * Output the SVG document's curve data as POV curves
121      */
122     bool doCurve(SPItem *item, const String &id);
123     bool doTreeRecursive(SPDocument *doc, SPObject *obj);
124     bool doTree(SPDocument *doc);
126     /**
127      * Actual method to save document
128      */
129     void saveDocument(SPDocument *doc, gchar const *filename);
132     /**
133      * used for saving information about shapes
134      */
135     class PovShapeInfo
136     {
137     public:
138         PovShapeInfo()
139             {}
140         PovShapeInfo(const PovShapeInfo &other)
141             { assign(other); }
142         PovShapeInfo operator=(const PovShapeInfo &other)
143             { assign(other); return *this; }
144         virtual ~PovShapeInfo()
145             {}
146         String id;
147         String color;
149     private:
150         void assign(const PovShapeInfo &other)
151             {
152             id    = other.id;
153             color = other.color;
154             }
155     };
157     //A list for saving information about the shapes
158     std::vector<PovShapeInfo> povShapes;
159     
160     //For formatted output
161         String outbuf;
163     //For statistics
164     int nrNodes;
165     int nrSegments;
166     int nrShapes;
167     int idIndex;
168     
169     double minx;
170     double miny;
171     double maxx;
172     double maxy;
174 };
179 }  // namespace Internal
180 }  // namespace Extension
181 }  // namespace Inkscape
185 #endif /* EXTENSION_INTERNAL_POV_OUT_H */