mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:43:00 +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)
|
||||
{
|
||||
int zm = f->a->max_z;
|
||||
int sz = f->sz*z0_scale(f);
|
||||
int x, z;
|
||||
double z0;
|
||||
guchar *rgbbuf, *p;
|
||||
|
||||
rgbbuf = p = calloc(f->sx*f->sz, 3);
|
||||
rgbbuf = p = calloc(f->sx*sz, 3);
|
||||
if (!rgbbuf) {
|
||||
perror("calloc");
|
||||
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);
|
||||
z0 = face_z0(f, x, y);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
gdk_draw_rgb_image(widget->window,
|
||||
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);
|
||||
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
int zm = f->a->max_z;
|
||||
int sz = f->sz*z0_scale(f);
|
||||
int y, z;
|
||||
double z0;
|
||||
guchar *rgbbuf, *p;
|
||||
|
||||
rgbbuf = p = calloc(f->sy*f->sz, 3);
|
||||
rgbbuf = p = calloc(f->sy*sz, 3);
|
||||
if (!rgbbuf) {
|
||||
perror("calloc");
|
||||
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);
|
||||
z0 = face_z0(f, x, f->sy-y-1);
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
gdk_draw_rgb_image(widget->window,
|
||||
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);
|
||||
|
||||
}
|
||||
@ -284,8 +298,8 @@ void level(GtkWidget *canvas, struct face *f)
|
||||
GDK_POINTER_MOTION_MASK);
|
||||
|
||||
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(zy, f->sz, f->sy);
|
||||
gtk_widget_set_size_request(xz, f->sx, f->sz*z0_scale(f));
|
||||
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_col_spacings(GTK_TABLE(tab), 2);
|
||||
|
Loading…
Reference in New Issue
Block a user