[Bf-committers] patch for tech mode

Kenneth Styrberg kenneth.styrberg at telia.com
Sun Jan 16 01:18:11 CET 2005


To whom it might concern!

I added a scale variable to the draw edge length and area for my own 
project, I'd like to share it to anyone interested.

I maybe did some shortcuts to get the scale variable to the drawobject 
function, so please check O:-)

//styken


-------------- next part --------------
? source/blender/makesdna/intern/dna.c
Index: source/blender/include/BIF_editmesh.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BIF_editmesh.h,v
retrieving revision 1.36
diff -u -r1.36 BIF_editmesh.h
--- source/blender/include/BIF_editmesh.h	24 Nov 2004 16:29:10 -0000	1.36
+++ source/blender/include/BIF_editmesh.h	16 Jan 2005 00:00:46 -0000
@@ -168,6 +168,7 @@
 extern void fill_mesh(void);
 extern void bevel_menu();
 void edge_rotate_selected(void);
+extern float get_meas_scale(void);
  
 #endif
 
Index: source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_editing.c,v
retrieving revision 1.90
diff -u -r1.90 buttons_editing.c
--- source/blender/src/buttons_editing.c	12 Jan 2005 22:28:12 -0000	1.90
+++ source/blender/src/buttons_editing.c	16 Jan 2005 00:10:12 -0000
@@ -159,7 +159,7 @@
 static float extr_offs= 1.0;
 static float editbutweight=1.0;
 short editbutflag= 1;
-float doublimit= 0.001, editbutvweight=1, editbutsize=0.1;
+float doublimit= 0.001, editbutvweight=1, editbutsize=0.1, meas_scale = 1.0; 
 float uv_calc_radius= 1.0, uv_calc_cubesize= 1.0;
 short uv_calc_mapdir= 1, uv_calc_mapalign= 1, facesel_draw_edges= 0;
 
@@ -384,6 +384,10 @@
 	}
 }
 
+float get_meas_scale(void) {
+	return meas_scale;
+}
+
 /* *************** */
 
 void do_common_editbuts(unsigned short event) // old name, is a mix of object and editing events.... 
@@ -2135,6 +2139,7 @@
 	uiDefButI(block, TOG|BIT|22, REDRAWVIEW3D, "Edge Length",	1125,131,150,19, &G.f, 0, 0, 0, 0, "Displays selected edge lengths");
 	uiDefButI(block, TOG|BIT|24, REDRAWVIEW3D, "Edge Angles",	1125,110,150,19,  &G.f, 0, 0, 0, 0, "Displays the angles in the selected edges in degrees");
 	uiDefButI(block, TOG|BIT|23, REDRAWVIEW3D, "Face Area",		1125,88,150,19, &G.f, 0, 0, 0, 0, "Displays the area of selected faces");
+	uiDefButF(block, NUM,        REDRAWVIEW3D, "Scale:",		1125,66,150,19, &meas_scale, 0.01, 100.0, 100, 0, "Sets the scale for displayed length and areas");
 	uiBlockEndAlign(block);
 
 }
Index: source/blender/src/drawobject.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawobject.c,v
retrieving revision 1.142
diff -u -r1.142 drawobject.c
--- source/blender/src/drawobject.c	12 Jan 2005 22:28:12 -0000	1.142
+++ source/blender/src/drawobject.c	16 Jan 2005 00:11:04 -0000
@@ -2729,7 +2729,7 @@
 	EditMesh *em = G.editMesh;
 	EditEdge *eed;
 	EditFace *efa;
-	float *v1, *v2, *v3, *v4, fvec[3];
+	float *v1, *v2, *v3, *v4, fvec[3], length = 0.0f;
 	char val[32]; /* Stores the measurement display text here */
 	float area, col[3]; /* area of the face,  colour of the text to draw */
 	
@@ -2753,7 +2753,8 @@
 				v2= eed->v2->co;
 				
 				glRasterPos3f( 0.5*(v1[0]+v2[0]),  0.5*(v1[1]+v2[1]),  0.5*(v1[2]+v2[2]));
-				sprintf(val,"%.3f", VecLenf(v1, v2));
+				length = VecLenf(v1, v2) * get_meas_scale();
+				sprintf(val,"%.3f", length);
 				BMF_DrawString( G.fonts, val);
 			}
 		}
@@ -2774,7 +2775,7 @@
 					area=  AreaQ3Dfl( efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
 				else
 					area = AreaT3Dfl( efa->v1->co, efa->v2->co, efa->v3->co);
-
+				area *= (get_meas_scale() * get_meas_scale());
 				sprintf(val,"%.3f", area);
 				glRasterPos3fv(efa->cent);
 				BMF_DrawString( G.fonts, val);


More information about the Bf-committers mailing list