summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: edac784)
raw | patch | inline | side by side (parent: edac784)
author | ishmal <ishmal@users.sourceforge.net> | |
Mon, 12 Mar 2007 15:51:30 +0000 (15:51 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Mon, 12 Mar 2007 15:51:30 +0000 (15:51 +0000) |
src/extension/internal/pov-out.cpp | patch | blob | history | |
src/extension/internal/pov-out.h | patch | blob | history |
index ecdd6bb34ef6d67356fc63417d6c734060a05464..14a27914e43bd66ef607adf80d11ce2e92db3087 100644 (file)
+//########################################################################
+//# U T I L I T Y
+//########################################################################
+
/**
}
+
+
+
//########################################################################
//# OUTPUT FORMATTING
//########################################################################
}
+
+
+
+
+/**
+ * Output data to the buffer, printf()-style
+ */
void PovOutput::out(char *fmt, ...)
{
va_list args;
va_start(args, fmt);
-#ifdef __MINGW32__
+#if !defined(__GNUC__) || defined(__MINGW32__)
vsnprintf(fmtbuf, 4096, fmt, args);
#else
vsprintf(fmtbuf, 4096, fmt, args);
+/**
+ * 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;
}
+
+
//########################################################################
//# 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 +614,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 +646,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
*/
index 6873061ecb22d633a051d80cc966db391e91ce4a..951921313e639e28ca3b47ebda0800c4876dd596 100644 (file)
+/**
+ * Output bezier splines in POVRay format.
+ *
+ * For information, @see:
+ * http://www.povray.org
+ */
class PovOutput : public Inkscape::Extension::Implementation::Implementation
{
+
+/**
+ * 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 *fmt, ...);
+ /**
+ * 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);
- String outbuf;
-
- char fmtbuf[2048];
+ /**
+ * Actual method to save document
+ */
+ void saveDocument(SPDocument *doc, const gchar *uri);
/**
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;
+ 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;
- }
+ 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;
+ char fmtbuf[2048];
+
+ //For statistics
int nrNodes;
int nrSegments;
int nrShapes;