*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "writeps.h"
-#include <cstdio>
-
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
-#include "gromacs/utility/smalloc.h"
+
+using namespace gmx;
const char *fontnm[efontNR] = {
"Times-Roman", "Times-Italic", "Times-Bold", "Times-BoldItalic",
"Courier", "Courier-Oblique", "Courier-Bold", "Courier-BoldOblique"
};
-
-/* Internal psdata structure (abstract datatype)
- * to maintain the current state of the ps engine.
- */
-struct t_int_psdata {
- FILE *fp;
- int maxrgb;
- int nrgb;
- t_rgb *rgb;
- real gen_ybox;
- int ostack;
-};
-
-
t_psdata ps_open(const char *fn, real x1, real y1, real x2, real y2)
{
t_psdata ps;
- snew(ps, 1);
-
- ps->fp = gmx_fio_fopen(fn, "w");
- fprintf(ps->fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
- fprintf(ps->fp, "%%%%Creator: GROMACS\n");
- fprintf(ps->fp, "%%%%Title: %s\n", fn);
- fprintf(ps->fp, "%%%%BoundingBox: %g %g %g %g\n", x1, y1, x2, y2);
- fprintf(ps->fp, "%%%%EndComments\n");
- fprintf(ps->fp, "/m {moveto} bind def\n");
- fprintf(ps->fp, "/l {lineto} bind def\n");
- fprintf(ps->fp, "/rm {rmoveto} bind def\n");
- fprintf(ps->fp, "/r {rlineto} bind def\n");
- fprintf(ps->fp, "/f {fill} bind def\n");
- fprintf(ps->fp, "/s {stroke} bind def\n");
-
- ps->nrgb = 0;
- ps->maxrgb = 0;
- ps->rgb = nullptr;
- ps->gen_ybox = 0;
- ps->ostack = 0;
+ ps.fp = gmx_fio_fopen(fn, "w");
+ fprintf(ps.fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
+ fprintf(ps.fp, "%%%%Creator: GROMACS\n");
+ fprintf(ps.fp, "%%%%Title: %s\n", fn);
+ fprintf(ps.fp, "%%%%BoundingBox: %g %g %g %g\n", x1, y1, x2, y2);
+ fprintf(ps.fp, "%%%%EndComments\n");
+ fprintf(ps.fp, "/m {moveto} bind def\n");
+ fprintf(ps.fp, "/l {lineto} bind def\n");
+ fprintf(ps.fp, "/rm {rmoveto} bind def\n");
+ fprintf(ps.fp, "/r {rlineto} bind def\n");
+ fprintf(ps.fp, "/f {fill} bind def\n");
+ fprintf(ps.fp, "/s {stroke} bind def\n");
return ps;
}
-void ps_linewidth(t_psdata ps, int lw)
+void ps_linewidth(t_psdata *ps, int lw)
{
fprintf(ps->fp, "%d setlinewidth\n", lw);
}
-static void ps_defcolor(t_psdata ps, real r, real g, real b, char *cname)
+static void ps_defcolor(t_psdata *ps, real r, real g, real b, char *cname)
{
fprintf(ps->fp, "/%s {%g %g %g setrgbcolor} bind def\n", cname, r, g, b);
}
-static void ps_selcolor(t_psdata ps, char *cname)
+static void ps_selcolor(t_psdata *ps, char *cname)
{
fprintf(ps->fp, "%s\n", cname);
}
-static int search_col(t_psdata ps, real r, real g, real b)
+static gmx::index search_col(t_psdata *ps, real r, real g, real b)
{
- int i;
- char buf[12];
-
- for (i = 0; (i < ps->nrgb); i++)
+ for (gmx::index i = 0; ssize(ps->rgb); ++i)
{
if ((ps->rgb[i].r == r) && (ps->rgb[i].g == g) && (ps->rgb[i].b == b))
{
}
}
- if (ps->nrgb >= ps->maxrgb)
- {
- ps->maxrgb += 100;
- srenew(ps->rgb, ps->maxrgb);
- }
-
- sprintf(buf, "C%d", ps->nrgb);
+ char buf[12];
+ int indexToBackElement = static_cast<int>(ssize(ps->rgb));
+ sprintf(buf, "C%d", indexToBackElement);
ps_defcolor(ps, r, g, b, buf);
- fprintf(ps->fp, "/B%d {%s b} bind def\n", ps->nrgb, buf);
- ps->rgb[i].r = r;
- ps->rgb[i].g = g;
- ps->rgb[i].b = b;
- ps->nrgb++;
+ fprintf(ps->fp, "/B%zu {%s b} bind def\n", ps->rgb.size(), buf);
+ ps->rgb.emplace_back(t_rgb {r, g, b});
- return (ps->nrgb-1);
+ return indexToBackElement;
}
-void ps_color(t_psdata ps, real r, real g, real b)
+void ps_color(t_psdata *ps, real r, real g, real b)
{
char buf[12];
- int i;
-
- i = search_col(ps, r, g, b);
+ int indexToElement = static_cast<int>(search_col(ps, r, g, b));
- sprintf(buf, "C%d", i);
+ sprintf(buf, "C%d", indexToElement);
ps_selcolor(ps, buf);
}
-void ps_rgb(t_psdata ps, t_rgb *rgb)
+void ps_rgb(t_psdata *ps, const t_rgb *rgb)
{
ps_color(ps, rgb->r, rgb->g, rgb->b);
}
-void ps_init_rgb_nbox(t_psdata ps, real xbox, real ybox)
+void ps_init_rgb_nbox(t_psdata *ps, real xbox, real ybox)
{
ps->gen_ybox = ybox;
fprintf(ps->fp, "/by {def currentpoint "
/* macro bn is used in ps_rgb_nbox to draw rectangular boxes */
}
-void ps_rgb_nbox(t_psdata ps, t_rgb *rgb, real n)
+void ps_rgb_nbox(t_psdata *ps, t_rgb *rgb, real n)
{
int i;
}
-void ps_init_rgb_box(t_psdata ps, real xbox, real ybox)
+void ps_init_rgb_box(t_psdata *ps, real xbox, real ybox)
{
fprintf(ps->fp, "/b {currentpoint "
"%g %g r %g %g r %g %g r %g %g r f %g add moveto} bind def\n",
/* macro b is used in search_col to define macro B */
}
-void ps_rgb_box(t_psdata ps, t_rgb *rgb)
+void ps_rgb_box(t_psdata *ps, t_rgb *rgb)
{
- fprintf(ps->fp, "B%d\n", search_col(ps, rgb->r, rgb->g, rgb->b));
+ fprintf(ps->fp, "B%zd\n", search_col(ps, rgb->r, rgb->g, rgb->b));
/* macro B is defined in search_col from macro b */
}
-void ps_lineto(t_psdata ps, real x, real y)
+void ps_lineto(t_psdata *ps, real x, real y)
{
fprintf(ps->fp, "%g %g l\n", x, y);
}
-void ps_linerel(t_psdata ps, real dx, real dy)
+void ps_linerel(t_psdata *ps, real dx, real dy)
{
fprintf(ps->fp, "%g %g r\n", dx, dy);
}
-void ps_moveto(t_psdata ps, real x, real y)
+void ps_moveto(t_psdata *ps, real x, real y)
{
fprintf(ps->fp, "%g %g m\n", x, y);
}
-void ps_moverel(t_psdata ps, real dx, real dy)
+void ps_moverel(t_psdata *ps, real dx, real dy)
{
fprintf(ps->fp, "%g %g rm\n", dx, dy);
}
-void ps_line(t_psdata ps, real x1, real y1, real x2, real y2)
+void ps_line(t_psdata *ps, real x1, real y1, real x2, real y2)
{
ps_moveto(ps, x1, y1);
ps_lineto(ps, x2, y2);
fprintf(ps->fp, "s\n");
}
-static void do_box(t_psdata ps, real x1, real y1, real x2, real y2)
+static void do_box(t_psdata *ps, real x1, real y1, real x2, real y2)
{
ps_moveto(ps, x1, y1);
ps_linerel(ps, 0, static_cast<real>(y2-y1));
ps_linerel(ps, static_cast<real>(x1-x2), 0);
}
-void ps_box(t_psdata ps, real x1, real y1, real x2, real y2)
+void ps_box(t_psdata *ps, real x1, real y1, real x2, real y2)
{
do_box(ps, x1, y1, x2, y2);
fprintf(ps->fp, "s\n");
}
-void ps_fillbox(t_psdata ps, real x1, real y1, real x2, real y2)
+void ps_fillbox(t_psdata *ps, real x1, real y1, real x2, real y2)
{
do_box(ps, x1, y1, x2, y2);
fprintf(ps->fp, "f\n");
}
-void ps_arc(t_psdata ps, real x1, real y1, real rad, real a0, real a1)
+void ps_arc(t_psdata *ps, real x1, real y1, real rad, real a0, real a1)
{
fprintf(ps->fp, "%g %g %g %g %g arc s\n", x1, y1, rad, a0, a1);
}
-void ps_fillarc(t_psdata ps, real x1, real y1, real rad, real a0, real a1)
+void ps_fillarc(t_psdata *ps, real x1, real y1, real rad, real a0, real a1)
{
fprintf(ps->fp, "%g %g %g %g %g arc f\n", x1, y1, rad, a0, a1);
}
-void ps_arcslice(t_psdata ps, real xc, real yc,
+void ps_arcslice(t_psdata *ps, real xc, real yc,
real rad1, real rad2, real a0, real a1)
{
fprintf(ps->fp, "newpath %g %g %g %g %g arc %g %g %g %g %g arcn closepath s\n",
xc, yc, rad1, a0, a1, xc, yc, rad2, a1, a0);
}
-void ps_fillarcslice(t_psdata ps, real xc, real yc,
+void ps_fillarcslice(t_psdata *ps, real xc, real yc,
real rad1, real rad2, real a0, real a1)
{
fprintf(ps->fp, "newpath %g %g %g %g %g arc %g %g %g %g %g arcn closepath f\n",
xc, yc, rad1, a0, a1, xc, yc, rad2, a1, a0);
}
-void ps_circle(t_psdata ps, real x1, real y1, real rad)
+void ps_circle(t_psdata *ps, real x1, real y1, real rad)
{
ps_arc(ps, x1, y1, rad, 0, 360);
}
-void ps_font(t_psdata ps, int font, real size)
+void ps_font(t_psdata *ps, int font, real size)
{
if ((font < 0) || (font > efontNR))
fprintf(ps->fp, "%g scalefont setfont\n", size);
}
-void ps_strfont(t_psdata ps, char *font, real size)
+void ps_strfont(t_psdata *ps, char *font, real size)
{
fprintf(ps->fp, "/%s findfont\n", font);
fprintf(ps->fp, "%g scalefont setfont\n", size);
}
-void ps_text(t_psdata ps, real x1, real y1, const char *str)
+void ps_text(t_psdata *ps, real x1, real y1, const std::string &str)
{
ps_moveto(ps, x1, y1);
- fprintf(ps->fp, "(%s) show\n", str);
+ fprintf(ps->fp, "(%s) show\n", str.c_str());
}
-void ps_flip(t_psdata ps, gmx_bool bPlus)
+void ps_flip(t_psdata *ps, gmx_bool bPlus)
{
if (bPlus)
{
}
}
-void ps_rotate(t_psdata ps, real angle)
+void ps_rotate(t_psdata *ps, real angle)
{
fprintf(ps->fp, "%f rotate\n", angle);
}
-void ps_ctext(t_psdata ps, real x1, real y1, const char *str, int expos)
+void ps_ctext(t_psdata *ps, real x1, real y1, const std::string &str, int expos)
{
if (expos == eXLeft)
{
return;
}
ps_moveto(ps, x1, y1);
- fprintf(ps->fp, "(%s) stringwidth\n", str);
+ fprintf(ps->fp, "(%s) stringwidth\n", str.c_str());
switch (expos)
{
case eXLeft:
default:
gmx_fatal(FARGS, "invalid position index (expos=%d)", expos);
}
- fprintf(ps->fp, "rmoveto (%s) show\n", str);
+ fprintf(ps->fp, "rmoveto (%s) show\n", str.c_str());
}
-void ps_translate(t_psdata ps, real x, real y)
+void ps_translate(t_psdata *ps, real x, real y)
{
fprintf(ps->fp, "%g %g translate\n", x, y);
}
-void ps_setorigin(t_psdata ps)
+void ps_setorigin(t_psdata *ps)
{
fprintf(ps->fp, "currentpoint dup 3 -1 roll dup 4 1 roll exch translate\n");
ps->ostack++;
}
-void ps_unsetorigin(t_psdata ps)
+void ps_unsetorigin(t_psdata *ps)
{
if (ps->ostack <= 0)
{
ps->ostack--;
}
-void ps_close(t_psdata ps)
+void ps_close(t_psdata *ps)
{
fprintf(ps->fp, "%%showpage\n");
fprintf(ps->fp, "%%%%EOF\n");
gmx_fio_fclose(ps->fp);
- sfree(ps->rgb);
- sfree(ps);
}
-void ps_comment(t_psdata ps, const char *s)
+void ps_comment(t_psdata *ps, const char *s)
{
fprintf(ps->fp, "%%%% %s\n", s);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#ifndef GMX_FILEIO_WRITEPS_H
#define GMX_FILEIO_WRITEPS_H
-#include <stdio.h>
+#include <cstdio>
+
+#include <string>
+#include <vector>
#include "gromacs/fileio/rgb.h"
#include "gromacs/utility/basedefinitions.h"
};
-typedef struct t_int_psdata *t_psdata;
-/* Only use t_psdata - it is a pointer to an abstract datatype
- * that maintains the state of the postscript currently written.
- */
+struct t_psdata
+{
+ FILE *fp = nullptr;
+ int maxrgb = 0;
+ std::vector<t_rgb> rgb;
+ real gen_ybox = 0;
+ int ostack = 0;
+};
+
extern const char *fontnm[efontNR];
t_psdata ps_open(const char *fn, real x1, real y1, real x2, real y2);
-void ps_linewidth(t_psdata ps, int lw);
-void ps_color(t_psdata ps, real r, real g, real b);
-void ps_rgb(t_psdata ps, t_rgb *rgb);
+void ps_linewidth(t_psdata *ps, int lw);
+void ps_color(t_psdata *ps, real r, real g, real b);
+void ps_rgb(t_psdata *ps, const t_rgb *rgb);
-void ps_rgb_box(t_psdata ps, t_rgb *rgb);
-void ps_rgb_nbox(t_psdata ps, t_rgb *rgb, real n);
-void ps_init_rgb_box(t_psdata ps, real xbox, real ybox);
-void ps_init_rgb_nbox(t_psdata ps, real xbox, real ybox);
+void ps_rgb_box(t_psdata *ps, t_rgb *rgb);
+void ps_rgb_nbox(t_psdata *ps, t_rgb *rgb, real n);
+void ps_init_rgb_box(t_psdata *ps, real xbox, real ybox);
+void ps_init_rgb_nbox(t_psdata *ps, real xbox, real ybox);
-void ps_lineto(t_psdata ps, real x, real y);
-void ps_linerel(t_psdata ps, real dx, real dy);
+void ps_lineto(t_psdata *ps, real x, real y);
+void ps_linerel(t_psdata *ps, real dx, real dy);
-void ps_moveto(t_psdata ps, real x, real y);
-void ps_moverel(t_psdata ps, real dx, real dy);
+void ps_moveto(t_psdata *ps, real x, real y);
+void ps_moverel(t_psdata *ps, real dx, real dy);
-void ps_line(t_psdata ps, real x1, real y1, real x2, real y2);
+void ps_line(t_psdata *ps, real x1, real y1, real x2, real y2);
-void ps_box(t_psdata ps, real x1, real y1, real x2, real y2);
-void ps_fillbox(t_psdata ps, real x1, real y1, real x2, real y2);
+void ps_box(t_psdata *ps, real x1, real y1, real x2, real y2);
+void ps_fillbox(t_psdata *ps, real x1, real y1, real x2, real y2);
-void ps_arc(t_psdata ps, real x1, real y1, real rad, real a0, real a1);
-void ps_fillarc(t_psdata ps, real x1, real y1, real rad, real a0, real a1);
-void ps_arcslice(t_psdata ps, real xc, real yc,
+void ps_arc(t_psdata *ps, real x1, real y1, real rad, real a0, real a1);
+void ps_fillarc(t_psdata *ps, real x1, real y1, real rad, real a0, real a1);
+void ps_arcslice(t_psdata *ps, real xc, real yc,
real rad1, real rad2, real a0, real a1);
-void ps_fillarcslice(t_psdata ps, real xc, real yc,
+void ps_fillarcslice(t_psdata *ps, real xc, real yc,
real rad1, real rad2, real a0, real a1);
-void ps_circle(t_psdata ps, real x1, real y1, real rad);
+void ps_circle(t_psdata *ps, real x1, real y1, real rad);
-void ps_font(t_psdata ps, int font, real size);
-void ps_strfont(t_psdata ps, char *font, real size);
+void ps_font(t_psdata *ps, int font, real size);
+void ps_strfont(t_psdata *ps, char *font, real size);
-void ps_text(t_psdata ps, real x1, real y1, const char *str);
-void ps_ctext(t_psdata ps, real x1, real y1, const char *str, int expos);
+void ps_text(t_psdata *ps, real x1, real y1, const std::string &str);
+void ps_ctext(t_psdata *ps, real x1, real y1, const std::string &str, int expos);
-void ps_close(t_psdata ps);
+void ps_close(t_psdata *ps);
-void ps_flip(t_psdata ps, gmx_bool bPlus);
+void ps_flip(t_psdata *ps, gmx_bool bPlus);
/* Rotate over 90 (bPlus) or -90 (!bPlus) degrees */
-void ps_rotate(t_psdata ps, real angle);
+void ps_rotate(t_psdata *ps, real angle);
-void ps_translate(t_psdata ps, real x, real y);
+void ps_translate(t_psdata *ps, real x, real y);
-void ps_setorigin(t_psdata ps);
-void ps_unsetorigin(t_psdata ps);
+void ps_setorigin(t_psdata *ps);
+void ps_unsetorigin(t_psdata *ps);
-void ps_comment(t_psdata ps, const char *s);
+void ps_comment(t_psdata *ps, const char *s);
#endif
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
const real fontasp = 0.6;
const real fontwidth = fontsize*fontasp;
- t_psdata out;
int i, sl, slen;
real ring, inner, outer;
real xc, yc, box;
bPh = bPhobics(nres, resnm);
- out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
+ t_psdata out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
xc = box;
yc = box;
- ps_font(out, efontHELV, 1.5*fontsize);
- ps_translate(out, xc, yc);
+ ps_font(&out, efontHELV, 1.5*fontsize);
+ ps_translate(&out, xc, yc);
if (title)
{
- ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter);
+ ps_ctext(&out, 0, -fontsize*1.5/2.0, title, eXCenter);
}
- ps_font(out, efontHELV, fontsize);
- ps_rotate(out, rot0);
+ ps_font(&out, efontHELV, fontsize);
+ ps_rotate(&out, rot0);
for (i = 0; (i < nres); )
{
if (bPh[i])
{
- ps_color(out, gray, gray, gray);
- ps_fillarcslice(out, 0, 0, inner, outer, -10, 10);
- ps_color(out, 0, 0, 0);
+ ps_color(&out, gray, gray, gray);
+ ps_fillarcslice(&out, 0, 0, inner, outer, -10, 10);
+ ps_color(&out, 0, 0, 0);
}
- ps_arcslice(out, 0, 0, inner, outer, -10, 10);
+ ps_arcslice(&out, 0, 0, inner, outer, -10, 10);
- ps_ctext(out, inner+fontwidth, -fontsize/2.0, rnms[i], eXLeft);
- ps_rotate(out, -100);
+ ps_ctext(&out, inner+fontwidth, -fontsize/2.0, rnms[i], eXLeft);
+ ps_rotate(&out, -100);
i++;
if ((i % 18) == 0)
outer += ring;
}
}
- ps_close(out);
+ ps_close(&out);
}
static void wheel2(const char *fn, int nres, char *resnm[], real rot0, char *title)
const int angle = 9;
const real fontwidth = fontsize*fontasp;
- t_psdata out;
int i, slen;
real ring, inner, outer;
real xc, yc, box;
outer = inner+ring;
box = (1+gmx::exactDiv(nres, 2*angle))*outer;
- out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
+ t_psdata out = ps_open(fn, 0, 0, 2.0*box, 2.0*box);
xc = box;
yc = box;
- ps_font(out, efontHELV, 1.5*fontsize);
- ps_translate(out, xc, yc);
- ps_color(out, 0, 0, 0);
+ ps_font(&out, efontHELV, 1.5*fontsize);
+ ps_translate(&out, xc, yc);
+ ps_color(&out, 0, 0, 0);
if (title)
{
- ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter);
+ ps_ctext(&out, 0, -fontsize*1.5/2.0, title, eXCenter);
}
- ps_font(out, efontHELV, fontsize);
+ ps_font(&out, efontHELV, fontsize);
- ps_rotate(out, rot0);
+ ps_rotate(&out, rot0);
for (i = 0; (i < nres); )
{
if ((i % 5) == 4)
{
- ps_color(out, gray, gray, 1.0);
- ps_fillarcslice(out, 0, 0, inner, outer, -angle, angle);
- ps_color(out, 0, 0, 0);
+ ps_color(&out, gray, gray, 1.0);
+ ps_fillarcslice(&out, 0, 0, inner, outer, -angle, angle);
+ ps_color(&out, 0, 0, 0);
}
- ps_arcslice(out, 0, 0, inner, outer, -angle, angle);
+ ps_arcslice(&out, 0, 0, inner, outer, -angle, angle);
- ps_ctext(out, inner+fontwidth, -fontsize/2.0, resnm[i], eXLeft);
- ps_rotate(out, -2*angle);
+ ps_ctext(&out, inner+fontwidth, -fontsize/2.0, resnm[i], eXLeft);
+ ps_rotate(&out, -2*angle);
i++;
if ((i % (2*angle)) == 0)
outer += ring;
}
}
- ps_close(out);
+ ps_close(&out);
}
int gmx_wheel(int argc, char *argv[])
return bDiff;
}
-static void leg_discrete(t_psdata ps, real x0, real y0, char *label,
+static void leg_discrete(t_psdata *ps, real x0, real y0, char *label,
real fontsize, char *font, int nmap, t_mapping map[])
{
int i;
}
}
-static void leg_continuous(t_psdata ps, real x0, real x, real y0, char *label,
+static void leg_continuous(t_psdata *ps, real x0, real x, real y0, char *label,
real fontsize, char *font,
int nmap, t_mapping map[],
int mapoffset)
- boxxh/2, yhh, map[nmap-1].desc, eXCenter);
}
-static void leg_bicontinuous(t_psdata ps, real x0, real x, real y0, char *label1,
+static void leg_bicontinuous(t_psdata *ps, real x0, real x, real y0, char *label1,
char *label2, real fontsize, char *font,
int nmap1, t_mapping map1[], int nmap2, t_mapping map2[])
{
return (psr->boxspacing > (1.5*psr->X.minorticklen));
}
-static void draw_boxes(t_psdata ps, real x0, real y0, real w,
+static void draw_boxes(t_psdata *ps, real x0, real y0, real w,
int nmat, t_matrix mat[], t_psrec *psr)
{
char buf[128];
}
}
-static void draw_zerolines(t_psdata out, real x0, real y0, real w,
+static void draw_zerolines(t_psdata *out, real x0, real y0, real w,
int nmat, t_matrix mat[], t_psrec *psr)
{
real xx, yy, dy, xx00, yy00;
int mapoffset)
{
char *legend;
- t_psdata out;
t_psrec psrec, *psr;
int W, H;
int i, x, y, col, leg = 0;
x += 5*DDD;
y += 4*DDD;
}
- out = ps_open(outf, 0, 0, x, y);
- ps_linewidth(out, static_cast<int>(psr->linewidth));
- ps_init_rgb_box(out, psr->xboxsize, psr->yboxsize);
- ps_init_rgb_nbox(out, psr->xboxsize, psr->yboxsize);
- ps_translate(out, psr->xoffs, psr->yoffs);
+ t_psdata out = ps_open(outf, 0, 0, x, y);
+ ps_linewidth(&out, static_cast<int>(psr->linewidth));
+ ps_init_rgb_box(&out, psr->xboxsize, psr->yboxsize);
+ ps_init_rgb_nbox(&out, psr->xboxsize, psr->yboxsize);
+ ps_translate(&out, psr->xoffs, psr->yoffs);
if (bFrame)
{
- ps_comment(out, "Here starts the BOX drawing");
- draw_boxes(out, x0, y0, w, nmat, mat, psr);
+ ps_comment(&out, "Here starts the BOX drawing");
+ draw_boxes(&out, x0, y0, w, nmat, mat, psr);
}
for (i = 0; (i < nmat); i++)
if (bTitle || (bTitleOnce && i == nmat-1) )
{
/* Print title, if any */
- ps_rgb(out, BLACK);
- ps_strfont(out, psr->titfont, psr->titfontsize);
+ ps_rgb(&out, BLACK);
+ ps_strfont(&out, psr->titfont, psr->titfontsize);
std::string buf;
if (!mat2 || (std::strcmp(mat[i].title, mat2[i].title) == 0))
{
{
buf = gmx::formatString("%s / %s", mat[i].title, mat2[i].title);
}
- ps_ctext(out, x0+w/2, y0+box_height(&(mat[i]), psr)+psr->titfontsize,
- buf.c_str(), eXCenter);
+ ps_ctext(&out, x0+w/2, y0+box_height(&(mat[i]), psr)+psr->titfontsize,
+ buf, eXCenter);
}
- ps_comment(out, gmx::formatString("Here starts the filling of box #%d", i).c_str());
+ ps_comment(&out, gmx::formatString("Here starts the filling of box #%d", i).c_str());
for (x = 0; (x < mat[i].nx); x++)
{
int nexty;
int nextcol;
xx = x0+x*psr->xboxsize;
- ps_moveto(out, xx, y0);
+ ps_moveto(&out, xx, y0);
y = 0;
bMap1 = ((mat2 == nullptr) || (x < y || (x == y && bFirstDiag)));
if ((bDiag) || (x != y))
{
if (bMap1)
{
- ps_rgb_nbox(out, &(mat[i].map[col].rgb), nexty-y);
+ ps_rgb_nbox(&out, &(mat[i].map[col].rgb), nexty-y);
}
else
{
assert(mat2);
- ps_rgb_nbox(out, &(mat2[i].map[col].rgb), nexty-y);
+ ps_rgb_nbox(&out, &(mat2[i].map[col].rgb), nexty-y);
}
}
else
{
- ps_moverel(out, 0, psr->yboxsize);
+ ps_moverel(&out, 0, psr->yboxsize);
}
y = nexty;
bMap1 = bNextMap1;
{
/* reset y0 for first box */
y0 = dh;
- ps_comment(out, "Here starts the zero lines drawing");
- draw_zerolines(out, x0, y0, w, nmat, mat, psr);
+ ps_comment(&out, "Here starts the zero lines drawing");
+ draw_zerolines(&out, x0, y0, w, nmat, mat, psr);
}
if (elegend != elNone)
{
- ps_comment(out, "Now it's legend time!");
- ps_linewidth(out, static_cast<int>(psr->linewidth));
+ ps_comment(&out, "Now it's legend time!");
+ ps_linewidth(&out, static_cast<int>(psr->linewidth));
if (mat2 == nullptr || elegend != elSecond)
{
bDiscrete = mat[0].bDiscrete;
}
if (bDiscrete)
{
- leg_discrete(out, psr->legfontsize, DDD, legend,
+ leg_discrete(&out, psr->legfontsize, DDD, legend,
psr->legfontsize, psr->legfont, leg_nmap, leg_map);
}
else
{
if (elegend != elBoth)
{
- leg_continuous(out, x0+w/2, w/2, DDD, legend,
+ leg_continuous(&out, x0+w/2, w/2, DDD, legend,
psr->legfontsize, psr->legfont, leg_nmap, leg_map,
mapoffset);
}
else
{
assert(mat2);
- leg_bicontinuous(out, x0+w/2, w, DDD, mat[0].legend, mat2[0].legend,
+ leg_bicontinuous(&out, x0+w/2, w, DDD, mat[0].legend, mat2[0].legend,
psr->legfontsize, psr->legfont, nmap1, map1, nmap2, map2);
}
}
- ps_comment(out, "Were there, dude");
+ ps_comment(&out, "Done processing");
}
- ps_close(out);
+ ps_close(&out);
}
static void make_axis_labels(int nmat, t_matrix *mat)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2013, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define MSIZE 4
-static void ps_draw_atom(t_psdata ps, int ai, iv2 vec2[], char **atomnm[])
+static void ps_draw_atom(t_psdata *ps, int ai, iv2 vec2[], char **atomnm[])
{
int xi, yi;
return true;
}
-static void ps_draw_bond(t_psdata ps,
+static void ps_draw_bond(t_psdata *ps,
int ai, int aj, iv2 vec2[],
rvec x[], char **atomnm[])
{
}
}
-static void ps_draw_objects(t_psdata ps, int nobj, t_object objs[], iv2 vec2[],
+static void ps_draw_objects(t_psdata *ps, int nobj, t_object objs[], iv2 vec2[],
rvec x[], char **atomnm[], bool bShowHydro)
{
int i;
v2[YY] = y0-sy*x4[YY]*inv_z;
}
-static void draw_box(t_psdata ps, t_3dview *view, matrix box,
+static void draw_box(t_psdata *ps, t_3dview *view, matrix box,
int x0, int y0, real sx, real sy)
{
int ivec[8][4] = {
}
}
-void ps_draw_mol(t_psdata ps, t_manager *man)
+void ps_draw_mol(t_psdata *ps, t_manager *man)
{
t_windata *win;
t_3dview *view;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#ifndef _molps_h
#define _molps_h
-#include "gromacs/fileio/writeps.h"
-
#include "manager.h"
-extern void ps_draw_mol(t_psdata ps, t_manager *man);
+struct t_psdata;
+
+extern void ps_draw_mol(t_psdata *ps, t_manager *man);
/* Draw molecules to a postscript file */
#endif /* _molps_h */
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
t_psdata ps;
ps = ps_open("view.ps", 0, 0, man->molw->wd.width, man->molw->wd.height);
- ps_draw_mol(ps, man);
- ps_close(ps);
+ ps_draw_mol(&ps, man);
+ ps_close(&ps);
}
static void done_gmx(t_x11 *x11, t_gmx *gmx)