1 /*
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
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 *
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.
14 *
15 */
16
17
18 #include "getHandleProperty.h"
19 #include "returnProperty.h"
20 #include "Scierror.h"
21 #include "localization.h"
22
23 #include "getGraphicObjectProperty.h"
24 #include "graphicObjectProperties.h"
25
26
27 /**
28 * Get the datatip orientation.
29 */
get_tip_orientation_property(void * _pvCtx,int iObjUID)30 void* get_tip_orientation_property(void* _pvCtx, int iObjUID)
31 {
32 int tip_orientation;
33 int *piTipOrientation = &tip_orientation;
34
35 getGraphicObjectProperty(iObjUID, __GO_DATATIP_ORIENTATION__, jni_int, (void **)&piTipOrientation);
36
37 if (piTipOrientation == NULL)
38 {
39 Scierror(999, _("'%s' property does not exist for this handle.\n"), "orientation");
40 return NULL;
41 }
42
43 return sciReturnInt(tip_orientation);
44 }
45
46 /**
47 * Old z_componet property, warns the user
48 */
get_tip_z_component_property(void * _pvCtx,int iObjUID)49 void* get_tip_z_component_property(void* _pvCtx, int iObjUID)
50 {
51 char * tip_display_components;
52 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_COMPONENTS__, jni_string, (void **)&tip_display_components);
53
54 //Only warns if the property exists for the object.
55 if (tip_display_components == NULL)
56 {
57 Scierror(999, _("'%s' property does not exist for this handle.\n"), "z_component");
58 }
59 else
60 {
61 Scierror(999, _("'%s' property is obsolete and will be removed, use '%s' instead.\n"), "z_component", "display_components");
62 }
63
64 return NULL;
65 }
66
67 /**
68 * Get display mode for datatips
69 */
get_datatip_display_mode_property(void * _pvCtx,int iObjUID)70 void* get_datatip_display_mode_property(void* _pvCtx, int iObjUID)
71 {
72 int datatip_display_mode = -1;
73 int * p_datatip_display_mode = &datatip_display_mode;
74 const char * name = NULL;
75 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_MODE__, jni_int, (void **)&p_datatip_display_mode);
76
77 if (datatip_display_mode == -1)
78 {
79 Scierror(999, _("'%s' property does not exist for this handle.\n"), "datatip_display_mode");
80 return NULL;
81 }
82
83 switch (datatip_display_mode)
84 {
85 case 0:
86 name = "always";
87 break;
88 case 1:
89 name = "mouseclick";
90 break;
91 case 2:
92 name = "mouseover";
93 break;
94 default:
95 name = "always";
96 break;
97 }
98
99 return sciReturnString(name);
100 }
101
102
103 /**
104 * Get the datatip components that should be displayed
105 */
get_tip_display_components_property(void * _pvCtx,int iObjUID)106 void* get_tip_display_components_property(void* _pvCtx, int iObjUID)
107 {
108 char * tip_display_components;
109 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_COMPONENTS__, jni_string, (void **)&tip_display_components);
110
111 if (tip_display_components == NULL)
112 {
113 Scierror(999, _("'%s' property does not exist for this handle.\n"), "display_components");
114 return NULL;
115 }
116
117 return sciReturnString(tip_display_components);
118 }
119
120 /**
121 * Get the status if the auto-orientation is enabled.
122 */
get_tip_auto_orientation_property(void * _pvCtx,int iObjUID)123 void* get_tip_auto_orientation_property(void* _pvCtx, int iObjUID)
124 {
125 int tip_auto_orientation;
126 int *piTip_auto_orientation = &tip_auto_orientation;
127
128 getGraphicObjectProperty(iObjUID, __GO_DATATIP_AUTOORIENTATION__, jni_bool, (void **)&piTip_auto_orientation);
129
130 if (piTip_auto_orientation == NULL)
131 {
132 Scierror(999, _("'%s' property does not exist for this handle.\n"), "auto_orientation");
133 return NULL;
134 }
135
136 if (tip_auto_orientation)
137 {
138 return sciReturnString("on");
139 }
140 else
141 {
142 return sciReturnString("off");
143 }
144 }
145
146 /**
147 * Get the datatip interpolation mode (on/off).
148 */
get_tip_interp_mode_property(void * _pvCtx,int iObjUID)149 void* get_tip_interp_mode_property(void* _pvCtx, int iObjUID)
150 {
151 int tip_interp_mode;
152 int *piTip_interp_mode = &tip_interp_mode;
153
154 getGraphicObjectProperty(iObjUID, __GO_DATATIP_INTERP_MODE__, jni_bool, (void **)&piTip_interp_mode);
155
156 if (piTip_interp_mode == NULL)
157 {
158 Scierror(999, _("'%s' property does not exist for this handle.\n"), "interp_mode");
159 return NULL;
160 }
161
162 if (tip_interp_mode)
163 {
164 return sciReturnString("on");
165 }
166 else
167 {
168 return sciReturnString("off");
169 }
170 }
171
172 /**
173 * Get the datatip box mode (true or false).
174 */
get_tip_box_mode_property(void * _pvCtx,int iObjUID)175 void* get_tip_box_mode_property(void* _pvCtx, int iObjUID)
176 {
177 int tip_box_mode;
178 int *piTip_box_mode = &tip_box_mode;
179
180 getGraphicObjectProperty(iObjUID, __GO_DATATIP_BOX_MODE__, jni_bool, (void **)&piTip_box_mode);
181
182 if (piTip_box_mode == NULL)
183 {
184 Scierror(999, _("'%s' property does not exist for this handle.\n"), "box_mode");
185 return NULL;
186 }
187
188 if (tip_box_mode)
189 {
190 return sciReturnString("on");
191 }
192 else
193 {
194 return sciReturnString("off");
195 }
196 }
197
198 /**
199 * Get the datatip label mode (true or false).
200 */
get_tip_label_mode_property(void * _pvCtx,int iObjUID)201 void* get_tip_label_mode_property(void* _pvCtx, int iObjUID)
202 {
203 int tip_label_mode;
204 int *piTip_label_mode = &tip_label_mode;
205
206 getGraphicObjectProperty(iObjUID, __GO_DATATIP_LABEL_MODE__, jni_bool, (void **)&piTip_label_mode);
207
208 if (piTip_label_mode == NULL)
209 {
210 Scierror(999, _("'%s' property does not exist for this handle.\n"), "label_mode");
211 return NULL;
212 }
213
214 if (tip_label_mode)
215 {
216 return sciReturnString("on");
217 }
218 else
219 {
220 return sciReturnString("off");
221 }
222 }
223
224
225 /**
226 * Get the datatip display function.
227 */
get_tip_disp_function_property(void * _pvCtx,int iObjUID)228 void* get_tip_disp_function_property(void* _pvCtx, int iObjUID)
229 {
230 char *tip_disp_function = NULL;
231 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DISPLAY_FNC__, jni_string, (void **)&tip_disp_function);
232
233 if (tip_disp_function == NULL)
234 {
235 Scierror(999, _("'%s' property does not exist for this handle.\n"), "display_function");
236 return NULL;
237 }
238
239 return sciReturnString(tip_disp_function);
240 }
241
get_tip_detached_property(void * _pvCtx,int iObjUID)242 void* get_tip_detached_property(void* _pvCtx, int iObjUID)
243 {
244 int isDetached = 0;
245 int *piDetached = &isDetached;
246 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DETACHED_MODE__, jni_bool, (void **)&piDetached);
247
248 if (piDetached == NULL)
249 {
250 Scierror(999, _("'%s' property does not exist for this handle.\n"), "detached_position");
251 return NULL;
252 }
253
254 if (!isDetached)
255 {
256 return sciReturnEmptyMatrix();
257 }
258 else
259 {
260 double *detached_pos = NULL;
261 getGraphicObjectProperty(iObjUID, __GO_DATATIP_DETACHED_POSITION__, jni_double_vector, (void **)&detached_pos);
262 return sciReturnRowVector(detached_pos, 3);
263 }
264 }
265