[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
=?UTF-8?Q?Re:_export_dialog_(was:_gEDA-dev:_gEDA/gaf_release_plans)?==?UTF-8?Q?___?=
Hello!
Here is my first try to add EPS export to Write image menu in gschem:
------------begin of patch------------
--- gaf/gschem/src/x_image.c.eps 2007-04-29 12:42:48.000000000 +0200
+++ gaf/gschem/src/x_image.c 2007-05-02 17:20:37.000000000 +0200
@@ -156,6 +156,7 @@
ptr = ptr->next;
}
g_slist_free (formats);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "EPS");
/* Set the default menu */
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), default_index);
@@ -182,7 +183,10 @@
GSList *formats = gdk_pixbuf_get_formats ();
GSList *ptr;
gchar *ptr_descr;
-
+
+ if (strcmp(descr, "EPS") == 0) /*WK - catch EPS export case*/
+ return(g_strdup("eps"));
+ else {
ptr = formats;
while (ptr) {
ptr_descr = gdk_pixbuf_format_get_description (ptr->data);
@@ -193,6 +197,7 @@
ptr = ptr->next;
}
+ }
g_free (descr);
return NULL;
#else
@@ -280,6 +285,41 @@
#endif
}
+/*! \brief Write eps image file.
+ * \par This function writes the eps file, using the postscript print code
+ * from libgeda. Orientation is portrait and type is extents without margins.
+ * \param w_current [in] the TOPLEVEL structure.
+ * \param filename [in] the image filename.
+ * \return nothing
+ *
+ */
+void x_image_write_eps(TOPLEVEL *w_current, const char* filename)
+{
+ int result;
+ int w, h, orientation, type;
+ w = w_current->paper_width;
+ h = w_current->paper_height;
+ orientation = w_current->print_orientation;
+ type = w_current->print_output_type;
+
+ w_current->paper_width = 0;
+ w_current->paper_height = 0;
+ w_current->print_orientation = PORTRAIT;
+ w_current->print_output_type = EXTENTS_NOMARGINS;
+ result = f_print_file (w_current, filename);
+ if (result) {
+ fprintf(stderr, "x_image_lowlevel: Unable to save eps file %s.\n",
+ filename);
+ s_log_message(_("x_image_lowlevel: Unable to write eps file %s.\n"),
+ filename);
+ }
+
+ w_current->paper_width = w;
+ w_current->paper_height = h;
+ w_current->print_orientation = orientation;
+ w_current->print_output_type = type;
+}
+
/*! \brief Write the image file, with the desired options.
* \par This function writes the image file, with the options set in the
* dialog by the user.
@@ -353,6 +393,9 @@
f_image_write(w_current, filename, width, height,
w_current->image_color);
#else
+ if (strcmp(filetype, "eps") == 0) /*WK - catch EPS export case*/
+ x_image_write_eps(w_current, filename);
+ else {
pixbuf = x_image_get_pixbuf(w_current);
if (pixbuf != NULL) {
if (!gdk_pixbuf_save(pixbuf, filename, filetype, &gerror, NULL)) {
@@ -402,6 +445,7 @@
fprintf(stderr, "x_image_lowlevel: Unable to get pixbuf from gschem's window.\n");
s_log_message(_("x_image_lowlevel: Unable to get pixbuf from gschem's window.\n"));
}
+ }
#endif
w_current->width = save_width;
--- gaf/libgeda/src/f_print.c.eps 2007-04-26 23:36:42.000000000 +0200
+++ gaf/libgeda/src/f_print.c 2007-04-30 16:04:32.000000000 +0200
@@ -94,7 +94,7 @@
* \return 0 on success, -1 on failure.
*/
int f_print_header(TOPLEVEL *w_current, FILE *fp,
- int paper_size_x, int paper_size_y)
+ int paper_size_x, int paper_size_y, int eps)
{
char *buf;
FILE *prolog;
@@ -116,8 +116,11 @@
}
/* Output the DSC comments at the beginning of the document */
- fprintf(fp, "%%!PS-Adobe-3.0\n"
- "%%%%Creator: gEDA gschem %s\n"
+ if (eps)
+ fprintf(fp, "%%!PS-Adobe-3.0 EPSF-3.0\n")
+ else
+ fprintf(fp, "%%!PS-Adobe-3.0\n");
+ fprintf(fp, "%%%%Creator: gEDA gschem %s\n"
"%%%%CreationDate: %s"
"%%%%Title: %s\n"
"%%%%Author: %s\n"
@@ -434,7 +437,8 @@
int unicode_count;
gunichar unicode_table [128]; /* to contain the list of unicode
characters that need mapping */
-
+ int eps;
+
/* Unicode support */
f_print_initialize_glyph_table(); /* Fill up unicode map */
@@ -485,6 +489,18 @@
}
+ if(w_current->paper_width == 0) {
+ eps = 1;
+ if(w_current->print_orientation == LANDSCAPE) {
+ w_current->paper_width = dx;
+ w_current->paper_height = dy;
+ } else { /* portrait */
+ w_current->paper_width = dy;
+ w_current->paper_height = dx;
+ }
+ } else
+ eps = 0;
+
scale = 0.0;
if(w_current->print_orientation == LANDSCAPE) {
/* First attempt to fit in x direction. */
@@ -512,7 +528,8 @@
/* Output the header */
if (f_print_header(w_current, fp,
w_current->paper_width,
- w_current->paper_height) != 0) {
+ w_current->paper_height,
+ eps) != 0) {
/* There was an error in f_print_header */
return -1;
------------end of patch--------------
It works only with GDK-PIXBUF. There is some things to do (as disabling size menu when EPS format is set.
Wojciech Kazubski
> >
> > > On Wed, 2007-04-25 at 20:51 +0200, Carlos Nieves Ănega wrote:
> > >
> > > > If you want to support more types, I'd suggest to add them to gdk-pixbuf
> > > > and gschem will support it automatically.
> > >
> > > The original suggestion was for a non scaled, non-rotated eps output, so
> > > thats not compatible with gdk-pixbuf (bitmap based).
> > >
> >
> > I don't really have a strong opinion of if EPS output goes into the
> > export or print dialog box (I could argue for either one), however, it
> > would be nice if any new EPS code reused the existing PS generating code.
>
> This requires slight modification of the first line of EPS flie to read something like %!PS-Adobe-3.0 EPSF-3.0 and adding some code to calculate picture size from schematic size. The rest of printing code should remain unchanged.
>
> > Also, is adding EPS support really worth it considering ps2epsi works
> > today (to convert gschem ps files to eps)?
>
> This works too, but requires some eztra work with cropping/resizing images.
> >
> > Thanks,
> >
> > -Ales
> >
> Wojciech Kazubski
>
>
> _______________________________________________
> geda-dev mailing list
> geda-dev@moria.seul.org
> http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev