Commit 78808089 authored by Claes Sjofors's avatar Claes Sjofors

Ge bugfix for scale with snap to grid

parent 7f772ff2
......@@ -1110,8 +1110,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
y2 = fy * mw.zoom_factor_y + mw.offset_y;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_x = (x2 - select_rect_stored_ll_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
scale_y = (y2 - select_rect_stored_ll_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
......@@ -1134,7 +1134,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
y2 = fy * mw.zoom_factor_y + mw.offset_y;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_y = (y2 - select_rect_stored_ll_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
}
......@@ -1170,8 +1170,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
y2 = fy * mw.zoom_factor_y + mw.offset_y;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_x = (x2 - select_rect_stored_ll_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
scale_y = -(y2 - select_rect_stored_ur_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
......@@ -1189,15 +1189,16 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
x2 = select_rect_stored_ll_x +
scale_x * (select_rect_stored_ur_x - select_rect_stored_ll_x);
y2 = select_rect_stored_ur_y;
break;
if ( grid_on) {
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
scale_x = (x2 - select_rect_stored_ll_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
}
break;
case glow_eScaleType_Right:
if ( select_rect_start_x == select_rect_stored_ur_x)
return 1;
......@@ -1215,7 +1216,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
scale_x = -(x2 - select_rect_stored_ur_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
}
......@@ -1251,8 +1252,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
y2 = fy * mw.zoom_factor_y + mw.offset_y;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_x = -(x2 - select_rect_stored_ur_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
scale_y = (y2 - select_rect_stored_ll_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
......@@ -1275,7 +1276,7 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
y2 = fy * mw.zoom_factor_y + mw.offset_y;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_y = -(y2 - select_rect_stored_ur_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
}
......@@ -1311,8 +1312,8 @@ int GrowCtx::event_handler( glow_eEvent event, int x, int y, int w, int h)
double fx, fy;
find_grid( (double)(x2 + mw.offset_x) / mw.zoom_factor_x,
(double)(y2 + mw.offset_y) / mw.zoom_factor_y, &fx, &fy);
x2 = fx * mw.zoom_factor_x + mw.offset_x;
y2 = fy * mw.zoom_factor_y + mw.offset_y;
x2 = fx * mw.zoom_factor_x - mw.offset_x;
y2 = fy * mw.zoom_factor_y - mw.offset_y;
scale_x = -(x2 - select_rect_stored_ur_x) / (select_rect_stored_ur_x - select_rect_stored_ll_x);
scale_y = -(y2 - select_rect_stored_ur_y) / (select_rect_stored_ur_y - select_rect_stored_ll_y);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment