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

Home » Public Forums » archive » Save the Usersym vectors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Save the Usersym vectors [message #93472] Wed, 27 July 2016 08:27 Go to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
In direct graphics (which I am temporarily forced to use again) one can define a plotting symbol using the USERSYM procedure. One gives USERSYM the X,Y vectors of the new plotting symbol, and then this new symbol is used whenever PSYM = 8. But is there any way to know what X,Y vectors are currently loaded into USERSYM?

I need this because there are programs (I am looking at you CGPLOTS) that define USERSYM internally, and so erase any pre-existing USERSYM vectors. If I could save the current USERSYM vectors before calling CGPLOTS, then I could restore them after they are erased.

I suspect the answer is no -- there is no way to know what plot symbol (X,Y vectors) is currently loaded into USERSYM.

Thanks, --Wayne
Re: Save the Usersym vectors [message #93474 is a reply to message #93472] Thu, 28 July 2016 13:44 Go to previous messageGo to next message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
Hi Wayne,

it _is_ possible, to get the x and y vectors used to define the user
plotting symbol. However, it is fairly complex. So first let me ask
for a simple solution. You defined the user symbol before calling
CGPLOTS. Isn't it possible, to save a copy of x and y when calling
USERSYM?

If not, here is the compex way: First plot the user symbol in a
vector-grafic-file:

device=!d.name
set_plot,'cgm'
device,file='temp.cgm'
plots,/device,!d.x_size/2,!d.y_size/2,psym=8,symsize=10.
device,/close
set_plot,device

I choose cgm here, since nobody probably is using it anymore and this
code can be nested within the output to other grafic devices. Next
read the temporary file into a byte array:

openr,lun,/get_lun,'temp.cgm'
a=bytarr((fstat(lun)).size)
readu,lun,a
free_lun,lun

Now you can extract the x and y vectors from the binary array:

start=(a['43'x] eq '3f'x)? '46'x : '44'x ; see note
b=byte(a,start,2,(n_elements(a)-start)/2-2)
b=transpose(b)
xy=b[*,0]*256s+b[*,1]
xy=reform(xy,2,n_elements(xy)/2,/overwrite)
xy=transpose(xy)
xy=(xy-2s^14)/2730.

Please note that the calculation of START and the number of bytes in
the following line is "quick and dirty". It may fail, particularly on
different operating systems. I did not study the cgm format and found
this rule by "hacking". I leave it to you, to read the specifications
and make this better. ;-)

I run my calculation with this IDL version: { x86 Win32 Windows
Microsoft Windows 8.0.1 Oct 5 2010 32 64}

Enjoy, Heinz
Re: Save the Usersym vectors [message #93475 is a reply to message #93474] Sat, 30 July 2016 04:52 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Hi Heinz

Thanks for the clever solution. The simple solution doesn't work for me because the programs are nested. I have a program (AL.LEGEND) which calls CGPLOTS but the USERSYM definition is done in a higher level program out of my control and not in AL_LEGEND

I'll see if I can take your ideas to write a GET_USERSYM prorgram to retrieve the current USERSYM definition. Wayne
Re: Save the Usersym vectors [message #93482 is a reply to message #93475] Mon, 01 August 2016 08:33 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Saturday, July 30, 2016 at 7:52:48 AM UTC-4, wlandsman wrote:
> Hi Heinz
>
> Thanks for the clever solution. The simple solution doesn't work for me because the programs are nested. I have a program (AL.LEGEND) which calls CGPLOTS but the USERSYM definition is done in a higher level program out of my control and not in AL_LEGEND
>
> I'll see if I can take your ideas to write a GET_USERSYM prorgram to retrieve the current USERSYM definition. Wayne

Yes, that is very clever!

I find it bizarre that this isn't just a field in !P.

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Lossless compression with IDLffVideoWrite
Next Topic: IDL Image Fusion Algorithm

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

Current Time: Wed Oct 08 07:16:27 PDT 2025

Total time taken to generate the page: 0.00603 seconds