ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* status of node.write
@ 2010-03-24  9:23 Michail Vidiassov
  2010-03-24  9:52 ` luigi scarso
  2010-03-24 10:17 ` status of node.write Hans Hagen
  0 siblings, 2 replies; 20+ messages in thread
From: Michail Vidiassov @ 2010-03-24  9:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear All,

I notice that broken code for inserting movies uses
node.write in codeinjections.insertmovie (in back-pdf.lua),
while figures.checkers.mov (in grph-inc.lua) expects text return
from codeinjections.insertmovie to feed to "texsprint(ctxcatcodes".

The 3D annotation code (it also seems not to work) has
node.write variant commented out and replaced with
"texsprint(ctxcatcodes" with "brrrr" comment!

    local annot, preview, ref = backends.pdf.helpers.insert3d {
       ......
     }
  -- node.write(pdfannotation(width,-height,0,annot()))
     texsprint(ctxcatcodes,format("\\pdfannot width %ssp height %ssp {%s}",width,height,annot())) -- brrrr
--~     if ref then -- wrong ! a direct ref should work
--~         texsprint(ctxcatcodes,format("\\smash{\\pdfrefximage%s\\relax}",ref)) -- 
brrrr
--~     end
     texsprint(ctxcatcodes,"\\stopfoundexternalfigure")

And the question is: does it make sense to try to make the current 3D 
annotation handling code work by complaining to the maintainers and/or
fixing it myself or nothing is supposed to work till migration to 
from "texsprint(ctxcatcodes" API to "node.write" API is complete?

              Sincerely, Michail
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: 3D annotations
@ 2010-04-17  7:00 Michail Vidiassov
  0 siblings, 0 replies; 20+ messages in thread
From: Michail Vidiassov @ 2010-04-17  7:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 6611 bytes --]

Dear Hans,

I wrote to you
> thank you for your latest effort to put u3d support in a working state, but

more thanks for more effort, but

> May be a more robust way is to read first 3 bytes of the model file, since
> "U3D" or "PRC" signature is always there - that can be done instead of 
> relying on file name extension or only in case it it not "u3d" or "prc".

you have implemented reading the file signature, but it is now 
almost useless, since if a file has extension other but U3D or PRC
3D annotation code will not be called by file inclusion mechanism
and "io.readdata" routine is called
local subtype, subdata = "U3D", io.readdata(foundname) or ""
- what's that?

One more point - preview bitmap images in 3D annotations are now disabled
since necessary functionality of measuring XForms is missing -
please, consider the following workaround.

--- lpdf-u3d.lua.org	2010-03-26 18:24:44.000000000 +0300
+++ lpdf-u3d.lua	2010-04-14 14:24:28.000000000 +0400
@@ -17,6 +17,7 @@
  local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs

  local pdfconstant   = lpdf.constant
+local pdfnumber     = lpdf.number
  local pdfboolean    = lpdf.boolean
  local pdfunicode    = lpdf.unicode
  local pdfdictionary = lpdf.dictionary
@@ -62,8 +63,7 @@

  local function make3dview(view)

-    local name = viewname
-    local name = pdfunicode((view.name ~= "" and name) or "unknown view")
+    local name = pdfunicode((view.name ~= "" and view.name) or "unknown view")

      local viewdict = pdfdictionary {
         Type = pdfconstant("3DView"),
@@ -311,9 +311,6 @@
          for i=1,#nodes do
              local node = checkedkey(nodes,i,"table")
              if node then
-                local position = checkedkey(node,"position","table")
-                position = position and #position == 12 and pdfarray(position)
-                if position then
                      nodelist[#nodelist+1] = pdfdictionary {
                          Type = pdfconstant("3DNode"),
                          N    = node.name or ("node_" .. i), -- pdfunicode ?
@@ -325,13 +322,18 @@
                          },
                          M    = position,
                      }
+                local position = checkedkey(node,"position","table")
+                position = position and #position == 12 and pdfarray(position)
+                if position then
+                    nodelist[#nodelist].M = position
                  end
              end
        end
-      viewdict.NR = true
        viewdict.NA = nodelist
     end

+    viewdict.NR = true
+
     return viewdict

  end
@@ -349,19 +351,19 @@

      local activationdict = pdfdictionary {
         TB = pdfboolean(param.toolbar,true),
-       NP = pdfboolean(param.tree,true),
+       NP = pdfboolean(param.tree,false),
      }

      local stream = streams[label]
      if not stream then

-        local subtype, subdata = "U3D", io.readdata(foundname) or ""
+        local subtype, subdata = "U3D", file.readdata(foundname) or ""
          if find(subdata,"^PRC") then
-            subtype == "PRC"
+            subtype = "PRC"
          elseif find(subdata,"^U3D") then
-            subtype == "U3D"
+            subtype = "U3D"
          elseif file.extname(foundname) == "prc" then
-            subtype == "PRC"
+            subtype = "PRC"
          end

          local attr = pdfdictionary {
@@ -423,12 +425,35 @@
          local ref = stored_pr[tag]
          if not ref then
          --  weird, has to be a /Form and not an /Image so we need a wrap = true key
-        --  local figure = img.immediatewrite { filename = preview, width = width, height = height }
-            local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
+            local figure = img.immediatewrite { filename = preview, width = width, height = height }
+        --  local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
              ref = figure.objnum
              stored_pr[tag] = ref
          end
-        annot.AP = ref and pdfdictionary { N = pdfreference(ref) }
+        if ref then
+            local pw   = pdfdictionary {
+                Type      = pdfconstant("XObject"),
+                Subtype   = pdfconstant("Form"),
+                FormType  = pdfnumber(1),
+                BBox      = pdfarray { pdfnumber(0), pdfnumber(0), pdfnumber(factor*width), pdfnumber(factor*height) },
+                Matrix    = pdfarray { pdfnumber(1), pdfnumber(0), pdfnumber(0), pdfnumber(1), pdfnumber(0), pdfnumber(0) },
+                Resources = pdfdictionary {
+                                XObject = pdfdictionary {
+                                    IM = pdfreference(ref)
+                                }
+                            },
+                ExtGState = pdfdictionary {
+                                GS = pdfdictionary {
+                                    Type = pdfconstant("ExtGState"),
+                                    CA   = pdfnumber(1),
+                                    ca   = pdfnumber(1)
+                                }
+                            },
+                ProcSet    = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") },
+            }
+            local pwd = pdf.immediateobj("stream",format("q /GS gs %s 0 0 %s 0 0 cm /IM Do Q",factor*width,factor*height),pw())
+            annot.AP = pdfdictionary { N = pdfreference(pwd) }
+        end
          return annot, figure, ref
      else
          activationdict.A = pdfconstant("PV")

Also I try to remind you AGAIN and AGAIN about pdfboolean problem in 
lpdf-ini.lua (old code is not OK if b is "false" and default is "true")

  local function pdfboolean(b,default)
-    if ((type(b) == "boolean") and b) or default then
-        return p_true
+    if type(b) ~= "boolean" then
+        if default then
+            return p_true
+        else
+            return p_false
+        end
      else
-        return p_false
+        if b then
+            return p_true
+        else
+            return p_false
+        end
      end
  end

        Sincerely, Michail

PS. And a great palliative way to deal with 3D annotations is via
attaching a 3D PDF file made with LaTeX (by Asymptote, for example).

But while your method of answering my messages in lua works OK for
new code (updating minimals and making a diff with old code is not
harder than checking e-mail inbox - "Your morning patch, sir!" ;),
I can not deduce from existing sea of ConTeXt code the status of file 
attachments support.

[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 29627 bytes --]

[-- Attachment #3: Type: TEXT/PLAIN, Size: 4822 bytes --]

--- lpdf-u3d.lua.org	2010-03-26 18:24:44.000000000 +0300
+++ lpdf-u3d.lua	2010-04-14 14:24:28.000000000 +0400
@@ -17,6 +17,7 @@
 local cos, sin, sqrt, pi, atan2, abs = math.cos, math.sin, math.sqrt, math.pi, math.atan2, math.abs
 
 local pdfconstant   = lpdf.constant
+local pdfnumber     = lpdf.number
 local pdfboolean    = lpdf.boolean
 local pdfunicode    = lpdf.unicode
 local pdfdictionary = lpdf.dictionary
@@ -62,8 +63,7 @@
 
 local function make3dview(view)
 
-    local name = viewname
-    local name = pdfunicode((view.name ~= "" and name) or "unknown view")
+    local name = pdfunicode((view.name ~= "" and view.name) or "unknown view")
 
     local viewdict = pdfdictionary {
        Type = pdfconstant("3DView"),
@@ -311,9 +311,6 @@
         for i=1,#nodes do
             local node = checkedkey(nodes,i,"table")
             if node then
-                local position = checkedkey(node,"position","table")
-                position = position and #position == 12 and pdfarray(position)
-                if position then
                     nodelist[#nodelist+1] = pdfdictionary {
                         Type = pdfconstant("3DNode"),
                         N    = node.name or ("node_" .. i), -- pdfunicode ?
@@ -325,13 +322,18 @@
                         },
                         M    = position,
                     }
+                local position = checkedkey(node,"position","table")
+                position = position and #position == 12 and pdfarray(position)
+                if position then
+                    nodelist[#nodelist].M = position
                 end
             end
       end
-      viewdict.NR = true
       viewdict.NA = nodelist
    end
 
+    viewdict.NR = true
+
    return viewdict
 
 end
@@ -349,19 +351,19 @@
 
     local activationdict = pdfdictionary {
        TB = pdfboolean(param.toolbar,true),
-       NP = pdfboolean(param.tree,true),
+       NP = pdfboolean(param.tree,false),
     }
 
     local stream = streams[label]
     if not stream then
 
-        local subtype, subdata = "U3D", io.readdata(foundname) or ""
+        local subtype, subdata = "U3D", file.readdata(foundname) or ""
         if find(subdata,"^PRC") then
-            subtype == "PRC"
+            subtype = "PRC"
         elseif find(subdata,"^U3D") then
-            subtype == "U3D"
+            subtype = "U3D"
         elseif file.extname(foundname) == "prc" then
-            subtype == "PRC"
+            subtype = "PRC"
         end
 
         local attr = pdfdictionary {
@@ -423,12 +425,35 @@
         local ref = stored_pr[tag]
         if not ref then
         --  weird, has to be a /Form and not an /Image so we need a wrap = true key
-        --  local figure = img.immediatewrite { filename = preview, width = width, height = height }
-            local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
+            local figure = img.immediatewrite { filename = preview, width = width, height = height }
+        --  local figure = img.immediatewrite { stream = ".5 .75 .75 rg 0 0 20 10 re f", bbox = {0,0,20,10 } }
             ref = figure.objnum
             stored_pr[tag] = ref
         end
-        annot.AP = ref and pdfdictionary { N = pdfreference(ref) }
+        if ref then
+            local pw   = pdfdictionary {
+                Type      = pdfconstant("XObject"),
+                Subtype   = pdfconstant("Form"),
+                FormType  = pdfnumber(1),
+                BBox      = pdfarray { pdfnumber(0), pdfnumber(0), pdfnumber(factor*width), pdfnumber(factor*height) },
+                Matrix    = pdfarray { pdfnumber(1), pdfnumber(0), pdfnumber(0), pdfnumber(1), pdfnumber(0), pdfnumber(0) },
+                Resources = pdfdictionary {
+                                XObject = pdfdictionary {
+                                    IM = pdfreference(ref)
+                                }
+                            },
+                ExtGState = pdfdictionary {
+                                GS = pdfdictionary {
+                                    Type = pdfconstant("ExtGState"),
+                                    CA   = pdfnumber(1),
+                                    ca   = pdfnumber(1)
+                                }
+                            },
+                ProcSet    = pdfarray { pdfconstant("PDF"), pdfconstant("ImageC") },
+            }
+            local pwd = pdf.immediateobj("stream",format("q /GS gs %s 0 0 %s 0 0 cm /IM Do Q",factor*width,factor*height),pw())
+            annot.AP = pdfdictionary { N = pdfreference(pwd) }
+        end
         return annot, figure, ref
     else
         activationdict.A = pdfconstant("PV")

[-- Attachment #4: Type: TEXT/PLAIN, Size: 571 bytes --]

--- lpdf-ini.lua.org	2010-04-07 19:51:31.000000000 +0400
+++ lpdf-ini.lua	2010-03-25 20:33:27.000000000 +0300
@@ -278,10 +280,18 @@
 end
 
 local function pdfboolean(b,default)
-    if ((type(b) == "boolean") and b) or default then
-        return p_true
+    if type(b) ~= "boolean" then
+        if default then
+            return p_true
+        else
+            return p_false
+        end
     else
-        return p_false
+        if b then
+            return p_true
+        else
+            return p_false
+        end
     end
 end
 

[-- Attachment #5: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: 3D annotations
@ 2010-05-02  9:08 gummybears
  0 siblings, 0 replies; 20+ messages in thread
From: gummybears @ 2010-05-02  9:08 UTC (permalink / raw)
  To: master; +Cc: mailing list for ConTeXt users


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

Hi Michail,

I read your email (17 april 2010) on the mailing list and applied the two
patches to my Context minimal distro
(the very latest version). When I run your test.tex through context the
preview image test.png
is not shown.

Which version of ConText should I use to make it work

Thanks in advance

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

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: 3D annotations
@ 2010-05-04 10:06 gummybears
  2010-05-04 14:15 ` Michail Vidiassov
  0 siblings, 1 reply; 20+ messages in thread
From: gummybears @ 2010-05-04 10:06 UTC (permalink / raw)
  To: master; +Cc: mailing list for ConTeXt users


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

On Sun, 2 May 2010, gummybears wrote:

I read your email (17 april 2010) on the mailing list and applied the two
patches to my Context minimal distro
(the very latest version). When I run your test.tex through context the
preview image test.png is not shown.


>did you recreate formats after patch
>("context -make" if memory serves me right)?
>I will test with current minimals today.

Probably not (my mistake), but now I did make the formats and with the
current minimals
I got the following error (when running your test.tex file)
bodyfont        : 12pt rm is loaded
language        : language en is active
systems         : begin file test.tex at line 3
floatblocks     : 1 placed
! LuaTeX error ...text/tex/texmf-context/tex/context/base/lpdf-mis.lua:163:
attempt to call field 'timestamp' (a nil value)
stack traceback:
    ...text/tex/texmf-context/tex/context/base/lpdf-mis.lua:163: in function
'setupidentity'
    <main ctx instance>:1: in main chunk.
\synchronizebackendidentity ...akeyword \!!es , }}

\actualshipout ...lio \or \the \everyfirstshipout
                                                  \global
\everyfirstshipout...
\myshipout ...\@@ppmethod }\gobbleoneargument {#1}
                                                  \setnextrealpageno
\afters...
\dofinaloutput ...hbox {\vbox {\dopagebody #1#2}}}
                                                  \the \everyaftershipout
\a...
\finaloutput ...EAEAEA \dofinaloutput \fi \fi #1#2
                                                  \resetselectiepagina
\incr...
\sidefloatoutput ...e \else \finalsidefloatoutput
                                                  \global \sidefloatvsize
\n...
...
l.23 \stopTEXpage

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

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2010-05-04 14:15 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-24  9:23 status of node.write Michail Vidiassov
2010-03-24  9:52 ` luigi scarso
2010-03-24 10:53   ` Michail Vidiassov
2010-03-24 11:10     ` luigi scarso
2010-03-24 13:02       ` Michail Vidiassov
2010-03-24 14:20         ` luigi scarso
2010-03-24 14:29           ` Hans Hagen
2010-03-24 16:46             ` Michail Vidiassov
2010-03-25 15:37               ` Hans Hagen
2010-03-25 14:18             ` PDF annotations problems - was: " Michail Vidiassov
2010-03-24 13:26   ` Hans Hagen
2010-03-25 19:12     ` 3D annotations - was: " Michail Vidiassov
2010-03-25 22:24       ` Hans Hagen
2010-03-26  5:53       ` 3D annotations Michail Vidiassov
2010-03-26 15:32         ` Hans Hagen
2010-03-24 10:17 ` status of node.write Hans Hagen
2010-04-17  7:00 3D annotations Michail Vidiassov
2010-05-02  9:08 gummybears
2010-05-04 10:06 gummybears
2010-05-04 14:15 ` Michail Vidiassov

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