Hi all,

I'd like to hear some comments about how to fix the rubberband relics 
when zooming while drawing.

All zooming/paning actions have the following actions:
* Save the current rubberband points (SCREENtoWORLD ...)
    at the moment only start_x/y and last_x/y (second_x/y is missing)
* recalc the drawing area
* redraw all objects
* recalc the saved points (WORLDtoSCREEN ...)
* the redraw of the rubberbands  << missing code

At the moment the redraw of the rubberbands are missing.
With the next mouse-move-event a XOR-PUT to the (not existing) 
rubberbands are made and the new rubberbands are drawn.

The XOR-PUT of not existing rubberbands causes the rubberband relics.


I guess that implementing the redraw of the missing rubberbands is not 
that easy. 
Instead implementing the statment "there are no rubberbands" would be 
easier. Just set every variable of the rubberband to it's "start" 
value.
The "start" values are those that are in the object draw start 
functions.

For the net it would be: (o_net_start()):
  last_x=second_x=start_x;
  ...

The circle needs: (o_circle_start()):
  last_x=start_x;
  distance=0;
  ...

Ok. Now the length of all rubberbands are zero and there are no 
rubberbands on the screen.
With the next mouse-move-event the rubberbands are redrawn and 
everything is fine.

What do you think about the concept?
Do you expect bad side effects?

The attached patch works for net objects, boxes and circles. 
zoomin and zoomout works. 

For other zooming/paning actions and objects the code doesn't work that 
well. There are a lot of places where minor changes are required to 
make zoom-while-drawing work completely. Tracking them will take a 
while.


Patch is against current CVS.

Regards
Werner


[1] rubberband points from st_toplevel
  int start_x;
  int start_y;
  int save_x;
  int save_y;
  int last_x;
  int last_y;
  int second_x;
  int second_y;
  int loc_x, loc_y;
  int distance;
? draw_while_zooming.diff
? gschem.log
? gschemrc
? xx.diff
? zoom_while_drawing.diff
? po/gschem.log
? src/GPATH
? src/GRTAGS
? src/GSYMS
? src/GTAGS
? src/HTML
? src/a_pan.c.old_pan_mouse
? src/o_net.c.ch
? src/o_net.c.diff
? tests/gschem.log
Index: noweb/a_pan.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/a_pan.nw,v
retrieving revision 1.7
diff -u -r1.7 a_pan.nw
--- noweb/a_pan.nw	9 Apr 2006 08:11:36 -0000	1.7
+++ noweb/a_pan.nw	11 Apr 2006 18:49:00 -0000
@@ -215,7 +215,7 @@
 void
 a_pan(TOPLEVEL *w_current, int x, int y)
 {
-  int sx, sy, lx, ly;
+  int start_x, start_y, save_x, save_y, last_x, last_y, second_x, second_y;
   double world_cx, world_cy;
 #if DEBUG
   printf("a_pan(): x=%d, y=%d\n", x, y);
@@ -226,16 +226,22 @@
   if (w_current->inside_action) {
     SCREENtoWORLD(w_current,
 		  w_current->start_x, w_current->start_y,
-		  &sx, &sy);
-    SCREENtoWORLD(w_current,
+		  &start_x, &start_y);
+/*    SCREENtoWORLD(w_current,
 		  w_current->last_x, w_current->last_y,
-		  &lx, &ly);
+		  &last_x, &last_y);
+    SCREENtoWORLD(w_current,
+		  w_current->save_x, w_current->save_y,
+		  &save_x, &save_y);
+    SCREENtoWORLD(w_current,
+		  w_current->second_x, w_current->second_y,
+		  &second_x, &second_y); */
     
 #if 0
-    printf("BEGIN: start x %d -> %d \n", w_current->start_x, sx);
-    printf("BEGIN: start y %d -> %d \n", w_current->start_y, sy);
-    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , lx);
-    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , ly);
+    printf("BEGIN: start x %d -> %d \n", w_current->start_x, start_x);
+    printf("BEGIN: start y %d -> %d \n", w_current->start_y, start_y);
+    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , last_x);
+    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , last_y);
 #endif
   }
 
@@ -247,19 +253,40 @@
 
   a_pan_general(w_current, world_cx, world_cy, 1, 0);
 
+
   /* convert world coords back to screen coords */
   if (w_current->inside_action) {
     WORLDtoSCREEN(w_current,
-		  sx, sy,
+		  start_x, start_y,
 		  &(w_current->start_x), &(w_current->start_y));
+/*    WORLDtoSCREEN(w_current,
+		  last_x, last_y,
+		  &(w_current->last_x), &(w_current->last_y));
+    WORLDtoSCREEN(w_current,
+		  save_x, save_y,
+		  &(w_current->save_x), &(w_current->save_y));
     WORLDtoSCREEN(w_current,
-		  lx, ly,
+		  second_x, second_y,
+		  &(w_current->second_x), &(w_current->second_y)); */
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
 		  &(w_current->last_x), &(w_current->last_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->save_x), &(w_current->save_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->second_x), &(w_current->second_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->loc_x), &(w_current->loc_y));
+    w_current->distance=0;
+
 #if 0
-    printf("END:   start x %d <- %d \n", sx, w_current->start_x);
-    printf("END:   start y %d <- %d \n", sy, w_current->start_y);
-    printf("END:   last  x %d <- %d \n", lx, w_current->last_x );
-    printf("END:   last  y %d <- %d \n", ly, w_current->last_y );
+    printf("END:   start x %d <- %d \n", start_x, w_current->start_x);
+    printf("END:   start y %d <- %d \n", start_y, w_current->start_y);
+    printf("END:   last  x %d <- %d \n", last_x, w_current->last_x );
+    printf("END:   last  y %d <- %d \n", last_y, w_current->last_y );
 #endif
   }
   /* not needed */
Index: noweb/a_zoom.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/a_zoom.nw,v
retrieving revision 1.9
diff -u -r1.9 a_zoom.nw
--- noweb/a_zoom.nw	9 Apr 2006 08:11:36 -0000	1.9
+++ noweb/a_zoom.nw	11 Apr 2006 18:49:01 -0000
@@ -116,8 +116,7 @@
 a_zoom(TOPLEVEL *w_current, int dir, int selected_from, int pan_flags)
 {
   double world_pan_center_x,world_pan_center_y,relativ_zoom_factor = - 1;
-  int sx, sy;
-  int lx, ly;
+  int start_x, start_y, save_x, save_y, last_x, last_y, second_x, second_y;
 
   /* check to see if we are inside an action draw net, etc.  If
    * yes, convert screen coords to world coords */
@@ -125,24 +124,25 @@
    * in the SRCEENtoWORLD and WORLDtoSCREEN function (wh)*/
   if (w_current->inside_action) {
     SCREENtoWORLD(w_current,
-                  w_current->start_x,
-                  w_current->start_y,
-                  &sx, &sy);
+		  w_current->start_x, w_current->start_y,
+		  &start_x, &start_y);
+/*    SCREENtoWORLD(w_current,
+		  w_current->last_x, w_current->last_y,
+		  &last_x, &last_y);
     SCREENtoWORLD(w_current,
-                  w_current->last_x,
-                  w_current->last_y,
-                  &lx, &ly);
+		  w_current->save_x, w_current->save_y,
+		  &save_x, &save_y);
+    SCREENtoWORLD(w_current,
+		  w_current->second_x, w_current->second_y,
+		  &second_x, &second_y); */
+
 #if DEBUG
     printf("a_zoom: Inside an action\n");
-    printf("BEGIN: start x %d -> %d \n", w_current->start_x, sx);
-    printf("BEGIN: start y %d -> %d \n", w_current->start_y, sy);
-    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , lx);
-    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , ly);
-#endif
-    w_current->start_x = sx;
-    w_current->start_y = sy;
-    w_current->last_x  = lx;
-    w_current->last_y  = ly;
+    printf("BEGIN: start x %d -> %d \n", w_current->start_x, start_x);
+    printf("BEGIN: start y %d -> %d \n", w_current->start_y, start_y);
+    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , last_x);
+    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , last_y);
+#endif
   }
 	
 	
@@ -192,31 +192,46 @@
   /* convert things back to screen coords*/
   if (w_current->inside_action) {
     WORLDtoSCREEN(w_current,
-                  w_current->start_x,
-                  w_current->start_y,
-                  &sx, &sy);
+		  start_x, start_y,
+		  &(w_current->start_x), &(w_current->start_y));
+/*    WORLDtoSCREEN(w_current,
+		  last_x, last_y,
+		  &(w_current->last_x), &(w_current->last_y));
+    WORLDtoSCREEN(w_current,
+		  save_x, save_y,
+		  &(w_current->save_x), &(w_current->save_y));
+    WORLDtoSCREEN(w_current,
+		  second_x, second_y,
+		  &(w_current->second_x), &(w_current->second_y)); */
     WORLDtoSCREEN(w_current,
-                  w_current->last_x,
-                  w_current->last_y,
-                  &lx, &ly);
+		  start_x, start_y,
+		  &(w_current->last_x), &(w_current->last_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->save_x), &(w_current->save_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->second_x), &(w_current->second_y));
+    WORLDtoSCREEN(w_current,
+		  start_x, start_y,
+		  &(w_current->loc_x), &(w_current->loc_y));
+    w_current->distance=0;
+
 #if DEBUG
     printf("END: current factor = %d\n", w_current->page_current
            ->zoom_factor);
-    printf("END:   start x %d <- %d \n", sx, w_current->start_x);
-    printf("END:   start y %d <- %d \n", sy, w_current->start_y);
-    printf("END:   last  x %d <- %d \n", lx, w_current->last_x);
-    printf("END:   last  y %d <- %d \n", ly, w_current->last_y);
-#endif
-    w_current->start_x = sx;
-    w_current->start_y = sy;
-    w_current->last_x = lx;
-    w_current->last_y = ly;
+    printf("END:   start x %d <- %d \n", start_x, w_current->start_x);
+    printf("END:   start y %d <- %d \n", start_y, w_current->start_y);
+    printf("END:   last  x %d <- %d \n", last_x, w_current->last_x);
+    printf("END:   last  y %d <- %d \n", last_y, w_current->last_y);
+#endif
   }
 
   /* warp the cursor to the right position */ 
   if (w_current->warp_cursor) {
-     WORLDtoSCREEN(w_current, world_pan_center_x, world_pan_center_y, &sx, &sy);
-     x_basic_warp_cursor(w_current->drawing_area, sx, sy, 0);
+     WORLDtoSCREEN(w_current, world_pan_center_x, world_pan_center_y, 
+		   &start_x, &start_y);
+     x_basic_warp_cursor(w_current->drawing_area, start_x, start_y, 0);
   }
 }
 

Reply via email to