home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / lisp / mcl / 1854 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  7.4 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!stanford.edu!apple!cambridge.apple.com!nrb!keunen@relay.EU.net
  2. From: nrb!keunen@relay.EU.net (Vincent Keunen)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: printing in CLIM - summary
  5. Message-ID: <19921218082349.1.KEUNEN@nrbmi1.ia.nrb.be>
  6. Date: 18 Dec 92 08:23:00 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Reply-To: nrb!keunen@relay.EU.net
  9. Lines: 206
  10. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  11.  
  12. Thanks to all that replied to my request.  I must say that I am *very*
  13. impressed by clim's abilities to print.  Boy, what a difference with
  14. other systems!!!  That's what I call a well tought, easy to use and
  15. reliable way to do things.  I had *no* problem.
  16.  
  17. If someone wants to create a clim FAQ, this can be inserted in it.
  18.  
  19. Here is the original request:
  20.  
  21.  
  22.      I'd like to print the content of what has been accumulated in a stream
  23.      (part of a pane of a frame).
  24.      
  25.      When the content is only text, it's easy, I just do:
  26.      
  27.      
  28.      (define-nanesse-history-command
  29.        (com-print-history :name t :menu t)
  30.      ()
  31.        (with-open-file (output-file "nanesse:to-print;history.text"
  32.                  :direction :output
  33.                  :if-exists :new-version)
  34.      (clim:copy-textual-output-history
  35.        (frame-standard-output clim:*application-frame*) output-file))
  36.        (cp:execute-command "hardcopy file" "nanesse:to-print;history.text"))
  37.      
  38.      
  39.      But when it's general clim drawing functions, I guess I must use
  40.      with-output-to-postscript-stream and somehow replay the history of my
  41.      pane (from the parent output-record, right?) in the new postscript
  42.      stream. 
  43.      
  44.      Does someone have a nice and easy example of this to help me out?
  45.  
  46.      vk
  47.  
  48.  
  49. Here are the replies (I think they are all useful in understanding the problem):
  50.  
  51. 1----------------
  52. Date: Mon, 14 Dec 92 18:48:33 +0100
  53. From: Oliver Christ <oli@adler.ims.uni-stuttgart.de>
  54. Message-Id: <9212141748.AA20718@adler.ims.uni-stuttgart.de>
  55. Received: by milan.ims.uni-stuttgart.de
  56.     id AA00441; Mon, 14 Dec 92 18:48:33 +0100
  57. To: keunen@nrb.be
  58. In-Reply-To: Vincent Keunen's message of Mon, 14 Dec 1992 17:33+0200 <19921214153325.9.KEUNEN@nrbmi1.ia.nrb.be>
  59. Subject: printing a clim stream
  60. Reply-To: oli@ims.uni-stuttgart.de
  61.  
  62. Hi Vincent,
  63.  
  64. I have been using something like
  65.  
  66.  
  67.     (with-open-file (psfile <<<filename>>> :direction :output :if-exists :supersede)
  68.       (clim:with-output-to-postscript-stream (stream psfile :multi-page t)
  69.         (clim:replay (slot-value (clim:get-frame-pane clim:*application-frame* 
  70.                               '<<<pane-name>>>)
  71.                                    'clim::output-record)
  72.                        stream)))
  73.  
  74. but it isn't as nice as redoing the whole output (call a redisplay function)
  75. with output to PostScript. 
  76.  
  77. Greetings,
  78.  
  79. Oli
  80.  
  81.  
  82. 2----------------
  83. Date: Mon, 14 Dec 1992 13:57-0500
  84. From: Scott McKay <SWM@STONY-BROOK.SCRC.Symbolics.COM>
  85. Subject: printing a clim stream
  86. To: nrb!keunen, clim@nrbmi2.ia.nrb.be
  87. In-Reply-To: <19921214153325.9.KEUNEN@nrbmi1.ia.nrb.be>
  88. Message-Id: <19921214185711.9.SWM@SUMMER.SCRC.Symbolics.COM>
  89.  
  90.  
  91. There is no such "nice and easy example", because it is not nice and
  92. easy.  Moving output records from one display device to another is not
  93. easy because text and graphics can have different sizes on different
  94. output devices.  Thus, using FORMATTING-TABLE on some window to format a
  95. table full of text can produce output records that no good for some
  96. postscript printer, because the alignment is all wrong.
  97.  
  98. The only way to reliably get good output for multiple display devices is
  99. to generate it freshly for each display device.
  100.  
  101.  
  102. 3----------------
  103. Date: Mon, 14 Dec 1992 14:54-0500
  104. From: Mark Nahabedian <naha@RIVERSIDE.SCRC.Symbolics.COM>
  105. Subject: printing a clim stream
  106. To: nrb!keunen, keunen@nrb.be, clim@nrbmi2.ia.nrb.be
  107. In-Reply-To: <19921214153325.9.KEUNEN@nrbmi1.ia.nrb.be>
  108. Message-Id: <19921214195452.5.NAHA@LILIKOI.SCRC.Symbolics.COM>
  109.  
  110. Actually what you should do is re-execute the code which did the
  111. drawing, this time doing the output to a PostScript stream instead of to
  112. the window where you drew it before.  Output histories are specific to
  113. the window they were created for and should not be used in conjunction
  114. with a different output stream.
  115.  
  116.  
  117. 4----------------
  118. Date: Mon, 14 Dec 1992 17:28:36 -0700
  119. From: Brent Reeves <brentr@sigi.cs.colorado.edu>
  120. Message-Id: <199212150028.AA27368@sigi.cs.colorado.edu>
  121. To: nrb!keunen
  122. In-Reply-To: Vincent Keunen's message of 14 Dec 1992 17:33+0200
  123. Subject: printing a clim stream
  124.  
  125.  
  126.  since the draw-work-area (below, in the com-ps command) function
  127.  takes a stream as input, it is easy to redirect this stream to
  128.  the postscript stream.  Notice in this command there is
  129.  strangeness going on... after I create the postscript stream, I
  130.  read it back in and delete a "setrgbcolor" line.  This oughtn't
  131.  have to be done, but for me [Genera 8.1 CLIM 1.1] it is the only
  132.  way I can get it to work.  Also, I print the file from a UNIX
  133.  box; "hardcopy file" does not work.  Others have not trouble
  134.  with postscript and "hardcopy file", so it may work fine like in
  135.  your example above.
  136.  
  137. (define-indy-command (com-ps :name t :menu nil)
  138.   ((scale 'float))
  139.   (with-open-file
  140.    (file-stream
  141.     "sigi:/homes/brentr/indy/src/testing/todel.ps"
  142.     :direction :output)
  143.    (clim:with-output-to-postscript-stream
  144.     (stream file-stream
  145.         :multi-page t)
  146.     (with-scaling (stream scale scale)
  147.           (draw-work-area *af* stream))))
  148.   ;;
  149.   ;; now remove the offending " 1.00 1.00 1.00 setrgbcolor" line
  150.   ;;
  151.   (let ((eof '|EOF|)
  152.     line)
  153.     (with-open-file
  154.      (input
  155.       "sigi:/homes/brentr/indy/src/testing/todel.ps"
  156.       :direction :input)
  157.      (with-open-file
  158.       (output
  159.        "sigi:/homes/brentr/indy/src/testing/indy.ps"
  160.        :direction :output)
  161.       (block exit
  162.          (loop do
  163.            (progn
  164.              (multiple-value-setq
  165.               (line nil)
  166.               (read-line input nil eof))
  167.              (when
  168.               (equal line eof)
  169.               (return-from exit nil))
  170.              (unless
  171.               (string-equal " 1.00 1.00 1.00 setrgbcolor" line)
  172.               (format output "~&~a" line))))))))
  173.   (com-replay-history)
  174.   (audit "~&Postscript file is
  175.   sigi:/homes/brentr/indy/src/testing/indy.ps"))
  176.  
  177.  
  178.  
  179. ----------------
  180. And here is the code I now use to print:
  181.  
  182. The code inside clim:with-output-to-postscript-stream is exactly the
  183. code used to draw the map on the screen.  Note that the last form is
  184. only valid on Genera machine.
  185.  
  186. (defun print-network-map ()
  187.   (let ((frame (nanesse-frame)))
  188.     (with-open-file (the-file "nanesse:to-print;network-map.ps"
  189.                   :direction :output
  190.                   :if-exists :new-version)
  191.       (clim:with-output-to-postscript-stream (stream the-file :multi-page t)
  192.     (vk-1dessine-villes0 stream)
  193.     (1initialise-coordonnees-noeuds0 (noeuds-a-afficher frame))
  194.     (initialise-elements-graphiques-a-afficher)
  195.     (ansi-loop::loop for one-node in (noeuds-a-afficher frame)
  196.          do
  197.       (clim:present one-node
  198.             `((network-point)
  199.               :up-or-down ,(up-or-down one-node)
  200.               :selected ,(selected one-node))
  201.             ;;(clos:class-name (clos:class-of one-node))
  202.             :view clim:+iconic-view+ :single-box t
  203.             :stream stream)))))
  204.   (cp:execute-command "hardcopy file"
  205.            "nanesse:to-print;network-map.ps"))
  206.  
  207. Thanks all for your help.  Hope this summary is useful.
  208.  
  209. vk
  210. --
  211. Never trust a pretty header: use keunen@nrb.be to reply
  212. --
  213. Keunen Vincent                  Network Research Belgium
  214. R&D, Software Engineer          Parc Industriel des Hauts-Sarts
  215. keunen@nrb.be                   2e Avenue, 65
  216. tel: +32 41 407282              B-4040 Herstal
  217. fax: +32 41 481170              Belgium
  218.