copy of axes must create a new axes 56/17156/3
Antoine ELIAS [Thu, 3 Sep 2015 15:44:28 +0000 (17:44 +0200)]
Change-Id: I270f4b7f5ba1560edc47474b1159b5a4cf37289a

scilab/modules/graphic_objects/src/nographic_objects/nographic_objects.c
scilab/modules/hdf5/sci_gateway/cpp/sci_hdf5_load_v3.cpp
scilab/modules/hdf5/src/cpp/handle_properties.cpp
scilab/modules/hdf5/src/cpp/handle_properties.hxx

index 15d72fd..dfda14c 100644 (file)
@@ -113,4 +113,14 @@ int getValidDefaultFigureId(void)
 {
     return 0;
 }
+
+int getCurrentFigure(void)
+{
+    return 0;
+}
+
+int createSubWin(int iParent)
+{
+    return 0;
+}
 /*--------------------------------------------------------------------------*/
index d45394c..50470fe 100644 (file)
@@ -925,18 +925,33 @@ static types::InternalType* import_handles(int dataset)
     int refs = getDataSetIdFromName(dataset, "__refs__");
     types::GraphicHandle* handles = new types::GraphicHandle(static_cast<int>(pdims.size()), pdims.data());
     long long* h = handles->get();
-    for (int i = 0; i < size; ++i)
+
+    if (size == 1)
     {
-        int ref = getDataSetIdFromName(refs, std::to_string(i).data());
-        int val = import_handle(ref, -1);
+        //%h_copy
+        int ref = getDataSetIdFromName(refs, std::to_string(0).data());
+        int val = add_current_entity(ref);
         if (val < 0)
         {
             return nullptr;
         }
 
-        h[i] = getHandle(val);
+        h[0] = getHandle(val);
     }
+    else
+    {
+        for (int i = 0; i < size; ++i)
+        {
+            int ref = getDataSetIdFromName(refs, std::to_string(i).data());
+            int val = import_handle(ref, -1);
+            if (val < 0)
+            {
+                return nullptr;
+            }
 
+            h[i] = getHandle(val);
+        }
+    }
     closeList6(refs);
     closeList6(dataset);
 
@@ -951,8 +966,8 @@ static types::InternalType* import_handles(int dataset)
             update_link_path(i, paths);
         }
     }
-    return handles;
 
+    return handles;
 }
 
 static types::InternalType* import_macro(int dataset)
index 638e23a..a8b2ff9 100644 (file)
@@ -25,8 +25,10 @@ extern "C"
 #include "graphicObjectProperties.h"
 #include "createGraphicObject.h"
 #include "FigureList.h"
+#include "CurrentFigure.h"
 #include "BuildObjects.h"
 #include "Matplot.h"
+#include "HandleManagement.h"
 }
 
 extern types::InternalType* import_data(int dataset);
@@ -1483,7 +1485,7 @@ static int import_handle_axes(int dataset, int parent)
 {
     //how to manage call by %h_copy ?
 
-    int axes = getOrCreateDefaultSubwin();
+    int axes = createSubWin(parent);
 
     //hide current axes
     int visible = 0;
@@ -3328,3 +3330,27 @@ static bool export_handle_children(int parent, int uid)
     closeList6(node);
     return true;
 }
+
+int add_current_entity(int dataset)
+{
+    int type = 0;
+    getHandleInt(dataset, "type", &type);
+
+    switch (type)
+    {
+        case __GO_FIGURE__:
+            return import_handle(dataset, -1);
+            break;
+        case __GO_AXES__:
+        {
+            //add handle to current figure
+            getOrCreateDefaultSubwin();
+            int iCurrentFigure = getCurrentFigure();
+            return import_handle(dataset, iCurrentFigure);
+            break;
+        }
+        default:
+            //add handle as child of current axes ( take care of compound ! )
+            return -1;
+    }
+}
index 8467421..11c1f81 100644 (file)
@@ -833,3 +833,4 @@ struct UicontrolHandle
 void update_link_path(int legend, Links::PathList& paths);
 int import_handle(int dataset, int parent);
 bool export_handle(int parent, const std::string& name, int uid);
+int add_current_entity(int handle);