Selective output of label text
Sorry to repeat posting on this topic. I think it's been done a few times in the last couple of years, and I either wasn't ready or skilled enough to actually take it up. And now I have a good use for it I can not find a posting that explains it sufficiently for my extremely limited MetaPost ability. The question is. How to implement selective printing of labels to pdf outputs? Back in June Martin suggested the following, and I'm tempted to try it, but I'll need some guidance on the MetaPost. The examples in the Wiki don't quite get me there. I think I need the original definition of p_label to start with? Bruce "I would just use symbol-hide command in the layout. It is possible to pre-define various sets of symbols which should be hidden at particular scale (in separate layouts which are copied into layout in use). If you want to hide only some (not all) of the symbols in a given type, you can use custom attributes combined with modifications in MetaPost definitions of symbols. (E.g. for p_label you would add condition that it should be displayed if the scale (denominator) is <=1000 or the attribute is_important is set to 1.) "
On Thu, Jan 29, 2009 at 3:23 AM, Bruce Mutton <bruce.mutton@paradise.net.nz> wrote:
The question is… How to implement selective printing of labels to pdf outputs?
just add following to the options for point labels you want to show (all other labels will be hidden): -attr visibility on ('visibility' and 'on' are just strings you can freely choose; just match them in the metapost macros) and use modified label definition in code tex-mpost vardef p_label@#(expr txt,pos,rot,mode) = if known ATTR_visibility: if ATTR_visibility="on": % ADDED CONDITIONS if (mode=1) or (mode=7): interim labeloffset:=(u/8) fi; lab:=thelabel@#(txt, pos); if mode>1: pickup PenD fi; if mode=1: pickup pencircle scaled (u/6); drawdot(pos); process_label(pos,0); elseif mode=2: process_uplabel; elseif mode=3: process_downlabel; elseif mode=4: process_updownlabel; elseif mode=5: process_circledlabel; elseif mode=6: process_boxedlabel; elseif mode=7: process_label(pos,rot); % station name elseif mode=8: process_filledlabel(pos, rot); else: process_label(pos,rot); fi; fi; fi; % END OF CONDITIONS enddef; Martin
just add following to the options for point labels you want to show (all other labels will be hidden):
-attr visibility on
('visibility' and 'on' are just strings you can freely choose; just match them in the metapost macros)
and use modified label definition in code tex-mpost
vardef p_label@#(expr txt,pos,rot,mode) = if known ATTR_visibility: if ATTR_visibility="on": % ADDED CONDITIONS if (mode=1) or (mode=7): interim labeloffset:=(u/8) fi; lab:=thelabel@#(txt, pos); if mode>1: pickup PenD fi; if mode=1: pickup pencircle scaled (u/6); drawdot(pos); process_label(pos,0); elseif mode=2: process_uplabel; elseif mode=3: process_downlabel; elseif mode=4: process_updownlabel; elseif mode=5: process_circledlabel; elseif mode=6: process_boxedlabel; elseif mode=7: process_label(pos,rot); % station name elseif mode=8: process_filledlabel(pos, rot); else: process_label(pos,rot); fi; fi; fi; % END OF CONDITIONS enddef;
Martin _______________________________________________
Martin In trying various versions of the above, the best I can get is an error; "... converting scraps ... done making map ... D:\Program Files\Therion\therion.exe: error -- Can't open file writing xtherion file ... done " I have tried many combinations of string, numeric, quotes, no quotes for the -attr variables parsed, and most cause identifiable metapost errors. If I comment out the metapost code it compiles perfectly. I'm a bit lost and assume I'm making a simple mistake somewhere. However, before pursuing this approach too much further, it is apparent that adding extra attributes to labels is a big imposition when they already have a -scale attribute that matches, more or less, their 'importance'. I have 18km of plans and elevations to adjust! Better to link the visibility of labels (and other entities perhaps) to the scale, ie at 1:1000 print all labels, at 1:5000 print only labels with -scale l and -scale xl. The attached file gives an indication of the approach I am looking at, and it will mean little or no change to my scrap drawings is needed. So, is there a way to modify the metapost code to progressively hide labels of -scale xs, s, m etc as the output scale increases from 1:1000, 1:2000, 1:5000 etc? Also I will need to modify the code for many entities I assume. Ie line label, point passage-gradient (perhaps?) and not just point label. There must be a location in my Windows Installation from where I can pluck the code for all the Therion entities, once I can figure out the pattern for the changes required? Or perhaps a simpler approach is to modify the syntax following; code metapost fonts_setup(0,0,0,4,6); where a font size of 0 means it is not printed (currently returns an error). Thanks for your patience. Any further guidance appreciated. Bruce
On Sun, Feb 15, 2009 at 10:03 AM, Bruce Mutton <bruce.mutton@paradise.net.nz> wrote:
I have tried many combinations of string, numeric, quotes, no quotes for the -attr variables parsed, and most cause identifiable metapost errors. If I comment out the metapost code it compiles perfectly. I'm a bit lost and assume I'm making a simple mistake somewhere.
I attach complete example with two labels; one of which is hidden using the code I sent.
However, before pursuing this approach too much further, it is apparent that adding extra attributes to labels is a big imposition when they already have a -scale attribute that matches, more or less, their 'importance'. I have 18km of plans and elevations to adjust!
You are right.
So, is there a way to modify the metapost code to progressively hide labels of -scale xs, s, m etc as the output scale increases from 1:1000, 1:2000, 1:5000 etc?
Therion core needs to be modified to support this (information about -scale option can't be evaluated by metapost currently), but then the same approach could be used.
Also I will need to modify the code for many entities I assume. Ie line label, point passage-gradient (perhaps?) and not just point label. There must be a location in my Windows Installation from where I can pluck the code for all the Therion entities, once I can figure out the pattern for the changes required?
The files are in the source distribution only (directory mpost). Other option would be to extend symbol-hide/show options to evaluate other conditions, like symbol-hide point label where option:scale not "xl" This would avoid a lot of modifications to metapost code but is not so easy to implement in therion. Martin
participants (2)
-
Bruce Mutton -
Martin Budaj