2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - INRIA - Fabrice Leray
4 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
14 /*------------------------------------------------------------------------*/
15 /* file: sci_xarrows.h */
16 /* desc : interface for xarrows routine */
17 /*------------------------------------------------------------------------*/
19 #include "gw_graphics.h"
21 #include "api_scilab.h"
22 #include "localization.h"
24 #include "HandleManagement.h"
25 #include "BuildObjects.h"
26 /*--------------------------------------------------------------------------*/
27 int sci_xarrows(char *fname, unsigned long fname_len)
41 int dstyle = -1, m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 1, n3 = 1;
42 int *style = NULL, flag = 0;
43 int m4 = 0, n4 = 0, mn2 = 0;
49 CheckInputArgument(pvApiCtx, 2, 5);
51 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1);
54 printError(&sciErr, 0);
58 // Retrieve a matrix of double at position 1.
59 sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1);
62 printError(&sciErr, 0);
63 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1);
67 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2);
70 printError(&sciErr, 0);
74 // Retrieve a matrix of double at position 2.
75 sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2);
78 printError(&sciErr, 0);
79 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
85 if (m1 != m2 || n1 != n2)
87 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1);
93 AssignOutputVariable(pvApiCtx, 1) = 0;
94 ReturnArguments(pvApiCtx);
98 if (nbInputArgument(pvApiCtx) >= 3)
100 sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrl3);
103 printError(&sciErr, 0);
107 // Retrieve a matrix of double at position 3.
108 sciErr = getMatrixOfDouble(pvApiCtx, piAddrl3, &m3, &n3, &l3);
111 printError(&sciErr, 0);
112 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
116 if (m3 == m1 && n3 == n1)
119 if (nbInputArgument(pvApiCtx) >= 4)
121 sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4);
124 printError(&sciErr, 0);
128 // Retrieve a matrix of double at position 4.
129 sciErr = getMatrixOfDouble(pvApiCtx, piAddr4, &m4, &n4, &dl4);
132 printError(&sciErr, 0);
133 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 4);
137 if (m4 != 1 || n4 != 1)
139 Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, 4);
146 else if (m3 == 1 && n3 == 1)
148 if (nbInputArgument(pvApiCtx) > 4)
150 Scierror(999, _("%s: Wrong number of input arguments: at least %d expected.\n"), fname, 4);
158 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix or a scalar expected.\n"), fname, 3, m1, n1);
163 if (nbInputArgument(pvApiCtx) >= stylePos)
165 sciErr = getVarAddressFromPosition(pvApiCtx, stylePos, &piAddr);
168 printError(&sciErr, 0);
172 // Retrieve a matrix of double at position 4 or 5.
173 sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr, &m4, &n4, &l4);
176 printError(&sciErr, 0);
177 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, stylePos);
182 if (m4 != 1 && n4 != 1)
184 Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, stylePos);
190 dstyle = *(int*)(l4);
192 if (m4 * n4 != 1 && m2 * n2 / 2 != m4 * n4)
194 Scierror(999, _("%s: Wrong size for input argument #%d: %d expected.\n"), fname, stylePos, m2 * n2 / 2);
200 if (nbInputArgument(pvApiCtx) == stylePos && m4 * n4 != 1)
211 getOrCreateDefaultSubwin();
213 Objsegs(style, flag, mn2, (l1), (l2), zptr, arsize);
215 AssignOutputVariable(pvApiCtx, 1) = 0;
216 ReturnArguments(pvApiCtx);
219 /*--------------------------------------------------------------------------*/