1
2 /*
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006 - INRIA - Fabrice Leray
5 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
7 *
8 * Copyright (C) 2012 - 2016 - Scilab Enterprises
9 *
10 * This file is hereby licensed under the terms of the GNU GPL v2.0,
11 * pursuant to article 5.3.4 of the CeCILL v.2.1.
12 * This file was originally licensed under the terms of the CeCILL v2.1,
13 * and continues to be available under such terms.
14 * For more information, see the COPYING file which you should have received
15 * along with this program.
16 *
17 */
18
19 /*------------------------------------------------------------------------*/
20 /* file: sci_rotate_axes.c */
21 /* desc : set the message about the rotation in the info box. */
22 /*------------------------------------------------------------------------*/
23
24 #include "gw_graphics.h"
25 #include "api_scilab.h"
26 #include "Scierror.h"
27 #include "localization.h"
28
29 #include "setGraphicObjectProperty.h"
30 #include "graphicObjectProperties.h"
31 #include "CurrentFigure.h"
32 #include "HandleManagement.h"
33 #include "getPropertyAssignedValue.h"
34 #include "getGraphicObjectProperty.h"
35 /*--------------------------------------------------------------------------*/
sci_rotate_axes(char * fname,void * pvApiCtx)36 int sci_rotate_axes(char *fname, void *pvApiCtx)
37 {
38 SciErr sciErr;
39
40 int* piAddrstackPointer = NULL;
41 long long* stackPointer = NULL;
42
43 int nbRow = 0;
44 int nbCol = 0;
45
46 int iUID = 0;
47 int* piUID = &iUID;
48 int iType = -1;
49 int *piType = &iType;
50
51 /* check size of input and output */
52 CheckInputArgument(pvApiCtx, 0, 1);
53 CheckOutputArgument(pvApiCtx, 0, 1);
54
55 if (nbInputArgument(pvApiCtx) == 0)
56 {
57 iUID = getCurrentFigure();
58 }
59 else
60 {
61 /* Get figure or subwin handle */
62 if ((!checkInputArgumentType(pvApiCtx, 1, sci_handles)))
63 {
64 Scierror(999, _("%s: Wrong type for input argument #%d: Single Figure or Axes handle expected.\n"), fname, 1);
65 return -1;
66 }
67
68 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrstackPointer);
69 if (sciErr.iErr)
70 {
71 printError(&sciErr, 0);
72 return 1;
73 }
74
75 // Retrieve a matrix of handle at position 1.
76 sciErr = getMatrixOfHandle(pvApiCtx, piAddrstackPointer, &nbRow, &nbCol, &stackPointer);
77 if (sciErr.iErr)
78 {
79 printError(&sciErr, 0);
80 Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1);
81 return 1;
82 }
83
84
85 if (nbRow * nbCol != 1)
86 {
87 Scierror(999, _("%s: Wrong type for input argument #%d: Single Figure or Axes handle expected.\n"), fname, 1);
88 return -1;
89 }
90
91 iUID = getObjectFromHandle((long int) * stackPointer);
92
93 getGraphicObjectProperty(iUID, __GO_TYPE__, jni_int, (void **)&piType);
94 if (iType == __GO_AXES__)
95 {
96 iUID = getParentObject(iUID);
97 }
98 }
99
100 if (iUID == 0)
101 {
102 Scierror(999, _("%s: The handle is not or no more valid.\n"), fname);
103 return -1;
104 }
105
106 setGraphicObjectProperty(iUID, __GO_INFO_MESSAGE__, "Right click and drag to rotate.", jni_string, 1);
107
108 AssignOutputVariable(pvApiCtx, 1) = 0;
109 ReturnArguments(pvApiCtx);
110
111 return 0;
112 }
113 /*--------------------------------------------------------------------------*/
114