mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 09:55:32 +02:00
Scale z axis in projection displays to obtain 1:1 aspect ratio.
- solidify/level.c (draw_xz, draw_zy): use f->sz-1 instead of zm as maximum value - solidify/level.c (draw_xz, draw_zy, level): scale z axis by step size ratio
This commit is contained in:
parent
46704e6b0e
commit
761002e0e5
@ -95,11 +95,12 @@ static void draw_image(GtkWidget *widget, struct face *f, int osd)
|
|||||||
static void draw_xz(GtkWidget *widget, struct face *f, int y)
|
static void draw_xz(GtkWidget *widget, struct face *f, int y)
|
||||||
{
|
{
|
||||||
int zm = f->a->max_z;
|
int zm = f->a->max_z;
|
||||||
|
int sz = f->sz*z0_scale(f);
|
||||||
int x, z;
|
int x, z;
|
||||||
double z0;
|
double z0;
|
||||||
guchar *rgbbuf, *p;
|
guchar *rgbbuf, *p;
|
||||||
|
|
||||||
rgbbuf = p = calloc(f->sx*f->sz, 3);
|
rgbbuf = p = calloc(f->sx*sz, 3);
|
||||||
if (!rgbbuf) {
|
if (!rgbbuf) {
|
||||||
perror("calloc");
|
perror("calloc");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -109,21 +110,27 @@ static void draw_xz(GtkWidget *widget, struct face *f, int y)
|
|||||||
z = get(f->a, x+f->a->min_x, y+f->a->min_y);
|
z = get(f->a, x+f->a->min_x, y+f->a->min_y);
|
||||||
z0 = face_z0(f, x, y);
|
z0 = face_z0(f, x, y);
|
||||||
if (z == UNDEF || z == z0) {
|
if (z == UNDEF || z == z0) {
|
||||||
aa_line(rgbbuf, x, zm-z0, zm-z0, zm, f->sx,
|
aa_line(rgbbuf, x,
|
||||||
|
(zm-z0)*z0_scale(f), (zm-z0)*z0_scale(f),
|
||||||
|
sz-1, f->sx,
|
||||||
(uint8_t *) "\0\0\xff", vpoint);
|
(uint8_t *) "\0\0\xff", vpoint);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (z > z0) {
|
if (z > z0) {
|
||||||
aa_line(rgbbuf, x, zm-z, zm-z0, zm, f->sx,
|
aa_line(rgbbuf, x,
|
||||||
|
(zm-z)*z0_scale(f), (zm-z0)*z0_scale(f),
|
||||||
|
sz-1, f->sx,
|
||||||
(uint8_t *) "\0\xff\0", vpoint);
|
(uint8_t *) "\0\xff\0", vpoint);
|
||||||
} else {
|
} else {
|
||||||
aa_line(rgbbuf, x, zm-z0, zm-z, zm, f->sx,
|
aa_line(rgbbuf, x,
|
||||||
|
(zm-z0)*z0_scale(f), (zm-z)*z0_scale(f),
|
||||||
|
sz-1, f->sx,
|
||||||
(uint8_t *) "\xff\0\0", vpoint);
|
(uint8_t *) "\xff\0\0", vpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gdk_draw_rgb_image(widget->window,
|
gdk_draw_rgb_image(widget->window,
|
||||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||||
0, 0, f->sx, f->sz, GDK_RGB_DITHER_MAX, rgbbuf, f->sx*3);
|
0, 0, f->sx, sz, GDK_RGB_DITHER_MAX, rgbbuf, f->sx*3);
|
||||||
free(rgbbuf);
|
free(rgbbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -132,11 +139,12 @@ static void draw_xz(GtkWidget *widget, struct face *f, int y)
|
|||||||
static void draw_zy(GtkWidget *widget, struct face *f, int x)
|
static void draw_zy(GtkWidget *widget, struct face *f, int x)
|
||||||
{
|
{
|
||||||
int zm = f->a->max_z;
|
int zm = f->a->max_z;
|
||||||
|
int sz = f->sz*z0_scale(f);
|
||||||
int y, z;
|
int y, z;
|
||||||
double z0;
|
double z0;
|
||||||
guchar *rgbbuf, *p;
|
guchar *rgbbuf, *p;
|
||||||
|
|
||||||
rgbbuf = p = calloc(f->sy*f->sz, 3);
|
rgbbuf = p = calloc(f->sy*sz, 3);
|
||||||
if (!rgbbuf) {
|
if (!rgbbuf) {
|
||||||
perror("calloc");
|
perror("calloc");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -146,21 +154,27 @@ static void draw_zy(GtkWidget *widget, struct face *f, int x)
|
|||||||
z = get(f->a, x+f->a->min_x, f->a->max_y-y);
|
z = get(f->a, x+f->a->min_x, f->a->max_y-y);
|
||||||
z0 = face_z0(f, x, f->sy-y-1);
|
z0 = face_z0(f, x, f->sy-y-1);
|
||||||
if (z == UNDEF || z == z0) {
|
if (z == UNDEF || z == z0) {
|
||||||
aa_line(rgbbuf, y, zm-z0, zm-z0, zm, f->sz,
|
aa_line(rgbbuf, y,
|
||||||
|
(zm-z0)*z0_scale(f), (zm-z0)*z0_scale(f),
|
||||||
|
sz-1, sz,
|
||||||
(uint8_t *) "\0\0\xff", hpoint);
|
(uint8_t *) "\0\0\xff", hpoint);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (z > z0) {
|
if (z > z0) {
|
||||||
aa_line(rgbbuf, y, zm-z, zm-z0, zm, f->sz,
|
aa_line(rgbbuf, y,
|
||||||
|
(zm-z)*z0_scale(f), (zm-z0)*z0_scale(f),
|
||||||
|
sz-1, sz,
|
||||||
(uint8_t *) "\0\xff\0", hpoint);
|
(uint8_t *) "\0\xff\0", hpoint);
|
||||||
} else {
|
} else {
|
||||||
aa_line(rgbbuf, y, zm-z0, zm-z, zm, f->sz,
|
aa_line(rgbbuf, y,
|
||||||
|
(zm-z0)*z0_scale(f), (zm-z)*z0_scale(f),
|
||||||
|
sz-1, sz,
|
||||||
(uint8_t *) "\xff\0\0", hpoint);
|
(uint8_t *) "\xff\0\0", hpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gdk_draw_rgb_image(widget->window,
|
gdk_draw_rgb_image(widget->window,
|
||||||
widget->style->fg_gc[GTK_STATE_NORMAL],
|
widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||||
0, 0, f->sz, f->sy, GDK_RGB_DITHER_MAX, rgbbuf, f->sz*3);
|
0, 0, sz, f->sy, GDK_RGB_DITHER_MAX, rgbbuf, sz*3);
|
||||||
free(rgbbuf);
|
free(rgbbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -284,8 +298,8 @@ void level(GtkWidget *canvas, struct face *f)
|
|||||||
GDK_POINTER_MOTION_MASK);
|
GDK_POINTER_MOTION_MASK);
|
||||||
|
|
||||||
gtk_widget_set_size_request(xy, f->sx, f->sy);
|
gtk_widget_set_size_request(xy, f->sx, f->sy);
|
||||||
gtk_widget_set_size_request(xz, f->sx, f->sz);
|
gtk_widget_set_size_request(xz, f->sx, f->sz*z0_scale(f));
|
||||||
gtk_widget_set_size_request(zy, f->sz, f->sy);
|
gtk_widget_set_size_request(zy, f->sz*z0_scale(f), f->sy);
|
||||||
|
|
||||||
gtk_table_set_row_spacings(GTK_TABLE(tab), 2);
|
gtk_table_set_row_spacings(GTK_TABLE(tab), 2);
|
||||||
gtk_table_set_col_spacings(GTK_TABLE(tab), 2);
|
gtk_table_set_col_spacings(GTK_TABLE(tab), 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user