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!1000
  • Loading branch information
jheinen committed Jan 24, 2023
2 parents b4b42d4 + 819fac7 commit 8a02b5b
Show file tree
Hide file tree
Showing 15 changed files with 494 additions and 114 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ if((Qt6Widgets_FOUND AND Qt6Core_FOUND) OR (Qt5Widgets_FOUND AND Qt5Core_FOUND))
target_link_libraries(grplot PRIVATE Qt5::Widgets Qt5::Core grm_static)
set(grplot_INSTALL_RPATH "${INSTALL_RPATH};${Qt5_LIBRARY_DIR}")
endif()
target_compile_definitions(grplot PRIVATE GRDIR="${GR_DIRECTORY}")
set_target_properties(
grplot PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON INSTALL_RPATH
"${grplot_INSTALL_RPATH}"
Expand Down
2 changes: 1 addition & 1 deletion lib/gks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ plugins:
endif

pasdemo: default
fpc -Px86_64 demo.p -g -Fl./ -k-rpath -k./
fpc demo.p -g -Fl./ -k-rpath -k./

install:
@if [ ! -d $(DESTDIR)$(GRDIR) ]; then mkdir -m 755 $(DESTDIR)$(GRDIR); fi
Expand Down
12 changes: 6 additions & 6 deletions lib/gks/demo.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
cc demo.c -L/usr/local/gr/lib -lGKS -Wl,-rpath,/usr/local/gr/lib
*/

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -132,12 +135,9 @@ int main(int argc, char *argv[])
gks_set_pline_linewidth(1.0 * i);
for (j = 1; j <= 4; j++)
{
if (j)
{
gks_set_pline_linetype(j);
y[1] = y[0] -= 0.02;
gks_polyline(2, x, y);
}
gks_set_pline_linetype(j);
y[1] = y[0] -= 0.02;
gks_polyline(2, x, y);
}
}

Expand Down
20 changes: 19 additions & 1 deletion lib/gks/demo.f
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
C*
C* gfortran demo.f -L/usr/local/gr/lib -lGKS -Wl,-rpath,/usr/local/gr/lib
C*
INTEGER ASF(13)
REAL X(10), Y(10), CPX, CPY, TX(4), TY(4)
INTEGER I, J, K
Expand Down Expand Up @@ -102,11 +105,22 @@
DO 100, J = -8, 4
IF (J .EQ. 0) GOTO 100
CALL GSLN(J)
Y(1) = Y(1) - 0.05
Y(1) = Y(1) - 0.02
Y(2) = Y(1)
CALL GPL(2, X, Y)
100 CONTINUE

DO 120, i = 1, 3
Y(1) = Y(1) - 0.03
CALL GSLWSC(1.0 * i)
DO 130, J = 1, 4
CALL GSLN(J)
Y(1) = Y(1) - 0.02
Y(2) = Y(1)
CALL GPL(2, X, Y)
130 CONTINUE
120 CONTINUE

C* markertypes
CALL GSMKSC(3.5)

Expand Down Expand Up @@ -199,12 +213,16 @@
CALL GSTXAL(1, 1)
CALL GSTXFP(3, 0)
CALL GSCHUP(-1., 0.)
CALL GSTXCI(200)
CALL GTX(.05, .15, 'up')
CALL GSCHUP(0., -1.)
CALL GSTXCI(400)
CALL GTX(.05, .15, 'left')
CALL GSCHUP(1., 0.)
CALL GSTXCI(600)
CALL GTX(.05, .15, 'down')
CALL GSCHUP(0., 1.)
CALL GSTXCI(800)
CALL GTX(.05, .15, 'right')

CALL GUWK(1, 0)
Expand Down
21 changes: 18 additions & 3 deletions lib/gks/demo.p
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
program demo(input, output);

{
fpc -Px86_64 demo.p
env DYLD_LIBRARY_PATH=/usr/local/gr/lib GKS_WSTYPE=x11 ./demo
fpc -Fl/usr/local/gr/lib -k-rpath -k/usr/local/gr/lib demo.p
}

uses
Expand Down Expand Up @@ -122,11 +121,24 @@ begin
if j <> 0 then
begin
gks_set_pline_linetype(j);
y[1] := y[1] - 0.05;
y[1] := y[1] - 0.02;
y[2] := y[1];
gks_polyline(2, x, y);
end;

for i := 1 to 3 do
begin
y[1] := y[1] - 0.03;
gks_set_pline_linewidth(1.0 * i);
for j := 1 to 4 do
begin
gks_set_pline_linetype(j);
y[1] := y[1] - 0.02;
y[2] := y[1];
gks_polyline(2, x, y);
end;
end;

{ Markertypes }
gks_set_pmark_size(3.5);

Expand Down Expand Up @@ -252,6 +264,9 @@ begin
else
begin
gks_update_ws(2, GKS_K_POSTPONE_FLAG);
write('Press RETURN to continue ...');
readln();

gks_set_pmark_type(2);
gks_request_locator(2, 1, inp_status, tnr, x[1], y[1]);
while inp_status = 1 do
Expand Down
2 changes: 1 addition & 1 deletion lib/gks/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,5 @@ void gks_lookup_font(int fd, int version, int font, int chr, stroke_data_t *s)

void gks_close_font(int fd)
{
if (fd != -1) gks_close_file(fd);
if (fd > 0) gks_close_file(fd);
}
21 changes: 13 additions & 8 deletions lib/gks/gks.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
static gks_state_list_t *s = NULL, *seg_state = NULL;

static int state = GKS_K_GKCL, api = 1;
static int fontfile = 0;

static int i_arr[13];
static double f_arr_1[6], f_arr_2[6];
Expand Down Expand Up @@ -576,7 +577,7 @@ void gks_open_gks(int errfil)
gks_parse_env();

/* postpone opening of the font database */
s->fontfile = 0;
fontfile = 0;

/* miscellaneous flags */
s->wiss = 0;
Expand Down Expand Up @@ -608,13 +609,13 @@ void gks_close_gks(void)
/* call the device driver link routine */
gks_ddlk(CLOSE_GKS, 0, 0, 0, i_arr, 0, f_arr_1, 0, f_arr_2, 0, c_arr, NULL);

if (s->fontfile > 0)
if (fontfile > 0)
{
/* close font database */
if (s->debug) fprintf(stdout, "[DEBUG:GKS] close font database (fd=%d)\n", s->fontfile);
if (s->debug) fprintf(stdout, "[DEBUG:GKS] close font database (fd=%d)\n", fontfile);

gks_close_font(s->fontfile);
s->fontfile = 0;
gks_close_font(fontfile);
fontfile = 0;
}

gks_list_free(av_ws_types);
Expand Down Expand Up @@ -1243,6 +1244,8 @@ void gks_text(double px, double py, char *str)
f_arr_1[0] = px;
f_arr_2[0] = py;

s->fontfile = fontfile;

/* call the device driver link routine */
gks_ddlk(TEXT, 0, 0, 0, i_arr, 1, f_arr_1, 1, f_arr_2, 1, utf8_str, NULL);
gks_free(utf8_str);
Expand Down Expand Up @@ -1582,14 +1585,14 @@ void gks_set_text_fontprec(int font, int prec)
{
if (font != s->txfont || prec != s->txprec)
{
if ((prec == GKS_K_TEXT_PRECISION_STROKE || prec == GKS_K_TEXT_PRECISION_CHAR) && s->fontfile == 0)
if ((prec == GKS_K_TEXT_PRECISION_STROKE || prec == GKS_K_TEXT_PRECISION_CHAR) && fontfile == 0)
{
/* open font database */
if (s->debug) fprintf(stdout, "[DEBUG:GKS] open font database ");

s->fontfile = gks_open_font();
fontfile = gks_open_font();

if (s->debug) fprintf(stdout, "=> fd=%d\n", s->fontfile);
if (s->debug) fprintf(stdout, "=> fd=%d\n", fontfile);
}

s->txfont = i_arr[0] = font;
Expand Down Expand Up @@ -3021,6 +3024,8 @@ void gks_inq_text_extent(int wkid, double px, double py, char *str, int *errind,
char *utf8_str = gks_malloc(strlen(str) * 2 + 1);
gks_input2utf8(str, utf8_str, s->input_encoding);

s->fontfile = fontfile;

gks_util_inq_text_extent(px, py, utf8_str, strlen(utf8_str), cpx, cpy, tx, ty);

gks_free(utf8_str);
Expand Down
7 changes: 6 additions & 1 deletion lib/gks/plugin/qtplugin_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ static void memory_plugin_dl_render(int fctid, int dx, int dy, int dimx, int *ia
}
return;
case 3:
if (fontfile != 0)
if (fontfile > 0)
{
gks_close_font(fontfile);
fontfile = 0;
Expand Down Expand Up @@ -1780,6 +1780,11 @@ void QT_PLUGIN_ENTRY_NAME(int fctid, int dx, int dy, int dimx, int *i_arr, int l
break;

case 3:
if (fontfile > 0)
{
gks_close_font(fontfile);
fontfile = 0;
}
release_data();

p = NULL;
Expand Down
36 changes: 10 additions & 26 deletions lib/gks/plugin/svgplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
svg_printf(p->stream,
"<polyline clip-path=\"url(#clip%02d%d)\" "
"style=\"stroke:#%02x%02x%02x; stroke-width:%g; stroke-opacity:%g; fill:none\" "
"points=\"\n ",
"points=\"",
path_id, p->rect_index, p->rgb[mcolor][0], p->rgb[mcolor][1], p->rgb[mcolor][2],
gkss->bwidth * p->nominal_size, p->transparency);
for (i = 0; i < marker[mtype][pc + 1]; i++)
Expand All @@ -455,12 +455,8 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol
yr = -scale * marker[mtype][pc + 3 + 2 * i];
seg_xform_rel(&xr, &yr);
svg_printf(p->stream, "%g,%g ", x - xr, y + yr);
if (!((i + 1) % 10))
{
svg_printf(p->stream, "\n ");
}
}
svg_printf(p->stream, "\n \"/>\n");
svg_printf(p->stream, "\"/>\n");
pc += 1 + 2 * marker[mtype][pc + 1];
break;

Expand Down Expand Up @@ -563,16 +559,12 @@ static void stroke(void)
"fill:none\" ",
path_id, p->rect_index, p->rgb[p->color][0], p->rgb[p->color][1], p->rgb[p->color][2], p->linewidth,
p->transparency);
svg_printf(p->stream, "points=\"\n ");
svg_printf(p->stream, "points=\"");
for (i = 0; i < p->npoints; i++)
{
svg_printf(p->stream, "%g,%g ", p->points[i].x, p->points[i].y);
if (!((i + 1) % 10))
{
svg_printf(p->stream, "\n ");
}
}
svg_printf(p->stream, "\n \"/>\n");
svg_printf(p->stream, "\"/>\n");

p->npoints = 0;
}
Expand Down Expand Up @@ -628,7 +620,7 @@ static void line_routine(int n, double *px, double *py, int linetype, int tnr)
}
svg_printf(p->stream, "stroke-dasharray=\"%s\" ", s);
}
svg_printf(p->stream, "points=\"\n %g,%g ", x0, y0);
svg_printf(p->stream, "points=\"%g,%g ", x0, y0);

xim1 = x0;
yim1 = y0;
Expand All @@ -647,13 +639,9 @@ static void line_routine(int n, double *px, double *py, int linetype, int tnr)
xim1 = xi;
yim1 = yi;
}
if (!((i + 1) % 10))
{
svg_printf(p->stream, "\n ");
}
}
if (linetype == 0) svg_printf(p->stream, "%g,%g", x0, y0);
svg_printf(p->stream, "\n \"/>\n");
svg_printf(p->stream, "\"/>\n");
}

static void fill_routine(int n, double *px, double *py, int tnr)
Expand Down Expand Up @@ -734,7 +722,7 @@ static void fill_routine(int n, double *px, double *py, int tnr)
}
}

svg_printf(p->stream, "<path clip-path=\"url(#clip%02d%d)\" d=\"\n", path_id, p->rect_index);
svg_printf(p->stream, "<path clip-path=\"url(#clip%02d%d)\" d=\"", path_id, p->rect_index);
for (i = 0; i < n; i++)
{
if (px[i] != px[i] && py[i] != py[i])
Expand All @@ -755,16 +743,12 @@ static void fill_routine(int n, double *px, double *py, int tnr)
{
svg_printf(p->stream, "L%g %g ", ix, iy);
}
if (!((i + 1) % 10))
{
svg_printf(p->stream, "\n ");
}
}
if (p->pattern)
svg_printf(p->stream, " Z\n \" fill=\"url(#pattern%d)\"", p->pattern_count);
svg_printf(p->stream, " Z\" fill=\"url(#pattern%d)\"", p->pattern_count);
else
svg_printf(p->stream, " Z\n \" fill=\"#%02x%02x%02x\" fill-rule=\"evenodd\" fill-opacity=\"%g\"",
p->rgb[p->color][0], p->rgb[p->color][1], p->rgb[p->color][2], p->transparency);
svg_printf(p->stream, " Z\" fill=\"#%02x%02x%02x\" fill-rule=\"evenodd\" fill-opacity=\"%g\"", p->rgb[p->color][0],
p->rgb[p->color][1], p->rgb[p->color][2], p->transparency);
svg_printf(p->stream, "/>\n");
}

Expand Down
Loading

0 comments on commit 8a02b5b

Please sign in to comment.