when i click on the line, it create a point that can be scroll up/down
to modify the line.
like they do for sound editor for example.
any ideas about that?
thanks
++
Sure, that is quite possible!
You will need to bind to several events though and it is not
completely
trivial, but if you look at the standard examples that come with Tk,
you
will find one where you can edit an xy-graph with dots.
The way to split up the line is:
set oldCoords [.c coords $line] ;# line holds the ID of the line
set newCoords [insertNewPoint $oldCoords $x $y] ;# Not entirely
trivial
;# - where should you
insert the new point?
.c coords $line $newCoords
Well, something along those lines
Regards,
Arjen
i've started like that, but i don't know how to use array in Tcl to
maintain several lines coordinates, because i think that each time i put
a point, i need to short the first line and create another one...
frame .f
canvas .f.c -width 100 -height 100
.f.c create line 0 0 100 100 -tags line0
bind .f.c <ButtonPress-1> {makePoint %W %x %y}
bind .f.c <B1-Motion> {thisPointMove %W %x %y}
pack .f .f.c -side top
set point(count) 0
proc makePoint {win p_x p_y} {
upvar #0 point v
set x [$win canvasx $p_x]
set y [$win canvasy $p_y]
set eline [$win gettags [$win find closest $x $y]]
if {[string equal -length 4 [string map {" current" ""} $eline] "line"]} {
$win create oval [expr {$x-4}] [expr {$y-4}] [expr {$x+4}] [expr
{$y+4}] -tags point$v(count) -fill red
incr v(count) 1
}
}
proc thisPointMove {win p_x p_y} {
upvar #0 point v
set x [$win canvasx $p_x]
set y [$win canvasy $p_y]
set point [string map {" current" ""} [$win gettags [$win find closest
$x $y 1]]]
if {[string equal -length 5 $point "point"]} {
$win coords $point [expr {$x-4}] [expr {$y-4}] [expr {$x+4}] [expr {$y+4}]
}
}
>
> Regards,
>
> Arjen
The coordinates are returned as a list. No need to mess about with
arrays :).
Your code looks a bit too complicated - you can use the move
subcommand to
move one or more objects around.
Regards,
Arjen
> The coordinates are returned as a list. No need to mess about with
> arrays :).
>
> Your code looks a bit too complicated - you can use the move
> subcommand to
> move one or more objects around.
--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+
Gerald,
thank you for pointing this demo, i added the selected tags to current
round in order to move it.
now, any suggestion to cut the line and maintain geometry in an array
(or somewhere...)
++
I do have a few, but no time at the moment to work that out, which is
a pity.
Regards,
Arjen
The other is to draw the segmented line as a succesion of two point lines
and maybe add some kind of tick at each common point.
uwe
swan lee <sl12...@free.fr> writes:
> hello,
> how would it be possible to have a in a canvas a line that can be cut in
> piece at the place i click with the mouse?
maybe too late for you (I don't know), but I was inspired by your
question and put together a small example, which you will find here:
Enjoy
-- tomás
Thomas,
that's very nice!!
it's not too late for me as it's something i'll add to my app in the future.
many thanks for sharing your work!
best regards