Beispiel #1
0
    def _draw_object(self, obj, trafo):
        if obj.childs:
            for child in obj.childs:
                self._draw_object(child, trafo)
        else:
            fill_anyway = False
            path = obj.cache_cpath

            if obj.is_text():
                path = libcairo.convert_bbox_to_cpath(obj.cache_bbox)
                fill_anyway = True
            if obj.is_curve() and len(obj.paths) > 100:
                path = libcairo.convert_bbox_to_cpath(obj.cache_bbox)
                fill_anyway = True
            if obj.is_pixmap():
                fill_anyway = True

            self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
            self.ctx.new_path()
            self.ctx.append_path(path)
            stroke_width = config.stroke_sensitive_size
            if not self.canvas.stroke_view and obj.style[0]:
                self.ctx.fill_preserve()
            if fill_anyway:
                self.ctx.fill_preserve()
            if obj.style[1]:
                stroke = obj.style[1]
                width = stroke[1] * trafo[0]
                stroke_width /= trafo[0]
                if width < stroke_width:
                    width = stroke_width
                self.ctx.set_line_width(width)
                self.ctx.stroke()
Beispiel #2
0
    def _draw_object(self, obj, trafo, fill_anyway=False):
        if obj.childs:
            for child in obj.childs:
                self._draw_object(child, trafo)
        else:
            path = obj.cache_cpath

            if obj.is_text():
                path = libcairo.convert_bbox_to_cpath(obj.cache_bbox)
                fill_anyway = True
            if obj.is_curve() and len(obj.paths) > 100:
                path = libcairo.convert_bbox_to_cpath(obj.cache_bbox)
                fill_anyway = True
            if obj.is_pixmap():
                fill_anyway = True

            self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
            self.ctx.new_path()
            self.ctx.append_path(path)
            stroke_width = config.stroke_sensitive_size
            if not self.canvas.stroke_view and obj.style[0]:
                self.ctx.fill_preserve()
            if fill_anyway:
                self.ctx.fill_preserve()
            if obj.style[1]:
                stroke = obj.style[1]
                width = stroke[1] * trafo[0]
                stroke_width /= trafo[0]
                if width < stroke_width: width = stroke_width
                self.ctx.set_line_width(width)
                self.ctx.stroke()
Beispiel #3
0
 def is_point_on_path(self, win_point, path):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     cpath = libgeom.create_cpath([path, ])
     self.ctx.new_path()
     self.ctx.append_path(cpath)
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)
Beispiel #4
0
 def is_point_on_path(self, win_point, path):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     cpath = libgeom.create_cpath([path])
     self.ctx.new_path()
     self.ctx.append_path(cpath)
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)
Beispiel #5
0
 def is_point_on_segment(self, win_point, start_point, end_point):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     if len(start_point) > 2: start_point = start_point[2]
     self.ctx.move_to(*start_point)
     if len(end_point) == 2:
         self.ctx.line_to(*end_point)
     else:
         p1, p2, p3 = end_point[:-1]
         self.ctx.curve_to(*(p1 + p2 + p3))
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)
Beispiel #6
0
 def is_point_on_segment(self, win_point, start_point, end_point):
     self.clear()
     trafo = self.get_context_trafo(win_point)
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
     stroke_width = config.stroke_sensitive_size
     stroke_width /= trafo[0]
     if len(start_point) > 2:
         start_point = start_point[2]
     self.ctx.move_to(*start_point)
     if len(end_point) == 2:
         self.ctx.line_to(*end_point)
     else:
         p1, p2, p3 = end_point[:-1]
         self.ctx.curve_to(*(p1 + p2 + p3))
     self.ctx.set_line_width(stroke_width)
     self.ctx.stroke()
     return not libcairo.check_surface_whiteness(self.surface)
Beispiel #7
0
	def set_trafo(self, point):
		trafo = [ZOOM, 0.0, 0.0, ZOOM, -point[0] * ZOOM, -point[1] * ZOOM]
		self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))
Beispiel #8
0
 def set_trafo(self, point):
     trafo = [ZOOM, 0.0, 0.0, ZOOM, -point[0] * ZOOM, -point[1] * ZOOM]
     self.ctx.set_matrix(libcairo.get_matrix_from_trafo(trafo))