CreateInterpressRope:
PUBLIC
PROC [action:
PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip:
BOOL ←
TRUE]
RETURNS [
ROPE] ~ {
ros: IO.STREAM ~ IO.ROS[];
outputMaster: ImagerInterpress.Ref ~ ImagerInterpress.CreateFromStream[ros, "Interpress/Xerox/3.0 "];
pageAction:
PROC [context: Imager.Context] ~ {
IF m # NIL THEN Imager.ConcatT[context, m];
IF clip THEN Imager.ClipRectangle[context, bounds];
action[context];
};
ImagerInterpress.DoPage[outputMaster, pageAction, 1.0];
ImagerInterpress.Finish[outputMaster];
RETURN [IO.RopeFromROS[ros]];
};
WriteArtwork:
PUBLIC
PROC [writer: TiogaAccess.Writer, action:
PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip:
BOOL
, fit:
BOOL] ~ {
interpress: ROPE ~ CreateInterpressRope[action, bounds, m, clip];
tc: TiogaAccess.TiogaChar ← [
charSet: 0,
char: '\n,
looks: ALL[FALSE],
format: NIL,
comment: TRUE,
endOfNode: FALSE,
deltaLevel: 0,
propList: NIL
];
PutRope:
PROC [rope:
ROPE] ~ {
action: Rope.ActionType ~ {tc.char ← c; TiogaAccess.Put[writer, tc]};
[] ← Rope.Map[base: rope, action: action];
};
PutLooksRope:
PROC [rope:
ROPE, look1, look2:
CHAR ← '\000] ~ {
save: TiogaAccess.Looks ~ tc.looks;
IF look1 # '\000 THEN tc.looks[look1] ← TRUE;
IF look2 # '\000 THEN tc.looks[look2] ← TRUE;
PutRope[rope];
tc.looks ← save;
};
PutRopeProp:
PROC [key:
ATOM, val:
ROPE] ~ {
tc.propList ← CONS[NEW[Atom.DottedPairNode ← [key: key, val: val]], tc.propList];
};
sepNeeded: BOOL ← FALSE;
Sp: PROC ~ {PutRope[" "]; sepNeeded ← FALSE};
Comma: PROC ~ {IF sepNeeded THEN PutRope[", "]; sepNeeded ← FALSE};
Putmm:
PROC [meters:
REAL] ~ {
PutLooksRope[Convert.RopeFromReal[meters*1000], 'f];
PutLooksRope["mm", 's, 'o];
sepNeeded ← TRUE;
};
PutKey:
PROC [rope:
ROPE] ~ {
Comma[];
PutLooksRope[rope, 'o];
PutLooksRope[": ", 'o];
sepNeeded ← TRUE;
};
PutKeyMeters:
PROC [name:
ROPE, meters, defaultMeters:
REAL] ~ {
IF meters#defaultMeters THEN {PutKey[name]; Putmm[meters]};
};
bb: Imager.Rectangle ← ImagerTransformation.TransformRectangle[m, bounds];
scale: REAL ~ 1000.0;
tc.endOfNode ← TRUE; PutRope["\n"]; tc.endOfNode ← FALSE;
PutLooksRope[" [Artwork node; type 'Artwork on' to command tool] ", 'n];
IF fit
AND bb.h > 0
AND bb.w > 0
THEN {
aspectRope: ROPE ~ Convert.RopeFromReal[bb.h/bb.w];
topSpaceRope: ROPE ~ Convert.RopeFromReal[topSpace];
topCalcRope: ROPE ~ Rope.Cat[aspectRope, " the lineLength .mul ", topSpaceRope, " .add "];
PutRopeProp[$Postfix, Rope.Cat[
topCalcRope, "topLeading ",
topCalcRope, "topIndent " ].Cat[
Convert.RopeFromReal[bottomSpace], " mm bottomLeading ",
"0.5 0.3 0.95 backgroundColor the topLeading 6 pt .sub backgroundAscent 3 pt backgroundDescent 4 pt outlineBoxThickness 1 pt outlineBoxBearoff"
]];
PutRopeProp[$Fit, "TRUE"];
}
ELSE {
PutRopeProp[$Postfix, Rope.Cat[
Convert.RopeFromReal[(bb.h+bb.y)*scale+topSpace], " mm topLeading ",
Convert.RopeFromReal[(bb.h+bb.y)*scale+topSpace], " mm topIndent " ].Cat[
Convert.RopeFromReal[(-bb.y)*scale+bottomSpace], " mm bottomLeading ",
"0.5 0.3 0.95 backgroundColor the topLeading 6 pt .sub backgroundAscent 3 pt backgroundDescent 4 pt outlineBoxThickness 1 pt outlineBoxBearoff"
]];
};
PutRopeProp[$Bounds, Rope.Cat[
Convert.RopeFromReal[bb.x*scale], " mm xmin ",
Convert.RopeFromReal[bb.y*scale], " mm ymin " ].Cat[
Convert.RopeFromReal[(bb.x+bb.w)*scale], " mm xmax ",
Convert.RopeFromReal[(bb.y+bb.h)*scale], " mm ymax "
]];
PutRopeProp[$Artwork, "Interpress"];
PutRopeProp[$Interpress, interpress];
tc.endOfNode ← TRUE;
tc.deltaLevel ← 1;
tc.char ← '\n;
tc.format ← $artworkFigure;
TiogaAccess.Put[writer, tc];
tc.format ← NIL;
tc ← vanillaTC;
PutLooksRope["", 't];
PutRope[" Insert caption here "];
PutLooksRope["", 't];
tc.endOfNode ← TRUE;
tc.char ← '\n;
tc.format ← $artworkCaption;
TiogaAccess.Put[writer, tc];
tc.format ← NIL;
};
PasteArtwork:
PUBLIC
PROC [action:
PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip:
BOOL, fit:
BOOL] ~ {
writer: TiogaAccess.Writer ← TiogaAccess.Create[];
locked:
PROC [root: TextNode.Ref, tSel:TEditDocument.Selection] ~ {
TEditInputOps.Break[];
TiogaAccess.WriteSelection[writer];
};
WriteArtwork[writer: writer, action: action, bounds: bounds, m: m, clip: clip, fit: fit];
TEditInputOps.CallWithLocks[locked];
};