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.
write me
Eric L. Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com
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.
CAD::Drawing::GUI Tk::Zinc
These make me behave like a Tk widget.
$view->ClassInit();
$view->InitObject();
$view->configure(%args);
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->group_is();
$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".
$view->add_drawing($number, $drw);
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.
$view->draw_item($obj, $tag);
$view->redraw_item();
$view->viewAll();
$view->viewArea(@bbox);
$view->viewWorldArea([$x1,$y1],[$x2,$y2]);
$view->zoom($factor);
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();
This is a freehand measuring tape. Maybe we'll have some snaps someday (but likely not with this graphical toolkit.)
$view->free_dist();
$view->pan($x,$y);
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.
Sets-up the wheel-zoom and middle-button pan. (This over-writes any bindings that you have made.)
$view->view_bindings();
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.
$view->bind_off(\%tmp, \%was);
$tag = addr_to_tag($n, $addr);
($n, $addr) = tag_to_addr($tag);
To install CAD::Drawing::GUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CAD::Drawing::GUI
CPAN shell
perl -MCPAN -e shell install CAD::Drawing::GUI
For more information on module installation, please visit the detailed CPAN module installation guide.