2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2004-2006 - INRIA - Fabrice Leray
4 * Copyright (C) 2006 - INRIA - Allan Cornet
5 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2009 - DIGITEO - Pierre Lando
7 * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
9 * This file must be used under the terms of the CeCILL.
10 * This source file is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at
13 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
17 /*------------------------------------------------------------------------*/
18 /* file: set_current_figure_property.c */
19 /* desc : function to modify in Scilab the current_figure field of */
21 /*------------------------------------------------------------------------*/
25 #include "setHandleProperty.h"
26 #include "SetProperty.h"
27 #include "GetProperty.h"
28 #include "getPropertyAssignedValue.h"
30 #include "localization.h"
31 #include "SetPropertyStatus.h"
32 #include "HandleManagement.h"
33 #include "sci_types.h"
35 #include "BuildObjects.h"
36 #include "CurrentFigure.h"
37 #include "setGraphicObjectProperty.h"
38 #include "getGraphicObjectProperty.h"
39 #include "graphicObjectProperties.h"
40 #include "FigureList.h"
41 #include "CurrentSubwin.h"
42 #include "createGraphicObject.h"
45 /*------------------------------------------------------------------------*/
46 int set_current_figure_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol)
53 int* piAxesUID = &iAxesUID;
57 /* This property should not be called on an handle */
58 Scierror(999, _("'%s' property does not exist for this handle.\n"), "current_figure");
59 return SET_PROPERTY_ERROR;
62 if (nbRow * nbCol != 1)
64 Scierror(999, _("Wrong size for '%s' property: A scalar expected.\n"), "current_figure");
65 return SET_PROPERTY_ERROR;
68 if ((valueType == sci_handles))
71 iCurFigUID = getObjectFromHandle((long)((long long*)_pvData)[0]);
75 Scierror(999, _("'%s' handle does not or no longer exists.\n"), "Figure");
76 return SET_PROPERTY_ERROR;
78 setCurrentFigure(iCurFigUID);
79 getGraphicObjectProperty(iCurFigUID, __GO_SELECTED_CHILD__, jni_int, (void**)&piAxesUID);
80 setCurrentSubWin(iAxesUID);
84 else if ((valueType == sci_matrix))
86 figNum = (int) ((double*)_pvData)[0];
90 Scierror(999, _("Wrong type for '%s' property: Real or '%s' handle expected.\n"), "current_figure", "Figure");
91 return SET_PROPERTY_ERROR;
94 /* Retrieve figure with figNum */
95 iFigureUID = getFigureFromIndex(figNum);
99 // No Figure available with this index, should create it !!
100 iFigureUID = createNewFigureWithAxes();
101 setGraphicObjectProperty(iFigureUID, __GO_ID__, &figNum, jni_int, 1);
103 setCurrentFigure(iFigureUID);
105 getGraphicObjectProperty(iFigureUID, __GO_SELECTED_CHILD__, jni_int, (void**)&piAxesUID);
106 setCurrentSubWin(iAxesUID);
109 /*------------------------------------------------------------------------*/