/aquaterm.pd

http://github.com/gitpan/PDL-Graphics-AquaTerm · Unknown · 803 lines · 578 code · 225 blank · 0 comment · 0 complexity · 259f223dafdc31a55bbdaea956cf0ce9 MD5 · raw file

  1. $VERSION = '0.02';
  2. pp_bless('PDL::Graphics::AquaTerm');
  3. ###
  4. # Header files
  5. ###
  6. pp_addhdr('
  7. #include "aquaterm/aquaterm.h"
  8. ');
  9. ###
  10. # pp_def
  11. ###
  12. # set the background color
  13. pp_def('callAqtSetBackgroundColor',
  14. Pars => 'rgb(n);',
  15. GenericTypes => [F],
  16. Code => '
  17. aqtSetBackgroundColor($rgb(n=>0), $rgb(n=>1), $rgb(n=>2));
  18. '
  19. );
  20. # set the current plot color
  21. pp_def('callAqtSetColor',
  22. Pars => 'rgb(n);',
  23. GenericTypes => [F],
  24. Code => '
  25. aqtSetColor($rgb(n=>0), $rgb(n=>1), $rgb(n=>2));
  26. '
  27. );
  28. # add a bitmap to the plot
  29. pp_def('callAqtBitmap',
  30. Pars => 'bm(n,m,o)',
  31. OtherPars => 'float dx; float dy; float dw; float dh',
  32. GenericTypes => [B],
  33. Code => '
  34. aqtEraseRect($COMP(dx), $COMP(dy), $COMP(dw), $COMP(dh));
  35. aqtAddImageWithBitmap($P(bm), $SIZE(m), $SIZE(o), $COMP(dx), $COMP(dy), $COMP(dw), $COMP(dh));
  36. '
  37. );
  38. # add a line to the plot
  39. # printf("size %d %f %f\n",$SIZE(n),$lx(n=>1),$ly(n=>1)); debugging relic
  40. pp_def('callAqtPolyline',
  41. Pars => 'lx(n); ly(n)',
  42. GenericTypes => [F],
  43. Code => '
  44. aqtAddPolyline($P(lx), $P(ly), $SIZE(n));
  45. '
  46. );
  47. ###
  48. # XS
  49. ###
  50. # deals with mouse events, which return a string giving the mouse location
  51. pp_addxs(<<'EOC');
  52. char *
  53. callAqtWaitNextEvent()
  54. CODE:
  55. int val;
  56. char temp[40];
  57. val = aqtWaitNextEvent(temp);
  58. RETVAL = temp;
  59. OUTPUT:
  60. RETVAL
  61. void
  62. aqtInit()
  63. void
  64. aqtOpenPlot(win_num)
  65. int win_num
  66. void
  67. aqtSelectPlot(win_num)
  68. int win_num
  69. void
  70. aqtSetPlotSize(size_x, size_y)
  71. int size_x
  72. int size_y
  73. void
  74. aqtSetPlotTitle(title)
  75. char *title
  76. void
  77. aqtMoveTo(x,y)
  78. int x
  79. int y
  80. void
  81. aqtAddLineTo(x,y)
  82. int x
  83. int y
  84. void
  85. aqtRenderPlot()
  86. void
  87. aqtClearPlot()
  88. void
  89. aqtAddLabel(text, x, y, angle, align)
  90. char *text
  91. float x
  92. float y
  93. float angle
  94. int align
  95. void
  96. aqtSetLinewidth(lw)
  97. float lw
  98. void
  99. aqtSetLineCapStyle(cs)
  100. int cs
  101. void
  102. aqtSetFontname(fn)
  103. char *fn
  104. void
  105. aqtSetFontsize(fs)
  106. float fs
  107. EOC
  108. ###
  109. # Perl subroutines
  110. ###
  111. pp_addpm(<<'EOD');
  112. ## we need PDL
  113. use PDL;
  114. ## private variables
  115. my $warning_message = ">>> AquaTerm.pm Warning : "; # generic start of warning messages
  116. my $debug_message = ">>> AquaTerm.pm Debug : "; # generic start of debugging messages
  117. my %open_windows; # stores whether the window exists (by whether the key/value is defined/undefined)
  118. my $win_counter = 1; # the default window number to open
  119. my $initialized = 0; # flag for whether the connection to the aquaterm program was already made
  120. my $warn_on = 0; # turn on/off whether warnings are desired
  121. my $debug_on = 0; # turn on/off whether debugging information is desired
  122. my $current_window = 1; # the currently active window
  123. my $color_table = pdl(0); # local storage for a user-defined color table
  124. my %window_options = ( # default window options
  125. SIZE_X => 400,
  126. SIZE_Y => 300,
  127. WIN_TITLE => "AquaTerm.pm",
  128. BACK_COLOR => [1.0, 1.0, 1.0],
  129. WARN_ON => 1,
  130. DEBUG_ON => 0
  131. );
  132. ## the private sub-routines
  133. # select a window if it exists, return 0 if it does not.
  134. sub selectWindow {
  135. my $ret = 1;
  136. my $win_num = $_[0];
  137. if ($win_num == -1) { # default to the currently open window
  138. $win_num = $current_window;
  139. }
  140. if ($open_windows{$win_num}) {
  141. unless ($current_window == $win_num) {
  142. aqtSelectPlot($win_num);
  143. $current_window = $win_num;
  144. }
  145. } else {
  146. print "$warning_message no such window number was available\n";
  147. $ret = 0;
  148. }
  149. $ret;
  150. }
  151. # parse options hashes
  152. sub parseOptions {
  153. my $input_options = shift;
  154. my $default_options = shift;
  155. if ($debug_on){
  156. print "$debug_message options hash is : \n";
  157. }
  158. while ( my($temp_key, $temp_value) = each %{$input_options} ) {
  159. if ($debug_on){
  160. print " " . $temp_key . " => " . $temp_value . "\n";
  161. }
  162. if (exists $default_options->{$temp_key}) {
  163. $default_options->{$temp_key} = $temp_value;
  164. } else {
  165. print "$warning_message no such option : $temp_key\n";
  166. }
  167. }
  168. }
  169. # output an options hash (for debugging mostly)
  170. sub outputHash {
  171. my $hash_name = shift;
  172. my $the_hash = shift;
  173. print "$debug_message $hash_name hash is : \n";
  174. foreach my $temp_key (keys %{$the_hash}){
  175. print " " . $temp_key . " => " . $the_hash->{$temp_key} . "\n";
  176. }
  177. }
  178. ## the public sub-routines
  179. # opens a window using user supplied parameters, or uses defaults if they don't exist
  180. sub aquaOpen{
  181. my %options;
  182. $window_options{"WIN_NUM"} = $win_counter;
  183. if ($debug_on){
  184. print "\n>>> aquaOpen\n\n";
  185. }
  186. # get, check and load any user supplied options
  187. if ($_[0]){ parseOptions($_[0], \%window_options); }
  188. # check if this window number already exists
  189. if (exists $open_windows{$window_options{"WIN_NUM"}}) {
  190. if ($warn_on) {
  191. print "$warning_message window number " . $window_options{"WIN_NUM"} . " already exists\n";
  192. }
  193. }
  194. my $win_title = '(' . $window_options{"WIN_NUM"} . ') ' . $window_options{"WIN_TITLE"};
  195. $current_window = $window_options{"WIN_NUM"};
  196. $open_windows{$window_options{"WIN_NUM"}} = 1;
  197. $win_counter++;
  198. # initialize connection to aquaterm program, if that hasn't already been done
  199. unless ($initialized) {
  200. aqtInit();
  201. $initialized = 1;
  202. }
  203. # set warnings & debugging flags
  204. $warn_on = $window_options{"WARN_ON"};
  205. $debug_on = $window_options{"DEBUG_ON"};
  206. # output the window_options hash if we are in debugging mode
  207. if ($debug_on){
  208. outputHash("window_options", \%window_options);
  209. outputHash("open_windows", \%open_windows);
  210. }
  211. # open up a window with the user/default parameters
  212. aqtOpenPlot($window_options{"WIN_NUM"});
  213. aqtSetPlotSize($window_options{"SIZE_X"}, $window_options{"SIZE_Y"});
  214. aqtSetPlotTitle($win_title);
  215. # this forces aquaterm to actually open and draw the window
  216. callAqtSetBackgroundColor(pdl($window_options{"BACK_COLOR"}));
  217. aqtMoveTo(0.0, 0.0);
  218. aqtAddLineTo(1.0, 1.0);
  219. aqtRenderPlot();
  220. aqtClearPlot();
  221. # if necessary, initialize the default color table (a gray scale)
  222. unless($color_table->ndims() == 2){
  223. $color_table = zeroes(byte,256,3);
  224. $color_table = xvals($color_table);
  225. }
  226. return 1;
  227. }
  228. # display a pdl as a 2 dimensional bitmap
  229. sub aquaBitmap{
  230. my %options;
  231. my %display_options = ( # default display options
  232. ERASE => 0,
  233. DEST_X => 0,
  234. DEST_Y => 0,
  235. DEST_W => -1,
  236. DEST_H => -1,
  237. AUTO_SCALE => 0,
  238. M_MIN => 0.0,
  239. M_MAX => 255.0,
  240. WIN_NUM => -1,
  241. TEXT => "",
  242. TEXT_X => 6.0,
  243. TEXT_Y => 10.0,
  244. TEXT_C => [0.0, 0.0, 0.0]
  245. );
  246. if ($debug_on){
  247. print "\n>>> aquaDisplayBitmap\n\n";
  248. }
  249. # get, check and load user supplied options
  250. my $num_dims;
  251. my @bmp_dims;
  252. my $the_bitmap;
  253. if (@_) {
  254. $the_bitmap = $_[0];
  255. $num_dims = $the_bitmap->ndims();
  256. @bmp_dims = $the_bitmap->dims();
  257. unless (($num_dims == 2) || ($num_dims == 3)) {
  258. print "$warning_message a pdl with $num_dims dimensions is not supported\n";
  259. return 0;
  260. }
  261. if ($_[1]) { parseOptions($_[1], \%display_options); }
  262. } else {
  263. print "$warning_message no pdl was supplied for aquaDisplayBitmap\n";
  264. return 0;
  265. }
  266. # if the user didn't provide the width and height of the part that they want to show, default to showing the whole thing
  267. if ($display_options{"DEST_W"} == -1) {
  268. if ($num_dims == 2) {
  269. $display_options{"DEST_W"} = $bmp_dims[0];
  270. } else {
  271. $display_options{"DEST_W"} = $bmp_dims[1];
  272. }
  273. }
  274. if ($display_options{"DEST_H"} == -1) {
  275. if ($num_dims == 2) {
  276. $display_options{"DEST_H"} = $bmp_dims[1];
  277. } else {
  278. $display_options{"DEST_H"} = $bmp_dims[2];
  279. }
  280. }
  281. # check whether the user wants to auto-scale the image
  282. if ($display_options{"AUTO_SCALE"}){
  283. $display_options{"M_MIN"} = min($the_bitmap);
  284. $display_options{"M_MAX"} = max($the_bitmap);
  285. }
  286. # re-scale the image if necessary
  287. if (($display_options{"M_MIN"} != 0.0) || ($display_options{"M_MAX"} != 255.0)){
  288. if($debug_on){
  289. print "$debug_message re-scaling image " . $display_options{"M_MIN"} . " - " . $display_options{"M_MAX"} . "\n";
  290. }
  291. $the_bitmap = float($the_bitmap);
  292. if($display_options{"M_MIN"} < $display_options{"M_MAX"}) {
  293. $the_bitmap = ($the_bitmap - $display_options{"M_MIN"}) * 255.0 / ($display_options{"M_MAX"} - $display_options{"M_MIN"});
  294. } else {
  295. print "$warning_message min is greater then max, image re-scale aborted\n";
  296. }
  297. }
  298. # threshold the image so that it doesn't roll over
  299. $the_bitmap = $the_bitmap * ($the_bitmap >= 0.0);
  300. $the_bitmap -= 255.0;
  301. $the_bitmap = $the_bitmap * ($the_bitmap <= 0.0);
  302. $the_bitmap += 255.0;
  303. $the_bitmap = byte($the_bitmap);
  304. # select the appropriate window, or open a new one if no such window is available
  305. unless(selectWindow($display_options{"WIN_NUM"})){
  306. aquaOpen({WIN_NUM => $display_options{"WIN_NUM"}, SIZE_X => $display_options{"DEST_W"}, SIZE_Y => $display_options{"DEST_H"}});
  307. }
  308. # output the display_options hash if we are in debugging mode
  309. if ($debug_on){ outputHash("display_options", \%display_options); }
  310. # make the image "true-color" if necessary
  311. if ($num_dims == 2) {
  312. $the_bitmap = index($color_table, $the_bitmap->dummy(0)); # convert the image to true color
  313. }
  314. if($display_options{"ERASE"}) { aqtClearPlot(); } # if desired, clear the current plot
  315. # display the image
  316. callAqtBitmap($the_bitmap, $display_options{"DEST_X"}, $display_options{"DEST_Y"}, $display_options{"DEST_W"}, $display_options{"DEST_H"});
  317. # if the user supplied a number, then add it to the plot
  318. if ($display_options{"TEXT"}){
  319. callAqtSetColor(pdl($display_options{"TEXT_C"}));
  320. aqtAddLabel($display_options{"TEXT"}, $display_options{"TEXT_X"}, $display_options{"TEXT_Y"}, 0.0, 0);
  321. }
  322. # tell aquaterm to draw the new plot
  323. aqtRenderPlot();
  324. return 1;
  325. }
  326. # Makes a local copy of a user supplied color table. It is assumed that the color
  327. # table pdl is of the form ($levels, $red, $green, $blue), a 256 x 4 pdl, as would
  328. # be generated by the command '$color_table = cat(lut_data("xx"))'. $levels is ignored.
  329. # $red, $green & $blue are assumed to range from 0 to 1.
  330. sub aquaSetColorTable{
  331. if ($debug_on){
  332. print "\n>>> aquaSetColorTable\n\n";
  333. }
  334. if (@_) {
  335. my $col_tab = $_[0];
  336. if (($col_tab->getdim(0) == 256)&&($col_tab->getdim(1) == 4)){
  337. $color_table = byte(255.0 * ($col_tab->slice('0:255,1:3'))->copy);
  338. } else {
  339. print "$warning_message color table has the wrong dimensions (256 x 4 expected)";
  340. }
  341. } else {
  342. print "$warning_message no color table supplied";
  343. }
  344. }
  345. # Draw lines between a set of points given by a PDL of size (2,n), where the first dimension is
  346. # x & y position of the points and n is the number of points
  347. sub aquaPolyLine{
  348. my %options;
  349. my %line_options = ( # default line options
  350. WIN_NUM => -1,
  351. ERASE => 0,
  352. WIDTH => 1,
  353. CAPS => 0,
  354. COLOR => [0.0, 0.0, 0.0]
  355. );
  356. if ($debug_on){
  357. print "\n>>> aquaPolyLine\n\n";
  358. }
  359. # get, check and load user supplied options
  360. my $the_line;
  361. if (@_) {
  362. $the_line = float($_[0]);
  363. if ($_[1]){ parseOptions($_[1], \%line_options); }
  364. } else {
  365. print "$warning_message no pdl was supplied for aquaPolyLine\n";
  366. return 0;
  367. }
  368. # output the line_options hash if we are in debugging mode
  369. if ($debug_on){ outputHash("line_options", \%line_options); }
  370. # select the right window to draw in
  371. unless(selectWindow($line_options{"WIN_NUM"})) { return; }
  372. # set up for line drawing
  373. if($line_options{"ERASE"}) { aqtClearPlot(); } # if desired, clear the current plot
  374. callAqtSetColor(pdl($line_options{"COLOR"})); # set the line color
  375. aqtSetLinewidth($line_options{"WIDTH"}); # set the line width
  376. aqtSetLineCapStyle($line_options{"CAPS"}); # set the line cap style
  377. # add the line to the plot
  378. my $x = $the_line->slice("0,:")->squeeze->copy;
  379. my $y = $the_line->slice("1,:")->squeeze->copy;
  380. callAqtPolyline($x, $y);
  381. # render the plot
  382. aqtRenderPlot();
  383. }
  384. # draw text on the screen with the selectable font, size & color
  385. sub aquaText{
  386. my %options;
  387. my %text_options = ( # default text options
  388. WIN_NUM => -1,
  389. ERASE => 0,
  390. NAME => "Times-Roman",
  391. ANGLE => 0.0,
  392. X => 6.0,
  393. Y => 10.0,
  394. JUST => 0,
  395. SIZE => 12.0,
  396. COLOR => [0.0, 0.0, 0.0]
  397. );
  398. if ($debug_on){
  399. print "\n>>> aquaDrawText\n\n";
  400. }
  401. # get, check and load user supplied options
  402. my $the_text;
  403. if (@_) {
  404. $the_text = $_[0];
  405. if ($_[1]){ parseOptions($_[1], \%text_options); }
  406. } else {
  407. print "$warning_message no text was supplied for aquaDrawText\n";
  408. return 0;
  409. }
  410. # output the text_options hash if we are in debugging mode
  411. if ($debug_on){ outputHash("text_options", \%text_options); }
  412. # select the right window to draw in
  413. unless(selectWindow($text_options{"WIN_NUM"})) { return; }
  414. # set the font size & type & color
  415. callAqtSetColor(pdl($text_options{"COLOR"}));
  416. aqtSetFontname($text_options{"NAME"});
  417. aqtSetFontsize($text_options{"SIZE"});
  418. # draw the text
  419. if($text_options{"ERASE"}) { aqtClearPlot(); } # if desired, clear the current plot
  420. aqtAddLabel($the_text, $text_options{"X"}, $text_options{"Y"}, $text_options{"ANGLE"}, $text_options{"JUST"});
  421. # render the plot
  422. aqtRenderPlot();
  423. }
  424. # return the coordinates of the next mouse click
  425. sub aquaMouse{
  426. my %options;
  427. my %mouse_options = ( # mouse options
  428. WIN_NUM => -1
  429. );
  430. if ($debug_on){
  431. print "\n>>> aquaMouse\n\n";
  432. }
  433. # get, check and load user supplied options
  434. if ($_[0]){ parseOptions($_[0], \%mouse_options); }
  435. # output the display_options hash if we are in debugging mode
  436. if ($debug_on){ outputHash("mouse_options", \%mouse_options); }
  437. # select the window that we want to click in
  438. unless(selectWindow($mouse_options{"WIN_NUM"})) { return; }
  439. my $event = callAqtWaitNextEvent();
  440. my @loc;
  441. if($event =~ /{([\d]+)[^\d]+([\d]+)}/){
  442. push @loc, $1, $2;
  443. # push @loc, $2;
  444. }
  445. @loc;
  446. }
  447. EOD
  448. ###
  449. # specify those functions that will be exported
  450. ###
  451. # clear the auto-generated list
  452. pp_export_nothing();
  453. # add the "right" functions
  454. pp_add_exported('', 'aquaOpen', 'aquaBitmap', 'aquaSetColorTable', 'aquaPolyLine', 'aquaText', 'aquaMouse');
  455. ###
  456. # Documentation
  457. ###
  458. pp_addpm({At=>'Bot'},<<'EOD');
  459. =head1 NAME
  460. PDL::Graphics::AquaTerm - Provides access to the AquaTerm Mac OS-X graphics terminal
  461. =head1 SYNOPSIS
  462. # example 1
  463. use PDL;
  464. use PDL::Graphics::LUT;
  465. use PDL::Graphics::AquaTerm;
  466. my $x_size = 255; my $y_size = 255;
  467. aquaOpen({SIZE_X => $x_size, SIZE_Y => $y_size});
  468. aquaSetColorTable(cat(lut_data('idl5')));
  469. my $a = xvals(zeroes(byte,$x_size,$y_size));
  470. aquaBitmap($a);
  471. # example 2
  472. use PDL;
  473. use PDL::Graphics::AquaTerm;
  474. my $x_size = 255; my $y_size = 255;
  475. aquaOpen({WIN_NUM => 1, SIZE_X => $x_size, SIZE_Y => $y_size});
  476. my $a = sin(xvals(zeroes(float, $x_size, $y_size)) * 0.1);
  477. aquaBitmap($a, {AUTO_SCALE => 1});
  478. =head1 DESCRIPTION
  479. This module interfaces PDL directly to the AquaTerm Mac OS-X graphics terminal. It is primarily intended for quickly and easily displaying bitmap images.
  480. The coordinate system is defined by the window size (given in pixels) with (0,0) at the bottom left corner of the window. This means that if the window is set to be 300 x 200, then the bottom left corner will have coordinates (0,0) and the upper right corner will have coordinates (300,200). Anything that is drawn outside this boundary will be automatically clipped.
  481. =head1 FUNCTIONS
  482. =head2 aquaOpen
  483. =for ref
  484. Open a new AquaTerm window
  485. =for usage
  486. Usage: aquaOpen(); # open the window with the defaults
  487. Usage: aquaOpen({SIZE_X => 200, SIZE_Y => 200, BACK_COLOR => [0.0, 0.0, 0.0]});
  488. Opens a new AquaTerm window, it also starts AquaTerm if necessary.
  489. Options recognized :
  490. SIZE_X - window x size in pixels (default = 400)
  491. SIZE_Y - window y size in pixels (default = 300)
  492. WIN_NUM - The window number, used by the drawing commands to specify which window to draw in
  493. WIN_TITLE - A title for the window, if desired (default = "Aquaterm.pm")
  494. BACK_COLOR - [r, g, b] the windows background color (default = [1.0, 1.0, 1.0], i.e. white)
  495. WARN_ON - set to 1 to turn on warning messages, 0 to turn off (default = 1)
  496. DEBUG_ON - set to 1 to turn on debugging message, 0 to turn off (default = 0)
  497. =head2 aquaBitmap
  498. =for ref
  499. Display a PDL as a bitmap.
  500. =for usage
  501. Usage: aquaDisplay($my_img); # display $my_img as a bitmap in the currently open window
  502. Usage: aquaDisplay($my_img, {AUTO_SCALE => 1.0, TEXT => "my image", TEXT_C => [1.0, 0.0, 0.0]});
  503. Displays a PDL as a bitmap. The PDL can be of size either (m,n) or (3,m,n). PDLs of size (m,n) are converted to indexed color based on the current color table (see aquaSetColorTable). PDLs of size (3,m,n) are displayed as true-color images with the first dimension specifying the color (RGB). Unless a re-scaling is specified, the minimum value displayed is 0.0 and the maximum is 255.0.
  504. Options recognized :
  505. DEST_X - position of the left side of the bitmap in pixels (default = 0)
  506. DEST_Y - position of the bottom of the bitmap in pixels (default = 0)
  507. DEST_W - width of the bitmap to be displayed (default = width of the PDL)
  508. DEST_H - height of the bitmap to be displayed (default = height of the PDL)
  509. AUTO_SCALE - if set equal to 1, the PDL will be rescaled such that its
  510. minimum value is 1 and its max is 255 (default = 0)
  511. M_MIN - the minimum value to be displayed (default = 0.0)
  512. M_MAX - the maximum value to be displayed (default = 255.0)
  513. WIN_NUM - specify which window to draw in (default = current window)
  514. TEXT - text to display on the bitmap
  515. TEXT_X - x location of the text in pixels (default = 6)
  516. TEXT_Y - y location of the text in pixels (default = 10)
  517. TEXT_C - RGB color of the text, (default = [0.0, 0.0, 0.0], i.e. black)
  518. =head2 aquaSetColorTable
  519. =for ref
  520. Set the color table
  521. =for usage
  522. Usage: aquaSetColorTable(cat(lut_data('idl5'))); # set the color table to idl5
  523. Makes a local copy of a user supplied color table. The color table must be a 256 x 4 pdl of the form (l,r,g,b), as would be generated by the command '$ct = cat(lut_data("xyz"))'. The l value is ignored. The r, g and b values should be in the range 0.0 - 1.0.
  524. =head2 aquaPolyLine
  525. =for ref
  526. Draws a (2,n) PDL as a line
  527. =for usage
  528. Usage: aquaPolyLine($line, {WIDTH => 3, COLOR => [0.0, 0.0, 0.0]}); # draw $line black with width 3
  529. Draw a poly-line between a set of points given by a PDL of size (2,n). The first dimension of the PDL gives the x & y position of the individual points, n is the total number of points.
  530. Options recognized
  531. WIN_NUM - which window to draw the line in
  532. ERASE - clear the selected window prior to drawing the line
  533. WIDTH - line width (default = 1)
  534. CAPS - line cap style, I'm still unsure exactly what this is...
  535. COLOR - RGB color of the line (default is black)
  536. =head2 aquaText
  537. =for ref
  538. Draw text
  539. =for usage
  540. # draw red 'hello world' at position 20, 30 in the current window
  541. Usage: aquaText("hello world", X => 20, Y => 30, COLOR => [1.0, 0.0, 0.0]);
  542. Draws text.
  543. Options recognized
  544. WIN_NUM - which window to draw the text in
  545. ERASE - clear the current window prior to drawing the text
  546. NAME - name of the font to use (default = "Times-Roman")
  547. ANGLE - angle to display the text relative to the horizontal in degrees (default = 0.0)
  548. X - position in the window of the text anchor point (which depends on the justification of the text) (default = 6)
  549. Y - position in the window of the bottom of the text (default = 10)
  550. JUST - text justification, left = 0, center = 1, right = -1? (default = 0)
  551. SIZE - font size in points (default = 12)
  552. COLOR - text color (default is black)
  553. =head2 aquaMouse
  554. = for ref
  555. Returns location of next mouse click in the active window
  556. = for usage
  557. ($mx, $my) = aquaMouse();
  558. Returns the location of the next mouse click in the active window as a 2 element array. The elements of the array are the x and y coordinates of the mouse click in pixels. The coordinates are relative to the bottom left corner of the active area of the window.
  559. Options recognized
  560. WIN_NUM - which window to get the mouse click in
  561. =head1 INSTALLATION
  562. You must install aquaterm prior to trying to install this module as it links against the aquaterm library. After AquaTerm installation you should have the following directory/file structure:
  563. /usr/local/include/aquaterm/aquaterm.h
  564. /usr/local/lib/libaquaterm.dylib
  565. as explained in the INSTALL file that accompanies aquaterm.
  566. =head1 KNOWN ISSUES
  567. If you are using this module in a perl script simultaneously with another drawing/graphing module such as PDL::Graphics::PGPLOT::Window then you may have problems with the two modules drawing into the same window. This is hard to work around since PGPlot will always draw in the currently active window regardless of which window it opened in the first place.
  568. The (0,0) of bitmaps is their upper left corner, but for mouse events it is the bottom left corner. If you are trying to use the mouse to select a portion of a bitmap then you need to adjust the coordinates returned by the mouse accordingly (i.e. $good_y = $bitmap_size_y - $y_from_aquaMouse).
  569. =head1 BUGS
  570. No known bugs yet.
  571. =head1 SEE ALSO
  572. http://sourceforge.net/projects/aquaterm/
  573. =head1 AUTHOR
  574. Hazen Babcock (hbabcockos1@mac.com)
  575. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
  576. =cut
  577. EOD
  578. pp_done();