pvbrowser manual
Zurück Inhalt Vor

Externe Plot Werkzeuge

Screenshot von gnuplot in pvbrowser
Screenshot von gnuplot in pvbrowser

Hier ist ein Beispiel für die Benutzung externer Plot Werkzeuge in pvserver an Hand von gnuplot . Geben Sie ein Custom Widget "QImage" ein. Benutzen Sie dessen "id", um das Ergebnis anzuzeigen.

static int showGnuplot(PARAM *p, int id, DATA *d)
{
  FILE *fout;
  char buf[80];
  if(d == NULL) return 1; // you may use d for writing gnuplot.dem

  // write gnuplot file
  sprintf(buf,"%sgnuplot.dem",p->file_prefix); // p->file_prefix makes filenames unique for multiple clients
  fout = fopen(buf,"w");
  if(fout == NULL) return 1;
  fprintf(fout,"# gnuplot test.dem\n");
  fprintf(fout,"set output \"%sgnuplot.png\"\n",p->file_prefix);
  fprintf(fout,"set terminal png\n");
  fprintf(fout,"set xlabel \"x\"\n");
  fprintf(fout,"set ylabel \"y\"\n");
  fprintf(fout,"set key top\n");
  fprintf(fout,"set border 4095\n");
  fprintf(fout,"set xrange [-15:15]\n");
  fprintf(fout,"set yrange [-15:15]\n");
  fprintf(fout,"set zrange [-0.25:1]\n");
  fprintf(fout,"set samples 25\n");
  fprintf(fout,"set isosamples 20\n");
  fprintf(fout,"set title \"Radial sinc function.\"\n");
  fprintf(fout,"splot sin(sqrt(x**2+y**2))/sqrt(x**2+y**2)\n");
  fclose(fout);

  // run gnuplot
  sprintf(buf,"gnuplot %sgnuplot.dem",p->file_prefix);
  system(buf);

  // send result to pvbrowser
  sprintf(buf,"%sgnuplot.png",p->file_prefix);
  pvDownloadFile(p,buf);
  pvSetImage(p,id,buf);

  // temopary files will be cleaned up at browser exit
  return 0;
}

Zurück Inhalt Vor