Save the Usersym vectors [message #93472] |
Wed, 27 July 2016 08:27  |
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   |
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 #93482 is a reply to message #93475] |
Mon, 01 August 2016 08:33  |
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.
|
|
|