From edc152c08c82299250e721ab5e607fc1e2e629a8 Mon Sep 17 00:00:00 2001 From: Ingo Heimbach Date: Fri, 24 Jan 2020 09:49:34 +0100 Subject: [PATCH 1/5] Pin the version of `cmake-format` to `0.6.7` `cmake-format` is still under heavy development, so the formatter output is likely to change in future versions. Use a pinned `cmake-format` version to avoid inconsistencies and failing CI pipelines. --- .setup_cmakeformat.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.setup_cmakeformat.sh b/.setup_cmakeformat.sh index 268df77c6..88eea05cc 100755 --- a/.setup_cmakeformat.sh +++ b/.setup_cmakeformat.sh @@ -1,5 +1,6 @@ #!/bin/bash +CMAKE_FORMAT_VERSION="0.6.7" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" VENV_NAME=".cmakeformat_venv" @@ -9,7 +10,8 @@ install_cmakeformat () { python3 -m venv "${VENV_NAME}" || return fi source "${VENV_NAME}/bin/activate" && \ - pip -qqq install -U cmake_format six && \ + # Guarantee that all team members use the same version (of dependent packages) + pip -qqq install --upgrade --upgrade-strategy eager "cmake_format==${CMAKE_FORMAT_VERSION}" && \ deactivate && \ echo "$(cd "${VENV_NAME}" && pwd)/bin/cmake-format" } @@ -17,8 +19,7 @@ install_cmakeformat () { main () { cd "${SCRIPT_DIR}" - # If `cmake-format` is already installed on the system, use that version - command -v "cmake-format" && return + # Always use a pinned version of `cmake-format` install_cmakeformat } From 97151f7590c1c2e7893e6e3282cb01e8c1c62e7b Mon Sep 17 00:00:00 2001 From: Code Formatter Date: Fri, 24 Jan 2020 09:53:18 +0100 Subject: [PATCH 2/5] Apply style changes of `cmake-format` version `0.6.7` --- CMakeLists.txt | 20 ++++++++------------ cmake/FindFfmpeg.cmake | 6 +++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca9f5b0b7..48788c308 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,9 +607,8 @@ if(Qt4_FOUND) set_target_properties(qt4gr PROPERTIES AUTOMOC OFF AUTORCC OFF) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_qt4_grwidget.cxx - COMMAND - ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${QT4_MOC_INCLUDE_FLAGS} - ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qt4_grwidget.cxx + COMMAND ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${QT4_MOC_INCLUDE_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qt4_grwidget.cxx DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.cxx ) target_sources(qt5gr PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/moc_qt4_grwidget.cxx) @@ -634,9 +633,8 @@ if(Qt5Widgets_FOUND set_target_properties(qt5gr PROPERTIES AUTOMOC OFF AUTORCC OFF) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_qt5_grwidget.cxx - COMMAND - ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${QT5_MOC_INCLUDE_FLAGS} - ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qt5_grwidget.cxx + COMMAND ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${QT5_MOC_INCLUDE_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qt5_grwidget.cxx DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/gr/qtgr/grwidget.cxx ) target_sources(qt5gr PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/moc_qt5_grwidget.cxx) @@ -714,16 +712,14 @@ if(Qt4_FOUND endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_gkswidget.cxx - COMMAND - ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${MOC_INCLUDE_FLAGS} - ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gkswidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_gkswidget.cxx + COMMAND ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${MOC_INCLUDE_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gkswidget.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_gkswidget.cxx DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gkswidget.h ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_gksserver.cxx - COMMAND - ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${MOC_INCLUDE_FLAGS} - ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gksserver.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_gksserver.cxx + COMMAND ${QT_MOC_EXECUTABLE} -DGRDIR=\"$(GR_DIRECTORY)\" ${MOC_INCLUDE_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gksserver.h -o ${CMAKE_CURRENT_BINARY_DIR}/moc_gksserver.cxx DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/gks/qt/gksserver.h ) add_custom_command( diff --git a/cmake/FindFfmpeg.cmake b/cmake/FindFfmpeg.cmake index 4aa1a3d19..cdc596ceb 100644 --- a/cmake/FindFfmpeg.cmake +++ b/cmake/FindFfmpeg.cmake @@ -99,8 +99,8 @@ if(FFMPEG_INCLUDE_DIR if(APPLE) list( APPEND - FFMPEG_LIBRARIES - "-framework VideoToolbox;-framework CoreVideo;-framework CoreFoundation;-framework CoreServices;-framework CoreMedia" + FFMPEG_LIBRARIES + "-framework VideoToolbox;-framework CoreVideo;-framework CoreFoundation;-framework CoreServices;-framework CoreMedia" ) endif() try_compile( @@ -116,7 +116,7 @@ if(FFMPEG_INCLUDE_DIR AND FFMPEG_LIBRARY_OPENH264 ) list(APPEND FFMPEG_LIBRARIES - "${FFMPEG_LIBRARY_THEORA};${FFMPEG_LIBRARY_OGG};${FFMPEG_LIBRARY_VPX};${FFMPEG_LIBRARY_OPENH264}" + "${FFMPEG_LIBRARY_THEORA};${FFMPEG_LIBRARY_OGG};${FFMPEG_LIBRARY_VPX};${FFMPEG_LIBRARY_OPENH264}" ) try_compile( FFMPEG_TEST_COMPILED ${CMAKE_CURRENT_BINARY_DIR}/ffmpeg_test ${CMAKE_CURRENT_LIST_DIR}/ffmpeg_test.cxx From 9eb8163b28e802ede9d668caa8a4077ce454db6f Mon Sep 17 00:00:00 2001 From: Ingo Heimbach Date: Fri, 24 Jan 2020 09:54:56 +0100 Subject: [PATCH 3/5] Updated `.git-blame-ignore-revs` --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index cfbe230ce..80b114d8b 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,3 +5,5 @@ 0785e7f81b7bb39dfc0cf9e9c9faea8336a83022 # Commit which applied the coding style guidelines for CMake files 1b886d02d4e32be1060e5330e1e756a4a04aa63f +# Commit which applied the new coding style of `cmake-format` version `0.6.7` +97151f7590c1c2e7893e6e3282cb01e8c1c62e7b From 10321644b297c4a14e8899feeee0d4bd29ce941f Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 27 Jan 2020 11:44:49 +0100 Subject: [PATCH 4/5] GKS: consider height and width information Consider height and width information of the output device when calculating line widths and marker sizes. Without this conversion, a device-independent definition of the associated scaling factors is not possible. --- lib/gks/gksquartz.h | 1 + lib/gks/pdf.c | 10 ++++++---- lib/gks/plugin/cairoplugin.c | 1 + lib/gks/plugin/gsplugin.c | 30 ++++++++++++++++------------- lib/gks/plugin/pgfplugin.c | 13 +++++++++---- lib/gks/plugin/qtplugin_impl.cxx | 33 +++++++++++++++++++++----------- lib/gks/plugin/svgplugin.c | 27 +++++++++++++------------- lib/gks/ps.c | 30 ++++++++++++++++------------- lib/gks/quartz/GKSView.m | 21 +++++++++++--------- 9 files changed, 99 insertions(+), 67 deletions(-) diff --git a/lib/gks/gksquartz.h b/lib/gks/gksquartz.h index c562038b7..5a8a1aae6 100644 --- a/lib/gks/gksquartz.h +++ b/lib/gks/gksquartz.h @@ -21,6 +21,7 @@ typedef struct double swidth, sheight; double a, b, c, d; double window[4], viewport[4]; + double nominal_size; CGColorRef rgb[MAX_COLOR]; int family, capheight; double angle; diff --git a/lib/gks/pdf.c b/lib/gks/pdf.c index 4c1786d4c..c59c06823 100644 --- a/lib/gks/pdf.c +++ b/lib/gks/pdf.c @@ -23,7 +23,6 @@ typedef unsigned long uLong; #define MAX_FONT 31 #define HATCH_STYLE 108 #define PATTERNS 120 -#define NOMINAL_SIZE 558.0 / 500 #define MEMORY_INCREMENT 32768 @@ -136,6 +135,7 @@ typedef struct ws_state_list_t double red[MAX_COLOR], green[MAX_COLOR], blue[MAX_COLOR]; int color, fillcolor, alpha, ltype, font, size, pt; double lwidth, angle; + double nominal_size; PDF_stream *stream; long object_number; long info, root, outlines, pages; @@ -762,6 +762,7 @@ static void set_xform(void) p->width = nint(p->a * (p->window[1] - p->window[0])); p->height = nint(p->c * (p->window[3] - p->window[2])); + p->nominal_size = min(p->width, p->height) / 500.0; } static void seg_xform(double *x, double *y) @@ -853,6 +854,7 @@ static void open_ws(int fd, int wstype) p->viewport[0] = p->viewport[2] = 0; p->viewport[1] = p->viewport[3] = 0.1984; p->width = p->height = 558; + p->nominal_size = 558 / 500.0; p->empty = 1; @@ -996,7 +998,7 @@ static void set_linetype(int ltype, double lwidth) if (p->ltype != ltype || p->lwidth != lwidth) { - gks_get_dash(ltype, lwidth * NOMINAL_SIZE, dash); + gks_get_dash(ltype, lwidth * p->nominal_size, dash); pdf_setdash(p, dash); p->ltype = ltype; } @@ -1006,7 +1008,7 @@ static void set_linewidth(double lwidth) { if (p->lwidth != lwidth) { - pdf_setlinewidth(p, lwidth * NOMINAL_SIZE); + pdf_setlinewidth(p, lwidth * p->nominal_size); p->lwidth = lwidth; } } @@ -1042,7 +1044,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol static double cy[4][3] = {{-1, -0.5523, 0}, {0.5523, 1, 1}, {1, 0.5523, 0}, {-0.5523, -1, -1}}; - mscale *= NOMINAL_SIZE; + mscale *= p->nominal_size; r = (int)(3 * mscale); scale = 0.01 * mscale / 3.0; diff --git a/lib/gks/plugin/cairoplugin.c b/lib/gks/plugin/cairoplugin.c index f8a0cbc3b..8e3f10870 100644 --- a/lib/gks/plugin/cairoplugin.c +++ b/lib/gks/plugin/cairoplugin.c @@ -2107,6 +2107,7 @@ void gks_cairoplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, doub { p->width = p->viewport[1] * p->w / p->mw; p->height = p->viewport[3] * p->h / p->mh; + p->nominal_size = fmin(p->width, p->height) / 500.0; } close_page(); open_page(); diff --git a/lib/gks/plugin/gsplugin.c b/lib/gks/plugin/gsplugin.c index 21dcf97d8..48196bb20 100644 --- a/lib/gks/plugin/gsplugin.c +++ b/lib/gks/plugin/gsplugin.c @@ -180,12 +180,14 @@ typedef struct ws_state_list_t int ltype; double cwidth, csize, cangle, cheight; - int font, height; + int font; gs_main_instance *gs_instance; int gs_argc; char *gs_argv[NUM_GS_ARGS]; int gs_position; + + double width, height, nominal_size; } ws_state_list; static ws_state_list *p; @@ -477,7 +479,7 @@ static unsigned int LZWEncodeImage(unsigned int number_pixels, unsigned char *pi return (0); } -static void set_xform(double *wn, double *vp, int *height) +static void set_xform(double *wn, double *vp) { p->e = (vp[1] - vp[0]) / (wn[1] - wn[0]); p->f = (6750 - 1) / 0.28575; @@ -492,7 +494,9 @@ static void set_xform(double *wn, double *vp, int *height) p->mw = p->a * (wn[1] - wn[0]); p->mh = p->c * (wn[3] - wn[2]); - *height = (int)p->c; + p->width = p->a; + p->height = p->c; + p->nominal_size = MIN(p->width, p->height) / 500.0 * 72 / 600; p->stroke = 0; } @@ -625,7 +629,7 @@ static void set_linewidth(double width) if (fabs(width - p->cwidth) > FEPS) { p->cwidth = fabs(width); - sprintf(buffer, "%.4g lw", p->cwidth * 600 / 72 * 558.0 / 500); + sprintf(buffer, "%.4g lw", p->cwidth * 600 / 72 * p->nominal_size); packb(buffer); } } @@ -637,7 +641,7 @@ static void set_markersize(double size) if (fabs(size - p->csize) > FEPS) { p->csize = fabs(size); - sprintf(buffer, "%.4g ms", p->csize * 558.0 / 500); + sprintf(buffer, "%.4g ms", p->csize * p->nominal_size); packb(buffer); } } @@ -843,7 +847,7 @@ static void set_clipping(double *clrt) packb(buffer); } -static void set_font(int font, int height) +static void set_font(int font) { double scale, w, h, ux, uy, chh; @@ -873,7 +877,7 @@ static void set_font(int font, int height) else font = 8; - p->ysize = p->cheight * height; + p->ysize = p->cheight * p->height; size = MIN(MAX((int)(p->ysize / caps[font]), 1), 7200); if (font != 12 && font != 29 && font != 30) @@ -1170,7 +1174,7 @@ static void ps_init(int *pages) set_linewidth(-1.0); set_markersize(-1.0); packb("0 ma"); - set_font(-1, p->height); + set_font(-1); set_clipping(p->window); packb("%%EndPageSetup"); update(); @@ -1270,7 +1274,7 @@ static void set_connection(int conid, char *path, int wtype) p->viewpt[2] = 0; p->viewpt[3] = p->viewpt[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); p->pages = 0; p->init = 0; @@ -1977,7 +1981,7 @@ void gks_gsplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double y = 1.0; seg_xform_rel(&x, &y); size *= sqrt(x * x + y * y); - set_markersize(23 * size / 24); + set_markersize(size); angle = -atan2(x, y) * 180.0 / M_PI; set_markerangle(angle); set_linewidth(1.0); @@ -2002,7 +2006,7 @@ void gks_gsplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double font = gkss->asf[6] ? gkss->txfont : predef_font[gkss->tindex - 1]; prec = gkss->asf[6] ? gkss->txprec : predef_prec[gkss->tindex - 1]; if (prec != GKS_K_TEXT_PRECISION_STROKE) - set_font(font, p->height); + set_font(font); else set_linewidth(1.0); color = gkss->asf[9] ? gkss->txcoli : 1; @@ -2108,7 +2112,7 @@ void gks_gsplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double p->window[1] = r1[1]; p->window[2] = r2[0]; p->window[3] = r2[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); init_norm_xform(); if (p->init) set_clipping(p->window); break; @@ -2119,7 +2123,7 @@ void gks_gsplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double p->viewpt[1] = r1[1]; p->viewpt[2] = r2[0]; p->viewpt[3] = r2[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); init_norm_xform(); break; diff --git a/lib/gks/plugin/pgfplugin.c b/lib/gks/plugin/pgfplugin.c index 8c7f8ffe8..4c2058c83 100644 --- a/lib/gks/plugin/pgfplugin.c +++ b/lib/gks/plugin/pgfplugin.c @@ -99,6 +99,7 @@ typedef struct ws_state_list_t double window[4], viewport[4]; char rgb[MAX_COLOR][7]; int width, height; + double nominal_size; int color, linewidth; double alpha, angle; int family, capheight; @@ -259,6 +260,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale) #include "marker.h" + mscale *= p->nominal_size; r = (int)(3 * mscale); scale = 0.01 * mscale / 3.0; @@ -362,7 +364,7 @@ static void polymarker(int n, double *px, double *py) mk_size = gkss->asf[4] ? gkss->mszsc : 1; mk_color = gkss->asf[5] ? gkss->pmcoli : 1; - p->linewidth = 1; + p->linewidth = nint(p->nominal_size); pgf_printf(p->stream, "\\definecolor{mycolor}{HTML}{%s}\n", p->rgb[mk_color]); @@ -521,7 +523,7 @@ static void fillarea(int n, double *px, double *py) int fl_color; fl_color = gkss->asf[12] ? gkss->facoli : 1; - p->linewidth = 1; + p->linewidth = nint(p->nominal_size); pgf_printf(p->stream, "\\definecolor{mycolor}{HTML}{%s}\n", p->rgb[fl_color]); @@ -545,7 +547,7 @@ static void polyline(int n, double *px, double *py) ln_width = gkss->asf[1] ? gkss->lwidth : 1; ln_color = gkss->asf[2] ? gkss->plcoli : 1; - width = nint(ln_width); + width = nint(ln_width * p->nominal_size); if (width < 1) width = 0; p->linewidth = width; @@ -888,7 +890,6 @@ static void open_page(void) "thickness/.code={\\thickness=#1},\n" "thickness=1pt\n}\n"); gks_write_file(fd, buf, strlen(buf)); - gks_write_file(fd, p->patternstream->buffer, p->patternstream->length); } else { @@ -904,6 +905,8 @@ static void write_page(void) { p->page_counter++; p->png_counter = 0; + gks_write_file(p->tex_file, p->patternstream->buffer, p->patternstream->length); + pgf_clear_stream(p->patternstream); sprintf(buf, "\\begin{tikzpicture}[yscale=-1, " "every node/.style={inner sep=0pt, outer sep=1pt, anchor=base west}]\n" @@ -1192,6 +1195,7 @@ void gks_pgfplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double p->height = 500; p->width = 500; + p->nominal_size = 1; p->window[0] = p->window[2] = 0.0; p->window[1] = p->window[3] = 1.0; p->viewport[0] = p->viewport[2] = 0; @@ -1384,6 +1388,7 @@ void gks_pgfplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double p->width = p->viewport[1] * WIDTH / MWIDTH; p->height = p->viewport[3] * HEIGHT / MHEIGHT; + p->nominal_size = min(p->width, p->height) / 500.0; set_xform(); init_norm_xform(); diff --git a/lib/gks/plugin/qtplugin_impl.cxx b/lib/gks/plugin/qtplugin_impl.cxx index d538fd917..16a70d3ee 100644 --- a/lib/gks/plugin/qtplugin_impl.cxx +++ b/lib/gks/plugin/qtplugin_impl.cxx @@ -92,6 +92,7 @@ typedef struct ws_state_list_t int width, height; double a, b, c, d; double window[4], viewport[4]; + double nominal_size; QRect rect[MAX_TNR]; QColor rgb[MAX_COLOR]; int transparency; @@ -186,6 +187,7 @@ static void resize_window(void) p->height = 2; p->mheight = (double)p->height / p->device_dpi_y * 0.0254; } + p->nominal_size = min(p->width, p->height) / 500.0; if (p->pm) { @@ -228,6 +230,8 @@ static void set_xform(void) p->b = x - p->window[0] * p->a; p->c = h / (p->window[2] - p->window[3]); p->d = y + p->window[2] * p->c; + + p->nominal_size = min(p->width, p->height) / 500.0; } static void seg_xform(double *x, double *y) @@ -349,6 +353,7 @@ static void polyline(int n, double *px, double *py) ln_width = gkss->asf[1] ? gkss->lwidth : 1; ln_color = gkss->asf[2] ? gkss->plcoli : 1; + ln_width *= p->nominal_size; if (ln_width < 1) ln_width = 1; if (ln_color < 0 || ln_color >= MAX_COLOR) ln_color = 1; @@ -389,6 +394,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol QColor border_color(p->rgb[gkss->bcoli]); border_color.setAlpha(p->transparency); + mscale *= p->nominal_size; r = (int)(3 * mscale); d = 2 * r; scale = 0.01 * mscale / 3.0; @@ -410,7 +416,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol { case 1: /* point */ - p->pixmap->setPen(QPen(marker_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(marker_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); p->pixmap->drawPoint(x, y); break; @@ -422,7 +428,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol seg_xform_rel(&xr, &yr); p->points->setPoint(i, nint(x - xr), nint(y + yr)); } - p->pixmap->setPen(QPen(marker_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(marker_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); p->pixmap->drawPolyline(p->points->constData(), 2); pc += 4; break; @@ -436,7 +442,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol seg_xform_rel(&xr, &yr); points->setPoint(i, nint(x - xr), nint(y + yr)); } - p->pixmap->setPen(QPen(marker_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(marker_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); p->pixmap->drawPolyline(points->constData(), marker[mtype][pc + 1]); pc += 1 + 2 * marker[mtype][pc + 1]; delete points; @@ -449,7 +455,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol { p->pixmap->setBrush(QBrush(marker_color, Qt::SolidPattern)); if (gkss->bcoli != mcolor) - p->pixmap->setPen(QPen(border_color, gkss->bwidth, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(border_color, gkss->bwidth * p->nominal_size, Qt::SolidLine, Qt::FlatCap)); else p->pixmap->setPen(Qt::NoPen); } @@ -468,7 +474,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol break; case 6: /* arc */ - p->pixmap->setPen(QPen(marker_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(marker_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); p->pixmap->drawArc(x - r, y - r, d, d, 0, 360 * 16); break; @@ -478,7 +484,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol { p->pixmap->setBrush(QBrush(marker_color, Qt::SolidPattern)); if (gkss->bcoli != mcolor) - p->pixmap->setPen(QPen(border_color, gkss->bwidth, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(border_color, gkss->bwidth * p->nominal_size, Qt::SolidLine, Qt::FlatCap)); else p->pixmap->setPen(Qt::NoPen); } @@ -644,7 +650,7 @@ static void text(double px, double py, int nchars, char *chars) p->pixmap->setRenderHint(QPainter::Antialiasing); QColor transparent_color(p->rgb[tx_color]); transparent_color.setAlpha(p->transparency); - p->pixmap->setPen(QPen(transparent_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(transparent_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); if (tx_prec == GKS_K_TEXT_PRECISION_STRING) { @@ -698,7 +704,7 @@ static void fillarea(int n, double *px, double *py) if (fl_inter == GKS_K_INTSTYLE_HOLLOW) { - p->pixmap->setPen(QPen(transparent_color, 1.0, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->setPen(QPen(transparent_color, p->nominal_size, Qt::SolidLine, Qt::FlatCap)); line_routine(n, px, py, DrawBorder, gkss->cntnr); } else if (fl_inter == GKS_K_INTSTYLE_SOLID) @@ -937,17 +943,20 @@ static void draw_path(int n, double *px, double *py, int nc, int *codes) path.closeSubpath(); cur_x = start_x; cur_y = start_y; - p->pixmap->strokePath(path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->strokePath( + path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth * p->nominal_size, Qt::SolidLine, Qt::FlatCap)); break; case 'S': /* stroke */ - p->pixmap->strokePath(path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->strokePath( + path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth * p->nominal_size, Qt::SolidLine, Qt::FlatCap)); break; case 'F': /* fill and stroke */ path.closeSubpath(); cur_x = start_x; cur_y = start_y; p->pixmap->fillPath(path, QColor(p->rgb[gkss->facoli])); - p->pixmap->strokePath(path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth, Qt::SolidLine, Qt::FlatCap)); + p->pixmap->strokePath( + path, QPen(QColor(p->rgb[gkss->bcoli]), gkss->bwidth * p->nominal_size, Qt::SolidLine, Qt::FlatCap)); break; case 'f': /* fill */ path.closeSubpath(); @@ -1383,6 +1392,7 @@ static int get_pixmap(void) p->height = device->height(); p->mwidth = (double)p->width / p->device_dpi_x * 0.0254; p->mheight = (double)p->height / p->device_dpi_y * 0.0254; + p->nominal_size = min(p->width, p->height) / 500.0; return 0; } @@ -1399,6 +1409,7 @@ void QT_PLUGIN_ENTRY_NAME(int fctid, int dx, int dy, int dimx, int *i_arr, int l p = new ws_state_list; p->width = p->height = 500; + p->nominal_size = 1; initialize_data(); diff --git a/lib/gks/plugin/svgplugin.c b/lib/gks/plugin/svgplugin.c index beac0ec35..b21462afa 100644 --- a/lib/gks/plugin/svgplugin.c +++ b/lib/gks/plugin/svgplugin.c @@ -26,7 +26,6 @@ #define WIDTH 4096 #define HEIGHT 3072 -#define NOMINAL_SIZE 4.0 #define NOMINAL_POINTSIZE 4 #define DrawBorder 0 @@ -114,7 +113,7 @@ typedef struct ws_state_list_t unsigned char rgb[MAX_COLOR][3]; int width, height; int color; - double linewidth; + double linewidth, nominal_size; double phi, angle; int family, capheight; int pattern, have_pattern[PATTERNS]; @@ -383,6 +382,7 @@ static void resize_window(void) { p->width = nint((p->viewport[1] - p->viewport[0]) / MWIDTH * WIDTH); p->height = nint((p->viewport[3] - p->viewport[2]) / MHEIGHT * HEIGHT); + p->nominal_size = min(p->width, p->height) / 500.0; } static void draw_marker(double xn, double yn, int mtype, double mscale, int mcolor) @@ -393,7 +393,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol #include "marker.h" - mscale *= 4; + mscale *= p->nominal_size; r = (int)(3 * mscale); scale = 0.01 * mscale / 3.0; @@ -480,7 +480,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol if (op == 4 && gkss->bcoli != mcolor) svg_printf(p->stream, "stroke=\"#%02x%02x%02x\" stroke-opacity=\"%g\" stroke-width=\"%g\"", p->rgb[gkss->bcoli][0], p->rgb[gkss->bcoli][1], p->rgb[gkss->bcoli][2], p->transparency, - gkss->bwidth * NOMINAL_SIZE); + gkss->bwidth * p->nominal_size); else svg_printf(p->stream, "stroke=\"none\""); svg_printf(p->stream, "/>\n"); @@ -508,7 +508,7 @@ static void draw_marker(double xn, double yn, int mtype, double mscale, int mcol if (op == 7 && gkss->bcoli != mcolor) svg_printf(p->stream, "stroke=\"#%02x%02x%02x\" stroke-opacity=\"%g\" stroke-width=\"%g\"", p->rgb[gkss->bcoli][0], p->rgb[gkss->bcoli][1], p->rgb[gkss->bcoli][2], p->transparency, - gkss->bwidth * NOMINAL_SIZE); + gkss->bwidth * p->nominal_size); else svg_printf(p->stream, "stroke=\"none\""); svg_printf(p->stream, "/>\n"); @@ -525,7 +525,7 @@ static void marker_routine(int n, double *px, double *py, int mtype, double msca double *clrt = gkss->viewport[gkss->cntnr]; int i, draw; - p->linewidth = NOMINAL_SIZE; + p->linewidth = p->nominal_size; for (i = 0; i < n; i++) { @@ -754,7 +754,7 @@ static void fillarea(int n, double *px, double *py) if (fl_inter == GKS_K_INTSTYLE_HOLLOW) { p->color = fl_color; - p->linewidth = NOMINAL_SIZE; + p->linewidth = p->nominal_size; line_routine(n, px, py, DrawBorder, gkss->cntnr); } else if (fl_inter == GKS_K_INTSTYLE_SOLID) @@ -787,7 +787,7 @@ static void polyline(int n, double *px, double *py) ln_width = gkss->asf[1] ? gkss->lwidth : 1; ln_color = gkss->asf[2] ? gkss->plcoli : 1; - p->linewidth = ln_width * NOMINAL_SIZE; + p->linewidth = ln_width * p->nominal_size; p->color = ln_color; line_routine(n, px, py, ln_type, gkss->cntnr); @@ -941,7 +941,7 @@ static void text(double px, double py, int nchars, char *chars) } else { - p->linewidth = NOMINAL_SIZE; + p->linewidth = p->nominal_size; gks_emul_text(px, py, nchars, chars, line_routine, fill_routine); } } @@ -1222,14 +1222,14 @@ static void draw_path(int n, double *px, double *py, int nc, int *codes) svg_printf(p->stream, "\" fill=\"none\" stroke=\"#%02x%02x%02x\" stroke-opacity=\"%g\" stroke-width=\"%g\" />", p->rgb[gkss->bcoli][0], p->rgb[gkss->bcoli][1], p->rgb[gkss->bcoli][2], p->transparency, - gkss->bwidth * NOMINAL_SIZE); + gkss->bwidth * p->nominal_size); in_path = 0; break; case 's': /* close and stroke */ svg_printf(p->stream, "Z\" fill=\"none\" stroke=\"#%02x%02x%02x\" stroke-opacity=\"%g\" stroke-width=\"%g\" />", p->rgb[gkss->bcoli][0], p->rgb[gkss->bcoli][1], p->rgb[gkss->bcoli][2], p->transparency, - gkss->bwidth * NOMINAL_SIZE); + gkss->bwidth * p->nominal_size); cur_x = start_x; cur_y = start_y; in_path = 0; @@ -1247,7 +1247,7 @@ static void draw_path(int n, double *px, double *py, int nc, int *codes) "stroke-opacity=\"%g\" stroke-width=\"%g\" />", p->rgb[p->color][0], p->rgb[p->color][1], p->rgb[p->color][2], p->transparency, p->rgb[gkss->bcoli][0], p->rgb[gkss->bcoli][1], p->rgb[gkss->bcoli][2], p->transparency, - gkss->bwidth * NOMINAL_SIZE); + gkss->bwidth * p->nominal_size); cur_x = start_x; cur_y = start_y; in_path = 0; @@ -1403,6 +1403,7 @@ void gks_drv_js( p->viewport[0] = p->viewport[2] = 0; p->viewport[1] = (double)p->width * MWIDTH / WIDTH; p->viewport[3] = (double)p->height * MHEIGHT / HEIGHT; + p->nominal_size = 2000 / 500.0; p->stream = svg_alloc_stream(); @@ -1414,7 +1415,7 @@ void gks_drv_js( p->page_counter = 0; p->offset = 0; - p->linewidth = NOMINAL_SIZE; + p->linewidth = p->nominal_size; p->transparency = 1.0; set_xform(); diff --git a/lib/gks/ps.c b/lib/gks/ps.c index 74ef07116..37b2752b5 100644 --- a/lib/gks/ps.c +++ b/lib/gks/ps.c @@ -133,7 +133,9 @@ typedef struct ws_state_list_t int ltype; double cwidth, csize, cangle, cheight; - int font, height; + int font; + + double width, height, nominal_size; } ws_state_list; static ws_state_list *p; @@ -425,7 +427,7 @@ static unsigned int LZWEncodeImage(unsigned int number_pixels, unsigned char *pi return (0); } -static void set_xform(double *wn, double *vp, int *height) +static void set_xform(double *wn, double *vp) { p->e = (vp[1] - vp[0]) / (wn[1] - wn[0]); p->f = (6750 - 1) / 0.28575; @@ -440,7 +442,9 @@ static void set_xform(double *wn, double *vp, int *height) p->mw = p->a * (wn[1] - wn[0]); p->mh = p->c * (wn[3] - wn[2]); - *height = (int)p->c; + p->width = p->a; + p->height = p->c; + p->nominal_size = MIN(p->width, p->height) / 500.0 * 72 / 600; p->stroke = 0; } @@ -573,7 +577,7 @@ static void set_linewidth(double width) if (fabs(width - p->cwidth) > FEPS) { p->cwidth = fabs(width); - sprintf(buffer, "%.4g lw", p->cwidth * 600 / 72 * 558.0 / 500); + sprintf(buffer, "%.4g lw", p->cwidth * 600 / 72 * p->nominal_size); packb(buffer); } } @@ -585,7 +589,7 @@ static void set_markersize(double size) if (fabs(size - p->csize) > FEPS) { p->csize = fabs(size); - sprintf(buffer, "%.4g ms", p->csize * 558.0 / 500); + sprintf(buffer, "%.4g ms", p->csize * p->nominal_size); packb(buffer); } } @@ -796,7 +800,7 @@ static void set_clipping(double *clrt) packb(buffer); } -static void set_font(int font, int height) +static void set_font(int font) { double scale, w, h, ux, uy, chh; @@ -826,7 +830,7 @@ static void set_font(int font, int height) else font = 8; - p->ysize = p->cheight * height; + p->ysize = p->cheight * p->height; size = MIN(MAX((int)(p->ysize / caps[font]), 1), 7200); if (font != 12 && font != 29 && font != 30) @@ -1121,7 +1125,7 @@ static void ps_init(int *pages) set_linewidth(-1.0); set_markersize(-1.0); packb("0 ma"); - set_font(-1, p->height); + set_font(-1); set_clipping(p->window); packb("%%EndPageSetup"); update(); @@ -1219,7 +1223,7 @@ static void set_connection(int conid, int wtype) p->viewpt[2] = 0; p->viewpt[3] = p->viewpt[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); p->pages = 0; p->init = 0; @@ -1805,7 +1809,7 @@ void gks_drv_ps(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r y = 1.0; seg_xform_rel(&x, &y); size *= sqrt(x * x + y * y); - set_markersize(23 * size / 24); + set_markersize(size); angle = -atan2(x, y) * 180.0 / M_PI; set_markerangle(angle); set_linewidth(1.0); @@ -1830,7 +1834,7 @@ void gks_drv_ps(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r font = gkss->asf[6] ? gkss->txfont : predef_font[gkss->tindex - 1]; prec = gkss->asf[6] ? gkss->txprec : predef_prec[gkss->tindex - 1]; if (prec != GKS_K_TEXT_PRECISION_STROKE) - set_font(font, p->height); + set_font(font); else set_linewidth(1.0); color = gkss->asf[9] ? gkss->txcoli : 1; @@ -1936,7 +1940,7 @@ void gks_drv_ps(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r p->window[1] = r1[1]; p->window[2] = r2[0]; p->window[3] = r2[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); init_norm_xform(); if (p->init) set_clipping(p->window); break; @@ -1947,7 +1951,7 @@ void gks_drv_ps(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r p->viewpt[1] = r1[1]; p->viewpt[2] = r2[0]; p->viewpt[3] = r2[1]; - set_xform(p->window, p->viewpt, &p->height); + set_xform(p->window, p->viewpt); init_norm_xform(); break; diff --git a/lib/gks/quartz/GKSView.m b/lib/gks/quartz/GKSView.m index 6138d4e0c..768cdbc32 100644 --- a/lib/gks/quartz/GKSView.m +++ b/lib/gks/quartz/GKSView.m @@ -375,6 +375,7 @@ - (void)interp:(char *)str p->width = [self bounds].size.width; p->height = [self bounds].size.height; + p->nominal_size = min(p->width, p->height) / 500.0; p->swidth = NSMaxX([[[NSScreen screens] objectAtIndex:0] frame]); p->sheight = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]); @@ -1043,6 +1044,7 @@ - (void)resize_window p->width = width; p->height = height; + p->nominal_size = min(p->width, p->height) / 500.0; [self setNeedsDisplay:YES]; [[self window] setFrame:rect display:YES]; @@ -1142,7 +1144,7 @@ - (void)polyline:(int)n:(double *)px:(double *)py CGContextSetLineDash(context, 0.0, lengths, dashlist[0]); } - CGContextSetLineWidth(context, ln_width); + CGContextSetLineWidth(context, ln_width * p->nominal_size); CGContextAddLines(context, points, n); CGContextDrawPath(context, kCGPathStroke); @@ -1157,6 +1159,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: #include "marker.h" + mscale *= p->nominal_size; r = (int)(3 * mscale); scale = 0.01 * mscale / 3.0; @@ -1182,7 +1185,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: case 2: // line CGContextBeginPath(context); - CGContextSetLineWidth(context, 1); + CGContextSetLineWidth(context, p->nominal_size); [self set_stroke_color:mcolor:context]; for (i = 0; i < 2; i++) { @@ -1200,7 +1203,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: case 3: // polyline CGContextBeginPath(context); - CGContextSetLineWidth(context, 1); + CGContextSetLineWidth(context, p->nominal_size); [self set_stroke_color:mcolor:context]; for (i = 0; i < marker[mtype][pc + 1]; i++) { @@ -1225,7 +1228,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: [self set_fill_color:mcolor:context]; if (gkss->bcoli != mcolor) { - CGContextSetLineWidth(context, gkss->bwidth); + CGContextSetLineWidth(context, gkss->bwidth * p->nominal_size); [self set_stroke_color:gkss->bcoli:context]; } } @@ -1252,7 +1255,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: case 6: // arc CGContextBeginPath(context); - CGContextSetLineWidth(context, 1); + CGContextSetLineWidth(context, p->nominal_size); [self set_stroke_color:mcolor:context]; CGContextAddArc(context, x, y, r, 0.0, 2 * M_PI, 0); CGContextDrawPath(context, kCGPathStroke); @@ -1266,7 +1269,7 @@ - (void)draw_marker:(double)xn:(double)yn:(int)mtype:(double)mscale:(int)mcolor: [self set_fill_color:mcolor:context]; if (gkss->bcoli != mcolor) { - CGContextSetLineWidth(context, gkss->bwidth); + CGContextSetLineWidth(context, gkss->bwidth * p->nominal_size); [self set_stroke_color:gkss->bcoli:context]; } } @@ -1445,7 +1448,7 @@ - (void)fillarea:(int)n:(double *)px:(double *)py { begin_context(context); CGContextBeginPath(context); - CGContextSetLineWidth(context, 1); + CGContextSetLineWidth(context, p->nominal_size); CGContextAddLines(context, points, n); CGContextClosePath(context); CGContextDrawPath(context, kCGPathStroke); @@ -1456,7 +1459,7 @@ - (void)fillarea:(int)n:(double *)px:(double *)py begin_context(context); [self set_fill_color:fl_color:context]; CGContextBeginPath(context); - CGContextSetLineWidth(context, 1); + CGContextSetLineWidth(context, p->nominal_size); CGContextAddLines(context, points, n); CGContextClosePath(context); CGContextDrawPath(context, kCGPathEOFill); @@ -1496,7 +1499,7 @@ - (void)draw_path:(int)n:(double *)px:(double *)py:(int)nc:(int *)codes begin_context(context); - CGContextSetLineWidth(context, gkss->bwidth); + CGContextSetLineWidth(context, gkss->bwidth * p->nominal_size); [self set_stroke_color:gkss->bcoli:context]; [self set_fill_color:gkss->facoli:context]; From 7b7c22f0fbcf5df9947d468dca320895a60f8471 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 27 Jan 2020 14:04:47 +0100 Subject: [PATCH 5/5] Correct linewidth and marker size for video output --- lib/gks/plugin/cairoplugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gks/plugin/cairoplugin.c b/lib/gks/plugin/cairoplugin.c index 8e3f10870..64db68cc6 100644 --- a/lib/gks/plugin/cairoplugin.c +++ b/lib/gks/plugin/cairoplugin.c @@ -1881,7 +1881,7 @@ void gks_cairoplugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, doub p->mw = p->w * 2.54 / 100 / p->dpi; p->mh = p->h * 2.54 / 100 / p->dpi; resize(width, height); - p->nominal_size = 2400 / 500.0; + p->nominal_size = min(width, height) / 500.0; } else if (p->wtype == 150) {