korp@atlantis.ees.anl.gov (Peter Korp) (11/17/90)
Here is a little ditty that allows one to view arbitrary size raster files
and quickly move around in them. This demo is especially impressive on GX
equipped machines. It uses the BTOL toolkit which will be posted in one of
the following messages. This program is a csh script and is called by
"viewmaster <rasterfilename>"
--------------------------------- Begin viewmaster ----------------------------
#! /bin/csh -f
if($1 == "") then
echo Usage: $0 rasterfile
exit
endif
psh <<+++
%% Viewmaster v1.0
%% by
%% Peter A. Korp
%%
%% This program was created to explore the limits of the NeWS shared
%% memory canvas capabilities. It images raster files and allows for an
%% overview navigation window, for quickly jumping to any part of the image.
%% This application is most impressive when used on a machine with a GX board.
%% Near "real time" response is possible on a 3/60 with GX, SS/1+ and higher
%% are quite nice.
%%
%% Note that this demo uses the BTOL toolkit from Argonne National Laboratory
%% and will not run without it
%%
%% This file is a product of Argonne National Laboratory, and is provided for
%% unrestricted use provided that this legend is included on all tape
%% media and as a part of the software program in whole or part. Users
%% may copy or modify this file without charge, but are not authorized to
%% license or distribute it to anyone else except as part of a product
%% or program developed by the user.
%%
%% THIS FILE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
%% WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
%% PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
%%
%% This file is provided with no support and without any obligation on the
%% part of Argonne National Laboratory to assist in its use, correction,
%% modification or enhancement.
%%
%% ARGONNE NATIONAL LABORATORY SHALL HAVE NO LIABILITY WITH RESPECT TO THE
%% INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS FILE
%% OR ANY PART THEREOF.
%%
%% In no event will Argonne National Laboratory be liable for any lost revenue
%% or profits or other special, indirect and consequential damages, even
%% if Sun has been advised of the possibility of such damages.
%%
%% Argonne National Laboratory
%% 9700 S. Cass Avenue
%% Argonne, Il. 6049
%%
systemdict /statusdict get begin 180 setjobtimeout end
/appname ($0) def
/appcurrentdir ($PWD) def
/appfilename ($1) def
appfilename 0 get 47 ne
{
/appfilename appcurrentdir (/) append appfilename append store
} if
(ARGONNE_HOME) getenv (/BTOL/BTOL.ps) append run
/OffsetX 0 def
/OffsetY 0 def
/Buffer pause appfilename readcanvas pause def
version cvr 2 ge
{
Buffer false getbbox
}
{
gsave Buffer setcanvas clippath pathbbox grestore
} ifelse
/ImageHeight exch def
/ImageWidth exch def
pop pop
/TheImage framebuffer newcanvas def
TheImage /Retained true put
/ViewCanvas TheImage newcanvas def
ViewCanvas /Transparent true put
gsave
newpath 0 0 ImageWidth ImageHeight rectpath
TheImage reshapecanvas
TheImage setcanvas
ImageWidth ImageHeight scale
Buffer imagecanvas
grestore
/Buffer null store
/myappwin (ViewMaster) /new BtolAppWin send def
{
2 (OverView) { {totop map} mysubwin send } /additem FrameMenu send
CreateCloseControl
CreateZapControl
pause
/mapblaster % event
{
begin
gsave
10 dict begin
setxhaircursor
ClientCanvas setcanvas
/myx0 XLocation def
/myy0 YLocation def
{
gsave
ViewCanvas setcanvas
OffsetX myx0 x sub add
ImageWidth ClientWidth sub min 0 max
OffsetY myy0 y sub add
ImageHeight ClientHeight sub min 0 max
movecanvas
ClientCanvas setcanvas
version cvr 2 lt
{ ClientWidth ClientHeight scale } if
ViewCanvas imagecanvas
grestore
} trackuser
/OffsetY
OffsetY myy0 4 -1 roll sub add
ImageHeight ClientHeight sub min 0 max
store
/OffsetX
OffsetX myx0 4 -1 roll sub add
ImageWidth ClientWidth sub min 0 max
store
setptrcursor
end
grestore
end
} def
/PaintClient
{
version cvr 2 lt
{ ClientWidth ClientHeight scale } if
ViewCanvas imagecanvas
} def
/destroy
{
ClientEventMgr killprocess
ZapNotify
} def
reshapefromuser
ClientWidth ImageWidth gt
ClientHeight ImageHeight gt or
{
FrameX FrameY
ImageWidth BorderLeft BorderRight add add
ImageHeight BorderTop BorderBottom add add
reshape
} if
gsave
TheImage setcanvas
newpath 0 0 ClientWidth ClientHeight rectpath
ViewCanvas reshapecanvas
grestore
pause
/ClientEventMgr
[
% need to overhide the downtransition so
% that 'slidewin' is not called
PointButton {pop}
DownTransition ClientCanvas eventmgrinterest
PointButton /mapblaster
UpTransition ClientCanvas eventmgrinterest
] forkeventmgr def
pause
attachframemenu
totop map
} myappwin send
/mysubwin (OverView) /newsubwin myappwin send def
{
/PaintClient
{
version cvr 2 ge
{
1 ImageWidth div
1 ImageHeight div scale
} if
ClientWidth ClientHeight scale
TheImage imagecanvas
} def
/destroy
{
ClientEventMgr killprocess
ZapNotify
} def
/mapblaster % event => -
{
begin
10 dict begin
setxcursor
/myw myappwin /ClientWidth get def
/myh myappwin /ClientHeight get def
/mysw myw ImageWidth div ClientWidth mul def
/mysh myh ImageHeight div ClientHeight mul def
/myhsw mysw 2 div def
/myhsh mysh 2 div def
ClientCanvas
{
newpath
x myhsw sub ClientWidth mysw sub min 0 max
y myhsh sub ClientHeight mysh sub min 0 max
mysw mysh rectpath stroke
} instancedrawing
gsave
/OffsetY exch myhsh sub ClientHeight mysh sub min 0 max
ImageHeight ClientHeight div mul store
/OffsetX exch myhsw sub ClientWidth mysw sub min 0 max
ImageWidth ClientWidth div mul store
ViewCanvas setcanvas
OffsetX OffsetY movecanvas
myappwin /ClientCanvas get setcanvas
ViewCanvas imagecanvas
grestore
setptrcursor
end
end
} def
CreateCloseControl
CreateZapControl
200 200
ImageHeight ImageWidth gt
{
ImageWidth ImageHeight div 256 mul 256
}
{
256 ImageHeight ImageWidth div 256 mul
} ifelse
exch BorderLeft BorderRight add add
exch BorderTop BorderBottom add add
reshape
/ClientEventMgr
[
PointButton /mapblaster
DownTransition ClientCanvas eventmgrinterest
] forkeventmgr def
} mysubwin send
newprocessgroup
currentfile closefile
+++