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
5 * Copyright (C) 2011 - DIGITEO - Bruno JOFRET
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution. The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
15 /*------------------------------------------------------------------------*/
17 /* desc : interface for sci_fec routine */
18 /*------------------------------------------------------------------------*/
20 #include "gw_graphics.h"
21 #include "api_scilab.h"
22 #include "GetCommandArg.h"
23 #include "BuildObjects.h"
25 #include "DefaultCommandArg.h"
26 #include "localization.h"
29 /*--------------------------------------------------------------------------*/
30 int sci_fec(char *fname, unsigned long fname_len)
33 int m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 0, n3 = 0, m4 = 0, n4 = 0, mn1 = 0;
35 static rhs_opts opts[] =
37 { -1, "colminmax", -1, 0, 0, NULL},
38 { -1, "colout", -1, 0, 0, NULL},
39 { -1, "leg", -1, 0, 0, NULL},
40 { -1, "mesh", -1, 0, 0, NULL},
41 { -1, "nax", -1, 0, 0, NULL},
42 { -1, "rect", -1, 0, 0, NULL},
43 { -1, "strf", -1, 0, 0, NULL},
44 { -1, "zminmax", -1, 0, 0, NULL},
45 { -1, NULL, -1, 0, 0, NULL}
51 double* zminmax = NULL;
52 int* colminmax = NULL;
56 BOOL withMesh = FALSE;
68 if (nbInputArgument(pvApiCtx) <= 0)
70 sci_demo(fname, fname_len);
74 CheckInputArgument(pvApiCtx, 4, 12);
76 if (getOptionals(pvApiCtx, fname, opts) == 0)
78 ReturnArguments(pvApiCtx);
84 Scierror(999, _("%s: Misplaced optional argument: #%d must be at position %d.\n"), fname, 1, 5);
88 //get variable address
89 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
92 printError(&sciErr, 0);
96 // Retrieve a matrix of double at position 1.
97 sciErr = getMatrixOfDouble(pvApiCtx, piAddr1, &m1, &n1, &l1);
100 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1);
101 printError(&sciErr, 0);
105 //get variable address
106 sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
109 printError(&sciErr, 0);
113 // Retrieve a matrix of double at position 2.
114 sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &m2, &n2, &l2);
117 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
118 printError(&sciErr, 0);
123 if (m1 != m2 || n1 != n2)
125 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1);
130 //get variable address
131 sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
134 printError(&sciErr, 0);
138 // Retrieve a matrix of double at position 3.
139 sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &m3, &n3, &l3);
142 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
143 printError(&sciErr, 0);
149 Scierror(999, _("%s: Wrong number of columns for input argument #%d: %d expected.\n"), fname, 3, 5);
153 //get variable address
154 sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4);
157 printError(&sciErr, 0);
161 // Retrieve a matrix of double at position 4.
162 sciErr = getMatrixOfDouble(pvApiCtx, piAddr4, &m4, &n4, &l4);
165 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 4);
166 printError(&sciErr, 0);
171 if (m1 * n1 == 0 || m3 == 0)
173 AssignOutputVariable(pvApiCtx, 1) = 0;
174 ReturnArguments(pvApiCtx);
178 GetStrf(pvApiCtx, fname, 5, opts, &strf);
179 GetLegend(pvApiCtx, fname, 6, opts, &legend);
180 GetRect(pvApiCtx, fname, 7, opts, &rect);
181 GetNax(pvApiCtx, 8, opts, &nax, &flagNax);
182 GetZminmax(pvApiCtx, fname, 9, opts, &zminmax);
183 GetColminmax(pvApiCtx, fname, 10, opts, &colminmax);
184 GetColOut(pvApiCtx, fname, 11, opts, &colOut);
185 GetWithMesh(pvApiCtx, fname, 12, opts, &withMesh);
187 getOrCreateDefaultSubwin();
189 if (isDefStrf (strf))
193 strcpy(strfl, DEFSTRFN);
196 if (!isDefRect(rect))
200 if (!isDefLegend(legend))
207 Objfec ((l1), (l2), (l3), (l4), &mn1, &m3, strf, legend, rect, nax, zminmax, colminmax, colOut, withMesh, flagNax);
209 AssignOutputVariable(pvApiCtx, 1) = 0;
210 ReturnArguments(pvApiCtx);
215 /*--------------------------------------------------------------------------*/