Enable drawlater/drawnow for Frame containing Axes. 80/14280/3
Bruno JOFRET [Tue, 1 Apr 2014 14:50:01 +0000 (16:50 +0200)]
Change-Id: Ia648e6e235e9d787220cacc1b28d869bee6c1f78

scilab/modules/graphics/sci_gateway/c/sci_drawlater.c
scilab/modules/graphics/sci_gateway/c/sci_drawnow.c
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java

index 77ef3ad..0bde9ef 100644 (file)
 int sci_drawlater(char * fname, unsigned long fname_len)
 {
     int iFalse =  (int)FALSE;
-    int iFigureUID = 0;
-    int* piFigureUID = &iFigureUID;
+    int iParentFigureUID = 0;
+    int* piParentFigureUID = &iParentFigureUID;
     int iSubwinUID = 0;
+    int iCurChildUID = 0;
+    int iType = -1;
+    int *piType = &iType;
 
     CheckInputArgument(pvApiCtx, 0, 0);
     CheckOutputArgument(pvApiCtx, 0, 1);
@@ -42,10 +45,19 @@ int sci_drawlater(char * fname, unsigned long fname_len)
         iSubwinUID = getOrCreateDefaultSubwin();
         if (iSubwinUID != 0)
         {
-            iFigureUID = getParentObject(iSubwinUID);
-            if (iFigureUID != 0)
+            // Look for top level figure
+            iCurChildUID = iSubwinUID;
+            do
             {
-                setGraphicObjectProperty(iFigureUID, __GO_IMMEDIATE_DRAWING__, &iFalse, jni_bool, 1);
+                iParentFigureUID = getParentObject(iCurChildUID);
+                getGraphicObjectProperty(iParentFigureUID, __GO_TYPE__, jni_int, (void **)&piType);
+                iCurChildUID = iParentFigureUID;
+            }
+            while (iParentFigureUID != 0 && iType != __GO_FIGURE__);
+
+            if (iParentFigureUID != 0)
+            {
+                setGraphicObjectProperty(iParentFigureUID, __GO_IMMEDIATE_DRAWING__, &iFalse, jni_bool, 1);
             }
         }
     }
index 0ea82d3..8baa5b9 100644 (file)
 int sci_drawnow(char *fname, unsigned long fname_len)
 {
     int iTrue = (int)TRUE;
-    int iFigureUID = 0;
-    int* piFigureUID = &iFigureUID;
+    int iParentFigureUID = 0;
+    int* piParentFigureUID = &iParentFigureUID;
     int iSubwinUID = 0;
+    int iCurChildUID = 0;
+    int iType = -1;
+    int *piType = &iType;
 
     CheckInputArgument(pvApiCtx, 0, 0);
     CheckOutputArgument(pvApiCtx, 0, 1);
@@ -40,10 +43,19 @@ int sci_drawnow(char *fname, unsigned long fname_len)
         iSubwinUID = getOrCreateDefaultSubwin();
         if (iSubwinUID != 0)
         {
-            iFigureUID = getParentObject(iSubwinUID);
-            if (iFigureUID != 0)
+            // Look for top level figure
+            iCurChildUID = iSubwinUID;
+            do
             {
-                setGraphicObjectProperty(iFigureUID, __GO_IMMEDIATE_DRAWING__, &iTrue, jni_bool, 1);
+                iParentFigureUID = getParentObject(iCurChildUID);
+                getGraphicObjectProperty(iParentFigureUID, __GO_TYPE__, jni_int, (void **)&piType);
+                iCurChildUID = iParentFigureUID;
+            }
+            while (iParentFigureUID != 0 && iType != __GO_FIGURE__);
+
+            if (iParentFigureUID != 0)
+            {
+                setGraphicObjectProperty(iParentFigureUID, __GO_IMMEDIATE_DRAWING__, &iTrue, jni_bool, 1);
             }
         }
     }
index 6558bcd..449b79b 100755 (executable)
@@ -965,6 +965,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                 openGLChildren.put(id, updatedOpenGLChildren);
             }
         }
+        
         try {
             if (needUpdate(id, property)) {
                 if (GraphicObjectProperties.__GO_COLORMAP__ == property) {
@@ -995,13 +996,13 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
 
                 Figure parentFigure = (Figure) GraphicController.getController().getObjectFromId(figure.getParentFigure());
                 if (figure.getVisible() && parentFigure != null && parentFigure.getVisible()) {
-                    if (figure instanceof Frame || isImmediateDrawing(id)) {
-                        if (figure instanceof Frame || GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__ == property) {
+                    if (isImmediateDrawing(id)) {
+                        if (GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__ == property) {
                             canvas.redrawAndWait();
                         } else {
                             canvas.redraw();
                         }
-                    }
+                    } 
                 }
             }
 
@@ -1108,8 +1109,9 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
 
             return true;
         }
-        // Special case if top level figure colormap has been updated, force redraw
-        if (property == GraphicObjectProperties.__GO_COLORMAP__  && id.intValue() == figure.getParentFigure().intValue()) {
+        // Special case if top level figure colormap/immediate_drawing has been updated, force redraw
+        if ((property == GraphicObjectProperties.__GO_COLORMAP__ ||  property == GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__) 
+                && id.intValue() == figure.getParentFigure().intValue()) {
             return true;
         }
         return false;
@@ -1117,7 +1119,10 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
 
     private boolean isImmediateDrawing(Integer id) {
         Integer parentId = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PARENT_FIGURE__);
-        if (parentId == null || !parentId.equals(figure.getIdentifier())) {
+        if (figure instanceof Frame) {
+            parentId = figure.getParentFigure();
+        }
+        if (figure instanceof Figure && (parentId == null || !parentId.equals(figure.getIdentifier()))) {
             return false;
         } else {
             Boolean b =  (Boolean) GraphicController.getController().getProperty(parentId, GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__);