MCPcopy Create free account
hub / github.com/PageBot/PageBot / _drawElementsNeedingInfo

Method _drawElementsNeedingInfo

Lib/pagebot/elements/views/mapview.py:458–534  ·  view source on GitHub ↗
(self, e)

Source from the content-addressed store, hash-verified

456 self.drawElementOrigin(e, origin)
457
458 def _drawElementsNeedingInfo(self, e):
459 b = self.b
460 context = self.context
461 for e, origin in self.elementsNeedingInfo.values():
462 #p = pointOffset(e.origin, origin)
463 #p = e._applyScale(self, p)
464 #px, py, _ = e._applyAlignment(p) # Ignore z-axis for now.
465 px, py, _ = pointOffset(e.origin, origin)
466 if (self.showElementInfo or e.isPage) or e.showElementInfo:
467 # Draw box with element info.
468 bs = context.newString(e.getElementInfoString(), style=dict(font=self.css('viewInfoFont'),
469 fontSize=self.css('viewInfoFontSize'), leading=self.css('viewInfoLeading'), textFill=color(0.1)))
470 tw, th = bs.textSize
471 # Padding in box and shadow offset.
472 Pd = 4
473 # Make info box outdent the element. Keeping shadow on the
474 # element top left corner..
475 tpx = px - Pd/2
476 tpy = py + e.h - th - Pd
477
478 # Tiny shadow
479 context.fill(color(0.3, 0.3, 0.3, 0.5))
480 context.stroke(noColor)
481 context.rect(tpx+Pd/2, tpy, tw+2*Pd, th+1.5*Pd)
482 # Frame
483 context.fill(self.css('viewInfoFill'))
484 context.stroke(color(0.3), w=0.25)
485 context.rect(tpx, tpy, tw+2.5*Pd, th+1.5*Pd)
486 context.text(bs, (tpx+Pd, tpy+th))
487
488 if (self.showDimensions or e.isPage) or e.showDimensions:
489 # TODO: Make separate arrow functio and better positions
490 # Draw width and height measures
491 context.fill(noColor)
492 context.stroke(blackColor, w=pt(0.25))
493 S = self.css('viewInfoOriginMarkerSize', pt(5))
494 x1, y1, x2, y2 = px + e.left, py + e.bottom, e.right, e.top
495
496 context.circle(x1, y1, 20)
497 context.circle(x1, y2, 20)
498 context.circle(x2, y1, 20)
499 context.circle(x2, y2, 20)
500
501 # Horizontal measure.
502 context.line((x1, y1 - 0.5*S), (x1, y1 - 3.5*S))
503 context.line((x2, y1 - 0.5*S), (x2, y1 - 3.5*S))
504 context.line((x1, y1 - 2*S), (x2, y1 - 2*S))
505 # Arrow heads.
506 context.line((x1, y1 - 2*S), (x1+S, y1 - 1.5*S))
507 context.line((x1, y1 - 2*S), (x1+S, y1 - 2.5*S))
508 context.line((x2, y1 - 2*S), (x2-S, y1 - 1.5*S))
509 context.line((x2, y1 - 2*S), (x2-S, y1 - 2.5*S))
510
511 bs = context.newString(asFormatted(x2 - x1),
512 style=dict(font=self.css('viewInfoFont'),
513 fontSize=self.css('viewInfoFontSize'),
514 leading=self.css('viewInfoLeading'),
515 textFill=color(0.1)))

Callers 1

buildMethod · 0.95

Calls 13

pointOffsetFunction · 0.90
colorFunction · 0.90
ptFunction · 0.90
asFormattedFunction · 0.85
newStringMethod · 0.80
_restoreScaleMethod · 0.80
cssMethod · 0.45
fillMethod · 0.45
strokeMethod · 0.45
rectMethod · 0.45
textMethod · 0.45
circleMethod · 0.45

Tested by

no test coverage detected