index ecdd6bb34ef6d67356fc63417d6c734060a05464..7ed7408db3632ddd8031a26910b22e5b28f1afe2 100644 (file)
+//########################################################################
+//# U T I L I T Y
+//########################################################################
+
/**
}
+
+
+
//########################################################################
//# OUTPUT FORMATTING
//########################################################################
}
-void PovOutput::out(char *fmt, ...)
+
+
+
+
+/**
+ * Output data to the buffer, printf()-style
+ */
+void PovOutput::out(char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
-#ifdef __MINGW32__
- vsnprintf(fmtbuf, 4096, fmt, args);
-#else
- vsprintf(fmtbuf, 4096, fmt, args);
-#endif
+ gchar * output = g_strdup_vprintf(fmt, args);
va_end(args);
- outbuf.append(fmtbuf);
+ outbuf.append(output);
+ g_free(output);
}
+/**
+ * Output a 3d vector
+ */
void PovOutput::vec2(double a, double b)
{
outbuf.append("<");
outbuf.append(">");
}
+
+
+/**
+ * Output a 3d vector
+ */
void PovOutput::vec3(double a, double b, double c)
{
outbuf.append("<");
outbuf.append(">");
}
+
+
+/**
+ * Output a v4d ector
+ */
void PovOutput::vec4(double a, double b, double c, double d)
{
outbuf.append("<");
}
+/**
+ * Output an rgbf color vector
+ */
void PovOutput::rgbf(double r, double g, double b, double f)
{
//"rgbf < %1.3f, %1.3f, %1.3f %1.3f>"
+/**
+ * Output one bezier's start, start-control, end-control, and end nodes
+ */
void PovOutput::segment(int segNr, double a0, double a1,
double b0, double b1,
double c0, double c1,
+/**
+ * Output the file header
+ */
void PovOutput::doHeader()
{
time_t tim = time(NULL);
}
+
+/**
+ * Output the file footer
+ */
void PovOutput::doTail()
{
out("\n\n");
+/**
+ * Output the curve data to buffer
+ */
void PovOutput::doCurves(SPDocument *doc)
{
std::vector<Inkscape::XML::Node *>results;
SPStyle *style = SP_OBJECT_STYLE(shape);
/* fixme: Handle other fill types, even if this means translating gradients to a single
flat colour. */
- if (style && (style->fill.type == SP_PAINT_TYPE_COLOR))
+ if (style && (style->fill.isColor()))
{
// see color.h for how to parse SPColor
float rgb[3];
}
+
+
//########################################################################
//# M A I N O U T P U T
//########################################################################
+/**
+ * Set values back to initial state
+ */
void PovOutput::reset()
{
nrNodes = 0;
/**
* Saves the <paths> of an Inkscape SVG file as PovRay spline definitions
-*/
-void
-PovOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *uri)
+ */
+void PovOutput::saveDocument(SPDocument *doc, gchar const *uri)
{
-
- Inkscape::IO::dump_fopen_call(uri, "L");
- FILE *f = Inkscape::IO::fopen_utf8name(uri, "w");
- if (!f)
- return;
-
reset();
+ //###### SAVE IN POV FORMAT TO BUFFER
//# Lets do the curves first, to get the stats
doCurves(doc);
String curveBuf = outbuf;
@@ -572,7 +611,16 @@ PovOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *
outbuf.append(curveBuf);
doTail();
-
+
+
+
+
+ //###### WRITE TO FILE
+ Inkscape::IO::dump_fopen_call(uri, "L");
+ FILE *f = Inkscape::IO::fopen_utf8name(uri, "w");
+ if (!f)
+ return;
+
for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); iter++)
{
int ch = *iter;
@@ -595,6 +643,18 @@ PovOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *
+/**
+ * API call to save document
+*/
+void
+PovOutput::save(Inkscape::Extension::Output *mod,
+ SPDocument *doc, gchar const *uri)
+{
+ saveDocument(doc, uri);
+}
+
+
+
/**
* Make sure that we are in the database
*/