1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
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 /*------------------------------------------------------------------------*/
17 /* file: set_ticks_st_property.c                                          */
18 /* desc : function to modify in Scilab the ticks_st field of              */
19 /*        a handle                                                        */
20 /*------------------------------------------------------------------------*/
21 
22 #include "setHandleProperty.h"
23 #include "SetProperty.h"
24 #include "getPropertyAssignedValue.h"
25 #include "SetPropertyStatus.h"
26 #include "Scierror.h"
27 #include "localization.h"
28 
29 #include "setGraphicObjectProperty.h"
30 #include "graphicObjectProperties.h"
31 
32 /*------------------------------------------------------------------------*/
set_ticks_st_property(void * _pvCtx,int iObjUID,void * _pvData,int valueType,int nbRow,int nbCol)33 int set_ticks_st_property(void* _pvCtx, int iObjUID, void* _pvData, int valueType, int nbRow, int nbCol)
34 {
35     BOOL status = FALSE;
36     int propr[3] = {__GO_X_AXIS_ST_FACTORS__, __GO_Y_AXIS_ST_FACTORS__, __GO_Z_AXIS_ST_FACTORS__};
37     double* values = (double*)_pvData;
38     int nb = nbRow * nbCol;
39     int i = 0;
40 
41     if (valueType != sci_matrix)
42     {
43         Scierror(999, _("Wrong type for '%s' property: Real matrix expected.\n"), "ticks_st");
44         return SET_PROPERTY_ERROR;
45     }
46 
47     if (nbRow != 2 && nbCol > 3)
48     {
49         Scierror(999, _("Wrong size for '%s' property: At most %d columns and %d rows expected.\n"), "ticks_st", 3, 2);
50         return SET_PROPERTY_ERROR;
51     }
52 
53     for (i = 0; i < nb / 2; i++)
54     {
55         status = setGraphicObjectProperty(iObjUID, propr[i], values + 2 * i, jni_double_vector, 2);
56         if (status == FALSE)
57         {
58             Scierror(999, _("'%s' property does not exist for this handle.\n"), "ticks_st");
59             return SET_PROPERTY_ERROR;
60         }
61     }
62 
63     return SET_PROPERTY_SUCCEED;
64 }
65 /*------------------------------------------------------------------------*/
66