1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Marcos CARDINOT
4 *
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 *
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
13 *
14 */
15
16 #include "StartGED.hxx"
17 #include "GiwsException.hxx"
18 #include "ScilabView.hxx"
19
20 extern "C"
21 {
22 #include "api_scilab.h"
23 #include "getScilabJavaVM.h"
24 #include "localization.h"
25 #include "Scierror.h"
26 #include "gw_gui.h"
27 #include "FigureList.h"
28 }
29
30
31 /*--------------------------------------------------------------------------*/
32 using namespace org_scilab_modules_gui_ged;
33
34 /*--------------------------------------------------------------------------*/
sci_openged(char * fname,void * pvApiCtx)35 int sci_openged(char *fname, void* pvApiCtx)
36 {
37 int iFigureUid = 0;
38 int* piAddr = NULL;
39 int* piData = NULL;
40 int m1 = 0;
41 int n1 = 0;
42 int iErr = 0;
43
44 SciErr sciErr;
45 CheckInputArgument(pvApiCtx, 1, 1);
46 CheckOutputArgument(pvApiCtx, 0, 1);
47
48 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
49 if (sciErr.iErr)
50 {
51 printError(&sciErr, 0);
52 return 1;
53 }
54
55 sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr, &m1, &n1, &piData);
56 if (sciErr.iErr)
57 {
58 Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
59 return 1;
60 }
61
62 if (m1 * n1 != 1)
63 {
64 Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, m1 * n1);
65 return 1;
66 }
67
68 try
69 {
70 iFigureUid = ScilabView::getFigureFromIndex(piData[0]);
71
72 if (!sciIsExistingFigure(piData[0]))
73 {
74 Scierror(999, "%s: Figure with figure_id %d does not exist.\n", fname, piData[0]);
75 return 1;
76 }
77
78 StartGED::quickGED(getScilabJavaVM(), iFigureUid);
79 }
80 catch (const GiwsException::JniException & e)
81 {
82 Scierror(999, _("%s: A Java exception arised:\n%s"), fname, e.whatStr().c_str());
83 return 1;
84 }
85
86 AssignOutputVariable(pvApiCtx, 1) = 0;
87 ReturnArguments(pvApiCtx);
88 return 0;
89 }
90 /*--------------------------------------------------------------------------*/
91