def process(self): p = self.inputs['Float'].sv_get() n_id = node_id(self) # end early nvBGL2.callback_disable(n_id) float_out = self.outputs['Float'] easing_func = easing_dict.get(int(self.selected_mode)) if float_out.is_linked: out = [] for obj in p: r = [] for i in obj: r.append(easing_func(i)) out.append(r) float_out.sv_set(out) else: float_out.sv_set([[None]]) if self.activate: palette = palette_dict.get(self.selected_theme_mode)[:] x, y = [int(j) for j in (self.location + Vector((self.width + 20, 0)))[:]] draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_grid_xy, 'loc': (x, y), 'args': (easing_func, palette) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) if self.output_mode == 'bgl': width, height, colm = self.width_custom_tex, self.height_custom_tex, self.color_mode total_size = width * height * factor_buffer_dict.get(colm) texture = bgl.Buffer( bgl.GL_FLOAT, total_size, np.resize(self.inputs[0].sv_get(), total_size).tolist()) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_dict.get(colm)) draw_data = { 'tree_name': self.id_data.name, 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (self.location[0] + self.width + 20, self.location[1]), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data) else: Im = bpy.data.images[self.image] Im.pixels = np.resize(self.inputs[0].sv_get(), len(Im.pixels))
def process(self): inputs = self.inputs n_id = node_id(self) # end early nvBGL.callback_disable(n_id) if self.activate and inputs[0].is_linked: # gather vertices from input data = inputs[0].sv_get(deepcopy=False) self.num_elements = len(data) if self.selected_mode == 'text-based': processed_data = nvBGL.parse_socket( inputs[0], self.rounding, self.element_index, self.view_by_element ) else: # # implement another nvBGL parses for gfx processed_data = data draw_data = { 'tree_name': self.id_data.name[:], 'content': processed_data, 'location': (self.location + Vector((self.width + 20, 0)))[:], 'color': self.text_color[:], 'mode': self.selected_mode[:], 'font_id': int(self.font_id) } nvBGL.callback_enable(n_id, draw_data)
def process(self): inputs = self.inputs n_id = node_id(self) # end early nvBGL.callback_disable(n_id) if self.activate and inputs[0].is_linked: try: with sv_preferences() as prefs: scale = prefs.stethoscope_view_scale location_theta = prefs.stethoscope_view_xy_multiplier except: # print('did not find preferences - you need to save user preferences') scale = 1.0 location_theta = 1.0 # gather vertices from input data = inputs[0].sv_get(deepcopy=False) self.num_elements = len(data) if self.selected_mode == 'text-based': props = lambda: None props.line_width = self.line_width props.compact = self.compact props.depth = self.depth or None processed_data = nvBGL.parse_socket( inputs[0], self.rounding, self.element_index, self.view_by_element, props ) else: # # implement another nvBGL parses for gfx processed_data = data node_width = (self.width_hidden + 30.0) if self.hide else self.width # adjust proposed text location in case node is framed. # take into consideration the hidden state _x, _y = recursive_framed_location_finder(self, self.location[:]) _x, _y = Vector((_x, _y)) + Vector((node_width + 20, 0)) # this alters location based on DPI/Scale settings. location = adjust_location(_x, _y, location_theta) draw_data = { 'tree_name': self.id_data.name[:], 'content': processed_data, 'location': location, 'color': self.text_color[:], 'scale' : float(scale), 'mode': self.selected_mode[:], 'font_id': int(self.font_id) } nvBGL.callback_enable(n_id, draw_data)
def process(self): inputs = self.inputs n_id = node_id(self) # end early nvBGL.callback_disable(n_id) if self.activate and inputs[0].is_linked: try: with sv_preferences() as prefs: scale = prefs.stethoscope_view_scale location_theta = prefs.render_location_xy_multiplier except: # print('did not find preferences - you need to save user preferences') scale = 1.0 location_theta = 1.0 # gather vertices from input data = inputs[0].sv_get(deepcopy=False) self.num_elements = len(data) if self.selected_mode == 'text-based': props = lambda: None props.line_width = self.line_width props.compact = self.compact props.depth = self.depth or None processed_data = nvBGL.parse_socket( inputs[0], self.rounding, self.element_index, self.view_by_element, props ) else: # # implement another nvBGL parses for gfx processed_data = data node_width = (self.width_hidden + 30.0) if self.hide else self.width # adjust proposed text location in case node is framed. # take into consideration the hidden state _x, _y = recursive_framed_location_finder(self, self.location[:]) _x, _y = Vector((_x, _y)) + Vector((node_width + 20, 0)) # this alters location based on DPI/Scale settings. location = adjust_location(_x, _y, location_theta) draw_data = { 'tree_name': self.id_data.name[:], 'content': processed_data, 'location': location, 'color': self.text_color[:], 'scale' : float(scale), 'mode': self.selected_mode[:], 'font_id': int(self.font_id) } nvBGL.callback_enable(n_id, draw_data)
def update(self): if not ("Data" in self.inputs): return try: if not self.inputs[0].other: nvBGL.callback_disable(node_id(self)) except: print('stethoscope update holdout (not a problem)')
def process(self): if not self.inputs['Float'].is_linked: return n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) size_tex = 0 width = 0 height = 0 if self.to_image_viewer: mode = self.color_mode pixels = np.array( self.inputs['Float'].sv_get(deepcopy=False)).flatten() width, height = self.texture_width_height resized_np_array = np.resize(pixels, self.calculate_total_size()) transfer_to_image(resized_np_array, self.texture_name, width, height, mode) if self.activate: texture = self.get_buffer() width, height = self.texture_width_height x, y = self.xy_offset gl_color_constant = gl_color_dict.get(self.color_mode) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) # adjust render location based on preference multiplier setting try: with sv_preferences() as prefs: multiplier = prefs.render_location_xy_multiplier scale = prefs.render_scale except: # print('did not find preferences - you need to save user preferences') multiplier = 1.0 scale = 1.0 x, y = [x * multiplier, y * multiplier] width, height = [width * scale, height * scale] draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (x, y), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): if not self.inputs['Float'].is_linked: return n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) size_tex = 0 width = 0 height = 0 if self.to_image_viewer: mode = self.color_mode pixels = np.array(self.inputs['Float'].sv_get(deepcopy=False)).flatten() width, height = self.texture_width_height resized_np_array = np.resize(pixels, self.calculate_total_size()) transfer_to_image(resized_np_array, self.texture_name, width, height, mode) if self.activate: texture = self.get_buffer() width, height = self.texture_width_height x, y = self.xy_offset gl_color_constant = gl_color_dict.get(self.color_mode) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) # adjust render location based on preference multiplier setting try: with sv_preferences() as prefs: multiplier = prefs.render_location_xy_multiplier scale = prefs.render_scale except: # print('did not find preferences - you need to save user preferences') multiplier = 1.0 scale = 1.0 x, y = [x * multiplier, y * multiplier] width, height =[width * scale, height * scale] draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (x, y), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): p = self.inputs['Float'].sv_get() n_id = node_id(self) # end early nvBGL2.callback_disable(n_id) float_out = self.outputs['Float'] easing_func = easing_dict.get(int(self.selected_mode)) if float_out.is_linked: out = [] for obj in p: r = [] for i in obj: r.append(easing_func(i)) out.append(r) float_out.sv_set(out) else: float_out.sv_set([[None]]) if self.activate: palette = palette_dict.get(self.selected_theme_mode)[:] x, y = [int(j) for j in (self.location + Vector((self.width + 20, 0)))[:]] # adjust render location based on preference multiplier setting try: with sv_preferences() as prefs: multiplier = prefs.render_location_xy_multiplier scale = prefs.render_scale except: # print('did not find preferences - you need to save user preferences') multiplier = 1.0 scale = 1.0 x, y = [x * multiplier, y * multiplier] draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_grid_xy, 'loc': (x, y), 'args': (easing_func, palette, scale) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): inputs = self.inputs n_id = node_id(self) # end early nvBGL.callback_disable(n_id) if self.activate and inputs[0].is_linked: try: with sv_preferences() as prefs: scale = prefs.stethoscope_view_scale location_theta = prefs.stethoscope_view_xy_multiplier except: # print('did not find preferences - you need to save user preferences') scale = 1.0 location_theta = 1.0 # gather vertices from input data = inputs[0].sv_get(deepcopy=False) self.num_elements = len(data) if self.selected_mode == 'text-based': processed_data = nvBGL.parse_socket(inputs[0], self.rounding, self.element_index, self.view_by_element) else: # # implement another nvBGL parses for gfx processed_data = data _x, _y = (self.location + Vector((self.width + 20, 0))) location = adjust_location(_x, _y, location_theta) draw_data = { 'tree_name': self.id_data.name[:], 'content': processed_data, 'location': location, 'color': self.text_color[:], 'scale': float(scale), 'mode': self.selected_mode[:], 'font_id': int(self.font_id) } nvBGL.callback_enable(n_id, draw_data)
def process(self): if not self.inputs['Float'].is_linked: return n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) size_tex = 0 width = 0 height = 0 if self.to_image_viewer: mode = self.color_mode pixels = np.array( self.inputs['Float'].sv_get(deepcopy=False)).flatten() width, height = self.texture_width_height resized_np_array = np.resize(pixels, self.calculate_total_size()) transfer_to_image(resized_np_array, self.texture_name, width, height, mode) if self.activate: texture = self.get_buffer() width, height = self.texture_width_height x, y = self.xy_offset gl_color_constant = gl_color_dict.get(self.color_mode) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (x, y), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): if not self.inputs['Float'].is_linked: return n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) size_tex = 0 width = 0 height = 0 if self.to_image_viewer: mode = self.color_mode pixels = np.array(self.inputs['Float'].sv_get(deepcopy=False)).flatten() width, height = self.texture_width_height resized_np_array = np.resize(pixels, self.calculate_total_size()) transfer_to_image(resized_np_array, self.texture_name, width, height, mode) if self.activate: texture = self.get_buffer() width, height = self.texture_width_height x, y = self.xy_offset gl_color_constant = gl_color_dict.get(self.color_mode) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (x, y), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) if self.output_mode == 'bgl': width, height, colm = self.width_custom_tex, self.height_custom_tex, self.color_mode total_size = width * height * factor_buffer_dict.get(colm) texture = bgl.Buffer(bgl.GL_FLOAT, total_size, np.resize(self.inputs[0].sv_get(), total_size)) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_dict.get(colm)) draw_data = { 'tree_name': self.id_data.name, 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (self.location[0] + self.width + 20, self.location[1]), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data) else: Im = bpy.data.images[self.image] Im.pixels = np.resize(self.inputs[0].sv_get(), len(Im.pixels))
def process(self): n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) if self.output_mode == 'bgl': width, height, colm = self.width_custom_tex, self.height_custom_tex, self.color_mode total_size = width * height * factor_buffer_dict.get(colm) texture = bgl.Buffer(bgl.GL_FLOAT, total_size, np.resize(self.inputs[0].sv_get(), total_size).tolist()) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_dict.get(colm)) # adjust render location based on preference multiplier setting try: with sv_preferences() as prefs: multiplier = prefs.render_location_xy_multiplier scale = prefs.render_scale except: # print('did not find preferences - you need to save user preferences') multiplier = 1.0 scale = 1.0 x, y = [self.location[0] * multiplier, self.location[1] * multiplier] width, height =[width * scale, height * scale] draw_data = { 'tree_name': self.id_data.name, 'mode': 'custom_function', 'custom_function': simple_screen, 'loc': (x + self.width*scale + 20, y), 'args': (texture, self.texture[n_id], width, height) } nvBGL2.callback_enable(n_id, draw_data) else: Im = bpy.data.images[self.image] Im.pixels = np.resize(self.inputs[0].sv_get(), len(Im.pixels))
def process(self): p = self.inputs['Float'].sv_get() n_id = node_id(self) # end early nvBGL2.callback_disable(n_id) float_out = self.outputs['Float'] easing_func = easing_dict.get(int(self.selected_mode)) if float_out.is_linked: out = [] for obj in p: r = [] for i in obj: r.append(easing_func(i)) out.append(r) float_out.sv_set(out) else: float_out.sv_set([[None]]) if self.activate: palette = palette_dict.get(self.selected_theme_mode)[:] x, y = [ int(j) for j in (self.location + Vector((self.width + 20, 0)))[:] ] draw_data = { 'tree_name': self.id_data.name[:], 'mode': 'custom_function', 'custom_function': simple_grid_xy, 'loc': (x, y), 'args': (easing_func, palette) } nvBGL2.callback_enable(n_id, draw_data)
def free(self): nvBGL2.callback_disable(node_id(self))
def free(self): nvBGL2.callback_disable(node_id(self)) self.delete_texture()
def update(self): if not ("Data" in self.inputs): return if not self.inputs[0].other: nvBGL.callback_disable(node_id(self))