CAD::Drawing::GUI::View - 2D graphics for CAD built on Tk::Zinc
This module provides methods to turn a CAD::Drawing object into a Zinc canvas.
Eric L. Wilhelm <ewilhelm at cpan dot org>
This module is copyright (C) 2004-2006 by Eric L. Wilhelm.
This module is distributed under the same terms as Perl. See the Perl source package for details.
You may use this software under one of the following licenses:
(1) GNU General Public License (found at http://www.gnu.org/copyleft/gpl.html) (2) Artistic License (found at http://www.perl.com/pub/language/misc/Artistic.html)
The source code of this module is made freely available and distributable under the GPL or Artistic License. Modifications to and use of this software must adhere to one of these licenses. Changes to the code should be noted as such and this notification (as well as the above copyright information) must remain intact on all copies of the code.
Additionally, while the author is actively developing this code, notification of any intended changes or extensions would be most helpful in avoiding repeated work for all parties involved. Please contact the author with any such development plans.
These make me behave like a Tk widget.
Filters configure arguments and adds non-tk args to our private data.
%args = $view->args_filter(%args);
This object expects you to draw all of your items in this group.
$view->active() or print "no\n"; $view->active(1); $view->active(0);
Retrieves or sets the -parent attribute (not to be confused with a parent window.)
$gui = $view->gui_parent(); $view->gui_parent($gui);
The following methods handle the drawing of items from CAD::Drawing objects.
Adds drawing $drw as number $number. This tags all of the items drawn by "$number:$type:$id:$layer".
Updates the canvas with the item at $addr.
$view->drawing_update($n, $drw, $addr);
Draws the $obj (possibly in multiple pieces), using $tag as the identifier.
Creates temporary bindings for drawing a rubber-band box and zooming on the area described by it. This will put back your existing bindings.
This is a freehand measuring tape. Maybe we'll have some snaps someday (but likely not with this graphical toolkit.)
Binds a subroutine to mouse button-1 clicks. In addition to creating the binding, this subroutine is guaranteed to be passed world coordinates. (its arguments are: $view, $x, $y)
The $button argument is optional, and defaults to 1.
I advise you to not use 2 if view_bindings() is active.
Sets-up the wheel-zoom and middle-button pan. (This over-writes any bindings that you have made.)
Change a canvas coordinate into a world coordinate.
@w_pt = $view->world_pt(@cnv_pt);
Change a world coordinate into a canvas coordinate.
@cnv_pt = $view->cnv_pt(@w_pt);
Returns the canvas (x,y) coordinates of the last event.
my ($x,$y) = $view->eventLocation();
Returns the world (x,y) coordinates of the last event.
($x,$y) = $view->event_coords();
almost straight from WorldCanvas
Sets all of the bindings specified in %tmp and returns the old bindings in %was.
%was = $view->bind_on(\%tmp);
Replaces the %was bindings and removes any leftover from %tmp.
$tag = addr_to_tag($n, $addr);
($n, $addr) = tag_to_addr($tag);