;*************************************************************************
;* *
;* Copyright (c) 2002, ESKO-GRAPHICS *
;* *
;* Tramstraat 69, B-9052 Gent *
;* Belgium *
;* *
;* *
;* All rights are reserved. Reproduction in whole are in part is *
;* prohibited without the written consent of the copyright owner. *
;* *
;*************************************************************************
; Image mark module - allows to use graphics as marks
; todo: clean up and migrate core procedures to m2k modules
; fbr - 21 Feb 00 - first version
; problem serialize 16 dec 2012 --> version 10 load set
; pemy - 20 Aug 13 - photocell ink now from product, not job. Use only from Suite 12.1 onwards!
; gut - 14 nov - when photocell ink is not found or csv file is not found the task will end with a red cross.
using .
; gut - 16 Sep 14 - allow rerun SmartMarks for barcodecode. Required for TraceAbility mark.
; gut - 14 apr 15 - no opacity mask ink for photocell (when taking ink from csv file)
global gmf_debug
global m2k_smartfield
global m2k_tmarkset
M2K_TMarkDialog:subclass "photocelldialog","ui"
M2K_TMark:subclass("photocell")
procedure photocelldialog:init(...)
ui==T_Dict:new()
super:init(...)
end
procedure photocelldialog:OpenSelector()
if isnil(ui["addimagedialog"])
ui["addimagedialog"] == dtl$globl["gmf_selectordialog"]:new(self,,"Add Image Mark")
fi
if ui["imagename"].Text <> ""
ui["addimagedialog"].path = fparse(ui["imagename"].text,"","node,dev,dir")
fi
local filespec = ui["addimagedialog"]:show()
if filespec <> ""
ui["imagename"].Text = filespec
self:filenamechanged()
fi
end
procedure photocelldialog:filenamechanged()
; if gmf_Debug then ty fmtstr("new file name is %",ui["imagename"].text)
self:CheckInkGroups()
end
procedure photocelldialog:build()
brix_icon:loadlibrary("step.iml")
local width = 8*appl:CharWidth()
ui["tabgrp"] == V_TabGroup:new(self)
ui["imgtab"] == V_TabEntry:new(ui["tabgrp"],,"Image/ink")
;ui["inktab"] == V_TabEntry:new(ui["tabgrp"],,"Inks")
ui["postab"] == V_TabEntry:new(ui["tabgrp"],,"Position")
; ui["reptab"] == V_TabEntry:new(ui["tabgrp"],,"Repeat")
ui["imageselector"] == V_Button:new(ui["imgtab"],,BRIX_Icon:new("filesel"))
ui["imageselector"].clickaction = "self.dialog:OpenSelector()"
local lab == V_Label:new(ui["imgtab"],,"Name:")
lab.alignment = "right"
ui["imagename"] == m2k_smartfield:new(ui["imgtab"])
ui["imagename"].changeaction == "self.dialog:filenamechanged()"
ui["imageselector"].height = ui["imagename"].height
ui["imageselector"]:PutVCenter(lab,ui["imagename"])
ui["inkphoto"] == v_label:new(ui["imgtab"],,"Photocell ink = job parameter \"photocell_ink\" if")
ui["inkphototxt1"] == v_label:new(ui["imgtab"],,"not defined then info from bg_data_marks:\\dat\\")
; ui["inkphototxt2"] == v_label:new(ui["imgtab"],,"info from bg_data_marks:\\dat\\PMS_COLORS.CSV")
ui["inkphototxt2"]== m2k_smartfield:new(ui["imgtab"])
ui["inkphototxt2"].changeaction == "self.dialog:filenamechanged()"
ui["inkphototxt2"].width==appl.charwidth*15
; ui["tpmphot"] == v_label:new(ui["imgtab"],,v_icon:new("bg_dtl_gmf2k:tpm_photocell.bmp"))
; ui["tpm"] == v_label:new(ui["imgtab"],,v_icon:new("bg_dtl_gmf2k:tpmtif.bmp"))
ui["tpmphot"] == v_label:new(ui["imgtab"],,v_icon:new("bg_data_marks:\\dat\\tpm_photocell.bmp"))
ui["tpm"] == v_label:new(ui["imgtab"],,v_icon:new("bg_data_marks:\\dat\\tpm_logo.bmp"))
ui["inkphoto"]:aligntop(ui["tpm"])
ui["position"] == GMF2K_Position:new(ui["postab"])
ui["imgtab"].width = ui["tabgrp"].innerwidth
V_UIObj:PutAside(lab,ui["imagename"],ui["imageselector"])
ui["imagename"].right = ui["imagename"].right + ui["imgtab"].innerwidth - ui["imageselector"].right
V_UIObj:PutAside(ui["imagename"],ui["imageselector"])
ui["imageselector"]:Alignright(ui["tpm"])
ui["tpm"]:AlignRight(ui["tpmphot"])
ui["imagename"]:Alignleft(ui["inkphoto"])
ui["imagename"]:Alignleft(ui["inkphototxt1"])
ui["imagename"]:Alignleft(ui["inkphototxt2"])
ui["rerun"] == V_ToggleButton:new(ui["imgtab"],,"Rerun SmartMarks")
ui["rerun"].value = 0
ui["rerun"]:Hide()
;;;
; ui["repvcnt_lab"] == V_Label:new(ui["reptab"],,BRIX_Icon:new("step_vcount"))
; ui["repvcnt_lab"].alignment = "right"
; ui["repvcnt"] == v_numericedit:new(ui["reptab"])
; ui["repvcnt"].value = 1
; ui["repvcnt"].width = width
; ui["rephcnt_lab"] == V_Label:new(ui["reptab"],,BRIX_Icon:new("step_hcount"))
; ui["rephcnt_lab"].alignment = "right"
; ui["rephcnt"] == v_numericedit:new(ui["reptab"])
; ui["rephcnt"].value = 1
; ui["rephcnt"].width = width
; ui["repvstep_lab"] == V_Label:new(ui["reptab"],,BRIX_Icon:new("step_vstep"))
; ui["repvstep_lab"].alignment = "right"
; ui["repvstep"] == BRIX_EvalField:new(ui["reptab"])
; ui["repvstep"].value = 0
; ui["repvstep"].width = width
; ui["rephstep_lab"] == V_Label:new(ui["reptab"],,BRIX_Icon:new("step_hstep"))
; ui["rephstep_lab"].alignment = "right"
; ui["rephstep"] == BRIX_EvalField:new(ui["reptab"])
; ui["rephstep"].value = 0
; ui["rephstep"].width = width
; V_UIObj:SameWidth(ui["repvcnt_lab"],ui["rephcnt_lab"],ui["repvstep_lab"],ui["rephstep_lab"])
; v_uiobj:Putaside(ui["repvcnt_lab"],ui["repvcnt"],ui["rephcnt_lab"],ui["rephcnt"])
; ui["repvcnt_lab"]:AlignTop(ui["repvcnt"],ui["rephcnt_lab"],ui["rephcnt"])
; ui["repvcnt_lab"]:putunder(ui["repvstep_lab"])
; v_uiobj:Putaside(ui["repvstep_lab"],ui["repvstep"],ui["rephstep_lab"],ui["rephstep"])
; ui["repvstep_lab"]:AlignTop(ui["repvstep"],ui["rephstep_lab"],ui["rephstep"])
super:build()
ui["rerun"]:Hide()
end
procedure photocelldialog:CheckInkGroups()
; if imagename is empty - pfs_findfile crashes
if trim(ui["imagename"].text) = "" then return
local oldbottom = ui["tabgrp"].bottom
ty fmtstr("checkinkgroups %",ui["imagename"].text)
if (posstr("/>",ui["imagename"].text,0) <> -1)
# contains smartname
ui["rerun"]:hide()
elsif photocell:ImageIsCT(ui["imagename"].text)
local ctdef == BRIX_CTDef:new(ui["imagename"].text,,)
if isnil(ctdef) or isnil(ctdef:inktable())
ui["rerun"]:Hide()
super:geometry()
else
ui["rerun"]:Hide()
fi
else
local nam = dtl$globl["m2k_smartfield"]:resolve(ui["imagename"].text)
if isnil(pfs_findfile(nam)) then return
local def == BRIX_Definition:new("",nam)
#ty fmtstr("definition % (%)",def,isnil(Def))
if isnil(def) or sizeof(def:fileinktable())<=1
ui["rerun"]:Hide()
else
ui["rerun"]:show()
fi
fi
self.height = self.height - oldbottom + ui["tabgrp"].bottom
super:geometry()
end
procedure photocelldialog:hide()
if not(self.visible) then return
if isnil(ui["imagename"])
; could be that dialog was not yet built
else
ui["imagename"]:close()
fi
super:hide()
end
procedure photocelldialog:params()
local pardict == T_Dict:new()
pardict["imagename"]=ui["imagename"].text
pardict["inkphototxt2"]=ui["inkphototxt2"].text
pardict == ui["position"]:params(pardict)
pardict["rerun"] = ui["rerun"].value
; make sure kernelversion is at least 2
if isnil(pardict["kernelversion"]) or pardict["kernelversion"] <2
pardict["kernelversion"] = 2
fi
;pardict["repvcnt"] = ui["repvcnt"].value
;pardict["rephcnt"] = ui["rephcnt"].value
;pardict["repvstep"] = ui["repvstep"].value
;pardict["rephstep"] = ui["rephstep"].value
return pardict
end
; msg overruled from m2k_controller class (to allow to regenerate offsetfield)
procedure photocelldialog:ParseMarkParams(params,obj)
return GMF2K_Position:ParseMarkParams(params,obj.contents)
end
procedure photocelldialog:setparams(markparams)
ui["position"]:setparams(markparams)
ui["imagename"].Text = Markparams["imagename"]
ui["inkphototxt2"].Text = Markparams["inkphototxt2"]
self:CheckInkGroups()
if not(isnil(markparams["rerun"])) then ui["rerun"].value = markparams["rerun"]
; if not(isnil(markparams["repvcnt"]))
; ui["repvcnt"].value = markparams["repvcnt"]
; fi
; if not(isnil(markparams["rephcnt"]))
; ui["rephcnt"].value = markparams["rephcnt"]
; fi
; if not(isnil(markparams["repvstep"]))
; ui["repvstep"].value = markparams["repvstep"]
; fi
; if not(isnil(markparams["rephstep"]))
; ui["rephstep"].value = markparams["rephstep"]
; fi
end
procedure photocelldialog:ForceReference()
local markset==M2K_IDo:GetMarkSet(object)
self:scanforreferences(markset.markparams["imagename"],1)
end
procedure photocelldialog:ReleaseReference()
local markset==M2K_IDo:GetMarkSet(object)
self:scanforreferences(markset.markparams["imagename"],0)
end
procedure photocelldialog:scanforreferences(imagename,val)
if posstr("/>",imagename,0) <> -1 then return
if photocell:ImageIsCT(pfs_findfile(imagename))
local def == BRIX_CTDef:new(imagename,"")
else
local def == BRIX_Definition:new("",imagename)
fi
if isnil(def)
if gmf_debug then ty fmtstr("Can't find definition %",imagename)
return
fi
if val
if gmf_Debug then ty fmtstr("add annotation to %",imagename)
def:AddAnnotation(M2K_IDo:GetAnnotationGen(),"Mark2KDef",0,,0)
else
if gmf_Debug then ty fmtstr("remove annotation from %",imagename)
def:RemoveAnnotation(M2K_IDo:GetAnnotationGen(),"Mark2KDef")
fi
end
procedure photocell::init()
super:init()
self:Autoregister()
end
procedure photocell::Required(featdict)
if isnil(featdict["BRIX"])
return %nil
else
featdict["BRIX"]=1
fi
if isnil(featdict["STEP"])
else
featdict["STEP"]=0
fi
return featdict
end
procedure photocell::ImageIsCT(imagename)
if posstr("/>",imagename) <> -1 then return 0
local is_ct=0
local tp = lowcase(fparse(imagename,"","type"))
if tp = ".ct"
is_ct = 1
elsif tp = ".tif"
local outname == TIF_outname(imagename, "")
if not isnil(outname)
tp == lowcase(fparse(outname,,"/typ"))
if tp = ".ct" then is_ct = 1
fi
fi
#ty fmtstr("image is ct % -> %",imagename,is_ct)
return is_ct
end
procedure photocell::ImageIsMultiColor(imagename)
if photocell:ImageIsCT(imagename)
local ctdef == BRIX_CTDef:new(imagename,,)
if isnil(ctdef) or isnil(ctdef:inktable())
return 0
else
return 1
fi
else
if isnil(pfs_findfile(imagename)) then return 0
local def == BRIX_Definition:new("",imagename)
if isnil(def) or sizeof(def:fileinktable())<=1
return 0
else
return 1
fi
fi
end
procedure photocell::Run(paramdict)
msg_message("version photocell - 14 apr 2015")
ty fmtstr("in photocell : %",paramdict["imagename"])
local cmb == photocell:DoRun(paramdict)
if isnil(cmb)
M2K_IDo:SetErrorLevel()
else
; M2K_IDo:AddObject(cmb)
local max==cmb:getbox
if not(isnil(max))
local maxx=max[3]-max[1]
local hei=max[2]-max[0]
local cmdtot==brix_combiobject:new()
cmdtot:addfirst(cmb)
; if not(isnil(paramdict["repvstep"]))
; local vstep=paramdict["repvstep"]
; local hstep=paramdict["rephstep"]
; for i=1 to paramdict["repvcnt"]
; for j=1 to paramdict["rephcnt"]
; local cmb1==cmb:copy
; ; ty fmtstr("i:% j:%",i,j)
; local t==brix_trafo:new(hstep*(j-1),vstep*(i-1))
; if i<>1 or j<>1
; cmb1:applytrafo(t)
; cmdtot:addfirst(cmb1)
; fi
; od
; od
; fi
;cmdtot:ApplyTrafo(Brix_Trafo:Rotate(paramdict["rotation"]))
local t==gmf2k_position:create_trafo(cmdtot,paramdict)
if not(isnil(t))
cmdtot:applytrafo(t)
fi
M2K_IDo:AddObject(cmdtot)
fi
fi
end
procedure photocell::DoRun(paramdict)
;ty fmtstr("in photocell : %",paramdict["imagename"])
if trim(paramdict["imagename"]) = ""
ty "No image name specified"
return %nil
fi
local imagename = paramdict["imagename"]
imagename = repl(">","/>",imagename,0)
imagename = repl("//>","/>",imagename,0)
local imagename_tn == M2K_SmartField:Resolve(imagename)
if imagename_tn <> paramdict["imagename"] then paramdict["rerun"] = 0
; local csv = paramdict["inkphototxt2"]
; csv = repl(">","/>",csv,0)
; csv = repl("//>","/>",csv,0)
; local csv_tn == M2K_SmartField:Resolve(csv)
; if imagename_tn <> paramdict["imagename"] then paramdict["rerun"] = 0
;msg_message(fmtstr("csv:%.csv",csv_tn))
local orig_numinks == TheInks:size()
local cmb == BRIX_CombiObject:new()
ty fmtstr("imagename_tn:%--------------",imagename_tn)
if Self:ImageIsCT(imagename_tn)
ty "in ct"
local ctdef == BRIX_CTDef:new(imagename_tn,,)
if isnil(ctdef)
local imagename = FFspec_Find(fparse(imagename_tn,"","name,type"))
if imagename = ""
; try jobdir
imagename = fparse(brix.jobdir,imagename_tn)
fi
local ctdef == BRIX_CTDef:new(imagename,,)
if isnil(ctdef)
MSG_Warning(loc_translate("photocell: CT file %s not found",imagename_tn))
M2K_IDo:SetErrorLevel(2)
return %nil
else
imagename_tn= ctdef.filename
fi
fi
if gmf_debug then ctdef:print
if isnil(ctdef:inktable())
; monochrome CT
local box = ctdef:getbox()
if isnil(box)
MSG_Warning(Loc_translate("Image mark %s cannot get dimensions",imagename_tn))
M2K_IDo:SetErrorLevel(2)
return %nil
fi
; local attrs == GMF2K_InkGroup:AllAttributes(paramdict)
local attrs == self:getinkphoto(paramdict)
local attrd=dict(2)
attrd["PMODE"]=%nil
attrd["PAINT"]==Brix_solid:new(attrs[0],100)
local i = 0
; for i=0 to attrs.Used-1
local t==GMF2K_Inkgroup:OffsetTrafo(box,paramdict,i)
local ct==BRIX_ct:new(ctdef,t)
;ct:SetFillAttribute(attrs[i])
ct:SetFillAttribute(attrd)
cmb:addfirst(ct)
; od
else
msg_warning("Colored ct not allowed")
M2K_IDo:SetErrorLevel(2)
fi
else
ty "in de not ct part"
ty fmtstr("imagename_tn:%",imagename_tn)
local def
local pagnr = 0
# reportmaker task creates page parameter to make sure right page from input file is selected
if not(isnil(paramdict["page"]))
pagnr = paramdict["page"]
fi
if (paramdict["imagename"] = "<taskinputfile>" or paramdict["imagename"] = "[taskinputfile]")
paramdict["imagename"]="<taskinputfile/>"
fi
if (imagename_tn = "") and (paramdict["imagename"] = "<taskinputfile/>" or paramdict["imagename"] = "<taskinputfile>" or paramdict["imagename"] = "[taskinputfile]")
; create dummy 'for example' job
if gmf_debug then ty fmtstr("file % not found - taking dummy ",imagename_tn)
def == self:CreateTemplateInputFile()
paramdict["allink_step"] = 0
else
def == BRIX_Definition:new(fparse(imagename_tn,"","name"),imagename_tn,"",pagnr)
if isnil(def)
local imagename = FFspec_Find(fparse(imagename_tn,"","name,type"))
if imagename = ""
; try jobdir
imagename = fparse(brix.jobdir,imagename_tn)
fi
local def == BRIX_Definition:new(fparse(imagename_tn,"","name"),imagename)
if isnil(def)
MSG_Warning(fmtstr("photocell: Could not load definition %",imagename_tn))
M2K_IDo:SetErrorLevel(2)
return %nil
else
imagename_tn= def.filename
fi
fi
fi
; fbr 19 Sep: added annotation again for VEVE/Plato
def:AddAnnotation("Mark2k","origname",imagename_tn)
def:AddAnnotation("Mark_hint","BRIX.IgnoreInks",0,,0)
local fileinklist == def:fileinktable()
if sizeof(fileinklist)<1
; no inks in definition - ie lp or lc
local box = def:getbox()
if isnil(box)
MSG_Warning(Loc_Translate("Image mark %s cannot get dimensions",imagename_tn))
M2K_IDo:SetErrorLevel(2)
return %nil
fi
; local attrs == GMF2K_InkGroup:AllAttributes(paramdict)
;attrs:show
;typa attrs[0]
local attrs == self:getinkphoto(paramdict)
local attrd=dict(2)
attrd["PMODE"]=%nil
attrd["PAINT"]==Brix_solid:new(attrs[0],100)
local i = 0
; for i=0 to attrs.Used-1
local t==GMF2K_Inkgroup:OffsetTrafo(box,paramdict,i)
local ref==BRIX_reference:new(def,t)
;ref:SetFillAttribute(attrs[i])
ref:SetFillAttribute(attrd)
cmb:addfirst(ref)
; od
elsif sizeof(fileinklist)=1
;paramdict:show
; local inks == GMF2K_InkGroup:AllInks(paramdict)
local inks == self:getinkphoto(paramdict)
;inks:show
if not(isnil(inks))
local inksubset == gmf:AllInks(paramdict["ignore_technical_inks"],paramdict["merge_similar_inks"],paramdict["ignore_varnish_inks"])
local oldsubset == gmf:setinksubset(inksubset)
local i = 0
local box = def:getbox()
local i=0
local j = gmf:retrieveinkidx(inks[i])
def:setinktable(list(inks[i]))
local t==GMF2K_Inkgroup:OffsetTrafo(box,paramdict,i)
local ref==BRIX_Reference:new(def,t)
local cno==BRIX_ContourObject:MakeBox(box[0], box[1], box[2], box[3])
cno:ApplyTrafo(t)
local refcmb == BRIX_CombiObject:new()
refcmb:addfirst(ref)
ref:makeactualobject()
self:ReRunMarks(refcmb,j,cno:getbox(),inks)
cmb:AddFirst(cno)
cmb:AddLast(refcmb)
gmf:setinksubset(oldsubset)
else
msg_warning("no valid ink for photocell")
M2K_IDo:SetErrorLevel(2)
fi
else
msg_warning("Not possible to use multi colored jobs")
M2K_IDo:SetErrorLevel(2)
fi
fi
cmb:ApplyTrafo(BRIX_Trafo:Rotate(paramdict["rotation"]))
local bkgdcno == GMF2K_Background:Object(paramdict,cmb:getbox())
if not(isnil(bkgdcno))
cmb:AddLast(bkgdcno)
fi
local t==GMF2K_Position:create_trafo(cmb,paramdict)
if not(isnil(t))
cmb:ApplyTrafo(t)
else
cmb == BRIX_CombiObject:new()
fi
return cmb
end
procedure photocell::GetDisableTrafo()
return list(0,2,2)
end
procedure photocell::getinkphoto(paramdict)
local jobpar_photocell_ink=""
local jobpar_photocell_ink_tn=""
;local infile = fopenr(ffspec("bg_dtl_gmf2k:pms_colors.csv"))
;ty paramdict["inkphototxt2"]
local jobpar_photocell_ink_jdf == "<pp.ed.photocell_ink/>"
jobpar_photocell_ink_jdf = repl(">","/>",jobpar_photocell_ink_jdf,0)
jobpar_photocell_ink_jdf = repl("//>","/>",jobpar_photocell_ink_jdf,0)
local jobpar_photocell_ink_jdf_tn == M2K_SmartField:Resolve(jobpar_photocell_ink_jdf)
ty fmtstr("product ink :%",jobpar_photocell_ink_jdf_tn)
if jobpar_photocell_ink_jdf_tn=jobpar_photocell_ink_jdf or collapse(jobpar_photocell_ink_jdf_tn)=""
local jobpar_photocell_ink == "<jp.jdfsmartname.photocell_ink/>"
jobpar_photocell_ink = repl(">","/>",jobpar_photocell_ink,0)
jobpar_photocell_ink = repl("//>","/>",jobpar_photocell_ink,0)
local jobpar_photocell_ink_tn == M2K_SmartField:Resolve(jobpar_photocell_ink)
ty fmtstr("jdfink :%",jobpar_photocell_ink_tn)
if jobpar_photocell_ink_tn=jobpar_photocell_ink or collapse(jobpar_photocell_ink_tn)=""
local jobpar_photocell_ink == "<jp.photocell_ink/>"
jobpar_photocell_ink = repl(">","/>",jobpar_photocell_ink,0)
jobpar_photocell_ink = repl("//>","/>",jobpar_photocell_ink,0)
local jobpar_photocell_ink_tn1 == M2K_SmartField:Resolve(jobpar_photocell_ink)
ty fmtstr("job ink :%",jobpar_photocell_ink_tn1)
;ty fmtstr("tn:% --- zonder : %",jobpar_photocell_ink_tn,jobpar_photocell_ink)
if jobpar_photocell_ink_tn1=jobpar_photocell_ink or collapse(jobpar_photocell_ink_tn1)=""
ty "ink from csv"
local csv = paramdict["inkphototxt2"]
csv = repl(">","/>",csv,0)
csv = repl("//>","/>",csv,0)
local csv_tn == M2K_SmartField:Resolve(csv)
; local infile = fopenr("bg_data_marks:\\dat\\pms_colors.csv")
local infile = fopenr(ffspec("bg_data_marks:\\dat\\"+csv_tn))
; msg_message(fmtstr("infile : %",infile))
msg_message(fmtstr("bg_data_marks:\\dat\\% used",csv_tn))
local inkd=t_dict:new()
if not isnil(infile)
local i=1
do
local line=fgetstr(infile)
exif isnil(line)
exif %eof
;inkd[upcase(collapse(line))]=i
inkd[upcase(compress(line))]=i
i=i+1
od
fclose(infile)
;inkd:show
local num=1000000
local photoink
local ink==theinks:allcomps
;msg_message(fmtstr("inksize : %",theinks.size))
for j=1 to theinks.size
local inkn == ink.next
; ty fmtstr("inkn softmaskink : %",inkn:issoftmaskink())
if not(inkn:issoftmaskink())
local numinlijst = inkd[upcase(inkn.shortname)]
; ty fmtstr("numinlijst : %",numinlijst)
if not isnil(numinlijst)
; ty fmtstr("inkd[%] : %, num :%",upcase(inkn.shortname),inkd[upcase(inkn.shortname)],num)
if inkd[upcase(inkn.shortname)]<num
; ty inkn.shortname
; ty num
num = inkd[upcase(inkn.shortname)]
; ty fmtstr("newnum : %",num)
photoink == inkn
fi
fi
fi
od
ty photoink
ty fmtstr("ink from %",csv_tn)
else
msg_warning(fmtstr("bg_data_marks:\\dat\\% not found",csv_tn))
M2K_IDo:SetErrorLevel(2)
fi
else
;jobparameter photocell_ink exists
; ty fmtstr("product parameter : photocell_ink exists = %",jobpar_photocell_ink_tn)
; msg_message(fmtstr("product parameter : photocell_ink exists = %",jobpar_photocell_ink_tn1))
local ink==theinks:allcomps
for j=1 to theinks.size
local inkn == ink.next
if not isnil(inkn)
if upcase(inkn.shortname) = upcase(jobpar_photocell_ink_tn1)
; ty fmtstr("inkn : %, tn:%",inkn.shortname,jobpar_photocell_ink_tn)
photoink == inkn
fi
fi
od
fi
else
; jdf jobparameter jdfsmartname.photocell_ink exists
; ty fmtstr("jobpar : photocell_ink exists = %",jobpar_photocell_ink_tn)
;msg_message(fmtstr("product parameter : jdfsmartnamephotocell_ink exists = %",jobpar_photocell_ink_tn))
local ink==theinks:allcomps
for j=1 to theinks.size
local inkn == ink.next
if not isnil(inkn)
if upcase(inkn.shortname) = upcase(jobpar_photocell_ink_tn)
; ty fmtstr("inkn : %, tn:%",inkn.shortname,jobpar_photocell_ink_tn)
photoink == inkn
fi
fi
od
fi
else
; jdf jobparameter jdfsmartname.photocell_ink exists
; ty fmtstr("jobpar : photocell_ink exists = %",jobpar_photocell_ink_tn)
; msg_message(fmtstr("product parameter : jdfsmartnamephotocell_ink exists = %",jobpar_photocell_ink_jdf_tn1))
local ink==theinks:allcomps
for j=1 to theinks.size
local inkn == ink.next
if not isnil(inkn)
if upcase(inkn.shortname) = upcase(jobpar_photocell_ink_jdf_tn)
; ty fmtstr("inkn : %, tn:%",inkn.shortname,jobpar_photocell_ink_jdf_tn)
photoink == inkn
fi
fi
od
fi
local t=t_array:new()
t[0]=photoink
;return photoink
if isnil(photoink)
return photoink
else
return t
fi
end
procedure photocell::CreateTemplateInputFile()
local ctxo == BRIX_ComposedTextObject:new(0,0,0)
ctxo:setStreamClass(GMF2K_TxtStream)
ctxo:SetText(fmtstr("<ff \"[AT1METR]Helvetica\"><sz 24pt><qc><vqc>%",LOC_Translate("taskinputfile")))
ctxo:SetFrame(200,200)
ctxo:ReCompose()
local cmbo == BRIX_CombiObject:new()
cmbo:AddFirst(ctxo)
ctxo:Contourize()
local box = cmbo:getbox()
local size = 200
local cno == BRIX_ContourObject:Makebox(0,0,size,size)
local d = 0.2
local d2 = d*sqrt(2)/2
cno:moveto(d,d); cno:lineto(d,size-d); cno:lineto(size-d,size-d); cno:lineto(size-d,d); cno:lineto(d,d); cno.closed=1
; cross
cno:moveto(d,d); cno:lineto(d,d+d2); cno:lineto(box[1]-d2,box[1]); cno:lineto(box[1],box[1]); cno:lineto(box[1],box[1]-d2)
cno:lineto(d+d2,d); cno:lineto(d,d); cno.closed=1
cno:moveto(size-d,d); cno:lineto(size-d,d+d2); cno:lineto(size-(box[1]-d2),box[1]); cno:lineto(size-box[1],box[1]); cno:lineto(size-box[1],box[1]-d2)
cno:lineto(size-(d+d2),d); cno:lineto(size-d,d); cno.closed=1
cno:moveto(d,size-d); cno:lineto(d,size-(d+d2)); cno:lineto(size-box[3]-d2,box[3]); cno:lineto(size-box[3],box[3]); cno:lineto(size-box[3],box[3]+d2)
cno:lineto(d+d2,size-d); cno:lineto(d,size-d); cno.closed=1
cno:moveto(size-d,size-d); cno:lineto(size-d,size-(d+d2)); cno:lineto(box[3]+d2,box[3]); cno:lineto(box[3],box[3]); cno:lineto(box[3],box[3]+d2)
cno:lineto(size-(d+d2),size-d); cno:lineto(size-d,size-d); cno.closed=1
local it == cmbo:allcompsrec()
do
exif it.done
local cno2 == it.next
exif isnil(cno2)
if cno2:IsA("BRIX_ContourObject")
local cntit == cno2:allcomps()
do
exif isnil(cntit)
local cnt == cntit.next
exif isnil(cnt)
if cnt:IsA("BRIX_Contour")
cno:Add(cnt)
fi
od
fi
od
local def == brix_definition:new("template",cno)
return def
end
procedure photocell::RemoveDummyInk(object,dumink)
local it == object:allCompsRec()
do
local obj == it.next
exif isnil(obj)
if obj.classname = "brix_dynobj"
photocell:RemoveDummyInk(obj.contents,dumink)
;elsif obj.classname = "brix_reference"
; all references already made internal
elsif obj.classname = "brix_ct"
local def == obj.definition
local inklist==def:Inkmap()
local i
for i=0 to sizeof(inklist)-1
; add paints to palette - to avoid unregistered paints
if dumink.Name <> inklist[i].Name
local pai==ThePaints:add(BRIX_Solid:new(inklist[i]))
else
local pai == ThePaints:add(BRIX_Solid:new())
fi
obj:setPlaneMapPaint(i,pai)
od
else
local attrit == object:AllAttributes
do
local attr = attrit.next
exif isnil(attr)
if attr["TYPE"] = "Fill" or attr["TYPE"]="Stroke"
if attr["PAINT"]:IsASolid()
attr["PAINT"]:RemoveInk(dumink)
elsif attr["PAINT"]:IsAVignet()
local paiit == attr["PAINT"]:AllComps
do
local pai == paiit.next
exif isnil(pai)
pai:RemoveInk(dumink)
od
fi
fi
od
fi
od
end
procedure photocell::ExpandReferences(object,ninks)
local it == object:allCompsRec()
do
local obj == it.next
exif isnil(obj)
if obj.classname = "brix_dynobj"
photocell:ExpandReferences(obj.contents,ninks)
elsif obj.classname = "brix_reference"
local def == obj:definition()
if sizeof(def:fileinktable())>ninks
; contains inks that have to be eliminated, expand reference and start all over
obj:makeactualobject()
; would be faster if we could restart with just the contents of the reference but as makeactualobject does not return anything...
; reset the definition's ui["inktab"]le (needed as definition object will be added somewhere in the GRS)
local inklist == def:inktable
local inkiter == TheInks:AllComps()
local firstink = inkiter.next
for i=0 to sizeof(inklist)-1
local ink=inklist[i]
if ink:name() = "gmf2kdummy"
if gmf_debug then ty fmtstr("Ink % not in ddb - replaced",ink:name())
inklist[i] == firstink
fi
od
def:setinktable(inklist)
photocell:ExpandReferences(object,ninks)
exit
fi
fi
od
end
global textmark
global rectangle
# 3 Sep 2002 - added inkarr reflecting inkset used for photocell - allows to rerun text and rectangles taking this ink set.
# still part missing: exclusion of technical/varnish is not passed to assembly of registration colors for rect/text
procedure photocell::ReRunMarks(cmb,inkidx, box, inkarr = %nil)
; reruns textmarks and rectangles
local oldscope == dtl$globl["placeholdercontroller"]:SetScope(cmb)
local allit == cmb:AllAnnotatedComps()
# to cope with photocells that contain cascaded marks, maintain a list of the 'unknown named objects' - and postpone
# regeneration till depending named objects is known
local AtomList == T_DblLnk:new()
local UnKnownNamedObjects == T_Dict:new()
do
exif allit.done
local atom == allit.next
exif isnil(atom)
; atom:print()
local marktypes = list("textmark","rectangle","photocell","ellipse","imagemark","m2k_barcode")
for i=0 to sizeof(marktypes)-1
if M2k_IDo:HasMarkAnnotation(atom,marktypes[i])
ty marktypes[i]
; atom:SetDisableTrafo(0,0,0)
AtomList:AddAtHead(atom)
local name == atom:ObjectName()
if not(isnil(name)) then UnknownNamedObjects:Add(name,1)
exit
fi
od
od
do
exif AtomList.Used = 0
local i = 0
do
exif i >= AtomList.Used
atom == AtomList[i]
i = i + 1
local ann == M2K_IDo:GetMarkAnnotation(atom)
local neededNamedObject = gmf2k_position:GetPlaceholder(ann["VAL"])
if not(isnil(neededNamedObject)) and not(isnil(UnknownNamedObjects[neededNamedObject]))
continue
fi
AtomList:Rem(atom)
local thisNamedObject = atom:ObjectName()
if not(isnil(thisNamedObject))
if not(isnil(UnknownNamedObjects[thisNamedObject])) then UnknownNamedObjects[thisNamedObject] = %nil
fi
if M2K_IDo:HasMarkAnnotation(atom,"textmark")
#local ann == M2K_IDo:GetMarkAnnotation(atom,"textmark")
local script = fparse(ann["KEY"],gmf:dtlpath(),"name")
local markset == M2K_TMarkSet:new()
local paramdict=ann["VAL"]
;if inkidx>=0
paramdict["text"]=GMF2K_TxtStream:ReplaceInkIdx(paramdict["text"],inkidx, inkarr)
paramdict == GMF2K_InkCombo:ReplaceInkIdx(paramdict,inkidx, inkarr)
ann["VAL"] = paramdict
;fi
GMF2K_Position:setlocalborders(1,box)
if gmf_Debug then ty fmtstr("rerun text (%) box % % % %",inkidx,box[0],box[1],box[2],box[3])
local obj == textmark:DoRun(ann["VAL"])
GMF2K_Position:setlocalborders(0,%nil)
atom:AddAnnotation(ann["GEN"], ann["KEY"], ann["VAL"])
local cmb == BRIX_CombiObject:new()
if not(isnil(obj))
cmb:AddFirst(obj)
fi
atom:setcontents (cmb,1)
elsif M2K_IDo:HasMarkAnnotation(atom,"rectangle") or atom:HasAnnotation("Mark2K","ellipse") or atom:HasAnnotation("Mark2K","m2k_barcode")
#local ann == M2K_IDo:GetMarkAnnotation(atom,"rectangle")
GMF2K_Position:setlocalborders(1,box)
if gmf_Debug then ty fmtstr("rerun rectangle (%) box % % % %",inkidx,box[0],box[1],box[2],box[3])
ann["VAL"] == GMF2K_InkCombo:ReplaceInkIdx(ann["VAL"],inkidx, inkarr)
local obj == dtl$globl[ann["KEY"]]:DoRun(ann["VAL"])
GMF2K_Position:setlocalborders(0,%nil)
atom:AddAnnotation(ann["GEN"], ann["KEY"], ann["VAL"])
local cmb == BRIX_CombiObject:new()
if not(isnil(obj))
cmb:AddFirst(obj)
fi
atom:setcontents (cmb,1)
elsif M2K_IDo:HasMarkAnnotation(atom,"photocell")
#local ann == M2K_IDo:GetMarkAnnotation(atom,"photocell")
GMF2K_Position:setlocalborders(1,box)
ann["VAL"] == GMF2K_InkCombo:ReplaceInkIdx(ann["VAL"],inkidx, inkarr)
local obj == photocell:DoRun(ann["VAL"])
GMF2K_Position:setlocalborders(0,%nil)
atom:AddAnnotation(ann["GEN"], ann["KEY"], ann["VAL"])
local cmb == BRIX_CombiObject:new()
if not(isnil(obj))
cmb:AddFirst(obj)
fi
atom:setcontents (cmb,1)
local combi == atom.contents:FirstComponent()
local cno == cmb:FirstComponent()
do
exif not(cno:IsA("BRIX_ContourObject"))
local cnobox == cno:GetBox()
local realcombi == cno:Next
if gmf_debug then ty fmtstr("recursive rerun image (%) % % % %",inkidx, cnobox[0],cnobox[1],cnobox[2],cnobox[3])
self:ReRunMarks(realcombi,inkidx, cno:GetBox(), inkarr)
cno == realcombi:Next
exif isnil(cno)
od
fi
od
od
dtl$globl["placeholdercontroller"]:SetScope(oldscope)
end
procedure photocell::Serialize(indict)
local nam = indict["imagename"]
ty nam
if isstring(nam) and (nam <> "")
local resolved = m2k_smartfield:resolve(nam)
if resolved = nam
local idx == BRIXIO:XFileToID(indict["imagename"])
if gmf_debug then ty fmtstr("serialize % to %",indict["imagename"],idx)
if not(isnil(idx)) then indict["imagename"] = idx
fi
fi
; if nam <> ""
; local resolved = m2k_smartfield:resolve(nam)
; if resolved = nam
; local idx == BRIXIO:XFileToID(indict["imagename"])
; if gmf_debug then ty fmtstr("serialize % to %",indict["imagename"],idx)
; if idx>0 then indict["imagename"] = idx
; fi
; fi
local str= convert_obj_to_str(indict)
indict["imagename"]= nam
return str
end
procedure photocell::DeSerialize(instr)
local outdict == convert_str_to_obj(instr)
local id == outdict["imagename"]
local fspec
if not(isnil(id))
fspec = BRIXIO:IDToXFile(id)
else
fspec = id
fi
; if isnumber(id)
; fspec = BRIXIO:IDToXFile(id)
;
; else
; fspec = id
;
; fi
if gmf_Debug then ty fmtstr("deserialize % to %",id,fspec)
if not isnil(fspec) then outdict["imagename"] = fspec
return outdict
end
procedure photocell::toPDFDict(outdict)
local nam = outdict["imagename"]
if isstring(nam) and (nam <> "")
if not(ImageMark:ContainsSmartName(nam))
;!; if (posstr("file>",nam,0) <> -1) or (posstr("file/>",nam,0) <> -1) or (posstr("<",nam,0) = 0)
;!; else
local idx == BRIXIO:XFileToID(outdict["imagename"])
if gmf_debug then ty fmtstr("serialize pdfdict % to %",outdict["imagename"],idx)
; ty fmtstr("serialize pdfdict % to %",outdict["imagename"],idx)
if not(isnil(idx)) then outdict["imagename"] = idx
elsif nam = "<taskinputfile/>"
else
local resolvedname = M2K_SmartField:Resolve(nam)
local idx == BRIXIO:XFileToID(resolvedname)
; ty fmtstr("serialize pdfdict resolved % to %",outdict["imagename"],idx)
if not(isnil(idx)) then outdict["imagename_tn"] = idx
fi
fi
return outdict
end
procedure photocell::fromPDFDict(outdict)
local id == outdict["imagename"]
local fspec
if not(isnil(outdict["imagename_tn"]))
id = outdict["imagename_tn"]
fi
if not(isnil(id))
fspec = BRIXIO:IDToXFile(id)
else
fspec = id
fi
if gmf_Debug then ty fmtstr("deserialize pdfdict % to %",id,fspec)
if not isnil(fspec)
if not(isnil(outdict["imagename_tn"]))
outdict["imagename_tn"] = fspec
else
outdict["imagename"] = fspec
fi
fi
return outdict
end
procedure photocell::GetXMP(adict)
local nam = adict["imagename"]
if isstring(nam) and (nam <> "")
if not(ImageMark:ContainsSmartName(nam))
nam = makepfs(nam)
if gmf_Debug then ty fmtstr("adding external reference %",nam)
return dict("ExtRef", nam, "ExtRefType", "mark")
else
local resolvedname = M2K_SmartField:Resolve(nam)
if resolvedname = "" or resolvedname = nam
else
if gmf_Debug then ty fmtstr("adding resolved external reference %",nam)
return dict("ExtRef", resolvedname, "ExtRefType", "mark")
fi
fi
fi
return %nil
end