From dbd7a031285807d02565891eb20f88a790d8cc47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20David?= Date: Fri, 2 Apr 2021 16:13:06 +0200 Subject: [PATCH] [graphics] Axe default x|y|zlabels & title font sizes better tuned Discussed @ http://mailinglists.scilab.org/Scilab-users-Default-x-y-z-labels-and-title-font-size-2-tp4041291p4041292.html Change-Id: I60ad48f5461716a0e5f49c65b5c69e110465b2b4 --- scilab/CHANGES.md | 1 + scilab/modules/graphics/includes/InitObjects.h | 2 +- scilab/modules/graphics/sci_gateway/c/sci_get.c | 327 ----------------------- scilab/modules/graphics/src/c/Axes.c | 8 +- scilab/modules/graphics/src/c/InitObjects.c | 26 +- 5 files changed, 27 insertions(+), 337 deletions(-) delete mode 100644 scilab/modules/graphics/sci_gateway/c/sci_get.c diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 5d37f45..313e68a 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -199,6 +199,7 @@ Feature changes and additions on 6.1.0 Feature changes and additions on 6.1.1 -------------------------------------- +* Axes labels and title default font size had been increased for better default rendering. * `gsort` is upgraded: - It can now sort any sparse 2D matrix, in all `g, r, c, lr, lc` methods, including sparse booleans and in multi-level mode. It was formerly limited to sparse real or complex vectors and only to the `g` mode. - Any hypermatrix can be sorted along a dimension > 2. diff --git a/scilab/modules/graphics/includes/InitObjects.h b/scilab/modules/graphics/includes/InitObjects.h index 702701c..72c231e 100644 --- a/scilab/modules/graphics/includes/InitObjects.h +++ b/scilab/modules/graphics/includes/InitObjects.h @@ -38,7 +38,7 @@ GRAPHICS_IMPEXP int C2F(graphicsmodels) (void); GRAPHICS_IMPEXP int sciInitGraphicMode (int iObjUID); -GRAPHICS_IMPEXP int initLabel(int iParentObjUID) ; /* INITOBJECT */ +GRAPHICS_IMPEXP int initLabel(int iParentObjUID, int associatedProperty) ; /* INITOBJECT */ GRAPHICS_IMPEXP void InitFigureModel(int iFiguremdlUID); /* INITOBJECT */ diff --git a/scilab/modules/graphics/sci_gateway/c/sci_get.c b/scilab/modules/graphics/sci_gateway/c/sci_get.c deleted file mode 100644 index a90ed6f..0000000 --- a/scilab/modules/graphics/sci_gateway/c/sci_get.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab - * Copyright (C) 2004 - INRIA - Djalel Abdemouche - * Copyright (C) 2006 - INRIA - Fabrice Leray - * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy - * Copyright (C) 2006 - INRIA - Vincent Couvert - * Copyright (C) 2011 - DIGITEO - Vincent Couvert - * - * Copyright (C) 2012 - 2016 - Scilab Enterprises - * - * This file is hereby licensed under the terms of the GNU GPL v2.0, - * pursuant to article 5.3.4 of the CeCILL v.2.1. - * This file was originally licensed under the terms of the CeCILL v2.1, - * and continues to be available under such terms. - * For more information, see the COPYING file which you should have received - * along with this program. - * - */ - -/*------------------------------------------------------------------------*/ -/* file: sci_get.c */ -/* desc : interface for sci_get routine */ -/*------------------------------------------------------------------------*/ -#include -#include "gw_graphics.h" -#include "HandleManagement.h" -#include "GetHashTable.h" -#include "BuildObjects.h" -#include "localization.h" -#include "Scierror.h" - -#include "HandleManagement.h" -#include "CurrentObject.h" -#include "CurrentSubwin.h" -#include "getConsoleIdentifier.h" -#include "returnProperty.h" - -#include "SetPropertyStatus.h" -#include "GetScreenProperty.h" -#include "freeArrayOfString.h" -#include "api_scilab.h" -#include "FigureList.h" -#include "MALLOC.h" - -/*--------------------------------------------------------------------------*/ -int sci_get(char *fname, void *pvApiCtx) -{ - SciErr sciErr; - - int* piAddrl1 = NULL; - long long* l1 = NULL; - int* piAddrl2 = NULL; - char* l2 = NULL; - - int m1 = 0, n1 = 0; - long hdl = 0; - - int lw = 0; - int iObjUID = 0; - - int status = SET_PROPERTY_ERROR; - - CheckInputArgument(pvApiCtx, 1, 2); - CheckOutputArgument(pvApiCtx, 0, 1); - - sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); - if (sciErr.iErr) - { - printError(&sciErr, 0); - return 1; - } - - if (isMListType(pvApiCtx, piAddrl1) || isTListType(pvApiCtx, piAddrl1)) - { - OverLoad(1); - return 0; - } - - /* - * The first input argument can be an ID or a marker (in this case, get returns the value of the current object */ - switch (getInputArgumentType(pvApiCtx, 1)) - { - case sci_matrix: //console handle - { - double dbll1 = 0; - - if (isScalar(pvApiCtx, piAddrl1) == 0) - { - Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); - return 1; - } - - // Retrieve a matrix of double at position 1. - if (getScalarDouble(pvApiCtx, piAddrl1, &dbll1)) - { - Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); - return 1; - } - - if ((int)dbll1 == 0) /* Console property */ - { - int* piAddrstkAdr = NULL; - char *stkAdr = NULL; - if (nbInputArgument(pvApiCtx) == 1) - { - if (sciReturnHandle(getHandle(getConsoleIdentifier())) != 0) /* Get Console handle */ - { - ReturnArguments(pvApiCtx); - return 0; - } - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - return 0; - } - - CheckInputArgument(pvApiCtx, 2, 2); - sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrstkAdr); - if (sciErr.iErr) - { - printError(&sciErr, 0); - return 1; - } - - // Retrieve a matrix of string at position 2. - if (getAllocatedSingleString(pvApiCtx, piAddrstkAdr, &stkAdr)) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); - return 1; - } - - if (GetScreenProperty(pvApiCtx, stkAdr) != SET_PROPERTY_SUCCEED) - { - Scierror(999, _("%s: Could not read property '%s' for console object.\n"), "get", stkAdr[0]); - freeAllocatedSingleString(stkAdr); - return 1; - } - freeAllocatedSingleString(stkAdr); - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - } - - return 0; - break; - } - case sci_handles: /* scalar argument (hdl + string) */ - CheckInputArgument(pvApiCtx, 1, 2); - - // Retrieve a matrix of handle at position 1. - sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1); - if (sciErr.iErr) - { - printError(&sciErr, 0); - Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); - return 1; - } - - if (m1 != 1 || n1 != 1) - { - //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); - OverLoad(1); - return 0; - } - - if (nbInputArgument(pvApiCtx) == 1) - { - //get path from handle - int uic = getObjectFromHandle((long) * l1); - char* path = get_path(uic); - if (path[0] == '\0') - { - Scierror(999, _("%s: Unable to get useful path from this handle.\n"), fname); - return 1; - } - - createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, path); - FREE(path); - - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - return 0; - } - - sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); - if (sciErr.iErr) - { - printError(&sciErr, 0); - return 1; - } - - if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); - return 1; - } - - // Retrieve a matrix of double at position 2. - if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); - return 1; - } - - hdl = (long) * l1; /* on recupere le pointeur d'objet par le handle */ - break; - case sci_strings: /* string argument (string) */ - { - char* pstFirst = NULL; - CheckInputArgument(pvApiCtx, 1, 2); - - if (isScalar(pvApiCtx, piAddrl1) == 0) - { - Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); - return 1; - } - - // Retrieve a matrix of double at position 1. - if (getAllocatedSingleString(pvApiCtx, piAddrl1, &pstFirst)) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 1); - return 1; - } - - if (strcmp(pstFirst, "default_figure") == 0 || - strcmp(pstFirst, "default_axes") == 0 || - strcmp(pstFirst, "current_figure") == 0 || - strcmp(pstFirst, "current_axes") == 0 || - strcmp(pstFirst, "current_entity") == 0 || - strcmp(pstFirst, "hdl") == 0 || - strcmp(pstFirst, "figures_id") == 0) - { - hdl = 0; - l2 = pstFirst; - } - else - { - int uid = search_path(pstFirst); - if (uid != 0) - { - freeAllocatedSingleString(pstFirst); - hdl = getHandle(uid); - - if (nbInputArgument(pvApiCtx) == 1) - { - createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, hdl); - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - return 0; - } - - sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); - if (sciErr.iErr) - { - printError(&sciErr, 0); - return 1; - } - - if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); - return 1; - } - - if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) - { - Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); - return 1; - } - } - else - { - createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1); - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - return 0; - } - } - break; - } - default: - //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); - OverLoad(1); - return 0; - break; - } - /* (l2) est la commande, l3 l'indice sur les parametres de la commande */ - CheckOutputArgument(pvApiCtx, 0, 1); - - if (hdl == 0) - { - /* No handle specified */ - if (callGetProperty(pvApiCtx, 0, (l2)) != 0) - { - /* An error has occurred */ - freeAllocatedSingleString(l2); - ReturnArguments(pvApiCtx); - return 0; - } - } - else - { - iObjUID = getObjectFromHandle(hdl); - if (iObjUID != 0) - { - - if (callGetProperty(pvApiCtx, iObjUID, (l2)) != 0) - { - /* An error has occurred */ - freeAllocatedSingleString(l2); - ReturnArguments(pvApiCtx); - return 0; - } - } - else - { - Scierror(999, _("%s: The handle is not or no more valid.\n"), fname); - freeAllocatedSingleString(l2); - return 0; - } - } - - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); - freeAllocatedSingleString(l2); - return 0; -} - -/*--------------------------------------------------------------------------*/ diff --git a/scilab/modules/graphics/src/c/Axes.c b/scilab/modules/graphics/src/c/Axes.c index 0b3ab01..461fd02 100644 --- a/scilab/modules/graphics/src/c/Axes.c +++ b/scilab/modules/graphics/src/c/Axes.c @@ -72,16 +72,16 @@ static void reinitSubWin(int iSubWinUID) initSubWinBounds(iSubWinUID); - iLabelUID = initLabel(iSubWinUID); + iLabelUID = initLabel(iSubWinUID, __GO_TITLE__); setGraphicObjectProperty(iSubWinUID, __GO_TITLE__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iSubWinUID); + iLabelUID = initLabel(iSubWinUID, __GO_X_AXIS_LABEL__); setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iSubWinUID); + iLabelUID = initLabel(iSubWinUID, __GO_Y_AXIS_LABEL__); setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iSubWinUID); + iLabelUID = initLabel(iSubWinUID, __GO_Z_AXIS_LABEL__); setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); /* bottom */ diff --git a/scilab/modules/graphics/src/c/InitObjects.c b/scilab/modules/graphics/src/c/InitObjects.c index 7897be8..c8684b4 100644 --- a/scilab/modules/graphics/src/c/InitObjects.c +++ b/scilab/modules/graphics/src/c/InitObjects.c @@ -564,16 +564,16 @@ int InitAxesModel() setGraphicObjectProperty(iAxesmdlUID, __GO_ARC_DRAWING_METHOD__, &arcDrawingMethod, jni_int, 1); /* Creates the Axes model's labels and sets the model as their parent */ - iLabelUID = initLabel(iAxesmdlUID); + iLabelUID = initLabel(iAxesmdlUID, __GO_TITLE__); setGraphicObjectProperty(iAxesmdlUID, __GO_TITLE__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iAxesmdlUID); + iLabelUID = initLabel(iAxesmdlUID, __GO_X_AXIS_LABEL__); setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iAxesmdlUID); + iLabelUID = initLabel(iAxesmdlUID, __GO_Y_AXIS_LABEL__); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); - iLabelUID = initLabel(iAxesmdlUID); + iLabelUID = initLabel(iAxesmdlUID, __GO_Z_AXIS_LABEL__); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); return 0; @@ -701,11 +701,12 @@ default: /*---------------------------------------------------------------------------------*/ /* allocate and set a new label to default values */ -int initLabel(int iParentObjUID) +int initLabel(int iParentObjUID, int associatedProperty) { int iNewLabel = 0; int iHidden = 1; int autoPosition = 1; + double fontSize = 1.0; iNewLabel = createGraphicObject(__GO_LABEL__); @@ -720,6 +721,21 @@ int initLabel(int iParentObjUID) cloneGraphicContext(iParentObjUID, iNewLabel); cloneFontContext(iParentObjUID, iNewLabel); + /* Set a specific font size for important labels */ + switch (associatedProperty) + { + case __GO_TITLE__: + fontSize = 3.0; + setGraphicObjectProperty(iNewLabel, __GO_FONT_SIZE__, &fontSize, jni_double, 1); + break; + case __GO_X_AXIS_LABEL__: // fallthrough + case __GO_Y_AXIS_LABEL__: // fallthrough + case __GO_Z_AXIS_LABEL__: // fallthrough + fontSize = 2.0; + setGraphicObjectProperty(iNewLabel, __GO_FONT_SIZE__, &fontSize, jni_double, 1); + break; + } + return iNewLabel; } /*---------------------------------------------------------------------------------*/ -- 1.7.9.5