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) 2010 - DIGITEO - Pierre Lando <pierre.lando@scilab.org>
7 * Copyright (C) 2011 - DIGITEO - Manuel Juliachs
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_links_property.c */
19 /* desc : function to modify in Scilab the related polyline to a legend. */
20 /*------------------------------------------------------------------------*/
24 #include "setHandleProperty.h"
25 #include "getPropertyAssignedValue.h"
26 #include "SetPropertyStatus.h"
27 #include "GetProperty.h"
29 #include "localization.h"
30 #include "HandleManagement.h"
32 #include "sci_types.h"
34 #include "getGraphicObjectProperty.h"
35 #include "setGraphicObjectProperty.h"
36 #include "graphicObjectProperties.h"
38 /*------------------------------------------------------------------------*/
39 int set_links_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol)
45 int* piParentAxes = &iParentAxes;
49 int* piLinksCount = &iLinksCount;
51 if (valueType != sci_handles)
53 Scierror(999, _("Wrong type for '%s' property: Graphic handle array expected.\n"), "links");
54 return SET_PROPERTY_ERROR;
57 getGraphicObjectProperty(iObjUID, __GO_LINKS_COUNT__, jni_int, (void**)&piLinksCount);
59 if (piLinksCount == NULL)
61 Scierror(999, _("'%s' property does not exist for this handle.\n"), "links");
62 return SET_PROPERTY_ERROR;
65 if (nbRow * nbCol != iLinksCount)
67 Scierror(999, _("Wrong size for '%s' property: %d elements expected.\n"), "links", iLinksCount);
68 return SET_PROPERTY_ERROR;
71 links = (int*) MALLOC(iLinksCount * sizeof(int));
75 Scierror(999, _("%s: No more memory.\n"), "set_z_ticks_property");
76 return SET_PROPERTY_ERROR;
79 getGraphicObjectProperty(iObjUID, __GO_PARENT_AXES__, jni_int, (void **)&piParentAxes);
83 for (i = 0 ; i < iLinksCount ; i++)
85 int iPolylineParentAxes;
86 int* piPoly = &iPolylineParentAxes;
87 int iPolylineObjectUID = getObjectFromHandle((long)((long long*)_pvData)[i]);
89 getGraphicObjectProperty(iPolylineObjectUID, __GO_TYPE__, jni_int, (void **)&piType);
91 if (type != __GO_POLYLINE__)
93 Scierror(999, _("%s: Input argument #%d must be a '%s' handle.\n"), "links", i, "polyline");
98 links[i] = iPolylineObjectUID;
100 getGraphicObjectProperty(iPolylineObjectUID, __GO_PARENT_AXES__, jni_int, (void **)&piPoly);
102 if (iPolylineParentAxes != iParentAxes)
104 Scierror(999, _("%s: Input argument and the legend must have the same parent axes.\n"), "links");
113 return SET_PROPERTY_ERROR;
116 status = setGraphicObjectProperty(iObjUID, __GO_LINKS__, links, jni_int_vector, iLinksCount);
122 return SET_PROPERTY_SUCCEED;
126 Scierror(999, _("'%s' property does not exist for this handle.\n"), "links");
127 return SET_PROPERTY_ERROR;
130 /*------------------------------------------------------------------------*/