Graham Bell > App-SourcePlot-1.18 > App::SourcePlot::Plotter::Tk

Download:
App-SourcePlot-1.18.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.11   Source   Latest Release: App-SourcePlot-1.22

NAME ^

App::SourcePlot::Plotter::Tk - creates a Tk canvas with easy-to-use method names.

DESCRIPTION ^

This class provides methods to use a GUI canvas with ease. The commands will be generalized to ensure easy transfer between graphing packages.

EXTERNAL MODULES ^

  Tk

PUBLIC METHODS ^

These are the methods avaliable in this class:

new

Create a new instance of Plotter::Tk object. A new canvas will be created with the specified coordinates. This method will create a new window for use by the canvas if one is not passed in.

  $plotter = new App::SourcePlot::Plotter::Tk();
  $plotter = new App::SourcePlot::Plotter::Tk($width, $height);
  $plotter = new App::SourcePlot::Plotter::Tk($width, $height, $numWindowsX, $numWindowsY);
  $plotter = new App::SourcePlot::Plotter::Tk($width, $height, $numWindowsX, $numWindowsY, $MainWindow);
destroy

Destroys an object of this type. Cleans up the variables and windows within.

  destroy $plotter;
getCanvas

Used specifically within this module, it allows the programmer to add new features to this module with ease by accessing the Tk canvas

  $can = $plotter->getCanvas();
currentCanvasNum

Either sets the current canvas by number or returns the current canvass number.

  $canNum = $plotter->currentCanvasNum();
  $plotter->currentCanvasNum(3);
nextCanvas

increments the current canvas number by one, looping back to 0 if passing the last.

  $plotter->nextCanvas();
numCanvases

Sets and returns the number of canvases.

  $numCan = $plotter->numCanvases();
  $plotter->numCanvases(3);
defaultSuffix

Returns the default suffix for graphics files

  $suf = $plotter->defaultSuffix();
  $plotter->defaultSuffix('gif');
width

Returns the width of a canvas.

  $w = $plotter->width();
height

Returns the width of a canvas.

  $w = $plotter->height();
setBackground

Sets the background color

  $plotter->setBackground('black');
setForeground

Sets the foreground color

  $plotter->setForeground('black');
font

Sets and returns the font currently being used

  $f = $plotter->font();
  $plotter->font($f);
fontColor

Sets and returns the font color

  $plotter->fontColor('black');
fontSize

Sets and returns the font size

  $plotter->fontSize(5);
  $size = $plotter->fontSize();
drawColor

Sets and returns the drawing color, used for filling as well.

  $plotter->drawColor('Black');
  $c = $plotter->drawColor();
penWidth

Sets and returns the width lines, circles, etc will be drawn in.

  $plotter->penWidth(3);
  $w = $plotter->penWidth();
pack

Packs the current canvas into a certain position within a main window or frame.

  $plotter->pack(-side => 'left');
worldCenter

Sets the center of the world coordinates on the screen Best to set the centre in pixels, and then the appropriate world coordinates can be set at this point using worldAtZero.

  $plotter->worldCenter ($centerx, $centery);
worldAtZero

Offsets the centre of the world coordinates to allow specific world coordinates to be the new centre coordinates.

  $plotter->worldAtZero ($centerx, $centery);
worldToPixelRatio

Sets the ratio between the world coordinates and pixels

  $plotter->worldToPixRatio ($dx, $dy);
usingWorld

Tells the module whether you wish to use the world coordinates when specifying coordinates, or if you want to use pixels Returns and sets the value (1 for on, 0 for off)

  $u = $plotter->usingWorld();
  $plotter->usingWorld(1);
setWorldSize

Sets the center of the world coordinates and the ratio between those coordinates and pixels

  $plotter->setWorldSize ($centerx, $centery, $dx, $dy);
toP

Converts coordinates into pixels. The input coordinates are assumed to be associated with the value in usingWorld.

  ($x, $y) = $plotter->toP ($x1, $y1);
  ($x) = $plotter->toPx ($x1);
  ($y) = $plotter->toPy ($y1);
toW

Converts pixel coordinates into current system. The output coordinates are assumed to be associated with the value in usingWorld.

  ($x, $y) = $plotter->toW ($x1, $y1);
  ($x) = $plotter->toWx ($x1);
  ($y) = $plotter->toWy ($y1);
clean

Removes all drawn objects from the canvas.

  $plotter->clean();
delete

Deletes all objects with one specific tag.

  $plotter->delete ('oval');
printCanvas

Prints the canvas to a printer

  $plotter->printCanvas ('file', 'filename');
  $plotter->printCanvas ('printer', '-PHello');
flushGraphics

This function is not used in this module but should be included as the last command before you want your graphics to appear. Allows for easy mobility between different plotters.

  $plotter->flushGraphics();
configureTag

Configures the items with the given tag.

  $plotter->configureTag ('oval', -fill => 'black');
bindTag

Binds the items with the given tag.

  $plotter->bindTag ('oval', '<Any-Enter>' => sub {print "hello"});
existTag

Returns the number of items associated with that tag

  $exists = $plotter->existTag ('oval');
raiseAbove

Raise the objects with the first tag above the objects with the second tag.

  $plotter->raiseAbove ('oval', 'square');
lowerBelow

Lowers the objects with the first tag below the objects with the second tag.

  $plotter->lowerBelow ('oval', 'square');
drawTextVert

Draws text on the current canvas in the given (x, y) coordinates using the current font, font size, and font Color. Returns the text item number. Adds a tag name if one is given. Draws it vertically

  $plotter->drawTextVert (5,5, "hello");
  $id = $plotter->drawTextVert (5,5, "hello", 'text');
drawText

Draws text on the current canvas in the given (x, y) coordinates using the current font, font size, and font Color. Returns the text item number. Adds a tag name if one is given.

  $plotter->drawText (5,5, "hello");
  $id = $plotter->drawText (5,5, "hello", 'text');
drawTextFromLeft

Draws text on the current canvas in the given (x, y) coordinates using the current font, font size, and font Color. Returns the text item number. Adds a tag name if one is given.

  $plotter->drawTextFromLeft (5,5, "hello");
  $id = $plotter->drawTextFromLeft (5,5, "hello", 'text');
drawTextFromRight

Draws text on the current canvas in the given (x, y) coordinates using the current font, font size, and font Color. Returns the text item number. Adds a tag name if one is given.

  $plotter->drawTextFromRight (5,5, "hello");
  $id = $plotter->drawTextFromRight (5,5, "hello", 'text');
drawOval

Draws an oval on the current canvas in the given set of (x, y) coordinates Returns the ovals item number. Adds a tag name if one is given.

  $plotter->drawOval (5,5, 10, 10);
  $id = $plotter->drawOval (5,5, 10, 10, 'oval');
drawFillOval

Draws an oval on the current canvas in the given set of (x, y) coordinates and fills it. Returns the ovals item number. Adds a tag name if one is given.

  $plotter->drawFillOval (5,5, 10, 10);
  $id = $plotter->drawFillOval (5,5, 10, 10, 'oval');
drawLine

Draws a line on the current canvas in the given set of (x, y) coordinates Returns the lines item number. Adds a tag name if one is given.

  $plotter->drawLine (5,5, 10, 10);
  $id = $plotter->drawLine (5,5, 10, 10, 'line');
drawSmoothLine

Draws a smooth line on the current canvas through the given (x, y) coordinates. Gives the object the tag $tag if one is given

  $plotter->drawSmoothLine (5=>5, 10=>10, 15=>5, 20=>0);
  $id = $plotter->drawSmoothLine (5=>5, 10=>10, 15=>5, 20=>0, $tag);
drawBox

Draws a box on the current canvas in the given set of (x, y) coordinates Returns the box item number. Adds a tag name if one is given.

  $plotter->drawBox (5,5, 10, 10);
  $id = $plotter->drawBox (5,5, 10, 10, 'box');
gamma

Sets the light intensity for the image.

  $g = $plotter->gamma();
  $plotter->gamma(3);
photoWorldSize

Sets and returns the current photos world sizes in arcseconds

  ($xs, $ys) = $plotter->photoWorldSize();
  $plotter->photoWorldSize(5,5);
photoFile

Sets and returns the current image file

  $img = $plotter->photoFile();
  $plotter->photoFile("file");
origPhot

Sets and returns the original image

  $img = $plotter->origPhot();
  $plotter->origPhot($img);
setImage

Sets the image stored in the file specified by photFile into memory.

  $plotter->setImage();
phot

Retrieves an image from the specified file. Returns the image object

  $img = $plotter->phot();
  $plotter->phot();
  $plotter->phot(100, 100);
drawPhot

Draws a picture on the current canvas, centering it. The picture is can be changed by using the phot method.

  $plotter->drawPhot ();
monitorXY

Monitor the X and Y coordinates of the cursor on the canvas. This can be used to provide feedback to the user as to the current cursor position.

Arguments are 2 scalar references. These references are updated to contain the current value of the cursor position or a value of 'undef' (a string) when the cursor is not present in the plotting area.

If called without arguments, the bindings are removed.

zoomOut

Zooms the world to pixel ratio and the current image out.

  $plotter->zoomOut ();
zoomIn

Zooms the world to pixel ratio and the current image in.

  $plotter->zoomIn();
zoomNum

Returns the zoom factor for the picture

  $plotter->zoomNum(5);
  $num = $plotter->zoomNum();

AUTHOR ^

Casey Best (University of Victoria) with help from Tim Jenness.

COPYRIGHT ^

Copyright (C) 2012 Science and Technology Facilities Council. Copyright 1998-2000 Particle Physics and Astronomy Research Council. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: