def show(node, err, script=False): if node.bl_idname == "SvRxVirtualNode": return # for now ng_name = node.id_data.name bgl_callback.callback_disable("error:" + ng_name) text = bpy.data.texts.get(ng_name + "_Error") if not text: text = bpy.data.texts.new(ng_name + "_Error") text.clear() msg = traceback.format_exc() print(msg, file=sys.stderr) text.from_string(msg) frames = traceback.extract_tb(err.__traceback__) if isinstance(err, SyntaxError): lines = ["SyntaxError"] lines.append("@ -> {}".format(err.text)) lines.append("{}:{}".format(err.filename, err.lineno)) else: lines = [str(type(err).__name__) + " " + str(err)] for info in reversed(frames): print(info) file = info[0].lower() if not script: loc = file.find("svrx") if loc == -1: loc = file.find("bpy.data") else: loc = file.find("bpy.data") print(loc, file, *info) if loc > -1: lines.append("@ -> {}".format(info[3])) lines.append("{}:{} in {}".format(file[loc:], *info[1:3])) break x = node.location.x y = node.location.y max_len = max(map(len, lines)) draw_data = { 'tree_name': ng_name, 'custom_function': draw_text, 'loc': (x, y), 'args': (lines, (node.width, node.height), max_len) } bgl_callback.callback_enable("error:" + node.id_data.name, draw_data)
def stop(self): bgl_callback.callback_disable(self.n_id) if self.activate: dt = self.node.inputs[0].data_tree lines = [ "total depth: {} object count: {}".format( dt.level, dt.count()), "" ] structure = parse_tree(dt, self.shape) lines.extend(pprint.pformat(structure).splitlines()) draw_data = { 'tree_name': self.node.id_data.name[:], 'custom_function': draw_text, 'loc': self.xy_offset, 'args': (lines, ) } bgl_callback.callback_enable(self.n_id, draw_data)
def show_timings_graphics(ng): bgl_callback.callback_disable("timings:" + ng.name) t_iter = iter(timings) ng_name, base_time = next(t_iter) _, dag_start = next(t_iter) _, dag_stop = next(t_iter) name, t = next(t_iter) nodes = [] res = collections.defaultdict(list) current_node = '' while name != ng_name: if name.startswith("SvRx") and current_node != name: current_node = name node_start = t elif name == current_node: current_node = '' nodes.append((name, node_start, t)) else: res[current_node].append((name, t)) name, t = next(t_iter) stop_time = t node_boxes = [] func_boxes = [] for node, start, stop in nodes: y = len(res[node]) * 5 x = (stop - start) * 10000 node_boxes.append((node, x, y, (start - base_time) * 10000)) func_data = res[node] for i in range(0, len(func_data), 2): func, start = func_data[i] _, stop = func_data[i + 1] y_f = 6 x_f = (stop - start) * 10000 func_boxes.append((func, x_f, y_f, (start - base_time) * 10000)) base_point = (max(n.location.x for n in ng.nodes) + 200, max(n.location.y for n in ng.nodes)) draw_data = { 'tree_name': ng.name, 'custom_function': water_fall, 'loc': base_point, 'args': (node_boxes, func_boxes) } bgl_callback.callback_enable("timings:" + ng.name, draw_data)
def clear(ng): bgl_callback.callback_disable("error:" + ng.name)
def free(self): bgl_callback.callback_disable(self.node_id)
def turn_graphics_off(self, context): bgl_callback.callback_disable("timings:" + self.name)