[Therion] Need metapost wizard: new text label
alastair gott
alastairgott at hotmail.com
Thu Feb 27 00:14:06 CET 2020
Sorry Beni you'll get this twice as I forgot to send to the list...
The function def p_continuation (I know not the one you're using).
has the line:
if known(ATTR__text) and picture(ATTR__text):
This seems to work, but not sure if it's because of the next few lines:
% set labeling color to light orange
push_label_fill_color(0.8, 0.8, 0.0);
% draw filled label with text next to symbol ?
p_label.urt(ATTR__text,(.5u,-.25u) transformed T,0.0,8);
% restore original labeling color
pop_label_fill_color;
fi;
It seems like the P_label.urt is fairly important, as this is what tells it where to place the label, in this case in the upper right (.urt) and then tells it to put the attr_text there.
[cid:4b8816ef-abef-4e06-8047-3dee7b44eed9]
https://books.google.co.uk/books?id=hh6rdgZ9m3MC&pg=PA65&lpg=PA65&dq=p_label.urt&source=bl&ots=1unNIgxr0Q&sig=ACfU3U39-oFLnFB5msQcedNUKtjMkbdY8A&hl=en&sa=X&ved=2ahUKEwig4MyeqfDnAhUyThUIHUSxDSIQ6AEwBHoECAkQAQ#v=onepage&q=p_label.urt&f=false
Regards,
Alastair Gott.
AlastairGott at hotmail.com,
M: 07931779380.
________________________________
From: Therion <therion-bounces at speleo.sk> on behalf of Benedikt Hallinger <beni at hallinger.org>
Sent: 26 February 2020 22:47
To: therion at speleo.sk <therion at speleo.sk>
Subject: Re: [Therion] Need metapost wizard: new text label
Hello,
meanwhile i tried to play more with this.
I'm nearly there, however i still have no clue how to read out the text
attribute i attached to the symbol in the th2. "txt := ATTR__text;"
throws metapost out the window.
The point is defined like this:
point 234.0909090909091 626.3636363636364 u:mappe -attr text 1234
Layout i came up with so far (does not support
scaling/alignment/rotation, but thats fine so far):
---------------------
layout m
# Symbol to denote assigned survey.
# If option -attr text <string> is given, it will be used; otherwise
current survey is shown.
code metapost
def p_u_mappe(expr pos, theta, sc, al) =
T:=identity aligned al rotated theta scaled sc shifted pos;
% GET LABEL TEXT:
string txt;
txt := "123";
%txt := ATTR__text; % does not work. How do i get the value from
' -attr text "345" '?
if known(ATTR__text):
txt := ATTR_text; % NEVER evaluates to TRUE!?!?
else:
txt := ATTR__survey;
fi;
% DRAW LABEL:
lab:=thelabel(txt, pos);
process_label(pos, 0.001);
% BORDER:
pickup PenA; % border thickness
interim bboxmargin:=6.5bp; % padding border->text
q:=((bbox lab) smoothed 4); % smoothness of corners
draw q;
enddef;
initsymbol("p_u_mappe");
endcode
endlayout
---------------------
Am 2020-02-19 18:34, schrieb Benedikt Hallinger:
> Hi there,
> i need some new point symbol (text label). Its a simple text on white
> color within a box with rounded corners, like the attached image.
>
>
> My metapostskills are not good enough to get this to work...
>
> For now i would be happy to have such a user point symbol.
> It would be important that it scales well and react to xtherions
> direction setting.
>
> Optional it would be cool if the default symbol could show the current
> survey identifier of the nearest station in the scrap and maybe also
> the nearest next survey.
> But this information could also be maintained manually for now.
>
> Is there someone here for my rescue? :)
> Thanks in advance,
> Beni
_______________________________________________
Therion mailing list
Therion at speleo.sk
https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.speleo.sk%2Flistinfo%2Ftherion&data=02%7C01%7C%7C2bdebe7ad80d4d85719908d7bb0df4e5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637183540918837472&sdata=pcZw3mupgUp94GoqSpUCkEtezYMPaJhzPwEIabpXt%2Fo%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.speleo.sk/pipermail/therion/attachments/20200226/a010a0b4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 32823 bytes
Desc: image.png
URL: <http://mailman.speleo.sk/pipermail/therion/attachments/20200226/a010a0b4/attachment.png>
More information about the Therion
mailing list