From c8b6425f617df7b8ba7cc9265f253c4a1a049533 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jun 2006 00:30:10 +0000 Subject: [PATCH] scaled comparison adjustment only effects editmode select group documented a workaround for python drawinf pixel aligned text in teh 2d view Added links from Draw.Test to the OpenGL functions that set the location and color. --- source/blender/python/api2_2x/Draw.c | 2 +- source/blender/python/api2_2x/doc/BGL.py | 17 +++++++++++++++++ source/blender/python/api2_2x/doc/Draw.py | 8 ++++++++ source/blender/src/editmesh_mods.c | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 28fefb204a8..fa96e6e70a7 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -1149,7 +1149,7 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) /* set the precission to display*/ if (range>=100.0f) precission=1.0f; else if (range>=10.0f) precission=2.0f; - else if (range>1.0f) precission=3.0f; + else if (range>=1.0f) precission=3.0f; else precission=4.0f; but->type = BFLOAT_TYPE; diff --git a/source/blender/python/api2_2x/doc/BGL.py b/source/blender/python/api2_2x/doc/BGL.py index 2bed4380b44..75bffd86605 100644 --- a/source/blender/python/api2_2x/doc/BGL.py +++ b/source/blender/python/api2_2x/doc/BGL.py @@ -1278,6 +1278,23 @@ def glRasterPos (x,y,z,w): @param x,y,z,w: Specify the x,y,z, and w object coordinates (if present) for the raster position. If function prototype ends in 'v' specifies a pointer to an array of two, three, or four elements, specifying x, y, z, and w coordinates, respectively. + @note: + If you are drawing to the 3d view with a Scriptlink of a space handeler + the zoom level of the panels will scale the glRasterPos by the view matrix. + so a X of 10 will not always offset 10 pixels as youd expect. + + To work around this get the scale value of the view matrix and use it to scale your pixel values. + + Workaround:: + + import Blender + from Blender.BGL import * + xval, yval= 100, 40 + # Get the scale of the view matrix + viewMatrix = Buffer(GL_FLOAT, 16) + glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix) + f = 1/viewMatrix[0] + glRasterPos2f(xval*f, yval*f) # Instead of the useual glRasterPos2i(xval, yval) """ def glReadBuffer(mode): diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py index 8fc88a83e6d..8a6bf60f734 100644 --- a/source/blender/python/api2_2x/doc/Draw.py +++ b/source/blender/python/api2_2x/doc/Draw.py @@ -603,6 +603,7 @@ def ColorPicker(event, x, y, width, height, initial, tooltip = None): @rtype: Blender Button @return: The Button created. @note: The color picker will not work if the Register's event function is None. + @note: Using the same button variable with more then 1 color picker at a time will corrupt memory. """ def Number(name, event, x, y, width, height, initial, min, max, tooltip = None): @@ -689,12 +690,19 @@ def GetStringWidth(string, fontsize = 'normal'): def Text(string, fontsize = 'normal'): """ Draw a string on the screen. + + Text location is set using the OpenGL raster location functions L{BGL.glRasterPos} before the text is drawn. + This sets the text location from the lower left corner of the current window. + + Text color is set using the OpenGL color functions L{BGL.glColor} before the text is drawn. + @type string: string @param string: The text string to draw. @type fontsize: string @param fontsize: The size of the font: 'large', 'normal', 'small' or 'tiny'. @rtype: int @return: The width of I{string} drawn with the chosen I{fontsize}. + @note: For drawing text in the 3d view see the workaround in L{BGL.glRasterPos} """ def Image(image, x, y, zoomx=1.0, zoomy=1.0, clipx=0, clipy=0, clipw=-1, cliph=-1): diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index 364be5afb46..b92906e261e 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -745,7 +745,7 @@ static int unified_findnearest(EditVert **eve, EditEdge **eed, EditFace **efa) } /* this as a way to compare the ares, perim of 2 faces thay will scale to different sizes */ -#define SCALE_CMP(a,b) (fabs(a-b) <= thresh || (a>0 && fabs(b/a)<=thresh)) +#define SCALE_CMP(a,b) (fabs(a-b) <= thresh*a || (a>0 && fabs(b/a)<=thresh)) /* **************** GROUP SELECTS ************** */ /* selects new faces/edges/verts based on the