def generateSvgFileForOperator(svgPath, op, detail): global slot_registry global op_registry slot_registry = {} op_registry = {} svgOp = SvgOperator(op, max_child_depth=detail) canvas = svg.SvgCanvas("") block = partial(svg.tagblock, canvas) with block( svg.svg, x=0, y=0, width=7000, height=2000 ): canvas += svg.inkscapeDefinitions() svgOp.drawAt(canvas, (10, 10) ) svgOp.drawConnections(canvas) with file(str(svgPath), 'w') as f: f.write( canvas.getvalue() )
def generateSvgFileForOperator(svgPath, op, detail): global slot_registry global op_registry slot_registry = {} op_registry = {} svgOp = SvgOperator(op, max_child_depth=detail) canvas = svg.SvgCanvas("") block = partial(svg.tagblock, canvas) with block(svg.svg, x=0, y=0, width=7000, height=2000): canvas += svg.inkscapeDefinitions() svgOp.drawAt(canvas, (10, 10)) svgOp.drawConnections(canvas) with file(str(svgPath), 'w') as f: f.write(canvas.getvalue())
# pass # Nothing to do here: our internal operators handle dirty propagation on their own # # opMultiThreshold = OpMultiThreshold(graph=graph) # opMultiThreshold.ThresholdLevel.setValue(3) # opMultiThreshold.Inputs.resize(3) # for slot in opMultiThreshold.inputs.values(): # slot.setValue(1) # svgOp = SvgOperator(opMultiThreshold, max_child_depth=1) opMultiThreshold = OperatorWrapper( OpThreshold, graph=graph, promotedSlotNames=['Input'] ) opMultiThreshold.Input.resize(2) svgOp = SvgOperator(opMultiThreshold, max_child_depth=1) block = partial(svg.tagblock, canvas) with block( svg.svg, x=0, y=0, width=1000, height=1000 ): canvas += svg.inkscapeDefinitions() # svgOp1.drawAt(canvas, (10, 10) ) svgOp.drawAt(canvas, (10, 10) ) svgOp.drawConnections(canvas) # slot = SvgMultiSlot(3) # # slot.resize(3) # for i in range(3): # slot[i].resize(5) # for j in range(5): # slot[i][j].resize(j+1) # slot.drawAt(canvas, (0,0) ) #print canvas.getvalue() f = file("/Users/bergs/Documents/svgfiles/canvas.svg", 'w') f.write( canvas.getvalue() )
# opMultiThreshold = OpMultiThreshold(graph=graph) # opMultiThreshold.ThresholdLevel.setValue(3) # opMultiThreshold.Inputs.resize(3) # for slot in opMultiThreshold.inputs.values(): # slot.setValue(1) # svgOp = SvgOperator(opMultiThreshold, max_child_depth=1) opMultiThreshold = OperatorWrapper(OpThreshold, graph=graph, promotedSlotNames=['Input']) opMultiThreshold.Input.resize(2) svgOp = SvgOperator(opMultiThreshold, max_child_depth=1) block = partial(svg.tagblock, canvas) with block(svg.svg, x=0, y=0, width=1000, height=1000): canvas += svg.inkscapeDefinitions() # svgOp1.drawAt(canvas, (10, 10) ) svgOp.drawAt(canvas, (10, 10)) svgOp.drawConnections(canvas) # slot = SvgMultiSlot(3) # # slot.resize(3) # for i in range(3): # slot[i].resize(5) # for j in range(5): # slot[i][j].resize(j+1) # slot.drawAt(canvas, (0,0) ) #print canvas.getvalue() f = file("/Users/bergs/Documents/svgfiles/canvas.svg", 'w') f.write(canvas.getvalue())