Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
merge develop into master

See merge request Scientific-IT-Systems/gr!723
  • Loading branch information
jheinen committed Oct 8, 2021
2 parents 0d34554 + bb6bc8f commit c1a1830
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 36 deletions.
27 changes: 16 additions & 11 deletions lib/gks/plugin/cairoplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ static void set_color(int index)
cairo_set_source_rgba(p->cr, p->rgb[index][0], p->rgb[index][1], p->rgb[index][2], p->transparency);
}

static void set_line_width(double width)
{
cairo_set_line_width(p->cr, width > 1 / 16. ? width : 1 / 16.);
}

static void draw_marker(double xn, double yn, int mtype, double mscale, int mcolor)
{
double x, y;
Expand Down Expand Up @@ -301,7 +306,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
{
case 1: /* point */
cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_width(p->cr, p->nominal_size);
set_line_width(p->nominal_size);
set_color(mcolor);
cairo_rectangle(p->cr, round(x), round(y), 1.0, 1.0);
cairo_fill(p->cr);
Expand All @@ -317,7 +322,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
seg_xform_rel(&x2, &y2);

cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_width(p->cr, p->nominal_size);
set_line_width(p->nominal_size);
set_color(mcolor);
cairo_move_to(p->cr, x - x1, y - y1);
cairo_line_to(p->cr, x - x2, y - y2);
Expand All @@ -334,7 +339,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol

cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width(p->cr, p->nominal_size);
set_line_width(p->nominal_size);
set_color(mcolor);
cairo_move_to(p->cr, x - xr, y + yr);
for (i = 1; i < marker[mtype][pc + 1]; i++)
Expand All @@ -353,7 +358,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
{
cairo_fill_preserve(p->cr);
set_color(gkss->bcoli);
cairo_set_line_width(p->cr, gkss->bwidth * p->nominal_size);
set_line_width(gkss->bwidth * p->nominal_size);
cairo_stroke(p->cr);
}
else
Expand All @@ -377,7 +382,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
{
cairo_fill_preserve(p->cr);
set_color(gkss->bcoli);
cairo_set_line_width(p->cr, gkss->bwidth * p->nominal_size);
set_line_width(gkss->bwidth * p->nominal_size);
cairo_stroke(p->cr);
}
else
Expand Down Expand Up @@ -454,7 +459,7 @@ static void line_routine(int n, double *px, double *py, int linetype, int tnr)

cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width(p->cr, p->linewidth);
set_line_width(p->linewidth);

cairo_move_to(p->cr, x0, y0);

Expand Down Expand Up @@ -589,7 +594,7 @@ static void polyline(int n, double *px, double *py)
cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
p->linewidth = ln_width * p->nominal_size;
cairo_set_line_width(p->cr, p->linewidth);
set_line_width(p->linewidth);

p->color = ln_color;
set_color(ln_color);
Expand Down Expand Up @@ -1671,7 +1676,7 @@ static void draw_path(int n, double *px, double *py, int nc, int *codes)
cairo_new_path(p->cr);
cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width(p->cr, gkss->bwidth * p->nominal_size);
set_line_width(gkss->bwidth * p->nominal_size);

j = 0;
for (i = 0; i < nc; ++i)
Expand Down Expand Up @@ -1862,7 +1867,7 @@ static void draw_lines(int n, double *px, double *py, int *attributes)

cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_ROUND);
line_width = 0.01 * attributes[j++];
cairo_set_line_width(p->cr, line_width * p->nominal_size);
set_line_width(line_width * p->nominal_size);
rgba = attributes[j++];
p->rgb[line_color][0] = (rgba & 0xff) / 255.0;
p->rgb[line_color][1] = ((rgba >> 8) & 0xff) / 255.0;
Expand Down Expand Up @@ -1932,7 +1937,7 @@ static void draw_triangles(int n, double *px, double *py, int ntri, int *tri)

cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width(p->cr, gkss->lwidth * p->nominal_size);
set_line_width(gkss->lwidth * p->nominal_size);
rgba = tri[j++];
p->rgb[line_color][0] = (rgba & 0xff) / 255.0;
p->rgb[line_color][1] = ((rgba >> 8) & 0xff) / 255.0;
Expand Down Expand Up @@ -1995,7 +2000,7 @@ static void fill_polygons(int n, double *px, double *py, int nply, int *ply)
set_color(gkss->bcoli);
cairo_set_line_cap(p->cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(p->cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width(p->cr, gkss->bwidth * p->nominal_size);
set_line_width(gkss->bwidth * p->nominal_size);
cairo_stroke(p->cr);
}
}
Expand Down
78 changes: 53 additions & 25 deletions lib/gr/gr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5364,10 +5364,12 @@ void gr_grid3d(double x_tick, double y_tick, double z_tick, double x_org, double
int major_y, int major_z)
{
int errind, tnr;
double clrt[4], wn[4], vp[4];
int modern_projection_type;

int ltype, color, clsw, major;
double width;

double clrt[4], wn[4], vp[4];
double x_min = 0, x_max = 0, y_min = 0, y_max = 0, z_min = 0, z_max = 0;

double x0, y0, z0, xi, yi, zi;
Expand All @@ -5389,7 +5391,10 @@ void gr_grid3d(double x_tick, double y_tick, double z_tick, double x_org, double
gks_inq_current_xformno(&errind, &tnr);
gks_inq_xform(tnr, &errind, wn, vp);

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
modern_projection_type =
gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC;

if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);
Expand Down Expand Up @@ -5625,7 +5630,7 @@ void gr_grid3d(double x_tick, double y_tick, double z_tick, double x_org, double
"majorx=\"%d\" majory=\"%d\" majorz=\"%d\"/>\n",
x_tick, y_tick, z_tick, x_org, y_org, z_org, major_x, major_y, major_z);

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
if (modern_projection_type)
{
gks_set_window(WC, wn[0], wn[1], wn[2], wn[3]);
setscale(lx.scale_options);
Expand Down Expand Up @@ -5858,6 +5863,7 @@ void gr_polyline3d(int n, double *px, double *py, double *pz)
{
int errind, clsw, i, tnr;
double clrt[4], wn[4], vp[4];
int modern_projection_type;

double x, y, z, x0, y0, z0, x1, y1, z1;
int clip = 1, visible = 1;
Expand All @@ -5870,13 +5876,19 @@ void gr_polyline3d(int n, double *px, double *py, double *pz)
gks_inq_xform(tnr, &errind, wn, vp);
gks_inq_clip(&errind, &clsw, clrt);

modern_projection_type =
gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC;

if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);
}

if (clsw == GKS_K_CLIP)
{
if (gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC || gpx.projection_type == GR_PROJECTION_PERSPECTIVE)
if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);

cxl = ix.xmin;
cxr = ix.xmax;
cyf = ix.ymin;
Expand Down Expand Up @@ -5945,7 +5957,7 @@ void gr_polyline3d(int n, double *px, double *py, double *pz)
gr_writestream("/>\n");
}

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
if (modern_projection_type)
{
gks_set_window(WC, wn[0], wn[1], wn[2], wn[3]);
setscale(lx.scale_options);
Expand Down Expand Up @@ -5983,6 +5995,7 @@ void gr_polymarker3d(int n, double *px, double *py, double *pz)
{
int errind, clsw, i, tnr;
double clrt[4], wn[4], vp[4];
int modern_projection_type;

double x, y, z;
point_3d *point;
Expand All @@ -5996,6 +6009,15 @@ void gr_polymarker3d(int n, double *px, double *py, double *pz)
gks_inq_xform(tnr, &errind, wn, vp);
gks_inq_clip(&errind, &clsw, clrt);

modern_projection_type =
gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC;

if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);
}

m = 0;
point = (point_3d *)xmalloc(n * sizeof(point_3d));

Expand All @@ -6007,16 +6029,13 @@ void gr_polymarker3d(int n, double *px, double *py, double *pz)

if (clsw == GKS_K_CLIP)
{
if (gpx.projection_type == GR_PROJECTION_DEFAULT)
if (modern_projection_type)
{
visible = x >= lx.xmin && x <= lx.xmax && y >= lx.ymin && y <= lx.ymax && z >= lx.zmin && z <= lx.zmax;
visible = x >= ix.xmin && x <= ix.xmax && y >= ix.ymin && y <= ix.ymax && z >= ix.zmin && z <= ix.zmax;
}
else
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);

visible = x >= ix.xmin && x <= ix.xmax && y >= ix.ymin && y <= ix.ymax && z >= ix.zmin && z <= ix.zmax;
visible = x >= lx.xmin && x <= lx.xmax && y >= lx.ymin && y <= lx.ymax && z >= lx.zmin && z <= lx.zmax;
}
}
else
Expand Down Expand Up @@ -6060,7 +6079,7 @@ void gr_polymarker3d(int n, double *px, double *py, double *pz)
gr_writestream("/>\n");
}

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
if (modern_projection_type)
{
gks_set_window(WC, wn[0], wn[1], wn[2], wn[3]);
setscale(lx.scale_options);
Expand Down Expand Up @@ -6394,10 +6413,12 @@ void gr_axes3d(double x_tick, double y_tick, double z_tick, double x_org, double
int major_y, int major_z, double tick_size)
{
int errind, tnr;
double clrt[4], wn[4], vp[4];
int modern_projection_type;

int ltype, halign, valign, font, prec, clsw, axis, tick_axis;
double chux, chuy, slant;

double clrt[4], wn[4], vp[4];
double x_min = 0, x_max = 0, y_min = 0, y_max = 0, z_min = 0, z_max = 0;

double r, alpha, beta;
Expand All @@ -6412,7 +6433,6 @@ void gr_axes3d(double x_tick, double y_tick, double z_tick, double x_org, double
int64_t i;
int decade, exponent;
char string[256];
int modern_projection_type;

if (x_tick < 0 || y_tick < 0 || z_tick < 0)
{
Expand Down Expand Up @@ -7032,10 +7052,12 @@ void gr_axes3d(double x_tick, double y_tick, double z_tick, double x_org, double
void gr_titles3d(char *x_title, char *y_title, char *z_title)
{
int errind, tnr;
double clrt[4], wn[4], vp[4];
int modern_projection_type;

int halign, valign, clsw, font, prec;
double chux, chuy;

double clrt[4], wn[4], vp[4];
double x_min, x_max, y_min, y_max, z_min, z_max;
double x_rel, y_rel, z_rel, x, y, z;

Expand All @@ -7052,7 +7074,6 @@ void gr_titles3d(char *x_title, char *y_title, char *z_title)
double xr, yr, zr;

int flip_x, flip_y, flip_z;
int modern_projection_type;

check_autoinit;

Expand All @@ -7066,13 +7087,16 @@ void gr_titles3d(char *x_title, char *y_title, char *z_title)
modern_projection_type =
gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC;

if (wx.phi != 0 || wx.delta != 90)
if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);
}

if (modern_projection_type || wx.phi != 0 || wx.delta != 90)
{
if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);

x_min = ix.xmin;
x_max = ix.xmax;
y_min = ix.ymin;
Expand Down Expand Up @@ -7749,6 +7773,7 @@ static void get_intensity(double *fx, double *fy, double *fz, double *light_sour
void gr_surface(int nx, int ny, double *px, double *py, double *pz, int option)
{
int errind, ltype, coli, int_style, tnr;
int modern_projection_type;

int i, ii, j, jj, k;
int color;
Expand Down Expand Up @@ -7795,7 +7820,10 @@ void gr_surface(int nx, int ny, double *px, double *py, double *pz, int option)
gks_inq_current_xformno(&errind, &tnr);
gks_inq_xform(tnr, &errind, wn, vp);

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
modern_projection_type =
gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC;

if (modern_projection_type)
{
gks_set_window(WC, -1, 1, -1, 1);
setscale(lx.scale_options);
Expand Down Expand Up @@ -8161,7 +8189,7 @@ void gr_surface(int nx, int ny, double *px, double *py, double *pz, int option)
gr_writestream(" option=\"%d\"/>\n", option);
}

if (gpx.projection_type == GR_PROJECTION_PERSPECTIVE || gpx.projection_type == GR_PROJECTION_ORTHOGRAPHIC)
if (modern_projection_type)
{
gks_set_window(WC, wn[0], wn[1], wn[2], wn[3]);
setscale(lx.scale_options);
Expand Down

0 comments on commit c1a1830

Please sign in to comment.