gnuplot with X11 and octave cygwin32

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gnuplot with X11 and octave cygwin32

Billinghurst, David
gnuplot-beta340 compiles out of the box using
cygwin32/egcs-1.0.2/X11r6.3 and works on NT4 SP3
This gnuplot works OK with octave-2.0.12

Under Windows 95 gnuplot crashes nearly all the time (but I ran a couple
of demos once ;-)


+++++++++++++++++++++++++++++++++++++++++
(Mr) David Billinghurst
Comalco Research and Technical Support
PO Box 316, Thomastown, Vic, Australia, 3074
Phone: +61 3 9469 0642
FAX: +61 3 9462 2700
Email: [hidden email]





Reply | Threaded
Open this post in threaded view
|

gnuplot with X11 and octave cygwin32

John W. Eaton-6
On 19-May-1998, Billinghurst, David <[hidden email]> wrote:

| gnuplot-beta340 compiles out of the box using
| cygwin32/egcs-1.0.2/X11r6.3 and works on NT4 SP3
| This gnuplot works OK with octave-2.0.12

OK, but that requires an X server running on your Windows system,
doesn't it?

| Under Windows 95 gnuplot crashes nearly all the time (but I ran a couple
| of demos once ;-)

Do you mean the version of gnuplot compiled with the gnu tools?

In any case, I think we have a better solution now.  You can use a
simple wrapper program like the one below to send messages to the
Windows binary of gnuplot (I've used the binary version of 3.6beta340
that's available on ftp.phys.soton.ac.uk on an NT system and it seems
to work fine).

To use the wrapper program, compile it and put it somewhere in your
path.  Rename the binary file something like pipe-gnuplot.exe.  Then
set

  gnuplot_binary = "pipe-gnuplot /gnuplot/wgnuplot"

replacing /gnuplot/wgnuplot with the actual name of your real gnuplot
binary (it must not contain spaces, though, or you may need to do some
quoting, or you can just modify the default location in the wrapper
program and recompile it).

I will make a binary and some more complete instructions available
soon.

If there are any Windows programmers out there who can improve this
bit of code, please let me know!

Thanks,

jwe


#include <stdio.h>
#include <windows.h>

int
main (int argc, char **argv)
{
  char *real_gnuplot = "C:\\gnuplot\\wgnuplot.exe";

  /* XXX FIXME XXX */
  if (argc > 1)
    real_gnuplot = argv[1];

  /* load gnuplot (minimized in order to show only the graphic window) */

  if (WinExec (real_gnuplot, SW_MINIMIZE) <= 32)
    fprintf (stderr, "can't load gnuplot\n");
  else
    {
      HWND hwnd_parent;

      /* wait for the gnuplot window */
      Sleep(1000);

      hwnd_parent = FindWindow ((LPSTR) NULL, (LPCTSTR) "gnuplot");

      if (! hwnd_parent)
        fprintf (stderr, "can't find the gnuplot window");
      else
        {
          /* find the child text window */

          HWND hwnd_text = FindWindowEx (hwnd_parent, (HWND) NULL,
                                         (LPCTSTR)"wgnuplot_text",
                                         (LPCTSTR) NULL);

          if (! hwnd_text)
            fprintf (stderr, "can't find wgnuplot_text");
          else
            {
              /* wait for commands on stdin, and send them to the
                 gnuplot text window */

              int c;

              while ((c = getchar ()) != EOF)
                PostMessage (hwnd_text, WM_CHAR, c, 1L);

              /* XXX FIXME XXX -- can't we send a string? */
              PostMessage (hwnd_text, WM_CHAR, 'q', 1L);
              PostMessage (hwnd_text, WM_CHAR, 'u', 1L);
              PostMessage (hwnd_text, WM_CHAR, 'i', 1L);
              PostMessage (hwnd_text, WM_CHAR, 't', 1L);
              PostMessage (hwnd_text, WM_CHAR, '\n', 1L);
             
              return 0;
            }
        }
    }

  return 1;
}