[Therion] symbol-show fixed points / point text
Ben Cooper
ben at caver.plus.com
Thu Dec 1 21:59:02 CET 2011
Hi Bruce,
Here is my re-defined p_station code that now works. For each station that
you want to print the text for, set attr print "true" in the th2 file as I
illustrated in my earlier email. If you want to turn off printing you can
set the text to "false". This works for any station, no matter what its
subtype or flags that are set. The code is as follows:
layout l_p_station_text
code metapost
def p_station(expr pos,mark,txt)(text flags) =
% draw default station
p_station_SKBB(pos, mark, txt, flags);
% now print the text
if picture(txt):
picture ATTR__text;
ATTR__text := txt;
if known(ATTR_print):
if (ATTR_print="true"):
if not numeric txt:
p_smartlabel(txt,pos);
else:
% draw filled label with text next
p_label.urt(ATTR__text,(.5u,-.25u) transformed T,0.0,8);
fi;
fi;
fi;
save ATTR__text;
fi;
enddef;
endcode
endlayout
_____
From: therion-bounces at speleo.sk [mailto:therion-bounces at speleo.sk] On Behalf
Of Ben Cooper
Sent: 01 December 2011 19:56
To: 'List for Therion users'
Subject: Re: [Therion] symbol-show fixed points / point text
Hi Bruce,
I've solved the problem - obvious really - I need to use p_station, not
p_station_SKBB. I'll send the example through later - I need to copy it off
another computer.
Regards,
- Ben
_____
From: therion-bounces at speleo.sk [mailto:therion-bounces at speleo.sk] On Behalf
Of Ben Cooper
Sent: 30 November 2011 22:35
To: 'List for Therion users'
Subject: Re: [Therion] symbol-show fixed points / point text
Hi Bruce,
You beat me to it! I've spent the last few days learning metapost and
rummaging around the bowels of the Therion's source code and have more or
less got to what you have summarised below. I also spotted the smartlabel,
though haven't yet tried it in the re-definition of p_continuation.
I surmise that stations with fixed co-ordinates are not exported by Therion
in any detectable way; while the th2 mark "fixed" is exported as "mark", and
the th2 flags are exported as "flags". The items that are exported are
accessible in metapost. In the debug output data.mp file, I saw that "attr
code" is exported by Therion as ATTR_code, where "code" is whatever attr has
been declated in the th2 file. Note that it only has one "_" whereas
ATTR__text has two "_". So one thing I tried that did work is to print the
value of my user define attr statements instead of the text, which is
potentially quite useful, as I can display a short code, and use
continuation.html for the longer description. However, this still relies on
having the "continuation" flag set.
I used the following re-definition of p_continuation using ATTR_code instead
of the example's ATTR__text, as follows
**THE FOLLOWING WORKS**
code metapost
def p_continuation(expr pos,theta,sc,al) =
% draw default continuation symbol
p_continuation_UIS(pos,theta,sc,al);
% if attr code is set
if known(ATTR_code):
% set labeling color to light orange
push_label_fill_color(1.0, 0.9, 0.8);
% draw filled label with text next to ?
p_label.urt(ATTR_code,(.5u,-.25u) transformed T,0.0,8);
% restore original labeling color
pop_label_fill_color;
fi;
enddef;
endcode
Looking at p_station_SKBB, the problem you and I are facing is that it's
only for the "continuation" flags that ATTR__text has been set. It occurred
to me that if it was possible to refedine p_station_SKBB in the thconfig
file, then it would be possible to output ATTR__text if an "attr code" has
been declared in the th2 file.
For example, th2 file:-
station 1 "Some text to output" entrance attr print "true"
My example p_station_SKBB is below. Unfortunately, I've so far not managed
to see it being executed. I can see it appear in the data.mp debug file,
but the changes I've made to it don't appear to work - the text is not yet
being output to my pdf file. Also, I don't understand yet the purpose of the
metapost "save" command, and the manual doesn't really shed much light on
it! So it's possible that I've just not yet properly understood metapost
syntax.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.speleo.sk/pipermail/therion/attachments/20111201/eb154185/attachment.htm>
More information about the Therion
mailing list