Пример #1
0
	def RedrawMethod(self, region=None):
		# draw the document

		if self.move_window_count >= 2:
			self.clear_window(update=0)
		self.move_window_count = 0

		region = self.do_clear(region)

		tkwin = self.tkwin
		if region:
			x, y, w, h = region.ClipBox()
			if x < 0:
				w = w - x; x = 0
			if y < 0:
				h = h - y; y = 0
			if w > tkwin.width:
				w = tkwin.width
			if h > tkwin.height:
				h = tkwin.height
		else:
			x = y = 0
			w = tkwin.width
			h = tkwin.height
		p1 = self.WinToDoc(x - 1, y - 1)
		p2 = self.WinToDoc(x + w + 1, y + h + 1)
		rect = Rect(p1, p2)

		self.renderer.draw(self.document, rect)

		return region
Пример #2
0
	def FitPageToWindow(self, save_viewport=1):
		self.begin_transaction()
		try:
			w, h = self.document.PageSize()
			self.zoom_fit_rect(Rect(0, 0, w, h),
								save_viewport=save_viewport)
		finally:
			self.end_transaction()
Пример #3
0
def coord_rect(points):
    p, t = points[0]
    x1 = x2 = p.x
    y1 = y2 = p.y
    for i in range(1, len(points)):
        p, t = points[i]
        x1 = min(x1, p.x)
        x2 = max(x2, p.x)
        y1 = min(y1, p.y)
        y2 = max(y2, p.y)
    return Rect(x1, y1, x2, y2)
Пример #4
0
 def update_rects(self):
     trafo = self.trafo
     start = trafo.offset()
     # On some systems, atan2 can raise a ValueError if both
     # parameters are 0. In that case, the actual value the of angle
     # is not important since in the computation of p below, the
     # coordinate depending on the angle will always be 0 because
     # both trafo coefficients are 0. So set the angle to 0 in case
     # of an exception.
     try:
         phi1 = atan2(trafo.m12, trafo.m11)
     except ValueError:
         phi1 = 0
     try:
         phi2 = atan2(trafo.m22, trafo.m21)
     except ValueError:
         phi2 = 0
     p = Point(trafo.m11 * cos(phi1) + trafo.m12 * sin(phi1),
               trafo.m21 * cos(phi2) + trafo.m22 * sin(phi2))
     self.coord_rect = r = Rect(start + p, start - p)
     if self.properties.HasLine():
         width = self.properties.line_width
         r = r.grown(width / 2 + 1)
         # add the bounding boxes of arrows
         if self.arc_type == ArcArc:
             pi2 = pi / 2
             arrow1 = self.properties.line_arrow1
             if arrow1 is not None:
                 pos = trafo(Polar(1, self.start_angle))
                 dir = trafo.DTransform(Polar(1, self.start_angle - pi2))
                 r = UnionRects(r, arrow1.BoundingRect(pos, dir, width))
             arrow2 = self.properties.line_arrow2
             if arrow2 is not None:
                 pos = trafo(Polar(1, self.end_angle))
                 dir = trafo.DTransform(Polar(1, self.end_angle + pi2))
                 r = UnionRects(r, arrow2.BoundingRect(pos, dir, width))
     self.bounding_rect = r
 def update_rects(self):
     width, height = self.data.Size()
     rect = self.trafo(Rect(0, 0, width, height))
     self.coord_rect = rect
     self.bounding_rect = rect.grown(2)
Пример #6
0
 def update_rectangle(self, same_center=1):
     if self:
         self.rect = TrafoRectangle(self.coord_rect, self.center)
     else:
         self.rect = TrafoRectangle(Rect(0, 0, 0, 0))
Пример #7
0
 def update_rectangle(self):
     if self:
         self.rect = SizeRectangle(self.coord_rect, self.anchor)
     else:
         self.rect = SizeRectangle(Rect(0, 0, 0, 0))
Пример #8
0
 def update_rects(self):
     self.coord_rect = Rect(self.start, self.end)
     self.bounding_rect = self.coord_rect