problem with logic/math
- From: Billy Patton <bpatton dal asp ti com>
- To: Gtk users <gtk-list gnome org>
- Subject: problem with logic/math
- Date: Wed, 25 Sep 2002 06:25:45 -0500 (CDT)
I have the beginning of an app. THis app is meant to display a cell of an
ASIC cell design (Application Specific Integrated Circuit)
THis cell can contain 1 to K's of rectangles, clodes polygons, text and
our own picular ty;pes of figures (center line figures, center point
rectangles, bla,bla,bla)
Inorder to view/edit this data I must have the ability to increase/
decrease the viewing scale. I do not yet hava a mouse zoom in/out
just "i" for zoom in and "o" for zoom out. The arrow keys move the data
around.
To control the data that is displayed and any scale I have the following
variables.
scale -> applied to all coords of the data
shiftX -> insures scaled data fits on the screen
shiftY -> insures scaled data fits on the screen
What I need to happen is that when I zoom in/out (with a key) the center
of the screen needs to remain the same. The shiftX/Y is not being
adjusted correctly. I don't seem to be able to see the trees for the
forest!
Here's a snippett of my key_press_event
from my key_press_event function
/* scroll the data */
case GDK_Left:
{
shiftX -= 50;
redraw();
break;
}
case GDK_Up:
{
shiftY -= 50;
redraw();
break;
}
case GDK_Right:
{
shiftX += 50;
redraw();
break;
}
case GDK_Down:
{
shiftY += 50;
redraw();
break;
}
/* fit the data to the screen */
case GDK_f:
{
int x;
set_scale(db,fcellp,windowExt,&scale);
x = (fcellp->extent.ur.x - fcellp->extent.ll.x) * scale;
shiftX = ((windowExt.ur.x - windowExt.ll.x) - x) / 2;
shiftY = 0;
redraw();
break;
}
/* zoom in */
case GDK_i:
{
scale *= 1.40;
shiftX = (int)(shiftX * 0.60);
shiftY = (int)(shiftY * 0.60);
redraw();
break;
}
/* zoom out */
case GDK_o:
{
scale *= 0.60;
shiftX = (int)(shiftX * 1.40);
shiftY = (int)(shiftY * 1.40);
redraw();
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]