2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Pedro Arthur dos S. Souza
4 * Copyright (C) 2012 - Caio Lucas dos S. Souza
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
17 #include "setHandleProperty.h"
18 #include "SetProperty.h"
19 #include "getPropertyAssignedValue.h"
21 #include "localization.h"
22 #include "SetPropertyStatus.h"
24 #include "setGraphicObjectProperty.h"
25 #include "graphicObjectProperties.h"
28 * Sets the datatip oriantation.
30 int set_tip_orientation_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
35 if ( !( valueType == sci_matrix ) )
37 Scierror(999, _("Wrong type for '%s' property: Integer expected.\n"), "orientation");
38 return SET_PROPERTY_ERROR;
41 tip_orientation = (int)((double*)_pvData)[0];
43 status = setGraphicObjectProperty(iObj, __GO_DATATIP_ORIENTATION__, &tip_orientation, jni_int, 1);
47 int auto_orientation = 0;
48 setGraphicObjectProperty(iObj, __GO_DATATIP_AUTOORIENTATION__, &auto_orientation, jni_bool, 1);
49 return SET_PROPERTY_SUCCEED;
53 Scierror(999, _("'%s' property does not exist for this handle.\n"), "orientation");
54 return SET_PROPERTY_ERROR;
59 * Old z_componet property, warns the user
61 int set_tip_z_component_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
63 char * tip_display_components;
64 getGraphicObjectProperty(iObj, __GO_DATATIP_DISPLAY_COMPONENTS__, jni_string, (void **)&tip_display_components);
66 //Only warns if the property exists for the object.
67 if (tip_display_components == NULL)
69 Scierror(999, _("'%s' property does not exist for this handle.\n"), "z_component");
73 Scierror(999, _("'%s' property is obsolete and will be removed, use '%s' instead.\n"), "z_component", "display_components");
80 * Set display mode for datatips
82 int set_datatip_display_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
85 const char * value = (const char*) _pvData;
86 int datatip_display_mode = -1;
87 if (strcmp(value, "always") == 0)
89 datatip_display_mode = 0;
91 else if (strcmp(value, "mouseclick") == 0)
93 datatip_display_mode = 1;
95 else if (strcmp(value, "mouseover") == 0)
97 datatip_display_mode = 2;
100 if (datatip_display_mode >= 0)
102 status = setGraphicObjectProperty(iObj, __GO_DATATIP_DISPLAY_MODE__, &datatip_display_mode, jni_int, 1);
105 return SET_PROPERTY_SUCCEED;
112 getGraphicObjectProperty(iObj, __GO_TYPE__, jni_int, (void **)&piType);
113 if (type == __GO_POLYLINE__)
115 Scierror(999, _("Inavlid value for '%s' property, use 'always', 'mouseclick' or 'mouseover'.\n"), "datatip_display_mode");
119 Scierror(999, _("'%s' property does not exist for this handle.\n"), "datatip_display_mode");
121 return SET_PROPERTY_ERROR;
126 * Set which coordinate components should be displayed
128 int set_tip_display_components_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
131 const char * value = (const char*) _pvData;
136 //check if the value is valid and throws properly error msg
139 if (valueType != sci_strings)
141 Scierror(999, _("Wrong type for '%s' property: String expected.\n"), "display_components");
142 return SET_PROPERTY_ERROR;
145 for (i = 0; i < 4; ++i)
147 if (value[i] == '\0')
151 Scierror(999, _("Wrong value for '%s' property: Non-empty string expected.\n"), "display_components");
152 return SET_PROPERTY_ERROR;
163 Scierror(999, _("Wrong value for '%s' property: String with length 3 or less expected.\n"), "display_components");
164 return SET_PROPERTY_ERROR;
172 Scierror(999, _("Wrong value for '%s' property: String contains 'x' component more than once.\n"), "display_components");
173 return SET_PROPERTY_ERROR;
181 Scierror(999, _("Wrong value for '%s' property: String contains 'y' component more than once.\n"), "display_components");
182 return SET_PROPERTY_ERROR;
190 Scierror(999, _("Wrong value for '%s' property: String contains 'z' component more than once.\n"), "display_components");
191 return SET_PROPERTY_ERROR;
196 Scierror(999, _("Wrong value for '%s' property: String with 'x|y|z' expected.\n"), "display_components");
197 return SET_PROPERTY_ERROR;
202 status = setGraphicObjectProperty(iObj, __GO_DATATIP_DISPLAY_COMPONENTS__, value, jni_string, 1);
205 return SET_PROPERTY_SUCCEED;
209 Scierror(999, _("'%s' property does not exist for this handle.\n"), "display_components");
210 return SET_PROPERTY_ERROR;
216 * Enable/disable the datatip auto-orientation.
218 int set_tip_auto_orientation_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
221 int auto_orientation = tryGetBooleanValueFromStack(_pvData, valueType, nbRow, nbCol, "auto_orientation");
222 if (auto_orientation == NOT_A_BOOLEAN_VALUE)
224 return SET_PROPERTY_ERROR;
226 status = setGraphicObjectProperty(iObj, __GO_DATATIP_AUTOORIENTATION__, &auto_orientation, jni_bool, 1);
230 return SET_PROPERTY_SUCCEED;
234 Scierror(999, _("'%s' property does not exist for this handle.\n"), "auto_orientation");
235 return SET_PROPERTY_ERROR;
241 * Set the datatip interpolation mode (on/off).
243 int set_tip_interp_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
246 int interp_mode = tryGetBooleanValueFromStack(_pvData, valueType, nbRow, nbCol, "interp_mode");
247 if (interp_mode == NOT_A_BOOLEAN_VALUE)
249 return SET_PROPERTY_ERROR;
251 status = setGraphicObjectProperty(iObj, __GO_DATATIP_INTERP_MODE__, &interp_mode, jni_bool, 1);
255 return SET_PROPERTY_SUCCEED;
259 Scierror(999, _("'%s' property does not exist for this handle.\n"), "interp_mode");
260 return SET_PROPERTY_ERROR;
265 * Set the datatip box mode (true or false).
267 int set_tip_box_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
270 int box_mode = tryGetBooleanValueFromStack(_pvData, valueType, nbRow, nbCol, "box_mode");
271 if (box_mode == NOT_A_BOOLEAN_VALUE)
273 return SET_PROPERTY_ERROR;
275 status = setGraphicObjectProperty(iObj, __GO_DATATIP_BOX_MODE__, &box_mode, jni_bool, 1);
279 return SET_PROPERTY_SUCCEED;
283 Scierror(999, _("'%s' property does not exist for this handle.\n"), "box_mode");
284 return SET_PROPERTY_ERROR;
289 * Set the datatip label mode (true or false).
291 int set_tip_label_mode_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
294 int label_mode = tryGetBooleanValueFromStack(_pvData, valueType, nbRow, nbCol, "label_mode");
295 if (label_mode == NOT_A_BOOLEAN_VALUE)
297 return SET_PROPERTY_ERROR;
299 status = setGraphicObjectProperty(iObj, __GO_DATATIP_LABEL_MODE__, &label_mode, jni_bool, 1);
303 return SET_PROPERTY_SUCCEED;
307 Scierror(999, _("'%s' property does not exist for this handle.\n"), "label_mode");
308 return SET_PROPERTY_ERROR;
313 int set_tip_disp_function_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
316 if (valueType != sci_strings)
318 Scierror(999, _("Wrong type for '%s' property: String expected.\n"), "display_function");
319 return SET_PROPERTY_ERROR;
322 status = setGraphicObjectProperty(iObj, __GO_DATATIP_DISPLAY_FNC__, _pvData, jni_string, 1);
326 return SET_PROPERTY_SUCCEED;
330 Scierror(999, _("'%s' property does not exist for this handle.\n"), "display_function");
331 return SET_PROPERTY_ERROR;
335 int set_tip_detached_property(void* _pvCtx, int iObj, void* _pvData, int valueType, int nbRow, int nbCol)
338 int isDetached = nbRow * nbCol != 0;
339 double* detached_position = NULL;
340 if (valueType != sci_matrix)
342 Scierror(999, _("Wrong type for '%s' property: Matrix expected.\n"), "detached_position");
343 return SET_PROPERTY_ERROR;
347 if (nbRow * nbCol != 3 && isDetached)
349 Scierror(999, _("Wrong size for '%s' property: Matrix with length 3 or [] expected.\n"), "detached_position");
350 return SET_PROPERTY_ERROR;
352 status = setGraphicObjectProperty(iObj, __GO_DATATIP_DETACHED_MODE__, &isDetached, jni_bool, 1);
355 status = setGraphicObjectProperty(iObj, __GO_DATATIP_DETACHED_POSITION__, _pvData, jni_double_vector, 3);
360 return SET_PROPERTY_SUCCEED;
364 Scierror(999, _("'%s' property does not exist for this handle.\n"), "detached_position");
365 return SET_PROPERTY_ERROR;