Loading ...
Sorry, an error occurred while loading the content.
 

Strange pl eps/ps generation problem

Expand Messages
  • bob884488
    I have just build a couple of scripts for real-time ploticus visualization of same data. I had these before already with x11 but this time I wanted to use gv
    Message 1 of 7 , Jun 26, 2003
      I have just build a couple of scripts for real-time ploticus
      visualization of same data.

      I had these before already with x11 but this time I wanted to use gv
      (ghostview) for higher quality. Plus with gv and monitoring enabled it
      will update its window without the need to destroy it.

      It works just great but there is one very strange problem with all eps
      files generated from ploticus.

      I'm using 2.10. I didn't see any changelog refering to eps/ps
      generation so I don't think 2.11 behaves here differently either.

      When I load a from ploticus generated eps file with gv and click
      "Redisplay" once, the page gets blank! If I click "Redisplay" a second
      time it appears again. So by this button I can actually toggle the
      ploticus plot on and off. With other eps files generated from
      different tools clicking "Redisplay" will do just that. No
      on/off-toggle. For my scripts this means that only every 2nd update is
      actually displayed in gv although all eps files are "ok".

      All ps files generated by ploticus have the same problem.

      Anyway, thanks again for the great tool. If I find a workaround myself
      I will post it here.
    • bob884488
      I did find a workaround but unfortunately it s sufferening from heavy quality loss. When I convert the original ploticus eps to pdf with epstopdf I still
      Message 2 of 7 , Jun 27, 2003
        I did find a workaround but unfortunately it's sufferening from
        heavy quality loss.

        When I convert the original ploticus eps to pdf with epstopdf I still
        maintain maximum quality. Unfortunately I have not found a
        tool to reload this file automatically. GV only works when the
        interpreter is manually stopped in between each refresh. I have not
        found a way to do this automatically.

        When this pdf is converted back to eps with e.g. pdf2ps the reload
        problem is gone. Unfortunately e.g. the fonts look much worse.
        Using convert also works, provided at least eps2 is used as target format.

        The SVG files also look great. If only there was a way to convert
        these to proper EPS files.
      • Stephen C. Grubb
        Hi, I don t currently have access to gv, so I can t prove anything here. As far as I know, ploticus generates valid eps and postscript output, and there have
        Message 3 of 7 , Jun 27, 2003
          Hi,

          I don't currently have access to gv, so I can't prove anything here.

          As far as I know, ploticus generates valid eps and postscript output, and
          there have been very few complaints received over the years.

          Here's something to try: edit a ploticus-generated eps file, go to the end
          of the file, and remove the %%Trailer line.. then try it with gv.

          If you can find a way to make the eps file work, let me know and I'll do
          my best to make ploticus generate files that work with gv..

          -Steve


          Stephen C. Grubb scg@...
          Scientific Software Engineer, The Jackson Laboratory
          600 Main Street Bar Harbor, Maine 04609 USA
        • bob884488
          ... the end ... Sorry for the confusion. The ploticus generated eps and ps files load just fine in gv. I never had any problems here! The problem only becomes
          Message 4 of 7 , Jun 27, 2003
            --- In ploticus@yahoogroups.com, "Stephen C. Grubb" <scg@j...> wrote:
            > Here's something to try: edit a ploticus-generated eps file, go to
            the end
            > of the file, and remove the %%Trailer line.. then try it with gv.

            Sorry for the confusion. The ploticus generated eps and ps files load
            just fine in gv. I never had any problems here!

            The problem only becomes apparent when you hit "Redisplay" while the
            file is being rendered in gv. When you do this, the plot suddenly
            vanishes off the screen. If you hit it again, it appears again. So for
            some reasons with ploticus generated eps/ps files the GV "Redisplay"
            button works like an on/off toggle (it does really reload at each 2nd
            reload though)
            GV shows the exact same problem when its monitoring is enabled or when
            a SIGHUP kill signal is send to it.

            I used gv 3.5.8 (debian) for testing and ploticus 2.10 with all
            features enabled.

            Removing the %%Trailer line has had no effect on this.

            > If you can find a way to make the eps file work, let me know and I'll do
            > my best to make ploticus generate files that work with gv..

            I did after one afternoon screwing around with tons of different
            conversion tools. :-)

            The following code works in linux in a bash script and generates
            properly sized ps files for real-time monitoring while still retaining
            the original image quality. It's rather cumbersome since it converts
            the file from eps to pdf and then on to ps but it works and thats all
            that matters. :-)

            Note: when converting the pdf to eps with the pdftops tool the
            redisplay problem occurs again. Neither the pdf nor the generated
            ps have this problem.

            -- snip --
            filename=`echo $1 | awk -F. '{print $1}'`.ps
            filenametmp=`echo $1 | awk -F. '{print $1}'`-tmp.ps
            filenameeps=`echo $1 | awk -F. '{print $1}'`.eps
            filenamepdf=`echo $1 | awk -F. '{print $1}'`.pdf

            // $1 is the pl script name e.g absolutebars.plo
            // pl is actually called here

            pl DATAFILE=$datafile SESSION=$session TYPE=$type
            PARTICIPANT=$participant TASK=$task $1 eps -o $filenameeps

            epstopdf $filenameeps
            # delete previously generated eps
            rm $filenameeps

            # get proper size for ps file generation
            width=`cat $filenamepdf | grep --binary-files=text
            "<</Type/Page/MediaBox" | awk -F[ '{print $2}' | awk -F] '{print $1}'
            | awk -F" " '{print $3}'`
            height=`cat $filenamepdf | grep --binary-files=text
            "<</Type/Page/MediaBox" | awk -F[ '{print $2}' | awk -F] '{print $1}'
            | awk -F" " '{print $4}'`

            pdftops -paperw $width -paperh $height $filenamepdf $filenametmp
            # delete previously generated pdf
            rm $filenamepdf

            if [ $? == 0 ]; then
            mv $filenametmp $filename
            else
            echo "ERROR occurred. Aborting..."
            exit 1
            fi

            --- end snip ----

            I finally load gv via e.g.

            gv -ad gv_full.ad -scale 0 -watch absolutebars.ps &

            The above script file monitors the datafile and updates the ps
            files accordingly. Only after they are completly done with
            conversion they are moved to the final ps which is being monitored
            by gv.

            This way gv will just blink for a milli-second and show the new plot
            with no big intermission like my earlier solution based on x11 output.

            Maybe someone wants to attempt something similar so I hope the above
            code helps a bit.

            Thanks again for making all this possible. Ploticus has an awesome
            ease of learning usability. Thanks!
          • Stephen C. Grubb
            ... When you press the gv redisplay button, it probably reads the eps file again. I thought maybe the %%Trailer line was somehow fooling gv into thinking
            Message 5 of 7 , Jun 30, 2003
              On Fri, 27 Jun 2003, bob884488 wrote:

              > --- In ploticus@yahoogroups.com, "Stephen C. Grubb" <scg@j...> wrote:
              > > Here's something to try: edit a ploticus-generated eps file, go to the
              > > end of the file, and remove the %%Trailer line.. then try it with gv.
              >
              > Sorry for the confusion. The ploticus generated eps and ps files load
              > just fine in gv. I never had any problems here!

              When you press the gv 'redisplay' button, it probably reads the eps file
              again. I thought maybe the %%Trailer line was somehow fooling gv into
              thinking there was an additional "page". You might also try removing the
              %%EOF line at the very end to see if that makes any difference.

              Another way to address this would be for you to find a _small_ eps file
              that gv handles correctly, and send me that eps file to examine. Perhaps
              I can then figure out how to make ploticus build "proper" eps files.


              > > If you can find a way to make the eps file work, let me know and I'll do
              > > my best to make ploticus generate files that work with gv..
              >
              > I did after one afternoon screwing around with tons of different
              > conversion tools. :-)

              I meant "If you can alter the ploticus eps file such that it will work".
              Our goal is to have ploticus build eps files that can work with gv
              directly.


              Steve



              Stephen C. Grubb scg@...
              Scientific Software Engineer, The Jackson Laboratory
              600 Main Street Bar Harbor, Maine 04609 USA
            • bob884488
              ... eps file ... Yes. That s the whole purpose of redisplay . :) ... removing the ... Nope. Does not help. I tried all standard gv switches which included
              Message 6 of 7 , Jun 30, 2003
                --- In ploticus@yahoogroups.com, "Stephen C. Grubb" <scg@j...> wrote:
                > On Fri, 27 Jun 2003, bob884488 wrote:

                > When you press the gv 'redisplay' button, it probably reads the
                eps file
                > again.

                Yes. That's the whole purpose of 'redisplay'. :)

                > I thought maybe the %%Trailer line was somehow fooling gv into
                > thinking there was an additional "page". You might also try
                removing the
                > %%EOF line at the very end to see if that makes any difference.

                Nope. Does not help. I tried all standard gv switches which included
                ignore EOF.

                > Another way to address this would be for you to find a _small_ eps
                file
                > that gv handles correctly, and send me that eps file to examine.
                Perhaps
                > I can then figure out how to make ploticus build "proper" eps
                files.

                You got email!

                > > I did after one afternoon screwing around with tons of different
                > > conversion tools. :-)
                >
                > I meant "If you can alter the ploticus eps file such that it will
                work".
                > Our goal is to have ploticus build eps files that can work with gv
                > directly.

                Of course! I just meant to imply that I found a solution which works
                for me. It's not perfect but good enough temporarily for my personal
                purposes.
              • bob884488
                ... work . ... Found a way. See email for details. Quick version: sed s!showpage!grestore!g ploticus-bad.eps ploticus-good.eps
                Message 7 of 7 , Jun 30, 2003
                  > I meant "If you can alter the ploticus eps file such that it will
                  work".
                  > Our goal is to have ploticus build eps files that can work with gv
                  > directly.

                  Found a way. See email for details.

                  Quick version:
                  sed 's!showpage!grestore!g' ploticus-bad.eps > ploticus-good.eps

                  :)
                Your message has been successfully submitted and would be delivered to recipients shortly.