xcaverot patch

Leandro Dybal Bertoni leandro@dybal.eti.br
Sun, 19 Mar 2000 20:04:38 -0300


This is a multi-part message in MIME format.
--------------FF3FD7D31E3CF3D408783833
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Michael Lake wrote:
> 
> Olly Betts wrote:
> >
> > In message <38CFAF8C.42864D77@zoo.ox.ac.uk>, John Pybus writes:
> > >Xcaverot isn't really under much active development at the moment.  I
> > >got it working in 96, and added a few experimental bits shortly after,
> > >but never got round to properly tidying it up.
> >
> > Ideally I'd like to phase out xcaverot in favour of aven.  But there
> > are barriers to this - xcaverot just requires an ANSI C compiler and
> > the most basic X libraries; aven requires a C++ compiler, GTK, GTK--,
> > and some gnome libraries.
> 
<snip>
> 
> It would be nice if xcaverot could remain - OK not developed further in
> termsof functionality, but just tidied up so its basic functionality was
> all there, no major bugs, and it could run then on any 486 PC with Linux
> or low end laptops with Linux. The gnome libs take lots of space and
> mem.
> 

That's why I keep fiddling (sp?) with xcaverot: my "field" computer is a
486 DX2 with 16Mb of RAM. If there were a SVGAlib version I probably
would be using it (and freeing some Mb of RAM from X+WM).

This is a patch to fix a number of small problems:

- lenght is scalebar and its text display
- mouse right-button "cave drag" and center-button "plan/elevation
switch"
- "menu button" zoom in/out now updates the drawing

Sorry for the "untimeliness" of the patch, but for most of the
pre0.92-series I was recovering from eye surgery and couldn work on it.

Enjoy,

Leandro

------------------------------------------------------------------------------
--------------FF3FD7D31E3CF3D408783833
Content-Type: text/plain; charset=us-ascii;
 name="xcaverot-0.93-patch.1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="xcaverot-0.93-patch.1"

--- survex-0.93.orig/src/xcaverot.c	Sun Mar 12 21:04:08 2000
+++ survex-0.93.new/src/xcaverot.c	Sun Mar 19 19:45:16 2000
@@ -497,6 +497,7 @@
 static void
 draw_scalebar(void)
 {
+   char temp[20];
    float l, m, n, o;
 
    if (changedscale) {
@@ -521,6 +522,11 @@
 
    XDrawLine(mydisplay, scalebar, scale_gc, 13, 2, 13,
 	     2 + scale * datafactor * sbar);
+   if (sbar<1000)
+     sprintf(temp, "%d m", (int)sbar);
+   else
+     sprintf(temp, "%d km", (int)sbar/1000);
+   XDrawString(mydisplay, mywindow, slab_gc, 8, BUTHEIGHT+5+FONTSPACE, temp, strlen(temp));
 }
 
 /* FIXME: Zoom In -> In / Zoom Out -> Out ??? */
@@ -532,6 +538,7 @@
    changedscale = 1;
    flip_button(display, mainwin, button, egc, mygc, "Zoom in");
    draw_scalebar();
+   fill_segment_cache();
 }
 
 void
@@ -542,6 +549,7 @@
    changedscale = 1;
    flip_button(display, mainwin, button, egc, mygc, "Zoom out");
    draw_scalebar();
+   fill_segment_cache();
 }
 
 void
@@ -978,7 +986,7 @@
    else
       sprintf(temp, "%d km", (int)sbar / 1000);
    // FIXME: add BUTHEIGHT to FONTSPACE if buttons on
-   XDrawString(mydisplay, window, slab_gc, 8, FONTSPACE, temp, strlen(temp));
+   XDrawString(mydisplay, window,  slab_gc, 8, FONTSPACE, temp, strlen(temp));
 }
 
 static void
@@ -1219,6 +1227,8 @@
 	 /* mouse moved down */
 	 scale = rotsc_scale * pow(2, -a);
       }
+      changedscale = 1;
+      draw_scalebar();
    }
 
    fill_segment_cache();
@@ -1373,7 +1383,7 @@
    myhint.x = 0;
    myhint.y = 0;
    myhint.width = WidthOfScreen(DefaultScreenOfDisplay(mydisplay))-5;
-   myhint.height = HeightOfScreen(DefaultScreenOfDisplay(mydisplay))-5;
+   myhint.height = HeightOfScreen(DefaultScreenOfDisplay(mydisplay))-25;
    myhint.flags = /* PPosition | */ PSize;
 
    if (have_double_buffering) {
@@ -1459,8 +1469,8 @@
 			  ind_fg, ind_bg);
 #else
    scalebar =
-      XCreateSimpleWindow(mydisplay, mywindow, 0, BUTHEIGHT, 23,
-			  attr.height - (BUTHEIGHT + FONTSPACE + 5), 0, ind_fg,
+      XCreateSimpleWindow(mydisplay, mywindow, 0, BUTHEIGHT+FONTSPACE+10, 23,
+			  attr.height - (BUTHEIGHT + FONTSPACE + 10) -5, 0, ind_fg,
 			  ind_bg);
 #endif
 
@@ -1675,7 +1685,9 @@
 		  press_left_button(myevent.xbutton.x, myevent.xbutton.y);
 		  /* process_focus(mydisplay, mywindow,
 		   * myevent.xbutton.x, myevent.xbutton.y); */
-	       } else if (myevent.xbutton.button == Button2) {
+	       }
+            }
+            else if (myevent.xbutton.button == Button2) {
 		  /* toggle plan/elevation */
 		  if (plan_elev == PLAN) {
 		     switch_to_elevation();
@@ -1686,7 +1698,6 @@
 		  /* translate cave */
 		  press_right_button(myevent.xbutton.x, myevent.xbutton.y);
 	       }
-	    }
 	 } else if (myevent.type == MotionNotify) {
 	    if (myevent.xmotion.window == ind_com) {
 	       int old_angle = (int)view_angle;
@@ -1895,6 +1906,7 @@
       }
       if (redraw) {
 	 perform_redraw();
+         draw_scalebar();
 #ifdef XCAVEROT_BUTTONS
 	 draw_buttons(mydisplay, mywindow, mygc, enter_gc);
 #endif

--------------FF3FD7D31E3CF3D408783833--