NAME
CAD::Drawing::GUI::View - 2D graphics for CAD built on Tk::Zinc
DESCRIPTION
This module provides methods to turn a CAD::Drawing object into a Zinc canvas.
SYNOPSIS
write me
AUTHOR
Eric L. Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com
COPYRIGHT
This module is copyright (C) 2004-2006 by Eric L. Wilhelm.
LICENSE
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)
Modifications
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.
SEE ALSO
CAD::Drawing::GUI
Tk::Zinc
Overridden Methods
These make me behave like a Tk widget.
ClassInit
$view->ClassInit();
InitObject
$view->InitObject();
configure
$view->configure(%args);
args_filter
Filters configure arguments and adds non-tk args to our private data.
%args = $view->args_filter(%args);
privateData accessor methods
group_is
This object expects you to draw all of your items in this group.
$view->group_is();
active
$view->active() or print "no\n";
$view->active(1);
$view->active(0);
gui_parent
Retrieves or sets the -parent attribute (not to be confused with a parent window.)
$gui = $view->gui_parent();
$view->gui_parent($gui);
Drawing Methods
The following methods handle the drawing of items from CAD::Drawing objects.
add_drawing
Adds drawing $drw as number $number. This tags all of the items drawn by "$number:$type:$id:$layer".
$view->add_drawing($number, $drw);
drawing_update
Updates the canvas with the item at $addr.
$view->drawing_update($n, $drw, $addr);
draw_item
Draws the $obj (possibly in multiple pieces), using $tag as the identifier.
$view->draw_item($obj, $tag);
redraw_item
$view->redraw_item();
Useful Methods
viewAll
$view->viewAll();
viewArea
$view->viewArea(@bbox);
viewWorldArea
$view->viewWorldArea([$x1,$y1],[$x2,$y2]);
zoom
$view->zoom($factor);
windowzoom
Creates temporary bindings for drawing a rubber-band box and zooming on the area described by it. This will put back your existing bindings.
$view->windowzoom();
free_dist
This is a freehand measuring tape. Maybe we'll have some snaps someday (but likely not with this graphical toolkit.)
$view->free_dist();
pan
$view->pan($x,$y);
Additional Methods
click_bind
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)
$view->click_bind($sub, $button);
The $button argument is optional, and defaults to 1.
I advise you to not use 2 if view_bindings() is active.
view_bindings
Sets-up the wheel-zoom and middle-button pan. (This over-writes any bindings that you have made.)
$view->view_bindings();
Coordinate System Methods
world_pt
Change a canvas coordinate into a world coordinate.
@w_pt = $view->world_pt(@cnv_pt);
cnv_pt
Change a world coordinate into a canvas coordinate.
@cnv_pt = $view->cnv_pt(@w_pt);
eventLocation
Returns the canvas (x,y) coordinates of the last event.
my ($x,$y) = $view->eventLocation();
event_coords
Returns the world (x,y) coordinates of the last event.
($x,$y) = $view->event_coords();
rubberBand
almost straight from WorldCanvas
bind_on
Sets all of the bindings specified in %tmp and returns the old bindings in %was.
%was = $view->bind_on(\%tmp);
bind_off
Replaces the %was bindings and removes any leftover from %tmp.
$view->bind_off(\%tmp, \%was);
Functions
addr_to_tag
$tag = addr_to_tag($n, $addr);
tag_to_addr
($n, $addr) = tag_to_addr($tag);