summaryrefslogtreecommitdiffstats
path: root/scilab
diff options
context:
space:
mode:
authorClément David <clement.david@esi-group.com>2021-04-02 16:13:06 +0200
committerClément David <clement.david@esi-group.com>2021-04-07 09:09:40 +0200
commitdbd7a031285807d02565891eb20f88a790d8cc47 (patch)
treed1aba1592d4a358876161b047a64c33c76d4a6da /scilab
parent5256d99f86cf31f1958c23b613b5187398bcd60f (diff)
downloadscilab-dbd7a031285807d02565891eb20f88a790d8cc47.zip
scilab-dbd7a031285807d02565891eb20f88a790d8cc47.tar.gz
[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
Diffstat (limited to 'scilab')
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/graphics/includes/InitObjects.h2
-rw-r--r--scilab/modules/graphics/sci_gateway/c/sci_get.c327
-rw-r--r--scilab/modules/graphics/src/c/Axes.c8
-rw-r--r--scilab/modules/graphics/src/c/InitObjects.c26
5 files changed, 27 insertions, 337 deletions
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
199Feature changes and additions on 6.1.1 199Feature changes and additions on 6.1.1
200-------------------------------------- 200--------------------------------------
201 201
202* Axes labels and title default font size had been increased for better default rendering.
202* `gsort` is upgraded: 203* `gsort` is upgraded:
203 - 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. 204 - 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.
204 - Any hypermatrix can be sorted along a dimension > 2. 205 - 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);
38 38
39GRAPHICS_IMPEXP int sciInitGraphicMode (int iObjUID); 39GRAPHICS_IMPEXP int sciInitGraphicMode (int iObjUID);
40 40
41GRAPHICS_IMPEXP int initLabel(int iParentObjUID) ; /* INITOBJECT */ 41GRAPHICS_IMPEXP int initLabel(int iParentObjUID, int associatedProperty) ; /* INITOBJECT */
42 42
43GRAPHICS_IMPEXP void InitFigureModel(int iFiguremdlUID); /* INITOBJECT */ 43GRAPHICS_IMPEXP void InitFigureModel(int iFiguremdlUID); /* INITOBJECT */
44 44
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 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2004 - INRIA - Djalel Abdemouche
4 * Copyright (C) 2006 - INRIA - Fabrice Leray
5 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2006 - INRIA - Vincent Couvert
7 * Copyright (C) 2011 - DIGITEO - Vincent Couvert
8 *
9 * Copyright (C) 2012 - 2016 - Scilab Enterprises
10 *
11 * This file is hereby licensed under the terms of the GNU GPL v2.0,
12 * pursuant to article 5.3.4 of the CeCILL v.2.1.
13 * This file was originally licensed under the terms of the CeCILL v2.1,
14 * and continues to be available under such terms.
15 * For more information, see the COPYING file which you should have received
16 * along with this program.
17 *
18 */
19
20/*------------------------------------------------------------------------*/
21/* file: sci_get.c */
22/* desc : interface for sci_get routine */
23/*------------------------------------------------------------------------*/
24#include <string.h>
25#include "gw_graphics.h"
26#include "HandleManagement.h"
27#include "GetHashTable.h"
28#include "BuildObjects.h"
29#include "localization.h"
30#include "Scierror.h"
31
32#include "HandleManagement.h"
33#include "CurrentObject.h"
34#include "CurrentSubwin.h"
35#include "getConsoleIdentifier.h"
36#include "returnProperty.h"
37
38#include "SetPropertyStatus.h"
39#include "GetScreenProperty.h"
40#include "freeArrayOfString.h"
41#include "api_scilab.h"
42#include "FigureList.h"
43#include "MALLOC.h"
44
45/*--------------------------------------------------------------------------*/
46int sci_get(char *fname, void *pvApiCtx)
47{
48 SciErr sciErr;
49
50 int* piAddrl1 = NULL;
51 long long* l1 = NULL;
52 int* piAddrl2 = NULL;
53 char* l2 = NULL;
54
55 int m1 = 0, n1 = 0;
56 long hdl = 0;
57
58 int lw = 0;
59 int iObjUID = 0;
60
61 int status = SET_PROPERTY_ERROR;
62
63 CheckInputArgument(pvApiCtx, 1, 2);
64 CheckOutputArgument(pvApiCtx, 0, 1);
65
66 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1);
67 if (sciErr.iErr)
68 {
69 printError(&sciErr, 0);
70 return 1;
71 }
72
73 if (isMListType(pvApiCtx, piAddrl1) || isTListType(pvApiCtx, piAddrl1))
74 {
75 OverLoad(1);
76 return 0;
77 }
78
79 /*
80 * The first input argument can be an ID or a marker (in this case, get returns the value of the current object */
81 switch (getInputArgumentType(pvApiCtx, 1))
82 {
83 case sci_matrix: //console handle
84 {
85 double dbll1 = 0;
86
87 if (isScalar(pvApiCtx, piAddrl1) == 0)
88 {
89 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
90 return 1;
91 }
92
93 // Retrieve a matrix of double at position 1.
94 if (getScalarDouble(pvApiCtx, piAddrl1, &dbll1))
95 {
96 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
97 return 1;
98 }
99
100 if ((int)dbll1 == 0) /* Console property */
101 {
102 int* piAddrstkAdr = NULL;
103 char *stkAdr = NULL;
104 if (nbInputArgument(pvApiCtx) == 1)
105 {
106 if (sciReturnHandle(getHandle(getConsoleIdentifier())) != 0) /* Get Console handle */
107 {
108 ReturnArguments(pvApiCtx);
109 return 0;
110 }
111 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
112 ReturnArguments(pvApiCtx);
113 return 0;
114 }
115
116 CheckInputArgument(pvApiCtx, 2, 2);
117 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrstkAdr);
118 if (sciErr.iErr)
119 {
120 printError(&sciErr, 0);
121 return 1;
122 }
123
124 // Retrieve a matrix of string at position 2.
125 if (getAllocatedSingleString(pvApiCtx, piAddrstkAdr, &stkAdr))
126 {
127 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
128 return 1;
129 }
130
131 if (GetScreenProperty(pvApiCtx, stkAdr) != SET_PROPERTY_SUCCEED)
132 {
133 Scierror(999, _("%s: Could not read property '%s' for console object.\n"), "get", stkAdr[0]);
134 freeAllocatedSingleString(stkAdr);
135 return 1;
136 }
137 freeAllocatedSingleString(stkAdr);
138 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
139 ReturnArguments(pvApiCtx);
140 }
141
142 return 0;
143 break;
144 }
145 case sci_handles: /* scalar argument (hdl + string) */
146 CheckInputArgument(pvApiCtx, 1, 2);
147
148 // Retrieve a matrix of handle at position 1.
149 sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1);
150 if (sciErr.iErr)
151 {
152 printError(&sciErr, 0);
153 Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1);
154 return 1;
155 }
156
157 if (m1 != 1 || n1 != 1)
158 {
159 //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx);
160 OverLoad(1);
161 return 0;
162 }
163
164 if (nbInputArgument(pvApiCtx) == 1)
165 {
166 //get path from handle
167 int uic = getObjectFromHandle((long) * l1);
168 char* path = get_path(uic);
169 if (path[0] == '\0')
170 {
171 Scierror(999, _("%s: Unable to get useful path from this handle.\n"), fname);
172 return 1;
173 }
174
175 createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, path);
176 FREE(path);
177
178 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
179 ReturnArguments(pvApiCtx);
180 return 0;
181 }
182
183 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2);
184 if (sciErr.iErr)
185 {
186 printError(&sciErr, 0);
187 return 1;
188 }
189
190 if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0)
191 {
192 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
193 return 1;
194 }
195
196 // Retrieve a matrix of double at position 2.
197 if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2))
198 {
199 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
200 return 1;
201 }
202
203 hdl = (long) * l1; /* on recupere le pointeur d'objet par le handle */
204 break;
205 case sci_strings: /* string argument (string) */
206 {
207 char* pstFirst = NULL;
208 CheckInputArgument(pvApiCtx, 1, 2);
209
210 if (isScalar(pvApiCtx, piAddrl1) == 0)
211 {
212 Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
213 return 1;
214 }
215
216 // Retrieve a matrix of double at position 1.
217 if (getAllocatedSingleString(pvApiCtx, piAddrl1, &pstFirst))
218 {
219 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 1);
220 return 1;
221 }
222
223 if (strcmp(pstFirst, "default_figure") == 0 ||
224 strcmp(pstFirst, "default_axes") == 0 ||
225 strcmp(pstFirst, "current_figure") == 0 ||
226 strcmp(pstFirst, "current_axes") == 0 ||
227 strcmp(pstFirst, "current_entity") == 0 ||
228 strcmp(pstFirst, "hdl") == 0 ||
229 strcmp(pstFirst, "figures_id") == 0)
230 {
231 hdl = 0;
232 l2 = pstFirst;
233 }
234 else
235 {
236 int uid = search_path(pstFirst);
237 if (uid != 0)
238 {
239 freeAllocatedSingleString(pstFirst);
240 hdl = getHandle(uid);
241
242 if (nbInputArgument(pvApiCtx) == 1)
243 {
244 createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, hdl);
245 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
246 ReturnArguments(pvApiCtx);
247 return 0;
248 }
249
250 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2);
251 if (sciErr.iErr)
252 {
253 printError(&sciErr, 0);
254 return 1;
255 }
256
257 if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0)
258 {
259 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
260 return 1;
261 }
262
263 if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2))
264 {
265 Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2);
266 return 1;
267 }
268 }
269 else
270 {
271 createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
272 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
273 ReturnArguments(pvApiCtx);
274 return 0;
275 }
276 }
277 break;
278 }
279 default:
280 //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx);
281 OverLoad(1);
282 return 0;
283 break;
284 }
285 /* (l2) est la commande, l3 l'indice sur les parametres de la commande */
286 CheckOutputArgument(pvApiCtx, 0, 1);
287
288 if (hdl == 0)
289 {
290 /* No handle specified */
291 if (callGetProperty(pvApiCtx, 0, (l2)) != 0)
292 {
293 /* An error has occurred */
294 freeAllocatedSingleString(l2);
295 ReturnArguments(pvApiCtx);
296 return 0;
297 }
298 }
299 else
300 {
301 iObjUID = getObjectFromHandle(hdl);
302 if (iObjUID != 0)
303 {
304
305 if (callGetProperty(pvApiCtx, iObjUID, (l2)) != 0)
306 {
307 /* An error has occurred */
308 freeAllocatedSingleString(l2);
309 ReturnArguments(pvApiCtx);
310 return 0;
311 }
312 }
313 else
314 {
315 Scierror(999, _("%s: The handle is not or no more valid.\n"), fname);
316 freeAllocatedSingleString(l2);
317 return 0;
318 }
319 }
320
321 AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
322 ReturnArguments(pvApiCtx);
323 freeAllocatedSingleString(l2);
324 return 0;
325}
326
327/*--------------------------------------------------------------------------*/
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)
72 72
73 initSubWinBounds(iSubWinUID); 73 initSubWinBounds(iSubWinUID);
74 74
75 iLabelUID = initLabel(iSubWinUID); 75 iLabelUID = initLabel(iSubWinUID, __GO_TITLE__);
76 setGraphicObjectProperty(iSubWinUID, __GO_TITLE__, &iLabelUID, jni_int, 1); 76 setGraphicObjectProperty(iSubWinUID, __GO_TITLE__, &iLabelUID, jni_int, 1);
77 77
78 iLabelUID = initLabel(iSubWinUID); 78 iLabelUID = initLabel(iSubWinUID, __GO_X_AXIS_LABEL__);
79 setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); 79 setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1);
80 80
81 iLabelUID = initLabel(iSubWinUID); 81 iLabelUID = initLabel(iSubWinUID, __GO_Y_AXIS_LABEL__);
82 setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); 82 setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1);
83 83
84 iLabelUID = initLabel(iSubWinUID); 84 iLabelUID = initLabel(iSubWinUID, __GO_Z_AXIS_LABEL__);
85 setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); 85 setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1);
86 86
87 /* bottom */ 87 /* 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()
564 setGraphicObjectProperty(iAxesmdlUID, __GO_ARC_DRAWING_METHOD__, &arcDrawingMethod, jni_int, 1); 564 setGraphicObjectProperty(iAxesmdlUID, __GO_ARC_DRAWING_METHOD__, &arcDrawingMethod, jni_int, 1);
565 565
566 /* Creates the Axes model's labels and sets the model as their parent */ 566 /* Creates the Axes model's labels and sets the model as their parent */
567 iLabelUID = initLabel(iAxesmdlUID); 567 iLabelUID = initLabel(iAxesmdlUID, __GO_TITLE__);
568 setGraphicObjectProperty(iAxesmdlUID, __GO_TITLE__, &iLabelUID, jni_int, 1); 568 setGraphicObjectProperty(iAxesmdlUID, __GO_TITLE__, &iLabelUID, jni_int, 1);
569 569
570 iLabelUID = initLabel(iAxesmdlUID); 570 iLabelUID = initLabel(iAxesmdlUID, __GO_X_AXIS_LABEL__);
571 setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); 571 setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1);
572 572
573 iLabelUID = initLabel(iAxesmdlUID); 573 iLabelUID = initLabel(iAxesmdlUID, __GO_Y_AXIS_LABEL__);
574 setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); 574 setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1);
575 575
576 iLabelUID = initLabel(iAxesmdlUID); 576 iLabelUID = initLabel(iAxesmdlUID, __GO_Z_AXIS_LABEL__);
577 setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); 577 setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1);
578 578
579 return 0; 579 return 0;
@@ -701,11 +701,12 @@ default:
701 701
702/*---------------------------------------------------------------------------------*/ 702/*---------------------------------------------------------------------------------*/
703/* allocate and set a new label to default values */ 703/* allocate and set a new label to default values */
704int initLabel(int iParentObjUID) 704int initLabel(int iParentObjUID, int associatedProperty)
705{ 705{
706 int iNewLabel = 0; 706 int iNewLabel = 0;
707 int iHidden = 1; 707 int iHidden = 1;
708 int autoPosition = 1; 708 int autoPosition = 1;
709 double fontSize = 1.0;
709 710
710 iNewLabel = createGraphicObject(__GO_LABEL__); 711 iNewLabel = createGraphicObject(__GO_LABEL__);
711 712
@@ -720,6 +721,21 @@ int initLabel(int iParentObjUID)
720 cloneGraphicContext(iParentObjUID, iNewLabel); 721 cloneGraphicContext(iParentObjUID, iNewLabel);
721 cloneFontContext(iParentObjUID, iNewLabel); 722 cloneFontContext(iParentObjUID, iNewLabel);
722 723
724 /* Set a specific font size for important labels */
725 switch (associatedProperty)
726 {
727 case __GO_TITLE__:
728 fontSize = 3.0;
729 setGraphicObjectProperty(iNewLabel, __GO_FONT_SIZE__, &fontSize, jni_double, 1);
730 break;
731 case __GO_X_AXIS_LABEL__: // fallthrough
732 case __GO_Y_AXIS_LABEL__: // fallthrough
733 case __GO_Z_AXIS_LABEL__: // fallthrough
734 fontSize = 2.0;
735 setGraphicObjectProperty(iNewLabel, __GO_FONT_SIZE__, &fontSize, jni_double, 1);
736 break;
737 }
738
723 return iNewLabel; 739 return iNewLabel;
724} 740}
725/*---------------------------------------------------------------------------------*/ 741/*---------------------------------------------------------------------------------*/