Do not recreate default axes on deletion. 09/14109/2
Bruno JOFRET [Mon, 24 Mar 2014 11:17:56 +0000 (12:17 +0100)]
Change-Id: I2acd4ced0ec15fa3f5417a1308286620df0606a9

scilab/modules/graphics/sci_gateway/c/sci_delete.c
scilab/modules/gui/tests/unit_tests/figure.dia.ref
scilab/modules/gui/tests/unit_tests/figure.tst

index 5c59604..bf0e368 100644 (file)
@@ -274,9 +274,13 @@ int sci_delete(char *fname, unsigned long fname_len)
             int iChildType = -1;
             int *piChildType = &iChildType;
             int iAxesFound = 0;
+            int iDefaultAxes = -1;
+            int *piDefaultAxes = &iDefaultAxes;
 
             getGraphicObjectProperty(iParentUID, __GO_CHILDREN_COUNT__, jni_int, (void **)&piChildCount);
             getGraphicObjectProperty(iParentUID, __GO_CHILDREN__, jni_int_vector, (void **)&piChildrenUID);
+            getGraphicObjectProperty(iParentUID, __GO_DEFAULT_AXES__, jni_bool, (void **)&piDefaultAxes);
+
             for (iChild = 0; iChild < iChildCount; iChild++)
             {
                 getGraphicObjectProperty(piChildrenUID[iChild], __GO_TYPE__, jni_int, (void **)&piChildType);
@@ -290,8 +294,9 @@ int sci_delete(char *fname, unsigned long fname_len)
                     break;
                 }
             }
-            if (!iAxesFound)
+            if (!iAxesFound && iDefaultAxes != 0)
             {
+
                 /*
                  * Clone a new Axes object using the Axes model which is then
                  * attached to the newly created Figure.
index fa600d9..7f5cb10 100644 (file)
@@ -33,3 +33,28 @@ assert_checkequal(a.filled, "off");
 assert_checkequal(size(f.color_map), [34, 3]);
 assert_checkequal(f.color_map(34,:), [0.5 0.2 0.6]);
 delete(f);
+// Figure without axes
+f = figure("default_axes", "off");
+assert_checkequal(f.children, []);
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children, []);
+delete(f);
+// Figure with axes
+f = figure();
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children(1).type, "Axes");
+f.default_axes = "off";
+delete(f.children(1));
+assert_checkequal(f.children, []);
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children, []);
+f.default_axes = "on";
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children(1).type, "Axes");
index 2853a19..ee8b5a7 100644 (file)
@@ -39,3 +39,29 @@ assert_checkequal(size(f.color_map), [34, 3]);
 assert_checkequal(f.color_map(34,:), [0.5 0.2 0.6]);
 delete(f);
 
+// Figure without axes
+f = figure("default_axes", "off");
+assert_checkequal(f.children, []);
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children, []);
+delete(f);
+
+// Figure with axes
+f = figure();
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children(1).type, "Axes");
+f.default_axes = "off";
+delete(f.children(1));
+assert_checkequal(f.children, []);
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children, []);
+f.default_axes = "on";
+newaxes(f);
+assert_checkequal(f.children(1).type, "Axes");
+delete(f.children(1));
+assert_checkequal(f.children(1).type, "Axes");
\ No newline at end of file