Update save and load functions for datatip entity. 58/13158/2
Adeline CARNIS [Thu, 14 Nov 2013 14:53:49 +0000 (15:53 +0100)]
Change-Id: I980dd2435388ee398d61594e38c5cbe7c44afdda

scilab/modules/graphics/tests/unit_tests/save_load.dia.ref
scilab/modules/graphics/tests/unit_tests/save_load.tst
scilab/modules/graphics/tests/unit_tests/save_load_v5.dia.ref
scilab/modules/graphics/tests/unit_tests/save_load_v5.tst
scilab/modules/io/macros/%_save.sci
scilab/modules/io/macros/%_sodload.sci

index f2e90a1..7d18fd4 100644 (file)
@@ -255,3 +255,21 @@ save(plotExportFile, "f");
 delete(f);
 // reload data
 load(plotExportFile);
+// datatip test
+x=linspace(0,1,9)';
+y=x.^3;
+clf();
+plot(x,y);
+e=gce();p=e.children(1);//get the handle on the polyline
+p.mark_mode="on";p.mark_style=2;p.mark_size=12;
+t=datatipCreate(p,5);
+// save the curves
+f = gcf();
+save(plotExportFile, "f");
+// close window
+delete(f);
+// reload data
+load(plotExportFile);
+e = gce();
+e = e.children(1);
+assert_checkequal(e.datatips.tip_data, [0.5, 0.125, 0]);
index f05b7d0..5b2f2d9 100644 (file)
@@ -292,3 +292,25 @@ save(plotExportFile, "f");
 delete(f);
 // reload data
 load(plotExportFile);
+
+
+// datatip test
+x=linspace(0,1,9)';
+y=x.^3;
+clf();
+plot(x,y);
+e=gce();p=e.children(1);//get the handle on the polyline
+p.mark_mode="on";p.mark_style=2;p.mark_size=12;
+t=datatipCreate(p,5);
+
+// save the curves
+f = gcf();
+save(plotExportFile, "f");
+// close window
+delete(f);
+// reload data
+load(plotExportFile);
+
+e = gce();
+e = e.children(1);
+assert_checkequal(e.datatips.tip_data, [0.5, 0.125, 0]);
index 2623e13..1e5b7da 100644 (file)
@@ -28,11 +28,11 @@ load(plotExportFile);
 axes = gca();
 // check axes properties
 surf1 = axes.children(1);
-if (surf1.clip_box <> [1, 2, 3, 4]) then bugmes();quit;end
-if (surf1.clip_state <> "on") then bugmes();quit;end
+assert_checkequal(surf1.clip_box, [1, 2, 3, 4]);
+assert_checkequal(surf1.clip_state, "on");
 surf2 = axes.children(2);
-if (surf2.clip_box <> []) then bugmes();quit;end
-if (surf2.clip_state <> "clipgrf") then bugmes();quit;end
+assert_checkequal(surf2.clip_box, []);
+assert_checkequal(surf2.clip_state, "clipgrf");
 // same for grayplot
 clf();
 x = 0:10;
@@ -110,3 +110,21 @@ if (surf1.clip_state <> "on") then bugmes();quit;end
 surf2 = axes.children(2).children(1);
 if (surf2.clip_box <> []) then bugmes();quit;end
 if (surf2.clip_state <> "clipgrf") then bugmes();quit;end
+// datatip test
+x=linspace(0,1,9)';
+y=x.^3;
+clf();
+plot(x,y);
+e=gce();p=e.children(1);//get the handle on the polyline
+p.mark_mode="on";p.mark_style=2;p.mark_size=12;
+t=datatipCreate(p,5);
+// save the curves
+f = gcf();
+save(plotExportFile, "f");
+// close window
+delete(f);
+// reload data
+load(plotExportFile);
+e = gce();
+e = e.children(1);
+assert_checkequal(e.datatips.tip_data, [0.5, 0.125, 0]);
index 8b0af02..ea25962 100644 (file)
@@ -36,11 +36,11 @@ axes = gca();
 
 // check axes properties
 surf1 = axes.children(1);
-if (surf1.clip_box <> [1, 2, 3, 4]) then pause; end
-if (surf1.clip_state <> "on") then pause; end
+assert_checkequal(surf1.clip_box, [1, 2, 3, 4]);
+assert_checkequal(surf1.clip_state, "on");
 surf2 = axes.children(2);
-if (surf2.clip_box <> []) then pause; end
-if (surf2.clip_state <> "clipgrf") then pause; end
+assert_checkequal(surf2.clip_box, []);
+assert_checkequal(surf2.clip_state, "clipgrf");
 
 // same for grayplot
 clf();
@@ -135,4 +135,23 @@ surf2 = axes.children(2).children(1);
 if (surf2.clip_box <> []) then pause; end
 if (surf2.clip_state <> "clipgrf") then pause; end
 
+// datatip test
+x=linspace(0,1,9)';
+y=x.^3;
+clf();
+plot(x,y);
+e=gce();p=e.children(1);//get the handle on the polyline
+p.mark_mode="on";p.mark_style=2;p.mark_size=12;
+t=datatipCreate(p,5);
+
+// save the curves
+f = gcf();
+save(plotExportFile, "f");
+// close window
+delete(f);
+// reload data
+load(plotExportFile);
 
+e = gce();
+e = e.children(1);
+assert_checkequal(e.datatips.tip_data, [0.5, 0.125, 0]);
index ad209de..116b58c 100644 (file)
@@ -328,6 +328,7 @@ function [] = %_save(%__filename__, varargin)
         "ScilabSingleHandle", ...
         "type", ...
         "visible", ...
+        "datatips", ...
         "data", ...
         "closed", ...
         "line_mode", ...
@@ -357,7 +358,7 @@ function [] = %_save(%__filename__, varargin)
         fields = fieldnames(returnedPolyline);
 
         for %__i__ = 1:size(fields, "*")
-            if fields(%__i__) == "children" then
+            if or(fields(%__i__) == ["children", "datatips"]) then
                 returnedPolyline(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__)));
             else
                 returnedPolyline(fields(%__i__)) = h(fields(%__i__));
@@ -712,31 +713,25 @@ function [] = %_save(%__filename__, varargin)
         "ScilabSingleHandle", ...
         "type", ...
         "visible", ...
-        "text", ...
-        "text_box", ...
-        "text_box_mode", ...
-        "foreground", ...
-        "font_style", ...
-        "font_size", ...
-        "font_angle", ...
-        "line_mode", ...
-        "fill_mode", ...
+        "tip_data", ...
+        "tip_box_mode", ...
+        "tip_label_mode", ...
+        "tip_orientation", ...
+        "tip_3component", ...
+        "tip_auto_orientation", ...
+        "tip_interp_mode", ...
+        "tip_disp_function", ...
         "font_foreground", ...
+        "foreground", ...
         "background", ...
-        "alignment", ...
-        "fractional_font", ...
-        "clip_state", ...
-        "clip_box", ...
         "mark_mode", ...
         "mark_style", ...
-        "mark_size", ...
         "mark_size_unit", ...
+        "mark_size", ...
         "mark_foreground", ...
         "mark_background", ...
-        "tip_data", ...
-        "tip_orientation", ...
-        "tip_auto_orientation", ...
-        "user_data"]);
+        "user_data", ...
+        ]);
 
         fields = fieldnames(returnedDatatip);
 
index 6a6a810..e44b7bd 100644 (file)
@@ -356,6 +356,8 @@ function %_sodload(%__filename__, varargin)
                 set(h, "mark_mode", mark_mode);
             elseif fields(i) == "children" then
                 createMatrixHandle(polylineProperties(fields(i)));
+            elseif fields(i) == "datatips" then
+                createMatrixHandle(polylineProperties(fields(i)));
             else
                 h(fields(i)) = polylineProperties(fields(i));
             end
@@ -696,13 +698,6 @@ function %_sodload(%__filename__, varargin)
 
         h = datatipCreate(%POLYLINE, 0);
 
-        if datatipProperties.clip_state=="on" then
-            set(h, "clip_box", datatipProperties.clip_box)
-        end
-        set(h, "clip_state", datatipProperties.clip_state);
-        fields(fields=="clip_box") = [];
-        fields(fields=="clip_state") = [];
-
         for i = 1:size(fields, "*")
             set(h, fields(i), datatipProperties(fields(i)));
         end