Kaynağa Gözat

enable checkerboard barscale with left side twice the freq of the right

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56846 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 12 yıl önce
ebeveyn
işleme
c309140111
2 değiştirilmiş dosya ile 47 ekleme ve 2 silme
  1. 45 0
      display/d.barscale/draw_scale.c
  2. 2 2
      display/d.barscale/main.c

+ 45 - 0
display/d.barscale/draw_scale.c

@@ -419,6 +419,51 @@ int draw_scale(double east, double north, int style, int text_posn,
 	    D_pos_rel(seg_len, 0);
 	}
     }
+
+    else if (style == STYLE_PART_CHECKER) {
+	D_begin();
+	D_move_abs(x_pos + 25, y_pos + 15 + 6);
+	/* actual width is line_len-1+1=line_len and height is 7+1=8 */
+	D_cont_rel(line_len, 0);
+	D_cont_rel(0, -12);
+	D_cont_rel(-line_len, 0);
+	D_cont_rel(0, +12);
+	D_close();
+	D_end();  /* no-op? */
+	D_stroke();
+
+	D_pos_rel(0, -6);
+	for (i = 1; i <= scales[incr].seg; i++) {
+	    if (i <= (scales[incr].seg == 5 ? 2 : 4)) {
+		xarr[0] = 0;		yarr[0] = 0;
+		xarr[1] = seg_len/2.;	yarr[1] = 0;
+		xarr[2] = 0;		yarr[2] = -6;
+		xarr[3] = -seg_len/2.;	yarr[3] = 0;
+		xarr[4] = 0;		yarr[4] = 6;
+		D_polygon_rel(xarr, yarr, 5);
+		D_pos_rel(seg_len/2., 0);
+
+		xarr[0] = 0;		yarr[0] = 0;
+		xarr[1] = seg_len/2.;	yarr[1] = 0;
+		xarr[2] = 0;		yarr[2] = 6;
+		xarr[3] = -seg_len/2.;	yarr[3] = 0;
+		xarr[4] = 0;		yarr[4] = -6;
+		D_polygon_rel(xarr, yarr, 5);
+		D_pos_rel(seg_len/2., 0);
+	    }
+	    else {
+		xarr[0] = 0;	    yarr[0] = 0;
+		xarr[1] = seg_len;  yarr[1] = 0;
+		xarr[2] = 0;	    yarr[2] = (i % 2 ? -6 : 6);
+		xarr[3] = -seg_len; yarr[3] = 0;
+		xarr[4] = 0;	    yarr[4] = (i % 2 ? 6 : -6);
+		/* width is seg_len and height is 4 */
+		D_polygon_rel(xarr, yarr, 5);
+		D_pos_rel(seg_len, 0);
+	    }
+
+	}
+    }
     else if (style == STYLE_TICKS_BOTH) {
 	/* draw simple line scale with corssing ticks */
 	D_move_abs(x_pos + 25, y_pos + 5);

+ 2 - 2
display/d.barscale/main.c

@@ -71,9 +71,9 @@ int main(int argc, char **argv)
     barstyle = G_define_option();
     barstyle->key = "style";
     barstyle->description = _("Type of barscale to draw");
-/* TODO:   barstyle->options: part_checker (left side twice the freq of the right) and  |<--arrow_ends-->| */
+/* TODO:   barstyle->options:  |<--arrow_ends-->| */
     barstyle->options =
-	"classic,line,solid,hollow,full_checker,up_ticks,down_ticks,both_ticks";
+	"classic,line,solid,hollow,full_checker,part_checker,up_ticks,down_ticks,both_ticks";
     barstyle->answer = "classic";
 
     coords = G_define_option();