Coordinates after scrolling?? 
Author Message
 Coordinates after scrolling??

Hello,
 I am newcomer in programming Tcl-Tk. I have now a problem with the
coordinates.  
 I have a canvas that is much bigger than the visible window. At the
begining the coordinates in canvas(x,y) and in visible window(%x,%y) are
the same. After the canvas being moved with scrollbar, the they have
been changed. More concretely, if you then click in the visible window,
you will get coordinates(%x, %y) which are different from (x,y).
x=x0+%x and y=y0+%y. (x0,y0) are the coordinates of the visible window's
top-left corner in canvas-coordinate system.

How can I get the coordinates of the top-left corner of the visible
window in canvas(x0,y0)?

Thanks in advance!

Xiaomin



Sun, 12 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

Quote:

> After the canvas being moved with scrollbar, the [coordinates] have
> been changed. More concretely, if you then click in the visible window,
> you will get coordinates(%x, %y) which are different from (x,y).

i think you want the canvasx and canvasy minors.

Quote:
> Xiaomin

--
Hume dot Smith at Dess dot Tallships dot iStar dot CA


Sun, 12 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

Quote:



> > > After the canvas being moved with scrollbar, the [coordinates] have
> > > been changed. More concretely, if you then click in the visible window,
> > > you will get coordinates(%x, %y) which are different from (x,y).

> > i think you want the canvasx and canvasy minors.
> How?

OK! I have solved it. Thanks!

I have now another question:
Could the canvas be zoomed? I mean, if the canvas was originally
500x2000.
I want it to be enlarged as 1000x4000. Ofcause all the objects in the
canvas
should be enlarged at the same time.
If Tk does not have this feature, are there any procedure that can
do it?

Thanks in advance!

Xiaomin

Quote:

> > > Xiaomin

> > --
> > Hume dot Smith at Dess dot Tallships dot iStar dot CA
> I have not found the solution in the Ousterhout's book.
> Does someone know the solution? or it is not so simple like i thought?

> Thanks

> Xiaomin



Sun, 12 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

Quote:


> > After the canvas being moved with scrollbar, the [coordinates] have
> > been changed. More concretely, if you then click in the visible window,
> > you will get coordinates(%x, %y) which are different from (x,y).

> i think you want the canvasx and canvasy minors.
How?

> > Xiaomin

> --
> Hume dot Smith at Dess dot Tallships dot iStar dot CA

I have not found the solution in the Ousterhout's book.
Does someone know the solution? or it is not so simple like i thought?

Thanks

Xiaomin



Sun, 12 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

.....snip

Quote:
> I have now another question:
> Could the canvas be zoomed? I mean, if the canvas was originally
> 500x2000.
> I want it to be enlarged as 1000x4000. Ofcause all the objects in the
> canvas
> should be enlarged at the same time.

.....snip

Here's a code fragment from Itcl catalog demo example for scrolled
canvas that should give a hint about zooming in and out.

button .zoomin -text "Zoom In" -command {
    .canv scale all 0 0 2 2

Quote:
}

pack .zoomin -side left -expand yes -padx 4 -pady 4

button .zoomout -text "Zoom Out" -command {
    .canv scale all 0 0 0.5 0.5
    .canv xview moveto 0
    .canv yview moveto 0

Quote:
}

--
Jeff Franks


Sun, 12 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??


Quote:
> I have a canvas that is much bigger than the visible window. At the
>begining the coordinates in canvas(x,y) and in visible window(%x,%y) are
>the same. After the canvas being moved with scrollbar, the they have
>been changed. More concretely, if you then click in the visible window,
>you will get coordinates(%x, %y) which are different from (x,y).
>x=x0+%x and y=y0+%y. (x0,y0) are the coordinates of the visible window's
>top-left corner in canvas-coordinate system.

>How can I get the coordinates of the top-left corner of the visible
>window in canvas(x0,y0)?

Read the canvas man pages, pay attention to the method section detailing
what canvasx and canvasy does.

****************************************************************************
* Gerald W. Lester                       | Voice:  +1 (504)-889-2784       *
* Computerized Processes Unlimited, Inc. | FAX:    +1 (504)-889-2799       *

* Metairie, LA 70001                     | Web:    http://www.cpu.com      *
****************************************************************************



Mon, 13 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

Quote:


> .....snip

> > I have now another question:
> > Could the canvas be zoomed? I mean, if the canvas was originally

> .....snip

> Here's a code fragment from Itcl catalog demo example for scrolled
> canvas that should give a hint about zooming in and out.

> button .zoomin -text "Zoom In" -command {
>     .canv scale all 0 0 2 2
> }
> pack .zoomin -side left -expand yes -padx 4 -pady 4

> button .zoomout -text "Zoom Out" -command {
>     .canv scale all 0 0 0.5 0.5
>     .canv xview moveto 0
>     .canv yview moveto 0
> }
> --
> Jeff Franks

Yes, it works well.
Could the 'scrollregion' also be zoomed?
It zooms all of the objects in canvas, but not the scrollregion. That
means,
if I press 'zoomin'-Button, all of the object become bigger, but 3/4
of the canvas surface are not visible, because it is outside of the
canvasregion, the scrollbar can also not help.
It would work only if I zoom the scrollregion, too.

Xiaomin



Tue, 14 Mar 2000 03:00:00 GMT  
 Coordinates after scrolling??

Quote:

> It would work only if I zoom the scrollregion, too.

my usual treatment of the scrollregion is
        $c scrollregion [$c bbox all]
but if you have a busy canvas that'll be slow, and it might not be what you
want anyway.  you could scale it yourself; have your scaling command query
the scrollregion, calculate new bounds using your center and scale, and set it.

Quote:
> Xiaomin

--
Hume dot Smith at Dess dot Tallships dot iStar dot CA


Tue, 14 Mar 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Q: Figuring out coordinates on a scrolling canvas?

2. 3d-coordinate to 2d coordinate

3. vrml model coordinates to screen coordinates...

4. VRML 2 (extracting coordinates, colour and texture coordinates for all vertices)

5. Converting canvas coordinates to window coordinates.......

6. Converting canvas coordinates to window coordinates in tkinter.........

7. Smalltalk coordinates to screen coordinates

8. Scrolled Window automatically scrolling

9. To scroll or not to scroll?

10. Mouse wheel doesn't scroll text scroll bar

11. only add a scroll bar when the window is minimized and scroll bar is needed

12. Why won't my scrolling canvas scroll?

 

 
Powered by phpBB® Forum Software