Hi, I have a broken flow cell connection in this minimal example. The broken flow cell is only triggered when drawn within a subsection with an overlay. The logic to create the underlined subsection is by the way copied from the metafun manual source. I do not have the slightest clue what is going wrong in this example. Thanks for ideas. Best, Bernd \usemodule[chart] \startuniqueMPgraphic{SectionUnderline} path p; p:= unitsquare xscaled OverlayWidth yscaled OverlayHeight; draw llcorner p -- lrcorner p; setbounds currentpicture to p; \stopuniqueMPgraphic \defineoverlay[SectionUnderline][\uniqueMPgraphic{SectionUnderline}] \starttexdefinition unexpanded ChapterCommand #1#2 \framed [background=SectionUnderline] {#2} \stoptexdefinition \setuphead [subsection] [command=\ChapterCommand] \starttext \subsection[title=Introduction] \startFLOWchart[toolchain] \startFLOWcell \location{1,1} \connection [bt] {compiler} \stopFLOWcell \startFLOWcell \name {compiler} \location{1,2} \shape{product} \stopFLOWcell \stopFLOWchart \FLOWchart[toolchain] \stoptext
Hi everyone, I have tested the minimal example mentioned above on a completely separate Linux installation, and I am seeing the same observable artifact. This leads me to believe that the issue might not be specific to my context installation. It seems that the overlay in the heading and the \shape{product} are essential components that trigger the behavior I’m experiencing. At this point, I'm uncertain whether this is an error on my part or a potential bug—possibly related to flowcharts. Could someone please confirm if the output of the minimal example matches what is shown in the attached PDF? Thank you! Best, Bernd Am Fr., 11. Okt. 2024 um 22:47 Uhr schrieb Bernd Donner < bleau1975@googlemail.com>:
Hi,
I have a broken flow cell connection in this minimal example. The broken flow cell is only triggered when drawn within a subsection with an overlay. The logic to create the underlined subsection is by the way copied from the metafun manual source. I do not have the slightest clue what is going wrong in this example. Thanks for ideas.
Best, Bernd
\usemodule[chart]
\startuniqueMPgraphic{SectionUnderline} path p; p:= unitsquare xscaled OverlayWidth yscaled OverlayHeight; draw llcorner p -- lrcorner p; setbounds currentpicture to p; \stopuniqueMPgraphic
\defineoverlay[SectionUnderline][\uniqueMPgraphic{SectionUnderline}]
\starttexdefinition unexpanded ChapterCommand #1#2 \framed [background=SectionUnderline] {#2} \stoptexdefinition
\setuphead [subsection] [command=\ChapterCommand]
\starttext
\subsection[title=Introduction]
\startFLOWchart[toolchain]
\startFLOWcell \location{1,1} \connection [bt] {compiler} \stopFLOWcell
\startFLOWcell \name {compiler} \location{1,2} \shape{product} \stopFLOWcell \stopFLOWchart
\FLOWchart[toolchain] \stoptext
On 15 Oct 2024, at 07:47, Bernd Donner via ntg-context
wrote: Could someone please confirm if the output of the minimal example matches what is shown in the attached PDF?
I too get the output as posted. (mtx-context | current version: 2024.09.25 11:53) If you change the following MWE line \connection [bt] {compiler} to \connection [br] {compiler} then the glitch goes away, so I suggest that means it is a bug in the flow chart module. Changing to draw from the bottom shape upwards also has the glitch on a straight line - so something to do with the straight line drawing code, perhaps? As a work-around, if you just want the section heading underlined (as opposed to a more complicated MP graphic that you omitted for simplicity) then your MWE becomes: \usemodule[chart] \starttext \subsection[title={\inframed[frame=off,bottomframe=on]{Introduction}}] \startFLOWchart[toolchain] \startFLOWcell \location{1,1} \connection [bt] {compiler} \stopFLOWcell \startFLOWcell \name {compiler} \location{1,2} \shape{product} \stopFLOWcell \stopFLOWchart \FLOWchart[toolchain] \stoptext If you don’t want the section number then use \subsubject instead of \subsection. Regards, — Bruce Horrocks Hampshire, UK
On 10/16/2024 7:48 PM, Bruce Horrocks wrote:
On 15 Oct 2024, at 07:47, Bernd Donner via ntg-context
wrote: Could someone please confirm if the output of the minimal example matches what is shown in the attached PDF?
I too get the output as posted. (mtx-context | current version: 2024.09.25 11:53)
If you change the following MWE line
\connection [bt] {compiler}
to
\connection [br] {compiler}
then the glitch goes away, so I suggest that means it is a bug in the flow chart module.
Changing to draw from the bottom shape upwards also has the glitch on a straight line - so something to do with the straight line drawing code, perhaps?
As a work-around, if you just want the section heading underlined (as opposed to a more complicated MP graphic that you omitted for simplicity) then your MWE becomes:
\usemodule[chart] \starttext \subsection[title={\inframed[frame=off,bottomframe=on]{Introduction}}]
You don't want that framed command in the table of content entry, so use \setuphead [subsection] [textcommand={\inframed[frame=off,bottomframe=on]}] or \definebar[SubSectionBar][underbar][offset=-1] \setuphead[subsection][textcommand=\SubSectionBar] instead, Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi Bruce,
If you change the following MWE line
\connection [bt] {compiler}
to
\connection [br] {compiler}
then the glitch goes away, so I suggest that means it is a bug in the flow chart module.
Actually not (but you're close) ... so for a moment put your calculator (hardware) hat on (although they use decimal clipping and rounding i guess) You noticed that coming from one directions gives a different result than coming from the other: metapost > message : 1.4999979972839355 1.8181943026455964 metapost > message : 1.5 2.1818056973544033 Now, why does this fail? We use a double instance here and as we calculate intersection points we are too precise compared to scaled where we get twice 1.5, so the points collapse in scaled mode and not in double. Maybe I need to make some helper for clipping a given precision. The mp graphic that does the framed loads a metafun double instance so a later instance with the same name in the chart (lua) module takes that one; when it is the first one it will take the scaled instance (mkiv is scaled by default and mkxl defaults to double). We can run these charts in their own instance (i'll do that). Here is the patch for mp-char.mpiv that fixes the issue: def flow_collapse_points = % this can become a core macro begingroup ; % remove redundant points save n ; numeric n ; n := 1 ; for i=2 upto flow_xypoint : % if not (flow_xypoints[i] = flow_xypoints[n]) : if abs(flow_xypoints[i] - flow_xypoints[n]) > eps : n := n + 1 ; flow_xypoints[n] := flow_xypoints[i] fi ; endfor ; flow_xypoint := n ; % make straight lines % if flow_xypoints[2] = flow_xypoints[flow_xypoint-1] : if abs(flow_xypoints[2] - flow_xypoints[flow_xypoint-1]) < eps : flow_xypoints[3] := flow_xypoints[flow_xypoint] ; flow_xypoint := 3 ; fi ; endgroup ; enddef ; But best check this! So the bt / tb was a clue indeed. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hello Bruce,
Hello Hans,
Thank you very much for your help and input. I tested the proposed patch
with the minimal example, and the glitch indeed disappeared.
I have to admit, I wasn’t aware that metafun could run in different
instances, let alone the existence of both a double instance and a scaled
instance. While your patch is quite clear, the inner workings of metapost
are a mystery to me. I greatly appreciate the quick fix and the explanation.
Best regards,
Bernd
---
This version improves readability, fixes minor typos, and maintains a
polite, professional tone.
On Wed, Oct 16, 2024, 22:34 Hans Hagen via ntg-context
Hi Bruce,
If you change the following MWE line
\connection [bt] {compiler}
to
\connection [br] {compiler}
then the glitch goes away, so I suggest that means it is a bug in the flow chart module.
Actually not (but you're close) ... so for a moment put your calculator (hardware) hat on (although they use decimal clipping and rounding i guess)
You noticed that coming from one directions gives a different result than coming from the other:
metapost > message : 1.4999979972839355 1.8181943026455964 metapost > message : 1.5 2.1818056973544033
Now, why does this fail? We use a double instance here and as we calculate intersection points we are too precise compared to scaled where we get twice 1.5, so the points collapse in scaled mode and not in double. Maybe I need to make some helper for clipping a given precision.
The mp graphic that does the framed loads a metafun double instance so a later instance with the same name in the chart (lua) module takes that one; when it is the first one it will take the scaled instance (mkiv is scaled by default and mkxl defaults to double).
We can run these charts in their own instance (i'll do that).
Here is the patch for mp-char.mpiv that fixes the issue:
def flow_collapse_points = % this can become a core macro begingroup ; % remove redundant points save n ; numeric n ; n := 1 ; for i=2 upto flow_xypoint : % if not (flow_xypoints[i] = flow_xypoints[n]) : if abs(flow_xypoints[i] - flow_xypoints[n]) > eps : n := n + 1 ; flow_xypoints[n] := flow_xypoints[i] fi ; endfor ; flow_xypoint := n ; % make straight lines % if flow_xypoints[2] = flow_xypoints[flow_xypoint-1] : if abs(flow_xypoints[2] - flow_xypoints[flow_xypoint-1]) < eps : flow_xypoints[3] := flow_xypoints[flow_xypoint] ; flow_xypoint := 3 ; fi ; endgroup ; enddef ;
But best check this! So the bt / tb was a clue indeed.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
participants (4)
-
Bernd Donner
-
Bruce Horrocks
-
Hans Hagen
-
Hans Hagen