xcaverot patch 2

Leandro Dybal Bertoni leandro@dybal.eti.br
Wed, 22 Mar 2000 15:27:47 -0300


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

Hi,

This patch:

- tides up the conditional code for the menu buttons (there where some
ifdefs missing)
- fixes the keyboard shortcuts
- fixes the station markers color

I hope that with this one the basic functionality of xcaverot is now
working.

Enjoy,

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

--- survex-0.93.1/src/xcaverot.c	Tue Mar 21 13:23:26 2000
+++ survex-0.93.new/src/xcaverot.c	Wed Mar 22 14:58:23 2000
@@ -103,6 +103,9 @@
 #define BUTWIDTH 60
 #define BUTHEIGHT 25
 
+/* length of cross station marker */
+#define CROSSLENGHT 3
+
 /* Width and height of compass and elevation indicator windows */
 #define FONTSPACE 20
 #define INDWIDTH 100	/* FIXME: allow INDWIDTH to be set dynamically - 50 is nice */
@@ -526,7 +529,11 @@
      sprintf(temp, "%d m", (int)sbar);
    else
      sprintf(temp, "%d km", (int)sbar/1000);
+#ifdef XCAVEROT_BUTTONS
    XDrawString(mydisplay, mywindow, slab_gc, 8, BUTHEIGHT+5+FONTSPACE, temp, strlen(temp));
+#else
+   XDrawString(mydisplay, mywindow, slab_gc, 8, FONTSPACE, temp, strlen(temp));
+#endif
 }
 
 /* FIXME: Zoom In -> In / Zoom Out -> Out ??? */
@@ -537,7 +544,6 @@
    scale *= zoomfactor;
    changedscale = 1;
    flip_button(display, mainwin, button, egc, mygc, "Zoom in");
-   draw_scalebar();
    fill_segment_cache();
 }
 
@@ -548,7 +554,6 @@
    scale /= zoomfactor;
    changedscale = 1;
    flip_button(display, mainwin, button, egc, mygc, "Zoom out");
-   draw_scalebar();
    fill_segment_cache();
 }
 
@@ -958,8 +963,10 @@
 	    x2 = toscreen_x(p);
 	    y2 = toscreen_y(p);
 	    if (crossing) {
-	       XDrawLine(display, window, gcs[srvy], x2 - 10, y2, x2 + 10, y2);
-	       XDrawLine(display, window, gcs[srvy], x2, y2 - 10, x2, y2 + 10);
+               XDrawLine(display, window, gcs[lab_col_ind], x2 - CROSSLENGHT, y2, x2 + CROSSLENGHT, y2);
+               XDrawLine(display, window, gcs[lab_col_ind], x2, y2 - CROSSLENGHT, x2, y2 + CROSSLENGHT);
+	     /*  XDrawLine(display, window, gcs[srvy], x2 - 10, y2, x2 + 10, y2);
+	       XDrawLine(display, window, gcs[srvy], x2, y2 - 10, x2, y2 + 10); */
 	    }
 
 	    if (labelling) {
@@ -986,7 +993,11 @@
    else
       sprintf(temp, "%d km", (int)sbar / 1000);
    // FIXME: add BUTHEIGHT to FONTSPACE if buttons on
+#ifdef XCAVEROT_BUTTONS
+   XDrawString(mydisplay, window,  slab_gc, 8, BUTHEIGHT+5+FONTSPACE, temp, strlen(temp));
+#else
    XDrawString(mydisplay, window,  slab_gc, 8, FONTSPACE, temp, strlen(temp));
+#endif
 }
 
 static void
@@ -1212,14 +1223,12 @@
 	 view_angle -= 360.0;
 
       /*dy = -dy; */
-
       /* U-D => scaling */
       if (fabs((float)dy) <= 1.0) {
 	 a = 0.0;
       } else {
 	 a = log(fabs((float)dy)) / 3;
       }
-
       if (dy <= 0) {
 	 /* mouse moved up or back to starting pt */
 	 scale = rotsc_scale * pow(2, a);
@@ -1228,14 +1237,11 @@
 	 scale = rotsc_scale * pow(2, -a);
       }
       changedscale = 1;
-      draw_scalebar();
    }
-
    fill_segment_cache();
 }
 
 #ifdef XCAVEROT_BUTTONS
-// FIXME:
 void
 draw_buttons(Display * display, Window mainwin, GC mygc, GC egc)
 {
@@ -1462,16 +1468,16 @@
    ind_elev =
       XCreateSimpleWindow(mydisplay, mywindow, attr.width - INDWIDTH * 2 - 1,
 			  0, INDWIDTH, INDDEPTH, 1, ind_fg, ind_bg);
-#if 0
-   scalebar =
-      XCreateSimpleWindow(mydisplay, mywindow, 0, BUTHEIGHT + 5 + FONTSPACE,
-			  23, attr.height - (BUTHEIGHT + FONTSPACE + 5), 0,
-			  ind_fg, ind_bg);
-#else
+#ifdef XCAVEROT_BUTTONS
    scalebar =
       XCreateSimpleWindow(mydisplay, mywindow, 0, BUTHEIGHT+FONTSPACE+10, 23,
-			  attr.height - (BUTHEIGHT + FONTSPACE + 10) -5, 0, ind_fg,
-			  ind_bg);
+                          attr.height - (BUTHEIGHT + FONTSPACE + 10) -5, 0, ind_fg,
+                          ind_bg);
+#else 
+   scalebar =
+      XCreateSimpleWindow(mydisplay, mywindow, 0, FONTSPACE,
+                          23, attr.height - 5, 0,
+                          ind_fg, ind_bg);
 #endif
 
    rot_but = XCreateSimpleWindow(mydisplay, mywindow, attr.width - INDWIDTH * 2
@@ -1638,7 +1644,8 @@
 	       /* right button has been released => stop dragging cave about */
 	       release_right_button();
 	    }
-	 } else if (myevent.type == ButtonPress) {
+	 } 
+         else if (myevent.type == ButtonPress) {
 	    orig.x = myevent.xbutton.x;
 	    orig.y = myevent.xbutton.y;
 #if 0
@@ -1680,7 +1687,6 @@
 		     redraw = 0;
 	       } else if (myevent.xbutton.window == scalebar) {
 		  scale_orig = scale;
-		  draw_scalebar();
 	       } else if (myevent.xbutton.window == mywindow) {
 		  press_left_button(myevent.xbutton.x, myevent.xbutton.y);
 		  /* process_focus(mydisplay, mywindow,
@@ -1698,7 +1704,8 @@
 		  /* translate cave */
 		  press_right_button(myevent.xbutton.x, myevent.xbutton.y);
 	       }
-	 } else if (myevent.type == MotionNotify) {
+	 } 
+         else if (myevent.type == MotionNotify) {
 	    if (myevent.xmotion.window == ind_com) {
 	       int old_angle = (int)view_angle;
 	       
@@ -1722,7 +1729,6 @@
 			      );
 	       
 	       changedscale = 1;
-	       draw_scalebar();
 	    } else if (myevent.xmotion.window == mywindow) {
 	       /* drag cave about / alter rotation or scale */
 	       
@@ -1730,7 +1736,7 @@
 			   myevent.xmotion.y);
 	    }
 	 }
-	 if (myevent.xany.window == mywindow) {
+	 else if (myevent.xany.window == mywindow) {
 	    switch (myevent.type) {
 	     case KeyPress:
 		 {
@@ -1775,6 +1781,7 @@
 			      break;
 			    case 127:	/* Delete => restore defaults */
 			      set_defaults();
+                              fill_segment_cache();
 			      break;
 			    case 'q':
 			      done = 1;
@@ -1783,11 +1790,15 @@
 			      elev_angle += 3.0;
 			      if (elev_angle > 90.0)
 				 elev_angle = 90.0;
+                              fill_segment_cache();
+                              redraw = 1;
 			      break;
 			    case 'd':	/* cave down */
 			      elev_angle -= 3.0;
 			      if (elev_angle < -90.0)
 				 elev_angle = -90.0;
+                              fill_segment_cache();
+                              redraw = 1;
 			      break;
 			    case 'l':	/* switch to elevation */
 			      switch_to_elevation();
@@ -1810,6 +1821,7 @@
 			      if (scale < 0.001) {
 				 scale = 0.001;
 			      }
+                              changedscale = 1;
 			      fill_segment_cache();
 			      redraw = 1;
 			      break;
@@ -1818,6 +1830,7 @@
 			      if (scale > 0.4) {
 				 scale = 0.4;
 			      }
+                              changedscale = 1;
 			      fill_segment_cache();
 			      redraw = 1;
 			      break;
@@ -1898,8 +1911,6 @@
 			   myevent.xconfigure.width - INDWIDTH - 1, 0);
 	       XMoveWindow(mydisplay, ind_elev,
 			   myevent.xconfigure.width - (2 * INDWIDTH) - 1, 0);
-	       
-	       draw_scalebar();
 	       break;
 	    }
 	 }

--------------03B5A538CE299F44FC1E2AFA--