comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » clipboard objects and postscript (unix)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Clipboard [message #14767 is a reply to message #13303] Wed, 24 March 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Kelly Dean (krdean@lamar.colostate.edu) writes:

> We just purchased 50 IDL licenses

50! Wow. Need a class? :-)

> from RSI which allowed us to upgrade
> many of are IDL users from IDL 3.6 to IDL 5.2. These people stuck in the
> darkages are missing two features of IDL 3.6 for Windows:
>
> 1. Copy a selected window to the clipboard
> 2. Print a selected window to the printer.
>
> I have Dave Fanning's PrintIt.pro that solves #2, but I was wondering if
> anyone has worked on a creating a simple routine to use the clipboard,
> much like PrintIt.pro.

Alright, here you go. Quick and dirty. Very little testing.
Just to serve (if my other program offerings are any indication)
as "inspiration" for something a whole lot better. :-)

I use the IDL graphics "clipboard" object to
write a screen dump of the window (you tell me which one
to use or I'll use the current window) to the clipboard
of the device. It took me 10 minutes to build and I've
tested it a little bit on my Windows machine. *Very* nice,
if I don't say so myself. I can copy the contents of any
IDL graphics window to the clipboard and paste the results
into, say, Paint.

IDL> Window, 5
IDL> !P.Multi = [0, 2, 1]
IDL> LoadCT, 5
IDL> TVImage, image, /Multi
IDL> Plot, Findgen(11), Color=200
IDL> Clipboard, 5

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155

[Note: This follow-up was e-mailed to the cited author.]

************************************************************ *
PRO Clipboard, windowIndex

; This procedure copies the window identified by the
; window index number (or the current window if an index
; number is not provided) to the clipboard.

IF N_Elements(windowIndex) EQ 0 THEN windowIndex = !D.Window

; Is this a valid window?

IF windowIndex LT 0 THEN BEGIN
ok = Dialog_Message('No current window to copy. Returning...')
RETURN
ENDIF

; Catch window setting errors.

Catch, error
IF error NE 0 THEN BEGIN
Catch, /Cancel
ok = Dialog_Message('Specified window is unavailable: ' + $
StrTrim(windowIndex, 2) + '. Returning...')
WSet, thisWindow
RETURN
ENDIF

; Set active window.

thisWindow = !D.Window
WSet, windowIndex
Catch, /Cancel

; Take a snapshot of window. Pay attention to visual depth.

Device, Get_Visual_Depth=thisDepth
IF thisDepth GT 8 THEN BEGIN
snapshot = TVRD(True=1)
snapshot = Color_Quan(snapshot, 1, r, g, b)
ENDIF ELSE BEGIN
snapshot = TVRD()
TVLCT, r, g, b, /Get
ENDELSE
s = Size(snapshot, /Dimensions)

; Create an object graphics image and hierarchy.

palette = Obj_New('IDLgrPalette', r, g, b)
image = Obj_New('IDLgrImage', snapshot, Palette=palette)
model = Obj_New('IDLgrModel')
model->Add, image
thisView = Obj_New('IDLgrView', ViewPlane_Rect=[0,0,s[0],s[1]])
thisView->Add, model

; Create a clipboard

theClipboard = Obj_New('IDLgrClipboard', Color_Model=1, $
Dimensions=[s[0], s[1]], N_Colors=!D.Table_Size, $
Resolution=[1.0/!D.X_PX_CM, 1.0/!D.Y_PX_CM], $
Palette=palette)

; Copy the snapshot to the clipboard.

theClipboard->Draw, thisView

; Destroy the objects.

Obj_Destroy, palette
Obj_Destroy, model
Obj_Destroy, thisView
Obj_Destroy, theClipboard

; Restore the current window.

WSet, thisWindow
END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Read DXF-File (Autocad 13 Format)
Next Topic: Colour maps overlaid on grey-scale (medical) images

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 03:15:28 PDT 2025

Total time taken to generate the page: 0.02601 seconds