Well, this is beyond my expertise, but I have collected together some clues from the code, in the attached file. Maybe someone else can make something of it. It seems like the distributed metapost code has boxed label capability built into it, but the overall implementation does not provide a way for it to be used (maybe). The C code allows for all the 'modes' to be used, except mode = 6 for boxed labels and mode = 8 for filled labels. So looks like there needs to be changes at that level.
Bruce -----Original Message----- From: Therion <therion-boun...@speleo.sk> On Behalf Of Bruce Mutton via Therion Sent: Friday, 21 September 2018 20:45 To: 'List for Therion users' <therion@speleo.sk> Cc: Bruce Mutton <br...@tomo.co.nz> Subject: Re: [Therion] Height numbers in square boxes It might be that this capability is already built into Therion. Look in the source files. /mpost/thText.mp line 84: vardef p_label@#(expr txt,pos,rot,mode) = ... 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; /mpost/therion.mp line 440: def process_boxedlabel = q:=bbox lab; draw lab; draw q; write_bbox(q); enddef; /mpost/therion.mp line 484: def write_bbox (expr q) = I think we just need to figure out how to invoke the various modes, and we can make use of the predefined label ornaments. Unfortunately I don't have time to play with any of this just now, I'm sure one of you will figure it out. Bruce _______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion
FROM thTex.mp point label definition ############################################################ vardef p_label@#(expr txt,pos,rot,mode) = 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; enddef; FROM therion.mp low level process_ various label types ############################################################ def fonts_setup (expr t,s,m,l,h) = write "\def\updown#1#2{\vbox{" & "\offinterlineskip" & "\setbox100=\hbox{#1}" & "\setbox101=\hbox{#2}" & "\ifnum\wd100>\wd101\hsize=\wd100\else\hsize=\wd101\fi" & "\centerline{\box100}\vskip4pt" & "\centerline{\box101}}}" & "\def\thlabel{\thnormalsize}" & "\def\thremark{\thsmallsize\si}" & "\def\thcomment{\thsmallsize}" & "\def\thentrance{\thsmallsize}" & "\def\thaltitude{\thsmallsize}" & "\def\thstationname{\thsmallsize}" & "\def\thdate{\thsmallsize}" & "\def\thheight{\thsmallsize}" & "\def\thheightpos{+\ignorespaces}" & "\def\thheightneg{-\ignorespaces}" & "\def\thframed{\thsmallsize}" & "\def\thwallaltitude{\thtinysize}" to "mptexpre.tex"; write "\def\thtinysize{\size[" & decimal max(optical_zoom*t,0) & "]}" & "\def\thsmallsize{\size[" & decimal max(optical_zoom*s,0) & "]}" & "\def\thnormalsize{\size[" & decimal max(optical_zoom*m,0) & "]}" & "\def\thlargesize{\size[" & decimal max(optical_zoom*l,0) & "]}" & "\def\thhugesize{\size[" & decimal max(optical_zoom*h,0) & "]}" to "mptexpre.tex"; write EOF to "mptexpre.tex"; enddef; % @MACRO % process_label -- % % draws a label saved in <I>lab</I> picture variable and calls % <A HREF="#write_bbox">write_bbox</A> macro. def process_label (expr cent, rot) = begingroup; interim bboxmargin:=0.8bp; q:=((bbox lab) smoothed 2) rotatedaround (cent, rot); draw lab rotatedaround (cent, rot); write_circ_bbox(q); % without corners smoothing it was enough to use % write_bbox(q); endgroup; enddef; % @MACRO % process_uplabel -- % % draws a label into semicircular box and writes clipping path to a file def process_uplabel = begingroup; interim bboxmargin := 0.8 bp; q:=bbox lab; endgroup; alef:=.8-.02*(xpart lrcorner q - xpart llcorner q); % show alef; q:=alef[llcorner q,ulcorner q]{up} .. {down}alef[lrcorner q, urcorner q] -- lrcorner q -- llcorner q -- cycle; draw lab; draw q; q:=reverse q; write_circ_bbox(q); enddef; % @MACRO % process_downlabel -- % % draws a label into down oriented semicircular box and writes % clipping path to a file def process_downlabel = begingroup; interim bboxmargin := 0.8 bp; q:=bbox lab; endgroup; alef:=1-(.8-.02*(xpart lrcorner q - xpart llcorner q)); q:=alef[llcorner q,ulcorner q]{down} .. {up}alef[lrcorner q, urcorner q] -- urcorner q -- ulcorner q -- cycle; draw lab; draw q; write_circ_bbox(q); enddef; % @MACRO % process_updownlabel -- % % draws a label splitted into down and up oriented semicircular boxes and % writes clipping path to a file def process_updownlabel = begingroup; interim bboxmargin := 0.8 bp; p:=bbox lab; endgroup; leftside:=xpart llcorner p; rightside:=xpart lrcorner p; draw (xpart llcorner p,.5[ypart llcorner p,ypart ulcorner p]) -- (xpart lrcorner p,.5[ypart llcorner p,ypart ulcorner p]); alef:=1.05-.02*(xpart lrcorner p - xpart llcorner p); % alef:=.8-.02*(rightside-leftside); p:=alef[(leftside, ypart llcorner p),(leftside, ypart ulcorner p)]{up} .. {down}alef[(rightside, ypart lrcorner p), (rightside, ypart urcorner p)] -- alef[(rightside, ypart urcorner p), (rightside, ypart lrcorner p)]{down} .. {up}alef[(leftside, ypart ulcorner p),(leftside, ypart llcorner p)] -- cycle; % p:=alef[llcorner p,ulcorner p]{up} .. {down}alef[lrcorner p, urcorner p] -- % aleff[llcorner p,ulcorner p]{down} .. % {up}aleff[lrcorner p, urcorner p] -- cycle; draw lab; draw p; p:=reverse p; write_circ_bbox(p); enddef; def process_updownlabel_OLD = p:=bbox lab; q:=bbox Lab; leftside:=min(xpart llcorner p, xpart ulcorner q); rightside:=max(xpart lrcorner p, xpart urcorner q); draw .5[(leftside, ypart llcorner p),(leftside, ypart ulcorner q)] -- .5[(rightside,ypart lrcorner p),(rightside,ypart urcorner q)]; alef:=.8-.02*(rightside-leftside); q:=alef[(leftside, ypart llcorner p),(leftside, ypart ulcorner p)]{up} .. {down}alef[(rightside, ypart lrcorner p), (rightside, ypart urcorner p)] -- alef[(rightside, ypart urcorner q), (rightside, ypart lrcorner q)]{down} .. {up}alef[(leftside, ypart ulcorner q),(leftside, ypart llcorner q)] -- cycle; draw lab; draw Lab; draw q; q:=reverse q; write_circ_bbox(q); enddef; % @MACRO % process_boxedlabel -- % % draws a label into circular box and writes % clipping path to a file def process_boxedlabel = q:=bbox lab; draw lab; draw q; write_bbox(q); enddef; % @MACRO % process_circledlabel -- % % draws a label into circular box and writes % clipping path to a file def process_circledlabel = begingroup; interim bboxmargin := 0.4 bp; q:=bbox lab; endgroup; q:=point 0 of q .. point 1 of q .. point 2 of q .. point 3 of q .. cycle; draw lab; draw q; write_circ_bbox(q); enddef; % @MACRO % write_bbox -- % % Arguments: % <I>path</I> variable -- rectangular bounding box of a label; % assumptions: path is cyclic, counterclockwise oriented, with four points, % composed from linear segments; % see general <A HREF="#write_circ_bbox">write_circ_bbox</A> macro % Results: % one file per figure which uses labels with a clipping path in pseudo-pdf % format def write_bbox (expr q) = file_name := jobname & "." & decimal(charcode) & "bbox"; for i:=4 downto 0: s := decimal(roundone(xpart point i of q)) & " " & decimal(roundone(ypart point i of q)) & if i=4: " m " else: " l" fi; write s to file_name; endfor; last_write := charcode; enddef; % @MACRO % write_circ_bbox -- % % Arguments: % <I>path</I> variable, only assumption is that <I>path</I> is cyclic % and counterclockwise oriented. % Results: % one file per figure which uses labels with a clipping path in pseudo-pdf % format def write_circ_bbox expr q = file_name := jobname & "." & decimal(charcode) & "bbox"; tmp:=length q; s := decimal(roundone(xpart point tmp of q)) & " " & decimal(roundone(ypart point tmp of q)) & " m"; write s to file_name; for i:=tmp downto 1: s := decimal(roundone(xpart precontrol i of q)) & " " & decimal(roundone(ypart precontrol i of q)) & " " & decimal(roundone(xpart postcontrol i-1 of q)) & " " & decimal(roundone(ypart postcontrol i-1 of q)) & " " & decimal(roundone(xpart point i-1 of q)) & " " & decimal(roundone(ypart point i-1 of q)) & " c"; write s to file_name; endfor; last_write := charcode; enddef; FROM thpoint.cxx C code for labels, including height ############################################################ ...from line 242 // if not found, try to set fathers properties default: if (cod.id == TT_2DOBJ_CLIP) { switch (this->type) { case TT_POINT_TYPE_STATION_NAME: case TT_POINT_TYPE_LABEL: case TT_POINT_TYPE_REMARK: case TT_POINT_TYPE_DATE: case TT_POINT_TYPE_ALTITUDE: case TT_POINT_TYPE_HEIGHT: case TT_POINT_TYPE_DIMENSIONS: case TT_POINT_TYPE_MAP_CONNECTION: case TT_POINT_TYPE_PASSAGE_HEIGHT: ththrow(("-clip not valid with type %s", thmatch_string(this->type,thtt_point_types))) break; } } th2ddataobject::set(cod, args, argenc, indataline); ...from line 399 Sets postprocess_label (aka process_label aka mode) = -1 ie default mode = -1 when none of the label modes are applicable ...from line 457 Sets postprocess_label values for points label, remark and station-name ...from line 574 Deals with point height variants, and near the bottom of this snippet sets postprocess_label to 7 case TT_POINT_TYPE_HEIGHT: if ((this->tags & (TT_POINT_TAG_HEIGHT_P | TT_POINT_TAG_HEIGHT_N | TT_POINT_TAG_HEIGHT_U)) != 0) { switch (this->tags & (TT_POINT_TAG_HEIGHT_P | TT_POINT_TAG_HEIGHT_N | TT_POINT_TAG_HEIGHT_U)) { case TT_POINT_TAG_HEIGHT_P: macroid = SYMP_HEIGHT_POSITIVE; break; case TT_POINT_TAG_HEIGHT_N: macroid = SYMP_HEIGHT_NEGATIVE; break; case TT_POINT_TAG_HEIGHT_U: macroid = SYMP_HEIGHT_UNSIGNED; break; default: return(false); } omacroid = macroid; if (this->context >= 0) macroid = this->context; if (!out->symset->is_assigned(macroid)) return(false); if (out->file == NULL) return(true); out->symset->get_mp_macro(omacroid); out->symset->export_mp_symbol_options(out->file, omacroid); fprintf(out->file,"p_label%s(btex \\thheight ",thpoint_export_mp_align2mp(thdb2d_rotate_align(this->align, xrr))); out->layout->export_mptex_font_size(out->file, this, false); if ((this->tags & TT_POINT_TAG_HEIGHT_P) != 0) fprintf(out->file,"\\thheightpos "); else if ((this->tags & TT_POINT_TAG_HEIGHT_N) != 0) fprintf(out->file,"\\thheightneg "); if (!thisnan(this->xsize)) { //if (double(int(this->xsize)) != this->xsize) // sprintf(buff,"%.1f",this->xsize); //else // sprintf(buff,"%.0f",this->xsize); fprintf(out->file,"%s",utf2tex(out->layout->units.format_human_length(this->xsize))); } this->db->buff_enc.strcpy((this->tags & (TT_POINT_TAG_HEIGHT_PQ | TT_POINT_TAG_HEIGHT_NQ | TT_POINT_TAG_HEIGHT_UQ)) != 0 ? "?" : "" ); fprintf(out->file,"%s etex,",utf2tex(this->db->buff_enc.get_buffer())); postprocess_label = 7; } postprocess = false; break;
_______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion