~ubuntu-branches/ubuntu/oneiric/inkscape/oneiric-updates

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/extension/internal/pov-out.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
15
 
 
16
#ifndef EXTENSION_INTERNAL_POV_OUT_H
 
17
#define EXTENSION_INTERNAL_POV_OUT_H
 
18
 
 
19
#include <glib.h>
 
20
#include "extension/implementation/implementation.h"
 
21
#include <sp-path.h>
 
22
 
 
23
 
 
24
namespace Inkscape
 
25
{
 
26
namespace Extension
 
27
{
 
28
namespace Internal
 
29
{
 
30
 
 
31
 
 
32
 
 
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
{
 
41
 
 
42
 
 
43
public:
 
44
 
 
45
    /**
 
46
     * Our internal String definition
 
47
     */
 
48
    typedef Glib::ustring String;
 
49
 
 
50
 
 
51
    /**
 
52
     * Check whether we can actually output using this module
 
53
     */
 
54
        bool check (Inkscape::Extension::Extension * module);
 
55
 
 
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);
 
61
 
 
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:
 
73
 
 
74
        /**
 
75
         * Format text to our output buffer
 
76
         */             
 
77
        void out(const char *fmt, ...) G_GNUC_PRINTF(2,3);
 
78
 
 
79
    /**
 
80
     * Output a 2d vector
 
81
     */
 
82
    void vec2(double a, double b);
 
83
 
 
84
    /**
 
85
     * Output a 3d vector
 
86
     */
 
87
    void vec3(double a, double b, double c);
 
88
 
 
89
    /**
 
90
     * Output a 4d vector
 
91
     */
 
92
    void vec4(double a, double b, double c, double d);
 
93
 
 
94
    /**
 
95
     * Output an rgbf color vector
 
96
     */
 
97
    void rgbf(double r, double g, double b, double f);
 
98
 
 
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);
 
107
 
 
108
 
 
109
    /**
 
110
     * Output the file header
 
111
     */
 
112
    bool doHeader();
 
113
 
 
114
    /**
 
115
     * Output the file footer
 
116
     */
 
117
    bool doTail();
 
118
 
 
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);
 
125
 
 
126
    /**
 
127
     * Actual method to save document
 
128
     */
 
129
    void saveDocument(SPDocument *doc, gchar const *filename);
 
130
 
 
131
 
 
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;
 
148
 
 
149
    private:
 
150
        void assign(const PovShapeInfo &other)
 
151
            {
 
152
            id    = other.id;
 
153
            color = other.color;
 
154
            }
 
155
    };
 
156
 
 
157
    //A list for saving information about the shapes
 
158
    std::vector<PovShapeInfo> povShapes;
 
159
    
 
160
    //For formatted output
 
161
        String outbuf;
 
162
 
 
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;
 
173
 
 
174
};
 
175
 
 
176
 
 
177
 
 
178
 
 
179
}  // namespace Internal
 
180
}  // namespace Extension
 
181
}  // namespace Inkscape
 
182
 
 
183
 
 
184
 
 
185
#endif /* EXTENSION_INTERNAL_POV_OUT_H */
 
186