ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using MetaPost graphics in ConTeXt
@ 2003-03-23 21:38 Giuseppe Bilotta
  2003-03-24  6:09 ` Johannes Hüsing
  2003-03-24 19:16 ` Simon Pepping
  0 siblings, 2 replies; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-23 21:38 UTC (permalink / raw)


Hello,

I'm trying to use some MetaPost-generated graphics with ConTeXt,
but I seem to be unable to do so. I have a file test.1 in the same
directory as the ConTeXt source, which is as minimal as:

\starttext
\input tufte
\placefigure[left]
{Esempio di settore circolare}
{\externalfigure[test.1]}
\input knuth
\stoptext

but it seems like it can't find the file test (no extension); I
tried adding options [type=mps] or [method=mps] or both, but each
fails with a different error: either it looks for test.mps or it
looks for test.unknown ...

What should I do (apart renaming the figure file)?

-- 
Giuseppe "Oblomov" Bilotta

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

* Re: Using MetaPost graphics in ConTeXt
  2003-03-23 21:38 Using MetaPost graphics in ConTeXt Giuseppe Bilotta
@ 2003-03-24  6:09 ` Johannes Hüsing
  2003-03-24 10:27   ` Re[2]: " Giuseppe Bilotta
  2003-03-24 19:16 ` Simon Pepping
  1 sibling, 1 reply; 12+ messages in thread
From: Johannes Hüsing @ 2003-03-24  6:09 UTC (permalink / raw)


Giuseppe Bilotta <gip.bilotta@iol.it> [Sun, Mar 23, 2003 at 10:38:37PM CET]:
> Hello,
> 
> I'm trying to use some MetaPost-generated graphics with ConTeXt,
> but I seem to be unable to do so. I have a file test.1 in the same
> directory as the ConTeXt source, which is as minimal as:
> 
> \starttext
> \input tufte
> \placefigure[left]
> {Esempio di settore circolare}
> {\externalfigure[test.1]}

\useexternalfigure[prova][test.1][width=450pt] % the last one is optional
\externalfigure[prova]

Greetings


Johannes
-- 
Johannes Hüsing   There is something fascinating about science. One gets
hannes@ruhrau.de  such wholesale returns of conjecture from such a 
                  trifling investment of fact.                Mark Twain

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

* Re[2]: Using MetaPost graphics in ConTeXt
  2003-03-24  6:09 ` Johannes Hüsing
@ 2003-03-24 10:27   ` Giuseppe Bilotta
  2003-03-24 12:30     ` Hans Hagen
  2003-03-24 13:06     ` Re[2]: " Guy Worthington
  0 siblings, 2 replies; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-24 10:27 UTC (permalink / raw)


Monday, March 24, 2003 Johannes Hüsing wrote:
>> I'm trying to use some MetaPost-generated graphics with ConTeXt,
>> but I seem to be unable to do so. I have a file test.1 in the same
>> directory as the ConTeXt source, which is as minimal as:
>> 
>> \starttext
>> \input tufte
>> \placefigure[left]
>> {Esempio di settore circolare}
>> {\externalfigure[test.1]}

JH> \useexternalfigure[prova][test.1][width=450pt] % the last one is optional
JH> \externalfigure[prova]

Doesn't work either. Fails with the same errors. Again, it works
correctly by changing the extension.

A possible reason for the error is that the name of the tex file
is the same as the name of the figure file (test), because ConTeXt
*does* check for this, and this is where it chooses not to handle
the picture. Given that the same file works if the extension is
mps, I can't understand why it refuses to do the job when the
extension is different, and still different from .tex and .pdf
(and therefore there is no chance of contrast).

-- 
Giuseppe "Oblomov" Bilotta

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

* Re[2]: Using MetaPost graphics in ConTeXt
  2003-03-24 10:27   ` Re[2]: " Giuseppe Bilotta
@ 2003-03-24 12:30     ` Hans Hagen
  2003-03-24 13:48       ` Re[3]: " Giuseppe Bilotta
  2003-03-24 13:06     ` Re[2]: " Guy Worthington
  1 sibling, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2003-03-24 12:30 UTC (permalink / raw)
  Cc: ntg-context

At 11:27 AM 3/24/2003 +0100, Giuseppe Bilotta wrote:
>Monday, March 24, 2003 Johannes Hüsing wrote:
> >> I'm trying to use some MetaPost-generated graphics with ConTeXt,
> >> but I seem to be unable to do so. I have a file test.1 in the same
> >> directory as the ConTeXt source, which is as minimal as:
> >>
> >> \starttext
> >> \input tufte
> >> \placefigure[left]
> >> {Esempio di settore circolare}
> >> {\externalfigure[test.1]}
>
>JH> \useexternalfigure[prova][test.1][width=450pt] % the last one is optional
>JH> \externalfigure[prova]
>
>Doesn't work either. Fails with the same errors. Again, it works
>correctly by changing the extension.
>
>A possible reason for the error is that the name of the tex file
>is the same as the name of the figure file (test), because ConTeXt
>*does* check for this, and this is where it chooses not to handle
>the picture. Given that the same file works if the extension is
>mps, I can't understand why it refuses to do the job when the
>extension is different, and still different from .tex and .pdf

or xml or the yet to be invented superior coding standard 'number one' with 
suffix 1



Hans

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: Re[2]: Using MetaPost graphics in ConTeXt
  2003-03-24 10:27   ` Re[2]: " Giuseppe Bilotta
  2003-03-24 12:30     ` Hans Hagen
@ 2003-03-24 13:06     ` Guy Worthington
  1 sibling, 0 replies; 12+ messages in thread
From: Guy Worthington @ 2003-03-24 13:06 UTC (permalink / raw)



> I'm trying to use some MetaPost-generated graphics with ConTeXt,
> but I seem to be unable to do so.

> A possible reason for the error is that the name of the tex file
> is the same as the name of the figure file (test), because ConTeXt
> *does* check for this, and this is where it chooses not to handle
> the picture.

I can't you whether you supposition is right because if Hans Hagen
goes out of his way to avoid name collisions with graphics then it's
good enough for me.

Here's an example from the metafun manual, that works with
\externalfigure (it also avoids name collisions).

-----

%output=pdf
\setupcolors [state=start]

\startMPcode
boolean show_labels ; show_labels := true;

def draw_problem (expr n, p, q, r, s) = % number & 4 postitions
  beginfig(n) ;

    save x,y ;

    z[1][1] = p ; z[2][1] = q ; z[3][1] = r ; z[4][1] = s ;

    for i = 1 upto 4 :
      z[i][1] = (x[i][1],y[i][1]) = z[if i=1: 4 else: i-1 fi][2] ;
      z[i][2] = (x[i][2],y[i][2]) ;
      z[i][3] = (x[i][2]-y[i][2]+y[i][1], y[i][2]+x[i][2]-x[i][1]) ;
      z[i][4] = (x[i][1]-y[i][2]+y[i][1], y[i][1]+x[i][2]-x[i][1]) ;
      z[i] = 0.5[z[i][1], z[i][3]] ;
    endfor ;

    z[0] = whatever[z[1], z[3]] = whatever[z[2], z[4]] ;

    pickup pencircle scaled .5pt ;

    for i = 1 upto 4 :
      draw z[i][1]--z[i][2]--z[i][3]--z[i][4]--cycle ;
      draw z[i][1]--z[i][3] ; draw z[i][2]--z[i][4] ;
      if i < 3 : draw z[i]--z[i+2] dashed evenly fi ;
    endfor ;

    draw ((1,0)--(1,1)--(0,1))
    zscaled (unitvector(z[1]-z[0])*10pt) shifted z[0] ;

    mark_rt_angle (z[1], z[0], z[2]) ; % z2 is not used at all


    if show_labels:
       pickup pencircle scaled 5pt ;

       dotlabel.llft(btex $Z_{11}$ etex, z[1][1]) ;
       dotlabel.ulft(btex $Z_{12}$ etex, z[1][2]) ;
       dotlabel.ulft(btex $Z_{13}$ etex, z[1][3]) ;
       dotlabel.llft(btex $Z_{14}$ etex, z[1][4]) ;

       dotlabel.lft (btex $Z_{21}$ etex, z[2][1]) ;
       dotlabel.llft(btex $Z_{22}$ etex, z[2][2]) ;
       dotlabel.urt (btex $Z_{23}$ etex, z[2][3]) ;
       dotlabel.llft(btex $Z_{24}$ etex, z[2][4]) ;

       dotlabel.urt (btex $Z_{31}$ etex, z[3][1]) ;
       dotlabel.ulft(btex $Z_{32}$ etex, z[3][2]) ;
       dotlabel.urt (btex $Z_{33}$ etex, z[3][3]) ;
       dotlabel.urt (btex $Z_{34}$ etex, z[3][4]) ;

       dotlabel.lft (btex $Z_{41}$ etex, z[4][1]) ;
       dotlabel.urt (btex $Z_{42}$ etex, z[4][2]) ;
       dotlabel.llft(btex $Z_{43}$ etex, z[4][3]) ;
       dotlabel.lrt (btex $Z_{44}$ etex, z[4][4]) ;

       dotlabel.urt (btex $Z_{0}$ etex, z[0]) ;
       dotlabel.lft (btex $Z_{1}$ etex, z[1]) ;
       dotlabel.top (btex $Z_{2}$ etex, z[2]) ;
       dotlabel.rt  (btex $Z_{3}$ etex, z[3]) ;
       dotlabel.bot (btex $Z_{4}$ etex, z[4]) ;

    fi ;

  endfig ;
  
enddef ;

angle_radius = 10pt ;

def mark_rt_angle (expr a, b, c) =
  draw ((1,0)--(1,1)--(0,1))
      zscaled (angle_radius*unitvector(a-b))
      shifted b
enddef ;

def do_draw_problem (expr n, i, j) =
  draw_problem (n,
    (400pt, 400pt), (400pt, 600pt),
  i[(400pt,600pt),(550pt,600pt)],
  j[(400pt,400pt),(550pt,400pt)] ) ;
enddef ;

do_draw_problem (50, 0.6, 1.0) ;

\stopMPcode

\starttext

\externalfigure[example22-mpgraph.50]

\stoptext

%%% Local Variables:
%%% mode:context
%%% End:

-----

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

* Re[3]: Using MetaPost graphics in ConTeXt
  2003-03-24 12:30     ` Hans Hagen
@ 2003-03-24 13:48       ` Giuseppe Bilotta
  2003-03-25  3:07         ` Gary Pajer
  0 siblings, 1 reply; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-24 13:48 UTC (permalink / raw)


Monday, March 24, 2003 Hans Hagen wrote:
>>Doesn't work either. Fails with the same errors. Again, it works
>>correctly by changing the extension.
>>
>>A possible reason for the error is that the name of the tex file
>>is the same as the name of the figure file (test), because ConTeXt
>>*does* check for this, and this is where it chooses not to handle
>>the picture. Given that the same file works if the extension is
>>mps, I can't understand why it refuses to do the job when the
>>extension is different, and still different from .tex and .pdf

HH> or xml or the yet to be invented superior coding standard 'number one' with
HH> suffix 1

Ok, but in the mean time how is one supposed to include MetaPost
output without having to rename the files?

-- 
Giuseppe "Oblomov" Bilotta

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

* Re: Using MetaPost graphics in ConTeXt
  2003-03-23 21:38 Using MetaPost graphics in ConTeXt Giuseppe Bilotta
  2003-03-24  6:09 ` Johannes Hüsing
@ 2003-03-24 19:16 ` Simon Pepping
  2003-03-24 23:07   ` Re[2]: " Giuseppe Bilotta
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Pepping @ 2003-03-24 19:16 UTC (permalink / raw)


On Sun, Mar 23, 2003 at 10:38:37PM +0100, Giuseppe Bilotta wrote:
> Hello,
> 
> I'm trying to use some MetaPost-generated graphics with ConTeXt,
> but I seem to be unable to do so. I have a file test.1 in the same
> directory as the ConTeXt source, which is as minimal as:
> 
> \starttext
> \input tufte
> \placefigure[left]
> {Esempio di settore circolare}
> {\externalfigure[test.1]}
> \input knuth
> \stoptext
> 
> but it seems like it can't find the file test (no extension); I
> tried adding options [type=mps] or [method=mps] or both, but each
> fails with a different error: either it looks for test.mps or it
> looks for test.unknown ...

The macro \calculateexternalfigure seems to set the extension to empty
if the figure file name is the same as the jobname:

   % redo message, only filename  
   \doifparentfileelse\@@effilename
     {\@EA\removefromcommalist\@EA{\jobsuffix}\figuretypes
      \let\@@efextension\empty
      \showmessage\m!figures9\@@effilename
      \donefalse}
     \donothing 

(core-fig.tex)

Therefore it does not search for your nonstandard extension.

Regards, Simon

-- 
Simon Pepping
email: spepping@scaprea.hobby.nl

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

* Re[2]: Using MetaPost graphics in ConTeXt
  2003-03-24 19:16 ` Simon Pepping
@ 2003-03-24 23:07   ` Giuseppe Bilotta
  0 siblings, 0 replies; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-24 23:07 UTC (permalink / raw)


Monday, March 24, 2003 Simon Pepping wrote:
>> but it seems like it can't find the file test (no extension); I
>> tried adding options [type=mps] or [method=mps] or both, but each
>> fails with a different error: either it looks for test.mps or it
>> looks for test.unknown ...

SP> The macro \calculateexternalfigure seems to set the extension to empty
SP> if the figure file name is the same as the jobname:

SP>    % redo message, only filename  
SP>    \doifparentfileelse\@@effilename
SP>      {\@EA\removefromcommalist\@EA{\jobsuffix}\figuretypes
SP>       \let\@@efextension\empty
SP>       \showmessage\m!figures9\@@effilename
SP>       \donefalse}
SP>      \donothing 

SP> (core-fig.tex)

SP> Therefore it does not search for your nonstandard extension.

Yup, after a little debugging I came to the same conclusion, but I
still it's incorrect behaviour. It's correct that it removes the
jobsuffix from the figuretypes to be searched, but it should still
try and look for the figure, after the change.

-- 
Giuseppe "Oblomov" Bilotta

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

* Re: Re[3]: Using MetaPost graphics in ConTeXt
  2003-03-24 13:48       ` Re[3]: " Giuseppe Bilotta
@ 2003-03-25  3:07         ` Gary Pajer
  2003-03-25 10:35           ` Re[5]: " Giuseppe Bilotta
  0 siblings, 1 reply; 12+ messages in thread
From: Gary Pajer @ 2003-03-25  3:07 UTC (permalink / raw)


> Monday, March 24, 2003 Hans Hagen wrote:
> >>Doesn't work either. Fails with the same errors. Again, it works
> >>correctly by changing the extension.
> >>
> >>A possible reason for the error is that the name of the tex file
> >>is the same as the name of the figure file (test), because ConTeXt
> >>*does* check for this, and this is where it chooses not to handle
> >>the picture. Given that the same file works if the extension is
> >>mps, I can't understand why it refuses to do the job when the
> >>extension is different, and still different from .tex and .pdf
>
> HH> or xml or the yet to be invented superior coding standard 'number one'
with
> HH> suffix 1
>
> Ok, but in the mean time how is one supposed to include MetaPost
> output without having to rename the files?

I've tried to resist, but I have to ask.  Why not write a simple batch file
that runs MetaPost *and* changes the extension?  That's what I do. ... Are
you processing several MP scripts in one file ??

-Gary

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

* Re[5]: Using MetaPost graphics in ConTeXt
  2003-03-25  3:07         ` Gary Pajer
@ 2003-03-25 10:35           ` Giuseppe Bilotta
  0 siblings, 0 replies; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-25 10:35 UTC (permalink / raw)


Tuesday, March 25, 2003 Gary Pajer wrote:

>> Ok, but in the mean time how is one supposed to include MetaPost
>> output without having to rename the files?

GP> I've tried to resist, but I have to ask.  Why not write a simple batch file
GP> that runs MetaPost *and* changes the extension?  That's what I do. ... Are
GP> you processing several MP scripts in one file ??

Oh, I can do many things. And I don't even *need* it --it's just
for testing purpouses, not for production stuff-- but why use a
workaround when the problem can be fixed?

-- 
Giuseppe "Oblomov" Bilotta

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

* Re[3]: Using MetaPost graphics in ConTeXt
  2003-03-25 12:26 ` Re[2]: " Hans Hagen
@ 2003-03-25 12:49   ` Giuseppe Bilotta
  0 siblings, 0 replies; 12+ messages in thread
From: Giuseppe Bilotta @ 2003-03-25 12:49 UTC (permalink / raw)


Tuesday, March 25, 2003 Hans Hagen wrote:

HH> At 11:38 AM 3/25/2003 +0100, you wrote:

>>The third point is too severe in its behaviour: it's a good thing that
>>circular
>>loading is prevented, but this shouldn't prevent inclusion of
>>other files with different extensions! After the removal of the
>>\jobsuffix extension, inclusion should go on normally!

HH> it will, fo rthose sufixes that are recognized as being supported by the
HH> backend; numbers are special case in the sense that they don't relate to a
HH> file format; if you uncomment the lines i mentioned you get them supported

The problem is not the numbers as such, it's a more general point;
especially then type= or method= are specified, extension should
be irrelevant as long as it doesn't cause name clash. On a very
general basis, I would say that the best approach would be:

Step 1: check for name clashes:
 * if name = \jobname:
   (a) if extension = \jobsuffix or output suffix (dvi, pdf), quit
   parsing
   (b) if no extension, remove jobsuffix and output suffix from
   list of searched extensions.

Step 2: if extension is specified, and no method is specified,
set method to the one associated with this extension, if there is
one.

Step 3: check if file exists;
 * if we have a full name, try to open the specified
 name.extension, with the specified method
 * if the file is not found, and no extension was specified, look
 for all the known extensions (except the ones forbidden by Step
 1, point b); if a method/type is specified and it has a default extension,
 start looking from that extension

Or something like this ...

-- 
Giuseppe "Oblomov" Bilotta

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

* Re: Re[3]: Using MetaPost graphics in ConTeXt
@ 2003-03-25  8:46 Hans Hagen
  0 siblings, 0 replies; 12+ messages in thread
From: Hans Hagen @ 2003-03-25  8:46 UTC (permalink / raw)


At 10:07 PM 3/24/2003 -0500, Gary Pajer wrote:

>I've tried to resist, but I have to ask.  Why not write a simple batch file
>that runs MetaPost *and* changes the extension?  That's what I do. ... Are
>you processing several MP scripts in one file ??


Remembering that i did look into it long ago, i took a look in the core-fig 
file; now, if you really want this kind of support, open core-fig.tex and 
search for:

   % new, test first

uncomment the doifnumberelse lines and you'll have the support needed (a 
new format needs to be generated)

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

end of thread, other threads:[~2003-03-25 12:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-23 21:38 Using MetaPost graphics in ConTeXt Giuseppe Bilotta
2003-03-24  6:09 ` Johannes Hüsing
2003-03-24 10:27   ` Re[2]: " Giuseppe Bilotta
2003-03-24 12:30     ` Hans Hagen
2003-03-24 13:48       ` Re[3]: " Giuseppe Bilotta
2003-03-25  3:07         ` Gary Pajer
2003-03-25 10:35           ` Re[5]: " Giuseppe Bilotta
2003-03-24 13:06     ` Re[2]: " Guy Worthington
2003-03-24 19:16 ` Simon Pepping
2003-03-24 23:07   ` Re[2]: " Giuseppe Bilotta
2003-03-25  8:46 Re[3]: " Hans Hagen
2003-03-25  8:46 Hans Hagen
2003-03-25 12:26 ` Re[2]: " Hans Hagen
2003-03-25 12:49   ` Re[3]: " Giuseppe Bilotta

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).