Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2005-06-26 19:37:36 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2005-06-26 19:37:36 +0400
commitece2733c63abbdc05b9d5b32ed4ad7ed3f0700d7 (patch)
tree3fa391ac92545b37a33f4b1419f78ec8d5777019 /source/blender/src
parent08169d7fbaedd09bec2966c89427dfaa4fd1e78b (diff)
Patch by Martin Poirier: display normalized coordinates in image window, with
a few small modifications: - also display normalized coords while transforming - adapt step size & precision for button - moved option to 'View' menu Also made sure pixel snapping when transforming uv's is off by default.
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/drawimage.c44
-rw-r--r--source/blender/src/editsima.c26
-rw-r--r--source/blender/src/header_image.c16
3 files changed, 55 insertions, 31 deletions
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index f1991f52a6f..efc2892c106 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -571,7 +571,7 @@ static void image_editvertex_buts(uiBlock *block)
static float ocent[2];
float cent[2]= {0.0, 0.0};
int imx, imy;
- int i, nactive= 0;
+ int i, nactive= 0, step, digits;
Mesh *me;
if( is_uv_tface_editing_allowed_silent()==0 ) return;
@@ -614,32 +614,46 @@ static void image_editvertex_buts(uiBlock *block)
if(block) { // do the buttons
if (nactive) {
- ocent[0]= (cent[0]*imx)/nactive;
- ocent[1]= (cent[1]*imy)/nactive;
+ ocent[0]= cent[0]/nactive;
+ ocent[1]= cent[1]/nactive;
+ if (G.sima->flag & SI_COORDFLOATS) {
+ step= 1;
+ digits= 3;
+ }
+ else {
+ ocent[0] *= imx;
+ ocent[1] *= imy;
+ step= 100;
+ digits= 2;
+ }
uiDefBut(block, LABEL, 0, "UV Vertex:",10,55,302,19,0,0,0,0,0,"");
+ uiBlockBeginAlign(block);
if(nactive==1) {
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_TRANS_IMAGE, "Vertex X:", 10, 35, 290, 19, &ocent[0], -10*imx, 10.0*imx, 100, 0, "");
- uiDefButF(block, NUM, B_TRANS_IMAGE, "Vertex Y:", 10, 15, 290, 19, &ocent[1], -10*imy, 10.0*imy, 100, 0, "");
- uiBlockEndAlign(block);
+ uiDefButF(block, NUM, B_TRANS_IMAGE, "Vertex X:", 10, 35, 290, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, "");
+ uiDefButF(block, NUM, B_TRANS_IMAGE, "Vertex Y:", 10, 15, 290, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, "");
}
else {
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_TRANS_IMAGE, "Median X:", 10, 35, 290, 19, &ocent[0], -10*imx, 10.0*imx, 100, 0, "");
- uiDefButF(block, NUM, B_TRANS_IMAGE, "Median Y:", 10, 15, 290, 19, &ocent[1], -10*imy, 10.0*imy, 100, 0, "");
- uiBlockEndAlign(block);
+ uiDefButF(block, NUM, B_TRANS_IMAGE, "Median X:", 10, 35, 290, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, "");
+ uiDefButF(block, NUM, B_TRANS_IMAGE, "Median Y:", 10, 15, 290, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, "");
}
+ uiBlockEndAlign(block);
}
}
else { // apply event
float delta[2];
- cent[0]= (cent[0]*imx)/nactive;
- cent[1]= (cent[1]*imy)/nactive;
+ cent[0]= cent[0]/nactive;
+ cent[1]= cent[1]/nactive;
- delta[0]= (ocent[0]-cent[0])/imx;
- delta[1]= (ocent[1]-cent[1])/imy;
+ if (G.sima->flag & SI_COORDFLOATS) {
+ delta[0]= ocent[0]-cent[0];
+ delta[1]= ocent[1]-cent[1];
+ }
+ else {
+ delta[0]= ocent[0]/imx - cent[0];
+ delta[1]= ocent[1]/imy - cent[1];
+ }
for (i=0; i<me->totface; i++) {
MFace *mf= &((MFace*) me->mface)[i];
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index fc6506579ab..8cb75c59050 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -229,12 +229,8 @@ static void sima_pixelgrid(float *loc, float sx, float sy)
{
float y;
float x;
-
- if(G.sima->flag & SI_NOPIXELSNAP) {
- loc[0]= sx;
- loc[1]= sy;
- }
- else {
+
+ if(G.sima->flag & SI_PIXELSNAP) {
if(G.sima->image && G.sima->image->ibuf) {
x= G.sima->image->ibuf->x;
y= G.sima->image->ibuf->y;
@@ -256,6 +252,10 @@ static void sima_pixelgrid(float *loc, float sx, float sy)
loc[1]= sy;
}
}
+ else {
+ loc[0]= sx;
+ loc[1]= sy;
+ }
}
@@ -539,11 +539,17 @@ void transform_tface_uv(int mode, int context) // 2 args, for callback
}
}
- ivec[0]= (vec[0]*xim);
- ivec[1]= (vec[1]*yim);
-
if(G.sima->flag & SI_BE_SQUARE) be_square_tface_uv(me);
-
+
+ if (G.sima->flag & SI_COORDFLOATS) {
+ ivec[0]= vec[0];
+ ivec[1]= vec[1];
+ }
+ else {
+ ivec[0]= (vec[0]*xim);
+ ivec[1]= (vec[1]*yim);
+ }
+
sprintf(str, "X: %.4f Y: %.4f ", ivec[0], ivec[1]);
headerprint(str);
}
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 683c8407e0d..9a1668c89b5 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -444,6 +444,10 @@ static void do_image_viewmenu(void *arg, int event)
break;
case 9:
image_viewcentre();
+ case 10: /* Display Normalized Coordinates */
+ G.sima->flag ^= SI_COORDFLOATS;
+ allqueue(REDRAWIMAGE, 0);
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -460,12 +464,13 @@ static uiBlock *image_viewmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Paint Tool...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
-
+ if(G.sima->flag & SI_COORDFLOATS) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Display Normalized Coordinates|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
+ else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Display Normalized Coordinates|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
if(G.f & G_DRAWFACES) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Faces", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Faces|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
if(G.sima->flag & SI_DRAWSHADOW) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Shadow Mesh", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Shadow Mesh|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
-
+
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBlockBut(block, image_view_viewnavmenu, NULL, ICON_RIGHTARROW_THIN, "View Navigation", 0, yco-=20, 120, 19, "");
@@ -956,8 +961,7 @@ static void do_image_uvsmenu(void *arg, int event)
G.scene->proportional= 1;
break;
case 7: /* UVs Snap to Pixel */
- if(G.sima->flag & SI_NOPIXELSNAP) G.sima->flag &= ~SI_NOPIXELSNAP;
- else G.sima->flag |= SI_NOPIXELSNAP;
+ G.sima->flag ^= SI_PIXELSNAP;
break;
case 8:
pin_tface_uv(1);
@@ -983,8 +987,8 @@ static uiBlock *image_uvsmenu(void *arg_unused)
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- if(G.sima->flag & SI_NOPIXELSNAP) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
- else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
+ if(G.sima->flag & SI_PIXELSNAP) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
+ else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
if(G.sima->flag & SI_BE_SQUARE) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");