ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Artifact in flow cell connection
@ 2024-10-11 20:47 Bernd Donner via ntg-context
  2024-10-15  6:47 ` [NTG-context] " Bernd Donner via ntg-context
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Donner via ntg-context @ 2024-10-11 20:47 UTC (permalink / raw)
  To: ntg-context; +Cc: Bernd Donner


[-- Attachment #1.1: Type: text/plain, Size: 1100 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1330 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
  2024-10-11 20:47 [NTG-context] Artifact in flow cell connection Bernd Donner via ntg-context
@ 2024-10-15  6:47 ` Bernd Donner via ntg-context
  2024-10-16 17:48   ` Bruce Horrocks
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Donner via ntg-context @ 2024-10-15  6:47 UTC (permalink / raw)
  To: ntg-context; +Cc: Bernd Donner


[-- Attachment #1.1: Type: text/plain, Size: 1982 bytes --]

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
>

[-- Attachment #1.2: Type: text/html, Size: 2377 bytes --]

[-- Attachment #2: bug_flowchart.pdf --]
[-- Type: application/pdf, Size: 6756 bytes --]

[-- Attachment #3: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
  2024-10-15  6:47 ` [NTG-context] " Bernd Donner via ntg-context
@ 2024-10-16 17:48   ` Bruce Horrocks
  2024-10-16 18:47     ` Hans Hagen
  2024-10-16 20:28     ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 7+ messages in thread
From: Bruce Horrocks @ 2024-10-16 17:48 UTC (permalink / raw)
  To: ntg-context mailing list; +Cc: Bernd Donner



> On 15 Oct 2024, at 07:47, Bernd Donner via ntg-context <ntg-context@ntg.nl> 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

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
  2024-10-16 17:48   ` Bruce Horrocks
@ 2024-10-16 18:47     ` Hans Hagen
  2024-10-16 20:28     ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2024-10-16 18:47 UTC (permalink / raw)
  To: ntg-context

On 10/16/2024 7:48 PM, Bruce Horrocks wrote:
> 
> 
>> On 15 Oct 2024, at 07:47, Bernd Donner via ntg-context <ntg-context@ntg.nl> 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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
  2024-10-16 17:48   ` Bruce Horrocks
  2024-10-16 18:47     ` Hans Hagen
@ 2024-10-16 20:28     ` Hans Hagen via ntg-context
  2024-10-17 14:39       ` Bernd Donner via ntg-context
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen via ntg-context @ 2024-10-16 20:28 UTC (permalink / raw)
  To: ntg-context; +Cc: Hans Hagen

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
  2024-10-16 20:28     ` Hans Hagen via ntg-context
@ 2024-10-17 14:39       ` Bernd Donner via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: Bernd Donner via ntg-context @ 2024-10-17 14:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Bernd Donner


[-- Attachment #1.1: Type: text/plain, Size: 3854 bytes --]

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 <ntg-context@ntg.nl>
wrote:

> 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
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 5511 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [NTG-context] Re: Artifact in flow cell connection
@ 2024-10-12  7:03 wangzhongtian
  0 siblings, 0 replies; 7+ messages in thread
From: wangzhongtian @ 2024-10-12  7:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/html, Size: 2723 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-17 14:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-11 20:47 [NTG-context] Artifact in flow cell connection Bernd Donner via ntg-context
2024-10-15  6:47 ` [NTG-context] " Bernd Donner via ntg-context
2024-10-16 17:48   ` Bruce Horrocks
2024-10-16 18:47     ` Hans Hagen
2024-10-16 20:28     ` Hans Hagen via ntg-context
2024-10-17 14:39       ` Bernd Donner via ntg-context
2024-10-12  7:03 wangzhongtian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).