def draw_end(self, point, tree, start): assert isinstance(start, garlicsim.data_structures.End) if start.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[start.step_profile]) else: color = wx.Colour(204, 204, 204) bitmap = my_color_replaced_bitmap( self.tree_browser.elements['Untouched End'], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color)) self.DrawBitmapPoint(bitmap, point, useMask=True) bitmap_size = bitmap.GetSize() temp = (point[0], point[1], point[0] + bitmap_size[0], point[1] + bitmap_size[1]) self.clickable_map[temp] = start last_height = 0 total_height = 0 self_width = bitmap_size[0] + connector_length max_width = self_width line_start = vectorish.add(point, (bitmap_size[0] - 1, bitmap_size[1] // 2)) return (max_width, max(total_height, bitmap_size[1] + connector_length))
def draw_end(self, point, tree, start): assert isinstance(start, garlicsim.data_structures.End) if start.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[start.step_profile] ) else: color = wx.Colour(204, 204, 204) bitmap = my_color_replaced_bitmap( self.tree_browser.elements['Untouched End'], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color) ) self.DrawBitmapPoint(bitmap, point, useMask=True) bitmap_size = bitmap.GetSize() temp = (point[0], point[1], point[0] + bitmap_size[0], point[1] + bitmap_size[1]) self.clickable_map[temp] = start last_height = 0 total_height = 0 self_width = bitmap_size[0] + connector_length max_width = self_width line_start = vectorish.add( point, ( bitmap_size[0] - 1, bitmap_size[1] // 2 ) ) return ( max_width, max( total_height, bitmap_size[1] + connector_length ) )
def draw_sub_tree(self, point, tree, start): if start.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[start.step_profile]) else: color = wx.Colour(204, 204, 204) make_block_stripe = False if isinstance(start, garlicsim.data_structures.Block): type = 'Block' kids = start[-1].children if start == self.active_soft_block: make_block_stripe = True type = 'Active ' + type elif isinstance(start, garlicsim.data_structures.Node): kids = start.children if start.touched: type = 'Touched' else: type = 'Untouched' if start.still_in_editing: type = 'Unfinalized ' + type if start == self.active_soft_block: type = 'Active ' + type else: raise Exception if make_block_stripe is True: bitmap = my_color_replaced_bitmap( self.tree_browser.elements['Block'], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color)) bitmap_size = bitmap.GetSize() self.gc.DrawBitmap(bitmap, point[0], point[1], bitmap_size[0], bitmap_size[1]) bitmap_size = bitmap.GetSize() second_bitmap = self.tree_browser.elements[type] slice = [None, None] length = float(len(start)) slice[0] = start.index(self.active_node) / length slice[1] = slice[0] + (1 / length) screen_slice = [ floor(point[0] + 4 + (bitmap_size[0] - 8) * slice[0]), ceil(point[0] + 4 + (bitmap_size[0] - 8) * slice[1]) ] self.pen.SetWidth(0) self.pen.SetStyle(wx.TRANSPARENT) self.gc.SetPen(self.pen) self.gc.SetBrush(wx.Brush(wx.Colour(255, 153, 51))) self.gc.DrawRectangle(screen_slice[0], point[1] + 4, screen_slice[1] - screen_slice[0], bitmap_size[1] - 8) else: bitmap = my_color_replaced_bitmap( self.tree_browser.elements[type], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color)) bitmap_size = bitmap.GetSize() self.gc.DrawBitmap(bitmap, point[0], point[1], bitmap_size[0], bitmap_size[1]) temp = (point[0] + 1, point[1], point[0] + bitmap_size[0] - 2, point[1] + bitmap_size[1]) self.clickable_map[temp] = start del temp last_height = 0 total_height = 0 self_width = bitmap_size[0] + connector_length max_width = self_width line_start = vectorish.add(point, (bitmap_size[0] - 1, bitmap_size[1] // 2)) for kid in kids: line_end = vectorish.add( point, (self_width + 1, total_height + bitmap_size[1] // 2)) temp = vectorish.add(point, (self_width, total_height)) (new_width, new_height) = \ self.draw_sub_tree(temp, tree, kid.soft_get_block()) del temp if kid.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[kid.step_profile]) else: color = wx.Colour(0, 0, 0) self.pen.SetColour(wx.Colour(0, 0, 0)) self.pen.SetWidth(1) self.pen.SetStyle(wx.SOLID) self.gc.SetPen(self.pen) self.gc.StrokeLine(line_start[0], line_start[1], line_end[0], line_end[1]) max_width = max(max_width, self_width + new_width) total_height += new_height ends = start.ends if isinstance(start, garlicsim.data_structures.Node)\ else start[-1].ends for end in ends: line_end = vectorish.add( point, (self_width + 1, total_height + bitmap_size[1] // 2)) temp = vectorish.add(point, (self_width, total_height)) (new_width, new_height) = \ self.draw_end(temp, tree, end) del temp if end.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[end.step_profile]) else: color = wx.Colour(0, 0, 0) self.pen.SetColour(wx.Colour(0, 0, 0)) self.pen.SetWidth(1) self.pen.SetStyle(wx.SOLID) self.gc.SetPen(self.pen) self.gc.StrokeLine(line_start[0], line_start[1], line_end[0], line_end[1]) max_width = max(max_width, self_width + new_width) total_height += new_height return (max_width, max(total_height, bitmap_size[1] + connector_length))
def draw_sub_tree(self, point, tree, start): if start.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[start.step_profile] ) else: color = wx.Colour(204, 204, 204) make_block_stripe = False if isinstance(start, garlicsim.data_structures.Block): type = 'Block' kids = start[-1].children if start == self.active_soft_block: make_block_stripe = True type = 'Active ' + type elif isinstance(start, garlicsim.data_structures.Node): kids = start.children if start.touched: type = 'Touched' else: type = 'Untouched' if start.still_in_editing: type = 'Unfinalized ' + type if start == self.active_soft_block: type = 'Active ' + type else: raise Exception if make_block_stripe is True: bitmap = my_color_replaced_bitmap( self.tree_browser.elements['Block'], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color) ) bitmap_size = bitmap.GetSize() self.gc.DrawBitmap(bitmap, point[0], point[1], bitmap_size[0], bitmap_size[1]) bitmap_size = bitmap.GetSize() second_bitmap = self.tree_browser.elements[type] slice = [None, None] length = float(len(start)) slice[0] = start.index(self.active_node) / length slice[1] = slice[0] + (1 / length) screen_slice = [ floor(point[0] + 4 + (bitmap_size[0] - 8) * slice[0]), ceil(point[0] + 4 + (bitmap_size[0] - 8) * slice[1]) ] self.pen.SetWidth(0) self.pen.SetStyle(wx.TRANSPARENT) self.gc.SetPen(self.pen) self.gc.SetBrush(wx.Brush(wx.Colour(255, 153, 51))) self.gc.DrawRectangle(screen_slice[0], point[1] + 4, screen_slice[1] - screen_slice[0], bitmap_size[1] - 8) else: bitmap = my_color_replaced_bitmap( self.tree_browser.elements[type], (0, 255, 0), wx_tools.wx_color_to_big_rgb(color) ) bitmap_size = bitmap.GetSize() self.gc.DrawBitmap(bitmap, point[0], point[1], bitmap_size[0], bitmap_size[1]) temp = (point[0] + 1, point[1], point[0] + bitmap_size[0] - 2, point[1] + bitmap_size[1]) self.clickable_map[temp] = start del temp last_height = 0 total_height = 0 self_width = bitmap_size[0] + connector_length max_width = self_width line_start = vectorish.add( point, ( bitmap_size[0] - 1, bitmap_size[1] // 2 ) ) for kid in kids: line_end = vectorish.add( point, ( self_width + 1, total_height + bitmap_size[1] // 2 ) ) temp = vectorish.add(point, (self_width, total_height)) (new_width, new_height) = \ self.draw_sub_tree(temp, tree, kid.soft_get_block()) del temp if kid.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[kid.step_profile] ) else: color = wx.Colour(0, 0, 0) self.pen.SetColour(wx.Colour(0, 0, 0)) self.pen.SetWidth(1) self.pen.SetStyle(wx.SOLID) self.gc.SetPen(self.pen) self.gc.StrokeLine(line_start[0], line_start[1], line_end[0], line_end[1]) max_width = max(max_width, self_width + new_width) total_height += new_height ends = start.ends if isinstance(start, garlicsim.data_structures.Node)\ else start[-1].ends for end in ends: line_end = vectorish.add( point, ( self_width + 1, total_height + bitmap_size[1] // 2 ) ) temp = vectorish.add(point, (self_width, total_height)) (new_width, new_height) = \ self.draw_end(temp, tree, end) del temp if end.step_profile: color = garlicsim_wx.misc.colors.hue_to_light_color( self.gui_project.step_profiles_to_hues[end.step_profile] ) else: color = wx.Colour(0, 0, 0) self.pen.SetColour(wx.Colour(0, 0, 0)) self.pen.SetWidth(1) self.pen.SetStyle(wx.SOLID) self.gc.SetPen(self.pen) self.gc.StrokeLine(line_start[0], line_start[1], line_end[0], line_end[1]) max_width = max(max_width, self_width + new_width) total_height += new_height return ( max_width, max( total_height, bitmap_size[1] + connector_length ) )