keep user_data in C 05/14005/7
Antoine ELIAS [Thu, 13 Mar 2014 10:53:49 +0000 (11:53 +0100)]
Change-Id: I44629072b31d42a2cd1c75755607add2f22a78b8

scilab/modules/graphic_objects/includes/ScilabView.hxx
scilab/modules/graphic_objects/src/cpp/ScilabView.cpp
scilab/modules/graphic_objects/src/cpp/getGraphicObjectProperty.cpp
scilab/modules/graphic_objects/src/cpp/setGraphicObjectProperty.cpp
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObject.java
scilab/modules/graphics/src/c/getHandleProperty/get_user_data_property.c

index e215b17..84dc377 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <map>
 #include <list>
+#include <vector>
 #include <string>
 
 #include "dynlib_graphic_objects.h"
@@ -57,6 +58,7 @@ private :
     typedef std::map<int, int>    __figureList;
     typedef __figureList::iterator          __figureList_iterator;
     typedef __figureList::reverse_iterator          __figureList_reverse_iterator;
+    typedef std::map<int, std::vector<int> >  __userdata;
 
     typedef  std::map<int, PathItem*> __pathList;
     typedef __pathList::iterator __pathList_iterator;
@@ -68,6 +70,7 @@ private :
     static __uidList        m_uidList;
     static __pathFigList    m_pathFigList;
     static __pathList       m_pathList;
+    static __userdata       m_userdata;
     static long             m_topHandleValue;
     static int              m_currentFigure;
     static int              m_currentObject;
@@ -115,6 +118,10 @@ public :
     static int search_path(char* _pstPath);
     static std::string get_path(int uid);
 
+    static void setUserdata(int _id, int* _data, int _datasize);
+    static int getUserdataSize(int _id);
+    static int* getUserdata(int _id);
+
 private :
     static PathItem* search_children(PathItem* _path, std::string _subPath, bool _bDeep, std::list<int>& _ignoredList);
 
index 79b8d2d..6921128 100644 (file)
@@ -29,6 +29,7 @@ extern "C"
 #include "graphicObjectProperties.h"
 #include "getScilabJavaVM.h"
 #include "deleteGraphicObject.h"
+#include "MALLOC.h"
 }
 
 /**
@@ -175,6 +176,8 @@ void ScilabView::createObject(int iUID)
 
     m_pathList[iUID] = item;
 
+    m_userdata[iUID]; //create an empty vector<int>
+
     //get existing information from current object
     updateObject(iUID, __GO_PARENT__);
     updateObject(iUID, __GO_CHILDREN__);
@@ -235,6 +238,7 @@ void ScilabView::deleteObject(int iUID)
     deleteDataObject(iUID);
 
     m_pathList.erase(iUID);
+    m_userdata.erase(iUID);
 }
 
 void ScilabView::updateObject(int iUID, int iProperty)
@@ -666,6 +670,30 @@ std::string ScilabView::get_path(int uid)
     return path;
 }
 
+void ScilabView::setUserdata(int _id, int* _data, int _datasize)
+{
+    m_userdata[_id] = std::vector<int>(_data, _data + _datasize);
+}
+
+int ScilabView::getUserdataSize(int _id)
+{
+    return (int)m_userdata[_id].size();
+}
+
+int* ScilabView::getUserdata(int _id)
+{
+    std::vector<int> &vect = m_userdata[_id];
+    int size = (int)vect.size();
+
+    if (size != 0)
+    {
+        return &(vect[0]);
+    }
+
+    //empty userdata must be == NULL
+    return NULL;
+}
+
 /*
 ** Allocate static class variable.
 */
@@ -680,3 +708,4 @@ int ScilabView::m_figureModel;
 int ScilabView::m_axesModel;
 ScilabView::__pathList ScilabView::m_pathList = *new __pathList();
 ScilabView::__pathFigList ScilabView::m_pathFigList = *new __pathFigList();
+ScilabView::__userdata ScilabView::m_userdata = *new __userdata();
index 4095c56..30d1fe5 100644 (file)
@@ -22,6 +22,7 @@ extern "C"
 
 #include "CallGraphicController.hxx"
 #include "DataController.hxx"
+#include "ScilabView.hxx"
 
 using namespace org_scilab_modules_graphic_objects;
 
@@ -33,140 +34,156 @@ void getGraphicObjectProperty(int iUID, int _iName, _ReturnType_ _returnType, vo
         return;
     }
 
-    /* All the Data model properties have the DATA_MODEL prefix */
-    if (_iName == __GO_DATA_MODEL__
-            || _iName == __GO_DATA_MODEL_COORDINATES__
-            || _iName == __GO_DATA_MODEL_X__
-            || _iName == __GO_DATA_MODEL_Y__
-            || _iName == __GO_DATA_MODEL_Z__
-            || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_NUM_ELEMENTS__
-            || _iName == __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__
-            || _iName == __GO_DATA_MODEL_NUM_VERTICES_PER_GON__
-            || _iName == __GO_DATA_MODEL_NUM_GONS__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SET__
-            || _iName == __GO_DATA_MODEL_COLORS__
-            || _iName == __GO_DATA_MODEL_NUM_COLORS__
-            || _iName == __GO_DATA_MODEL_NUM_VERTICES__
-            || _iName == __GO_DATA_MODEL_NUM_INDICES__
-            || _iName == __GO_DATA_MODEL_INDICES__
-            || _iName == __GO_DATA_MODEL_VALUES__
-            || _iName == __GO_DATA_MODEL_FEC_TRIANGLES__
-            || _iName == __GO_DATA_MODEL_NUM_X__
-            || _iName == __GO_DATA_MODEL_NUM_Y__
-            || _iName == __GO_DATA_MODEL_NUM_Z__
-            || _iName == __GO_DATA_MODEL_GRID_SIZE__
-            || _iName == __GO_DATA_MODEL_X_DIMENSIONS__
-            || _iName == __GO_DATA_MODEL_Y_DIMENSIONS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_BOUNDS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_INFOS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_ORDER__
-            || _iName == __GO_DATA_MODEL_MATPLOT_GL_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__
-            || _iName == __GO_DATA_MODEL_MATPLOT_IMAGE_DATASIZE__
-            || _iName == __GO_DATA_MODEL_DISPLAY_FUNCTION__
-            || _iName == __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__
-       )
+    switch (_iName)
     {
-        DataController::getGraphicObjectProperty(iUID, _iName, _pvData);
-        return;
-    }
+        case __GO_USER_DATA__ :
+        {
+            *_pvData = ScilabView::getUserdata(iUID);
+            break;
+        }
+        case __GO_USER_DATA_SIZE__ :
+        {
+            ((int *)*_pvData)[0] = ScilabView::getUserdataSize(iUID);
+            break;
+        }
 
-    try
-    {
-        switch (_returnType)
+        /* All the Data model properties have the DATA_MODEL prefix */
+        case __GO_DATA_MODEL__ :
+        case __GO_DATA_MODEL_COORDINATES__ :
+        case __GO_DATA_MODEL_X__ :
+        case __GO_DATA_MODEL_Y__ :
+        case __GO_DATA_MODEL_Z__ :
+        case __GO_DATA_MODEL_X_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_Y_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_NUM_ELEMENTS__ :
+        case __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__ :
+        case __GO_DATA_MODEL_NUM_VERTICES_PER_GON__ :
+        case __GO_DATA_MODEL_NUM_GONS__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SET__ :
+        case __GO_DATA_MODEL_COLORS__ :
+        case __GO_DATA_MODEL_NUM_COLORS__ :
+        case __GO_DATA_MODEL_NUM_VERTICES__ :
+        case __GO_DATA_MODEL_NUM_INDICES__ :
+        case __GO_DATA_MODEL_INDICES__ :
+        case __GO_DATA_MODEL_VALUES__ :
+        case __GO_DATA_MODEL_FEC_TRIANGLES__ :
+        case __GO_DATA_MODEL_NUM_X__ :
+        case __GO_DATA_MODEL_NUM_Y__ :
+        case __GO_DATA_MODEL_NUM_Z__ :
+        case __GO_DATA_MODEL_GRID_SIZE__ :
+        case __GO_DATA_MODEL_X_DIMENSIONS__ :
+        case __GO_DATA_MODEL_Y_DIMENSIONS__ :
+        case __GO_DATA_MODEL_MATPLOT_BOUNDS__ :
+        case __GO_DATA_MODEL_MATPLOT_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_INFOS__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_ORDER__ :
+        case __GO_DATA_MODEL_MATPLOT_GL_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__ :
+        case __GO_DATA_MODEL_MATPLOT_IMAGE_DATASIZE__ :
+        case __GO_DATA_MODEL_DISPLAY_FUNCTION__ :
+        case __GO_DATA_MODEL_DISPLAY_FUNCTION_SIZE__ :
         {
-            case jni_string:
-            {
-                *(_pvData) = CallGraphicController::getGraphicObjectPropertyAsString(getScilabJavaVM(), iUID, _iName);
-                return;
-            }
-            case jni_string_vector:
-            {
-                *_pvData = CallGraphicController::getGraphicObjectPropertyAsStringVector(getScilabJavaVM(), iUID, _iName);
-                return;
-            }
-            case jni_double:
+            DataController::getGraphicObjectProperty(iUID, _iName, _pvData);
+            break;
+        }
+        default : //property in Java Model
+        {
+            try
             {
-                double * ret = CallGraphicController::getGraphicObjectPropertyAsDoubleVector(getScilabJavaVM(), iUID, _iName);
-                if (ret == NULL)
-                {
-                    *_pvData = NULL;
-                }
-                else
+                switch (_returnType)
                 {
-                    ((double *)*_pvData)[0] = *ret;
-                    delete[] ret;
-                }
+                    case jni_string:
+                    {
+                        *(_pvData) = CallGraphicController::getGraphicObjectPropertyAsString(getScilabJavaVM(), iUID, _iName);
+                        return;
+                    }
+                    case jni_string_vector:
+                    {
+                        *_pvData = CallGraphicController::getGraphicObjectPropertyAsStringVector(getScilabJavaVM(), iUID, _iName);
+                        return;
+                    }
+                    case jni_double:
+                    {
+                        double * ret = CallGraphicController::getGraphicObjectPropertyAsDoubleVector(getScilabJavaVM(), iUID, _iName);
+                        if (ret == NULL)
+                        {
+                            *_pvData = NULL;
+                        }
+                        else
+                        {
+                            ((double *)*_pvData)[0] = *ret;
+                            delete[] ret;
+                        }
 
-                return;
-            }
-            case jni_double_vector:
-            {
-                *_pvData = CallGraphicController::getGraphicObjectPropertyAsDoubleVector(getScilabJavaVM(), iUID, _iName);
-                return;
-            }
-            case jni_bool:
-            {
-                int * ret = CallGraphicController::getGraphicObjectPropertyAsBooleanVector(getScilabJavaVM(), iUID, _iName);
-                if (ret == NULL)
-                {
-                    *_pvData = NULL;
-                }
-                else
-                {
-                    ((int *)*_pvData)[0] = *ret;
-                    delete[] ret;
-                }
+                        return;
+                    }
+                    case jni_double_vector:
+                    {
+                        *_pvData = CallGraphicController::getGraphicObjectPropertyAsDoubleVector(getScilabJavaVM(), iUID, _iName);
+                        return;
+                    }
+                    case jni_bool:
+                    {
+                        int * ret = CallGraphicController::getGraphicObjectPropertyAsBooleanVector(getScilabJavaVM(), iUID, _iName);
+                        if (ret == NULL)
+                        {
+                            *_pvData = NULL;
+                        }
+                        else
+                        {
+                            ((int *)*_pvData)[0] = *ret;
+                            delete[] ret;
+                        }
 
-                return;
-            }
-            case jni_bool_vector:
-            {
-                *_pvData = CallGraphicController::getGraphicObjectPropertyAsBooleanVector(getScilabJavaVM(), iUID, _iName);
-                return;
-            }
-            case jni_int:
-            {
-                int * ret = CallGraphicController::getGraphicObjectPropertyAsIntegerVector(getScilabJavaVM(), iUID, _iName);
-                if (ret == NULL)
-                {
-                    *_pvData = NULL;
-                }
-                else
-                {
-                    ((int *)*_pvData)[0] = *ret;
-                    delete[] ret;
-                }
+                        return;
+                    }
+                    case jni_bool_vector:
+                    {
+                        *_pvData = CallGraphicController::getGraphicObjectPropertyAsBooleanVector(getScilabJavaVM(), iUID, _iName);
+                        return;
+                    }
+                    case jni_int:
+                    {
+                        int * ret = CallGraphicController::getGraphicObjectPropertyAsIntegerVector(getScilabJavaVM(), iUID, _iName);
+                        if (ret == NULL)
+                        {
+                            *_pvData = NULL;
+                        }
+                        else
+                        {
+                            ((int *)*_pvData)[0] = *ret;
+                            delete[] ret;
+                        }
 
-                return;
+                        return;
+                    }
+                    case jni_int_vector:
+                    {
+                        *_pvData = CallGraphicController::getGraphicObjectPropertyAsIntegerVector(getScilabJavaVM(), iUID, _iName);
+                        return;
+                    }
+                    default:
+                        *_pvData = NULL;
+                        return;
+                }
             }
-            case jni_int_vector:
+            catch (std::exception &e)
             {
-                *_pvData = CallGraphicController::getGraphicObjectPropertyAsIntegerVector(getScilabJavaVM(), iUID, _iName);
-                return;
-            }
-            default:
+                e.what();
+                // If we have an exception, return null to scilab to manage error.
                 *_pvData = NULL;
                 return;
+            }
         }
     }
-    catch (std::exception &e)
-    {
-        e.what();
-        // If we have an exception, return null to scilab to manage error.
-        *_pvData = NULL;
-        return;
-    }
 
+    return;
 }
 
 
index b7c9ea7..4847516 100644 (file)
@@ -22,6 +22,7 @@ extern "C"
 
 #include "CallGraphicController.hxx"
 #include "DataController.hxx"
+#include "ScilabView.hxx"
 
 using namespace org_scilab_modules_graphic_objects;
 
@@ -60,91 +61,97 @@ BOOL setGraphicObjectPropertyAndWarn(int _iID, int _iName, void const* _pvValue,
         return FALSE;
     }
 
-
-    // Special Case for data, no need to go through Java.
-    if (_iName == __GO_DATA_MODEL__
-            || _iName == __GO_DATA_MODEL_COORDINATES__
-            || _iName == __GO_DATA_MODEL_X__
-            || _iName == __GO_DATA_MODEL_Y__
-            || _iName == __GO_DATA_MODEL_Z__
-            || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT__
-            || _iName == __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__
-            || _iName == __GO_DATA_MODEL_NUM_ELEMENTS__
-            || _iName == __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__
-            || _iName == __GO_DATA_MODEL_NUM_VERTICES_PER_GON__
-            || _iName == __GO_DATA_MODEL_NUM_GONS__
-            || _iName == __GO_DATA_MODEL_Z_COORDINATES_SET__
-            || _iName == __GO_DATA_MODEL_COLORS__
-            || _iName == __GO_DATA_MODEL_NUM_COLORS__
-            || _iName == __GO_DATA_MODEL_NUM_VERTICES__
-            || _iName == __GO_DATA_MODEL_NUM_INDICES__
-            || _iName == __GO_DATA_MODEL_INDICES__
-            || _iName == __GO_DATA_MODEL_VALUES__
-            || _iName == __GO_DATA_MODEL_FEC_TRIANGLES__
-            || _iName == __GO_DATA_MODEL_NUM_X__
-            || _iName == __GO_DATA_MODEL_NUM_Y__
-            || _iName == __GO_DATA_MODEL_NUM_Z__
-            || _iName == __GO_DATA_MODEL_GRID_SIZE__
-            || _iName == __GO_DATA_MODEL_X_DIMENSIONS__
-            || _iName == __GO_DATA_MODEL_Y_DIMENSIONS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_BOUNDS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_INFOS__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_DATA_ORDER__
-            || _iName == __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__
-            || _iName == __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__
-            || _iName == __GO_DATA_MODEL_DISPLAY_FUNCTION__
-       )
+    switch (_iName)
     {
-        BOOL ret = DataController::setGraphicObjectProperty(_iID, _iName, _pvValue, numElements);
-        if ((ret || _iName == __GO_DATA_MODEL__) && warnJava)
+        case __GO_USER_DATA__ :
         {
-            ///printf("debug property value=%d\n",_iName);
-            CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, __GO_DATA_MODEL__, _iID);
+            ScilabView::setUserdata(_iID, (int*) _pvValue, numElements);
+            return TRUE;
+        }
+        case __GO_DATA_MODEL__ :
+        case __GO_DATA_MODEL_COORDINATES__  :
+        case __GO_DATA_MODEL_X__ :
+        case __GO_DATA_MODEL_Y__ :
+        case __GO_DATA_MODEL_Z__ :
+        case __GO_DATA_MODEL_X_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_Y_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SHIFT__ :
+        case __GO_DATA_MODEL_X_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_Y_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SHIFT_SET__ :
+        case __GO_DATA_MODEL_NUM_ELEMENTS__ :
+        case __GO_DATA_MODEL_NUM_ELEMENTS_ARRAY__ :
+        case __GO_DATA_MODEL_NUM_VERTICES_PER_GON__ :
+        case __GO_DATA_MODEL_NUM_GONS__ :
+        case __GO_DATA_MODEL_Z_COORDINATES_SET__ :
+        case __GO_DATA_MODEL_COLORS__ :
+        case __GO_DATA_MODEL_NUM_COLORS__ :
+        case __GO_DATA_MODEL_NUM_VERTICES__ :
+        case __GO_DATA_MODEL_NUM_INDICES__ :
+        case __GO_DATA_MODEL_INDICES__ :
+        case __GO_DATA_MODEL_VALUES__ :
+        case __GO_DATA_MODEL_FEC_TRIANGLES__ :
+        case __GO_DATA_MODEL_NUM_X__ :
+        case __GO_DATA_MODEL_NUM_Y__ :
+        case __GO_DATA_MODEL_NUM_Z__ :
+        case __GO_DATA_MODEL_GRID_SIZE__ :
+        case __GO_DATA_MODEL_X_DIMENSIONS__ :
+        case __GO_DATA_MODEL_Y_DIMENSIONS__ :
+        case __GO_DATA_MODEL_MATPLOT_BOUNDS__ :
+        case __GO_DATA_MODEL_MATPLOT_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_INFOS__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_DATA_ORDER__ :
+        case __GO_DATA_MODEL_MATPLOT_IMAGE_TYPE__ :
+        case __GO_DATA_MODEL_MATPLOT_IMAGE_DATA__ :
+        case __GO_DATA_MODEL_DISPLAY_FUNCTION__ :
+        {
+            BOOL res = DataController::setGraphicObjectProperty(_iID, _iName, _pvValue, numElements);
+            if ((res || _iName == __GO_DATA_MODEL__) && warnJava)
+            {
+                ///printf("debug property value=%d\n",_iName);
+                CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, __GO_DATA_MODEL__, _iID);
+            }
+            return res;
         }
-        return ret;
-    }
-
-    switch (_valueType)
-    {
-        case jni_string :
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (char *)_pvValue);
-            break;
-
-        case jni_string_vector :
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (char**)_pvValue, numElements);
-            break;
-        case jni_double :
-            doubleValue = *(double*)_pvValue;
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (double)doubleValue);
-            break;
-        case jni_double_vector :
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (double*)_pvValue, numElements);
-            break;
-        case jni_int :
-            intValue = *(int*)_pvValue;
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (int)intValue);
-            break;
-        case jni_int_vector :
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (int*)_pvValue, numElements);
-            break;
-        case jni_bool :
-            boolValue = *(BOOL*)_pvValue;
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, BOOLtobool(boolValue));
-            break;
-        case jni_bool_vector :
-            result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (bool*)_pvValue, numElements);
-            break;
         default :
-            /* Do Nothing */
-            break;
+        {
+            switch (_valueType)
+            {
+                case jni_string :
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (char *)_pvValue);
+                    break;
+
+                case jni_string_vector :
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (char**)_pvValue, numElements);
+                    break;
+                case jni_double :
+                    doubleValue = *(double*)_pvValue;
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (double)doubleValue);
+                    break;
+                case jni_double_vector :
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (double*)_pvValue, numElements);
+                    break;
+                case jni_int :
+                    intValue = *(int*)_pvValue;
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (int)intValue);
+                    break;
+                case jni_int_vector :
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (int*)_pvValue, numElements);
+                    break;
+                case jni_bool :
+                    boolValue = *(BOOL*)_pvValue;
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, BOOLtobool(boolValue));
+                    break;
+                case jni_bool_vector :
+                    result = CallGraphicController::setGraphicObjectProperty(getScilabJavaVM(), _iID, _iName, (bool*)_pvValue, numElements);
+                    break;
+                default :
+                    /* Do Nothing */
+                    break;
+            }
+        }
     }
-
     return booltoBOOL(result);
 }
 
index 4b48c70..e98f7a4 100644 (file)
@@ -21,7 +21,6 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHAMP__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN_COUNT__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SPINNER__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_COMPOUND__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP__;
@@ -65,11 +64,10 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SPINNER__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_USER_DATA_SIZE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_USER_DATA__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VALID__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_WAITBAR__;
@@ -108,7 +106,7 @@ public abstract class GraphicObject implements Cloneable {
                      };
 
     /** GraphicObject properties */
-    public enum GraphicObjectPropertyType { PARENT, CHILDREN, CHILDREN_COUNT, HIDDEN, VISIBLE, USERDATA, USERDATASIZE, TYPE, REFERENCED, VALID, DATA,
+    public enum GraphicObjectPropertyType { PARENT, CHILDREN, CHILDREN_COUNT, HIDDEN, VISIBLE, TYPE, REFERENCED, VALID, DATA,
                                             PARENT_FIGURE, PARENT_AXES, HASLEGENDCHILD, LEGENDCHILD, SELECTEDCHILD, TAG, CALLBACK, CALLBACKTYPE, UNKNOWNPROPERTY
                                           };
 
@@ -133,9 +131,6 @@ public abstract class GraphicObject implements Cloneable {
     /** Specifies if the "handle" is hidden, i.e not listed as children in Scilab view */
     private boolean hidden;
 
-    /** User data */
-    private Integer[] userData;
-
     /** Tag */
     private String tag;
 
@@ -156,7 +151,6 @@ public abstract class GraphicObject implements Cloneable {
         parent = 0;
         children = new LinkedList<Integer>();
         visible = true;
-        userData = null;
         valid = true;
         referenced = false;
         selectedChild = 0;
@@ -313,10 +307,6 @@ public abstract class GraphicObject implements Cloneable {
                 return GraphicObjectPropertyType.HIDDEN;
             case __GO_VISIBLE__ :
                 return GraphicObjectPropertyType.VISIBLE;
-            case __GO_USER_DATA__ :
-                return GraphicObjectPropertyType.USERDATA;
-            case __GO_USER_DATA_SIZE__ :
-                return GraphicObjectPropertyType.USERDATASIZE;
             case __GO_REFERENCED__ :
                 return GraphicObjectPropertyType.REFERENCED;
             case __GO_VALID__ :
@@ -371,10 +361,6 @@ public abstract class GraphicObject implements Cloneable {
                 return isHidden();
             case VISIBLE:
                 return getVisible();
-            case USERDATA:
-                return getUserData();
-            case USERDATASIZE:
-                return getUserDataSize();
             case PARENT_FIGURE:
                 return getParentFigure();
             case PARENT_AXES:
@@ -430,11 +416,6 @@ public abstract class GraphicObject implements Cloneable {
             case VISIBLE:
                 setVisible((Boolean) value);
                 break;
-            case USERDATA:
-                setUserData((Integer[]) value);
-                break;
-            case USERDATASIZE:
-                return UpdateStatus.Fail;
             case SELECTEDCHILD:
                 setSelectedChild((Integer) value);
                 break;
@@ -557,32 +538,6 @@ public abstract class GraphicObject implements Cloneable {
     }
 
     /**
-     * @return the userData
-     */
-    public Object getUserData() {
-        return userData;
-    }
-
-    /**
-     * @param userData the userData to set
-     * @return TODO
-     */
-    public UpdateStatus setUserData(Integer[] userData) {
-        this.userData = userData;
-        return UpdateStatus.Success;
-    }
-
-    /**
-     * @return the userDataSize
-     */
-    public Integer getUserDataSize() {
-        if (userData != null) {
-            return userData.length;
-        }
-        return 0;
-    }
-
-    /**
      * @return the tag
      */
     public String getTag() {
@@ -649,7 +604,7 @@ public abstract class GraphicObject implements Cloneable {
         if (getParent() != 0 && GraphicController.getController().getObjectFromId(getParent()) != null) {
             return GraphicController.getController().getObjectFromId(getParent()).getParentFigure();
         }
-        
+
         /* No parent Figure found */
         return 0;
     }
index 5e9d98d..47fe20c 100644 (file)
@@ -48,7 +48,6 @@ int get_user_data_property(void* _pvCtx, int iObjUID)
     else
     {
         status = sciReturnUserData(_pvCtx, piUserData, iUserDataSize);
-        free(piUserData);
     }
 
     return status;