2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
17 #include "getGraphicObjectProperty.h"
18 #include "graphicObjectProperties.h"
19 #include "getScilabJavaVM.h"
22 #include "CallGraphicController.hxx"
23 #include "DataController.hxx"
25 using namespace org_scilab_modules_graphic_objects;
27 void getGraphicObjectProperty(char const* _pstID, int _iName, _ReturnType_ _returnType, void **_pvData)
29 // do not perform anything if the id is undefined
35 /* All the Data model properties have the DATA_MODEL prefix */
36 if (_iName == __GO_DATA_MODEL__
37 || _iName == __GO_DATA_MODEL_COORDINATES__
38 || _iName == __GO_DATA_MODEL_X__
39 || _iName == __GO_DATA_MODEL_Y__
40 || _iName == __GO_DATA_MODEL_Z__
41 || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT__
42 || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT__
43 || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT__
44 || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__
45 || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__
46 || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__
47 || _iName == __GO_DATA_MODEL_NUM_ELEMENTS__
48 || _iName == __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__
49 || _iName == __GO_DATA_MODEL_NUM_VERTICES_PER_GON__
50 || _iName == __GO_DATA_MODEL_NUM_GONS__
51 || _iName == __GO_DATA_MODEL_Z_COORDINATES_SET__
52 || _iName == __GO_DATA_MODEL_COLORS__
53 || _iName == __GO_DATA_MODEL_NUM_COLORS__
54 || _iName == __GO_DATA_MODEL_NUM_VERTICES__
55 || _iName == __GO_DATA_MODEL_NUM_INDICES__
56 || _iName == __GO_DATA_MODEL_INDICES__
57 || _iName == __GO_DATA_MODEL_VALUES__
58 || _iName == __GO_DATA_MODEL_FEC_TRIANGLES__
59 || _iName == __GO_DATA_MODEL_NUM_X__
60 || _iName == __GO_DATA_MODEL_NUM_Y__
61 || _iName == __GO_DATA_MODEL_NUM_Z__
62 || _iName == __GO_DATA_MODEL_GRID_SIZE__
63 || _iName == __GO_DATA_MODEL_X_DIMENSIONS__
64 || _iName == __GO_DATA_MODEL_Y_DIMENSIONS__
65 || _iName == __GO_DATA_MODEL_MATPLOT_BOUNDS__
66 || _iName == __GO_DATA_MODEL_MATPLOT_TYPE__
69 DataController::getGraphicObjectProperty(_pstID, _iName, _pvData);
79 *(_pvData) = CallGraphicController::getGraphicObjectPropertyAsString(getScilabJavaVM(), _pstID, _iName);
82 case jni_string_vector:
84 *_pvData = CallGraphicController::getGraphicObjectPropertyAsStringVector(getScilabJavaVM(), _pstID, _iName);
89 ((double *)*_pvData)[0] = (double)CallGraphicController::getGraphicObjectPropertyAsDouble(getScilabJavaVM(), _pstID, _iName);
92 case jni_double_vector:
94 *_pvData = CallGraphicController::getGraphicObjectPropertyAsDoubleVector(getScilabJavaVM(), _pstID, _iName);
99 ((int *)*_pvData)[0] = (int)CallGraphicController::getGraphicObjectPropertyAsBoolean(getScilabJavaVM(), _pstID, _iName);
102 case jni_bool_vector:
104 *_pvData = CallGraphicController::getGraphicObjectPropertyAsBooleanVector(getScilabJavaVM(), _pstID, _iName);
109 ((int *)*_pvData)[0] = CallGraphicController::getGraphicObjectPropertyAsInteger(getScilabJavaVM(), _pstID, _iName);
114 *_pvData = CallGraphicController::getGraphicObjectPropertyAsIntegerVector(getScilabJavaVM(), _pstID, _iName);
122 catch (std::exception &e)
125 // If we have an exception, return null to scilab to manage error.
133 void releaseGraphicObjectProperty(int _iName, void * _pvData, enum _ReturnType_ _returnType, int numElements)
136 /* All the Data model properties have the DATA_MODEL prefix */
137 if (_iName == __GO_DATA_MODEL__)
139 // passed by reference, do not free them
147 delete[] (char*) _pvData;
150 case jni_string_vector:
152 char** data = (char**) _pvData;
153 for (int i = 0; i < numElements; ++i)
165 case jni_double_vector:
167 delete[] (double*) _pvData;
175 case jni_bool_vector:
177 delete[] (int*) _pvData;
187 delete[] (int*) _pvData;