Support for pngcairo in draw, and backward compatibility issues



I have a few small patches which I hope will find their way into 5.23.1.

First: the 'pic_width' and 'pic_height' options of the draw package are
now deprecated and print warnings whenever they are used.  Both Imaxima
and wxMaxima pass these options when their wx* commands are used.  Here
is a small fix to interfaces/emacs/imaxima/imaxima.lisp to use
'dimensions' instead:

--- imaxima-orig.lisp	2009-11-16 17:09:19.000000000 -0500
+++ imaxima.lisp	2011-01-05 13:04:29.000000000 -0500
@@ -673,8 +673,11 @@
 		     (append
 		      `(
 			((mequal simp) $terminal $eps)
-			((mequal simp) $pic_width ,($first $wxplot_size))
-			((mequal simp) $pic_height ,($second $wxplot_size))
+			((mequal simp) $dimensions
+				       ((mlist simp)
+					;; convert points to 1/100 of cm
+					,(* 3.53 ($first $wxplot_size))
+					,(* 3.53 ($second $wxplot_size))))
 			((mequal simp) $file_name ,filename))
 		      args)))
     ($ldisp `((wxxmltag simp) ,(format nil "~a.eps" filename) "img"))

Second: the {eps,pdf}_{width,height} options, formerly specified in cm,
have been replaced by 'dimensions' which is specified in cm/100.  The
code still accepts the old options, but fails to do the necessary
conversion from cm to cm/100.

The following patch does the necessary conversion, and also silences the
warnings about 'pic_height' and 'pic_width'.  The reason for the latter
is that wxMaxima uses those options, and it looks bad to see the
warnings before every inline plot.  Yet how can wxMaxima fix this bug
without breaking support for older versions of Maxima?  I suggest that
we wait a few releases before issuing these warnings.

--- grcommon-orig.lisp	2010-12-02 16:13:26.000000000 -0500
+++ grcommon.lisp	2011-01-05 13:52:39.000000000 -0500
@@ -831,17 +833,17 @@
         ($print "WARNING: 'rot_horizontal' is deprecated, using 'view' instead...")
         (update-view (list '(mlist) (first (gethash '$view *gr-options*)) val)))
       ($pic_width
-        ($print "WARNING: 'pic_width' is deprecated, using 'dimensions' instead...")
+        ;; ($print "WARNING: 'pic_width' is deprecated, using 'dimensions' instead...")
         (update-dimensions (list '(mlist) val (second (gethash '$dimensions *gr-options*)))))
       ($pic_height
-        ($print "WARNING: 'pic_height' is deprecated, using 'dimensions' instead...")
+        ;; ($print "WARNING: 'pic_height' is deprecated, using 'dimensions' instead...")
         (update-dimensions (list '(mlist) (first (gethash '$dimensions *gr-options*)) val)))
       (($eps_width $pdf_width)
         ($print "WARNING: 'eps_width' is deprecated, using 'dimensions' instead...")
-        (update-dimensions (list '(mlist) val (second (gethash '$dimensions *gr-options*)))))
+        (update-dimensions (list '(mlist) (* 100 val) (second (gethash '$dimensions *gr-options*)))))
       (($eps_height $pdf_height)
         ($print "WARNING: 'eps_height' is deprecated, using 'dimensions' instead...")
-        (update-dimensions (list '(mlist) (first (gethash '$dimensions *gr-options*)) val)))
+        (update-dimensions (list '(mlist) (first (gethash '$dimensions *gr-options*)) (* 100 val))))
 
       (otherwise (merror "draw: unknown option ~M " opt))  ) )
 

Finally, attached below is a patch to add support for gnuplot's pngcairo
terminal to draw.  The plots look much better, especially when drawing
direction fields with drawdf.  Many small arrows look very bad without
anti-aliasing.

This patch also includes a small hack to allow users of wxMaxima to
easily make use of pngcairo for inline plots: if $draw_use_pngcairo is
true, then pngcairo will be used when 'png' is requested.

[There's one other minor fix here as well: the gnuplot terminal options
 "enhanced truecolor" were specified when drawing "png" directly, but
 not when using $draw_file.  The following patch fixes that.]

   Thanks,
     Mark


--- draw-orig.lisp	2010-12-13 12:00:38.000000000 -0500
+++ draw.lisp	2011-01-05 13:46:27.000000000 -0500
@@ -41,6 +41,8 @@
 
 (defvar $draw_compound t)
 
+(defvar $draw_use_pngcairo nil "If true, use pngcairo terminal when png is requested.")
+
 (defvar *windows-OS* (string= *autoconf-win32* "true"))
 
 (defmacro write-font-type ()
@@ -3161,6 +3163,11 @@
                            (round (second (get-option '$dimensions)))
                            (hex-to-xhex (get-option '$background_color))
                            (get-option '$file_name) ) )
+        ($pngcairo (format cmdstorage "set terminal pngcairo enhanced truecolor ~a size ~a, ~a~%set out '~a.png'"
+                           (write-font-type)
+                           (round (first (get-option '$dimensions)))
+                           (round (second (get-option '$dimensions)))
+                           (get-option '$file_name) ) )
         ($eps (format cmdstorage "set terminal postscript eps enhanced ~a size ~acm, ~acm~%set out '~a.eps'"
                            (write-font-type)
                            (/ (first (get-option '$dimensions)) 100.0)
@@ -3383,12 +3390,17 @@
          (update-gr-option ($lhs x) ($rhs x))
          (merror "draw: item ~M is not recognized as an option assignment" x)))
    (case (get-option '$terminal)
-      ($png (setf str (format nil "set terminal png ~a size ~a, ~a ~a~%set out '~a.png'"
+      ($png (setf str (format nil "set terminal png enhanced truecolor ~a size ~a, ~a ~a~%set out '~a.png'"
                            (write-font-type)
                            (round (first (get-option '$dimensions)))
                            (round (second (get-option '$dimensions)))
                            (hex-to-xhex (get-option '$background_color))
                            (get-option '$file_name) ) ))
+      ($pngcairo (setf str (format nil "set terminal pngcairo enhanced truecolor ~a size ~a, ~a~%set out '~a.png'"
+                           (write-font-type)
+                           (round (first (get-option '$dimensions)))
+                           (round (second (get-option '$dimensions)))
+                           (get-option '$file_name) ) ))
       ($eps (setf str (format nil "set terminal postscript eps enhanced ~a size ~acm, ~acm~%set out '~a.eps'"
                            (write-font-type) ; other alternatives are Arial, Courier
                            (/ (first (get-option '$dimensions)) 100.0)
--- grcommon-orig.lisp	2010-12-02 16:13:26.000000000 -0500
+++ grcommon.lisp	2011-01-05 13:52:39.000000000 -0500
@@ -328,10 +328,12 @@
 (defvar *draw-terminal-number* "")
 
 (defun update-terminal (val)
-  (let ((terms '($screen $png $jpg $gif $eps $eps_color $svg
+  (let ((terms '($screen $png $pngcairo $jpg $gif $eps $eps_color $svg
                  $pdf $pdfcairo $wxt $animated_gif $aquaterm)))
      (cond
        ((member val terms)
+	  (when (and (eq val '$png) $draw_use_pngcairo)
+	    (setq val '$pngcairo))
           (setf (gethash '$terminal *gr-options*) val
                 *draw-terminal-number* ""))
        ((and ($listp val)