Graphics: avoid useless redraw 92/10492/3
Calixte DENIZET [Fri, 15 Feb 2013 13:31:24 +0000 (14:31 +0100)]
Change-Id: Ie1d1a8ea2fee13d842ea4caa711b17ac5949eabe

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicController/GraphicController.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java

index 6ad8f86..a0b48d5 100644 (file)
@@ -191,7 +191,7 @@ public class GraphicController {
      * @return the created object's id
      */
     public String askObject(Type type) {
-        
+
         try {
             UID id = createUID();
             GraphicModel.getModel().createObject(id.toString(), type);
@@ -365,7 +365,7 @@ public class GraphicController {
             objectUpdate(parentId, GraphicObjectProperties.__GO_CHILDREN__);
         }
 
-       // Useless (already done in setProperty(childId, GraphicObjectProperties.__GO_PARENT__, parentId);)
+        // Useless (already done in setProperty(childId, GraphicObjectProperties.__GO_PARENT__, parentId);)
         //objectUpdate(childId, GraphicObjectProperties.__GO_PARENT__);
     }
 
@@ -389,6 +389,7 @@ public class GraphicController {
             //objectUpdate(id, GraphicObjectProperties.__GO_PARENT__);
         }
 
+        killMe.setValid(false);
         recursiveDeleteChildren(killMe);
 
         deleteObject(id);
@@ -398,7 +399,9 @@ public class GraphicController {
         String children[] = killMe.getChildren();
 
         for (int i = 0 ; i < children.length ; ++i) {
-            recursiveDeleteChildren(getObjectFromId(children[i]));
+            GraphicObject killMeThisChild = getObjectFromId(children[i]);
+            killMeThisChild.setValid(false);
+            recursiveDeleteChildren(killMeThisChild);
             deleteObject(children[i]);
         }
     }
index db61a49..795b3f1 100644 (file)
@@ -375,7 +375,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
             colorMap = figure.getColorMap();
             drawingTools.clear(ColorFactory.createColor(colorMap, figure.getBackground()));
             drawingTools.clearDepthBuffer();
-            if (figure.getVisible() && figure.getImmediateDrawing()) {
+            if (figure.isValid() && figure.getVisible() && figure.getImmediateDrawing()) {
                 askAcceptVisitor(figure.getChildren());
             }
         }
@@ -917,7 +917,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
 
     private boolean isImmediateDrawing(String id) {
         String parentId = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PARENT_FIGURE__);
-        if (parentId == null) {
+        if (parentId == null || !parentId.equals(figure.getIdentifier())) {
             return false;
         } else {
             Boolean b =  (Boolean) GraphicController.getController().getProperty(parentId, GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__);
@@ -934,7 +934,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         if (isImmediateDrawing(id)) {
             canvas.redraw();
         }
-        
+
         dataManager.dispose(id);
         markManager.dispose(id);
         textManager.dispose(id);
@@ -942,7 +942,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         axesDrawer.dispose(id);
         legendDrawer.dispose(id);
         fecDrawer.dispose(id);
-        textureManager.dispose(id); 
+        textureManager.dispose(id);
         /*
          * Check we are deleting Figure managed by DrawerVisitor(this)
          * Otherwise do nothing on deletion.
@@ -950,6 +950,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         if (!figure.getIdentifier().equals(id)) {
             return;
         }
+
         visitorMap.remove(id);
         GraphicController.getController().unregister(this);
         if (SwingUtilities.isEventDispatchThread()) {
@@ -957,10 +958,10 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         } else {
             try {
                 SwingUtilities.invokeAndWait(new Runnable() {
-                    public void run() {
-                        canvas.destroy();
-                    }
-                });
+                        public void run() {
+                            canvas.destroy();
+                        }
+                    });
             } catch (Exception e) { }
         }
     }