perlquestion
KuntalBhusan
Dear Monks,
I want to create two Tk::Abstract canvases. One (lets call it Canvas1) would display a huge graph (consisting of nodes and edges) and other small canvas (lets call it Canvas2) which will contain a smaller view of the same graph (using the ViewAll function of AbstractCanvas). I want to use some simple interactions like a small rectangle in Canvas2 to scroll and view the big network of Canvas1.
<p>Under the module description part of Tk::Abstract Canvas, I can find the topic "updating a second AbstractCanvas which is displaying the view region of the first AbstractCanvas" and a code example too, but I cannot figure out how to implement the same.</p>
My code is something like this :
<code>
$abstractcanvas1 = $SomeFrame->Scrolled(qw/
AbstractCanvas -bg white
-confine 1
-scrollbars se/,
)->pack(-fill => 'both',-expand => 1);
$can = $abstractcanvas2->Subwidget('scrolled');
$abstractcanvas2 = $SomeFrame->Scrolled(qw/
AbstractCanvas -bg white
-confine 1
-scrollbars se/,
)->pack(-fill => 'both',-expand => 1);
$can = $abstractcanvas2->Subwidget('scrolled');
## code to display the network in $Canvas1
</code>
Where should I now use this code part as described in the Module help of Tk::AbstractCanvas
<code>
$abstractcanvas2 = $f_Left->Scrolled(qw/
AbstractCanvas -bg white
-confine 1
-scrollbars se/,
)->pack(-fill => 'both',-expand => 1);
$can_1 = $abstractcanvas2->Subwidget('scrolled');
$abstractcanvas1->configure(-changeView => [\&changeView, $abstractcanvas2]);
# viewAll if AbstractCanvas2 widget is resized.
$abstractcanvas2->CanvasBind('<Configure>' => sub {$abstractcanvas2->viewAll});
{
my $viewBox;
sub changeView {
my ($canvas2, @coords) = @_;
$canvas2->delete($viewBox) if $viewBox;
$viewBox = $canvas2->createRectangle(@coords, -outline => 'orange');
}
}
</code>
And how to do it ??
Thanks,
Kuntal