def convert_stroke_to_curve(self): doc = self.app.current_doc selection = self.app.current_doc.selection doc.canvas.set_mode(modes.WAIT_MODE) try: objs = [] for obj in selection.objs: if obj.is_primitive() and not obj.is_pixmap() and obj.style[1] \ and obj.style[1][1]: pths = apply_trafo_to_paths(obj.get_initial_paths(), obj.trafo) style = doc.model.get_def_style() style[0] = [ sk2_const.FILL_SOLID, deepcopy(obj.style[1][2]) ] pths = stroke_to_curve(pths, obj.style[1]) objs.append(doc.api.create_curve(pths, style)) selection.set(objs) except: doc.canvas.set_mode() msg = _('Error occurred during this operation.') msg += '\n' + _( 'Perhaps this was due to the imperfection of the algorithm.') error_dialog(self.app.mw, self.app.appdata.app_name, msg) doc.canvas.set_mode()
def convert_stroke_to_curve(self): doc = self.app.current_doc selection = self.app.current_doc.selection doc.canvas.set_mode(modes.WAIT_MODE) try: objs = [] for obj in selection.objs: if obj.is_primitive and not obj.is_pixmap and obj.style[1] \ and obj.style[1][1]: pths = libgeom.apply_trafo_to_paths(obj.get_initial_paths(), obj.trafo) style = [ [sk2const.FILL_EVENODD, sk2const.FILL_SOLID, deepcopy(obj.style[1][2])], [], [], []] pths = libgeom.stroke_to_curve(pths, obj.style[1]) objs.append(doc.api.create_curve(pths, style)) if obj.cache_arrows: for pair in obj.cache_arrows: [objs.append(doc.api.create_curve( libcairo.get_path_from_cpath(item), style)) for item in pair if item] selection.set(objs) if len(objs) > 1: doc.api.group_selected() except Exception as e: LOG.error('Error in convert_stroke_to_curve(), %s', e) doc.canvas.set_mode() msg = _('Error occurred during this operation.') msg += '\n' + _( 'Perhaps this was due to the imperfection of the algorithm.') error_dialog(self.app.mw, self.app.appdata.app_name, msg) doc.canvas.set_mode()
def convert_stroke_to_curve(self): doc = self.app.current_doc selection = self.app.current_doc.selection doc.canvas.set_mode(modes.WAIT_MODE) try: objs = [] for obj in selection.objs: if obj.is_primitive() and not obj.is_pixmap() and obj.style[1] \ and obj.style[1][1]: pths = apply_trafo_to_paths(obj.get_initial_paths(), obj.trafo) style = doc.model.get_def_style() style[0] = [sk2_const.FILL_SOLID, deepcopy(obj.style[1][2])] pths = stroke_to_curve(pths, obj.style[1]) objs.append(doc.api.create_curve(pths, style)) selection.set(objs) except: doc.canvas.set_mode() msg = _('Error occurred during this operation.') msg += '\n' + _('Perhaps this was due to the imperfection of the algorithm.') error_dialog(self.app.mw, self.app.appdata.app_name, msg) doc.canvas.set_mode()