def Render(self, dc): # Draw some stuff on the plain dc sz = self.GetSize() dc.SetPen(wx.Pen("navy", 1)) x = y = 0 while x < sz.width * 2 or y < sz.height * 2: x += 20 y += 20 dc.DrawLine(x, 0, 0, y) # now draw something with cairo ctx = wx.lib.wxcairo.ContextFromDC(dc) ctx.set_line_width(15) ctx.move_to(125, 25) ctx.line_to(225, 225) ctx.rel_line_to(-200, 0) ctx.close_path() ctx.set_source_rgba(0, 0, 0.5, 1) ctx.stroke() # and something else... ctx.arc(200, 200, 80, 0, math.pi * 2) ctx.set_source_rgba(0, 1, 1, 0.5) ctx.fill_preserve() ctx.set_source_rgb(1, 0.5, 0) ctx.stroke() # here's a gradient pattern ptn = cairo.RadialGradient(315, 70, 25, 302, 70, 128) ptn.add_color_stop_rgba(0, 1, 1, 1, 1) ptn.add_color_stop_rgba(1, 0, 0, 0, 1) ctx.set_source(ptn) ctx.arc(328, 96, 75, 0, math.pi * 2) ctx.fill() # Draw some text face = wx.lib.wxcairo.FontFaceFromFont( wx.FFont(10, wx.SWISS, wx.FONTFLAG_BOLD)) ctx.set_font_face(face) ctx.set_font_size(60) ctx.move_to(360, 180) ctx.set_source_rgb(0, 0, 0) ctx.show_text("Hello") # Text as a path, with fill and stroke ctx.move_to(400, 220) ctx.text_path("World") ctx.set_source_rgb(0.39, 0.07, 0.78) ctx.fill_preserve() ctx.set_source_rgb(0, 0, 0) ctx.set_line_width(2) ctx.stroke() # Show iterating and modifying a (text) path ctx.new_path() ctx.move_to(0, 0) ctx.set_source_rgb(0.3, 0.3, 0.3) ctx.set_font_size(30) text = "This path was warped..." ctx.text_path(text) tw, th = ctx.text_extents(text)[2:4] self.warpPath(ctx, tw, th, 360, 300) ctx.fill() # Drawing a bitmap. Note that we can easily load a PNG file # into a surface, but I wanted to show how to convert from a # wx.Bitmap here instead. This is how to do it using just cairo: #img = cairo.ImageSurface.create_from_png(opj('bitmaps/toucan.png')) # And this is how to convert a wx.Btmap to a cairo image # surface. NOTE: currently on Mac there appears to be a # problem using conversions of some types of images. They # show up totally transparent when used. The conversion itself # appears to be working okay, because converting back to # wx.Bitmap or writing the image surface to a file produces # the expected result. The other platforms are okay. bmp = wx.Bitmap(opj('bitmaps/toucan.png')) #bmp = wx.Bitmap(opj('bitmaps/splash.png')) img = wx.lib.wxcairo.ImageSurfaceFromBitmap(bmp) ctx.set_source_surface(img, 70, 230) ctx.paint() # this is how to convert an image surface to a wx.Bitmap bmp2 = wx.lib.wxcairo.BitmapFromImageSurface(img) dc.DrawBitmap(bmp2, 280, 300)
def draw(self, dc, f, **key): dc.SetPen(wx.Pen((255, 0, 0), width=1, style=wx.SOLID)) dc.DrawLines([f(*i) for i in self.body])
def draw_background(self, gc: wx.GraphicsContext): """ Drawing the gridlines background. """ gc.SetPen(wx.Pen(wx.BLACK)) gc.StrokeLineSegments(self.begin_points, self.end_points)
def DrawCase(self, dc, texteDate, x, y, l, h, survol=False): IDobjet = self.DateEnIDobjet(texteDate) dc.SetId(IDobjet) # Application des couleurs normales dc.SetBrush(wx.Brush(self.couleurNormal)) dc.SetPen(wx.Pen(self.couleurFond, 1)) # Si c'est un jour de vacances if texteDate in self.joursVacances: dc.SetBrush(wx.Brush(self.couleurVacances)) # Si c'est un jour de Week-end jourSemaine = texteDate.isoweekday() if jourSemaine == 6 or jourSemaine == 7: dc.SetBrush(wx.Brush(self.couleurWE)) # Si c'est un jour férié if (texteDate.day, texteDate.month) in self.listeFeriesFixes: dc.SetBrush(wx.Brush(self.couleurFerie)) else: if texteDate in self.listeFeriesVariables: dc.SetBrush(wx.Brush(self.couleurFerie)) # Si c'est une case survolée if survol == True: #dc.SetBrush(wx.Brush('black', wx.TRANSPARENT)) dc.SetPen(wx.Pen(self.couleurSurvol, 1)) # Dessine d'une case sélectionnée if len(self.listeSelections) != 0: if texteDate in self.listeSelections: dc.SetBrush(wx.Brush(self.couleurSelect)) # Dessin de la case dc.DrawRectangle(x, y, l, h) # Dessin du symbole Aujourd'hui if texteDate == datetime.date.today(): dc.SetBrush(wx.Brush((255, 0, 0))) dc.SetPen(wx.Pen((255, 0, 0), 0)) posG = x + l - 2 posH = y + 1 tailleTriangle = 5 dc.DrawPolygon([(posG, posH), (posG - tailleTriangle, posH), (posG, posH + tailleTriangle)]) # Dessin texte if six.text_type(texteDate) in self.listeJoursAvecPresents: dc.SetTextForeground(self.couleurFontJoursAvecPresents) else: dc.SetTextForeground(self.couleurFontJours) font = self.GetFont() font.SetPointSize(self.tailleFont(l, h)) dc.SetFont(font) dc.DrawText(str(texteDate.day), x + 3, y + 2) # Traitement pour le PseudoDC r = wx.Rect(x, y, l, h) dc.SetIdBounds(IDobjet, r)
def __init__(self, parent, dstack=None, aspect=1, do=None, voxelsize=[1, 1, 1]): if (dstack is None and do is None): dstack = scipy.zeros((10, 10)) if do is None: self.do = DisplayOpts(dstack, aspect=aspect) self.do.Optimise() else: self.do = do self.voxelsize = voxelsize scrolledImagePanel.ScrolledImagePanel.__init__(self, parent, self.DoPaint, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) self.do.WantChangeNotification.append(self.GetOpts) #self.do.WantChangeNotification.append(self.Refresh) self.SetVirtualSize(wx.Size(self.do.ds.shape[0], self.do.ds.shape[1])) #self.imagepanel.SetSize(wx.Size(self.do.ds.shape[0],self.do.ds.shape[1])) self.points = [] self.pointsR = [] self.showPoints = True self.showTracks = True self.showContours = True self.showScaleBar = True self.scaleBarLength = 2000 self.pointMode = 'confoc' self.pointTolNFoc = { 'confoc': (5, 5, 5), 'lm': (2, 5, 5), 'splitter': (2, 5, 5) } self.showAdjacentPoints = False self.pointSize = 11 self.layerMode = 'Add' self.psfROIs = [] self.psfROISize = [30, 30, 30] self.lastUpdateTime = 0 self.lastFrameTime = 2e-3 #self.do.scale = 0 self.crosshairs = True #self.showSelection = True self.selecting = False self.aspect = 1. self._slice = None self._sc = None self.overlays = [] self._oldIm = None self._oldImSig = None self.CenteringHandlers = [] self.selectHandlers = [] self.labelPens = [ wx.Pen( wx.Colour(*[ int(c) for c in matplotlib.cm.hsv(v, alpha=.5, bytes=True) ]), 2) for v in numpy.linspace(0, 1, 16) ] # if not aspect is None: # if scipy.isscalar(aspect): # self.do.aspects[2] = aspect # elif len(aspect) == 3: # self.do.aspects = aspect #self.SetOpts() #self.optionspanel.RefreshHists() self.updating = 0 self.showOptsPanel = 1 self.refrTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnRefrTimer) self.imagepanel.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) self.imagepanel.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) #wx.EVT_KEY_DOWN(self.Parent(), self.OnKeyPress) self.imagepanel.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.imagepanel.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.imagepanel.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown) self.imagepanel.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleUp) self.imagepanel.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.imagepanel.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) self.imagepanel.Bind(wx.EVT_MIDDLE_DCLICK, self.OnMiddleDClick) self.imagepanel.Bind(wx.EVT_MOTION, self.OnMotion) # self.imagepanel.Bind(wx.EVT_ERASE_BACKGROUND, self.DoNix) self.Bind(wx.EVT_ERASE_BACKGROUND, self.DoNix)
def drawStrip(self): n_stripBmps = len(self.data_sel_keys) stripFramePos = 0, self.bufferHeight * 2.0 / 3.0 stripFrameHeight = self.bufferHeight / 3.0 stripBmpHeight = stripFrameHeight * 0.8 stripBmpWidth = stripBmpHeight * 0.8 stripBmpGap = stripFrameHeight * 0.1 stripBmpFrameWidth = stripBmpWidth + 2 * stripBmpGap stripFrameMarginLR = (self.bufferWidth - stripBmpWidth) / 2.0 - stripBmpGap stripFrameWidth = stripBmpFrameWidth * n_stripBmps + stripFrameMarginLR * 2 if stripFrameWidth < self.bufferWidth: stripFrameWidth = self.bufferWidth self.nav_left = stripFramePos[0], stripFramePos[1], \ stripFramePos[0] + self.bufferWidth/ 2.0, \ stripFramePos[1] + stripFrameHeight self.nav_right = stripFramePos[0] + self.bufferWidth/ 2.0, stripFramePos[1], \ stripFramePos[0] + self.bufferWidth, \ stripFramePos[1] + stripFrameHeight self.stripBmpFrameWidth = stripBmpFrameWidth self.stripBmpWidth = stripBmpWidth self.stripBmpHeight = stripBmpHeight self.stripFrameWidth = stripFrameWidth self.stripFrameHeight = stripFrameHeight self.stripFramePos = stripFramePos self.stripFrameMarginLR = stripFrameMarginLR self.middleBmpPos = stripFrameMarginLR + stripBmpGap, stripFramePos[ 1] + stripBmpGap stripBuffer = wx.EmptyBitmap(stripFrameWidth, stripFrameHeight) tmp_dc = wx.BufferedDC(None, stripBuffer) # draw light gray background first pen = wx.Pen(stars.STRIP_VIEW_BG_COLOR) tmp_dc.SetPen(pen) brush = wx.Brush(stars.STRIP_VIEW_BG_COLOR) tmp_dc.SetBrush(brush) tmp_dc.DrawRectangle(0, 0, stripFrameWidth, stripFrameHeight) font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) tmp_dc.SetFont(font) # draw each bmp at strip area tmp_dc.SetBrush(wx.Brush(stars.STRIP_VIEW_MAP_BG_COLOR)) for i in range(n_stripBmps): start_pos = stripFrameMarginLR + stripBmpFrameWidth * i + stripBmpGap, stripBmpGap bmp = wx.EmptyBitmapRGBA(stripBmpWidth, stripBmpHeight, red=stars.STRIP_VIEW_BG_COLOR.red, green=stars.STRIP_VIEW_BG_COLOR.green, blue=stars.STRIP_VIEW_BG_COLOR.blue, alpha=stars.STRIP_VIEW_BG_COLOR.alpha) self.drawSubView(i, stripBmpWidth, stripBmpHeight, bmp) tmp_dc.SetBrush(wx.WHITE_BRUSH) tmp_dc.SetPen(wx.TRANSPARENT_PEN) tmp_dc.DrawRectangle(start_pos[0], start_pos[1], stripBmpWidth, stripBmpHeight) tmp_dc.DrawBitmap(bmp, start_pos[0], start_pos[1]) # draw label for each map in subview start_date, end_date = self.datetime_intervals[i] if isinstance(start_date, datetime.date): info_tip = "%d/%d/%d - %d/%d/%d"% \ (start_date.month, start_date.day, start_date.year, end_date.month, end_date.day, end_date.year) else: info_tip = "t%d" % (start_date) txt_w, txt_h = tmp_dc.GetTextExtent(info_tip) tmp_dc.DrawText(info_tip, start_pos[0] + (stripBmpWidth - txt_w) / 2, start_pos[1] + stripBmpHeight + 2) #tmp_dc.Destroy() return stripBuffer
def OnPaint(self, event): """ Handles the ``wx.EVT_PAINT`` event for L{CalendarHeatmap}. :param `event`: a `wx.PaintEvent` event to be processed. """ dc = wx.BufferedPaintDC(self) self._getGridDate() self._setDimensions( dc ) am = AM.ArtManager() gc = wx.GraphicsContext.Create(dc) dc.SetBackground(wx.Brush(self.GetParent().GetBackgroundColour())) dc.Clear() colour = self.GetForegroundColour() textColour = am.DarkColour(wx.WHITE, 3.0) if am.IsDark(colour) else am.LightColour(wx.BLACK, 3.0) valueMax = max( v for v in self.dates.values() ) gc = wx.GraphicsContext.Create(dc) for r, w in enumerate('MTWTFSS'): x, y = self.leftLabelRect.GetX(), self.leftLabelRect.GetY() + self.rowHeight*r width = dc.GetTextExtent(w)[0] dc.DrawText( w, x + (self.leftLabelRect.GetWidth() - width) // 2, y ) if self.date: x, y = self._xyFromDate( self.date ) dText = '{}: {}'.format( self.date.strftime('%Y-%m-%d'), self.dates.get(self.date, 0) ) width = dc.GetTextExtent( dText )[0] if x+width > self.bodyRect.GetRight(): x = self.bodyRect.GetRight() - width dc.DrawText( dText, x, self.bottomLabelRect.GetY() ) else: dText = '{}'.format( self.year ) dc.DrawText( dText, self.bottomLabelRect.GetX(), self.bottomLabelRect.GetY() ) backgrounds = [wx.Brush(wx.Colour(200,200,200), wx.SOLID), wx.Brush(wx.Colour(230,230,230), wx.SOLID)] monthCur = 0 gc.SetPen( wx.TRANSPARENT_PEN ) for d in daterange(datetime.date(self.year, 1, 1), datetime.date(self.year+1, 1, 1)): x, y = self._xyFromDate( d ) gc.SetBrush( backgrounds[d.month&1] if d != self.date else wx.GREEN_BRUSH ) gc.DrawRectangle( x, y, self.rowHeight, self.rowHeight ) s = self.dates.get(d, None) if s: gc.SetBrush( wx.RED_BRUSH ) size = max(3, self.rowHeight * sqrt((float(s) / valueMax))) cc = (self.rowHeight - size) / 2 gc.DrawEllipse( x + cc, y + cc, size, size ) if d.month != monthCur: y = self.topLabelRect.GetY() dc.DrawText( d.strftime('%b'), x, y ) monthCur = d.month if self.dateSelect: x, y = self._xyFromDate( self.dateSelect ) gc.SetBrush( wx.TRANSPARENT_BRUSH ) gc.SetPen( wx.Pen(wx.BLACK, 2) ) gc.DrawRectangle( x-1, y-1, self.rowHeight+1, self.rowHeight+1 )
def draw_background(self, grid, dc, rect, row, col, is_selected, flat_style=False): # Rect gets modified, so make a copy of it rect = wx.Rect(rect.x, rect.y, rect.width, rect.height) node = grid.get_row_as_node(row) column_collection = grid.get_column_collection() column_object = column_collection.column_order[col] # Magic number for bumping the selection draw caps out of the clipping region offset_buffer = 10 if hasattr(node, 'get_render_colors'): # if this is the asset manager override the node colors for all node types if grid.get_pane_callback_id( ) is ctg.ae2.ui.const.PANE_LISTENER_ASSET_MANAGER_CALLBACK_ID: node_color_set = ctg.ae2.ui.const.NODE_COLORS_ASSET_MANAGER else: node_color_set = node.get_render_colors(column_object) is_even = (row % 2 == 0) bg_color = node_color_set.get_color(False, is_even) color = node_color_set.get_color(is_selected, is_even) color_bg_top = color color_bg_bottom = scale_color(color, 0.7) color_stroke_inner = scale_color(color, 0.9) color_stroke_outer = scale_color(color, 0.4) self._color_cell_border = node_color_set.get_color(is_selected, is_even, border=True) self._color_column_border_sel = node_color_set.get_color( is_selected, is_even, border=True) else: bg_color = self.get_background_color_for_row( row, is_selected=is_selected, flat_style=flat_style) color_bg_top = self._color_bg_grad_top color_bg_bottom = self._color_bg_grad_bottom color_stroke_inner = self._color_stroke_grad_inner color_stroke_outer = self._color_stroke_grad dc.SetBrush(wx.Brush(bg_color, wx.SOLID)) if flat_style: dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(rect) else: dc.DestroyClippingRegion() dc.SetClippingRegion(*rect) # Change rect a bit so we don't have doubled borders rect.x -= 1 rect.width += 1 bg_rect = wx.Rect(*rect) bg_rect.y -= 1 bg_rect.height += 1 if grid.lister_style == vlib.ui.lister_lib.const.STYLE_TREE: if hasattr(grid, 'show_tree_connections'): bg_rect.Inflate(1, 0) border_pen = wx.Pen(self.get_border_color(), 1) dc.SetPen(border_pen) dc.DrawRectangleRect(bg_rect) if is_selected == True: draw_divider = False # Make the selection capsule look correct if it extends multiple columns rect_grad = wx.Rect(*rect) if col == 0: if grid.GetNumberCols() > 1: # Send capsule right side beyond clipping region rect_grad.width += offset_buffer draw_divider = True else: # Only column if grid.GetScrollThumb(1): rect_grad.width -= wx.SystemSettings.GetMetric( wx.SYS_VTHUMB_Y ) + 2 # Remove the 2 pixel buffer problem else: if col == (grid.GetNumberCols() - 1): # Last column, bump left side rect_grad.x -= offset_buffer rect_grad.width += offset_buffer else: # Middle columns rect_grad.Inflate(offset_buffer, 0) draw_divider = True rect_grad.Deflate(2, 2) dc.GradientFillLinear(rect_grad, color_bg_top, color_bg_bottom, wx.DOWN) dc.SetBrush(wx.TRANSPARENT_BRUSH) # Draw stroke stroke_pen_inner = wx.Pen(color_stroke_inner, 1) stroke_pen_inner.SetJoin(wx.JOIN_MITER) dc.SetPen(stroke_pen_inner) rect_grad.Inflate(1, 1) dc.DrawRoundedRectangleRect(rect_grad, 2) stroke_pen = wx.Pen(color_stroke_outer, 1.5) stroke_pen.SetJoin(wx.JOIN_MITER) dc.SetPen(stroke_pen) rect_grad.Inflate(1, 1) dc.DrawRoundedRectangleRect(rect_grad, 3) if draw_divider: dc.SetPen(wx.Pen(scale_color(color_bg_top, 1.1), 1)) rect.Deflate(0, 1) t_pt = rect.GetTopRight() b_pt = rect.GetBottomRight() dc.DrawLine(t_pt.x, t_pt.y, b_pt.x, b_pt.y) dc.DestroyClippingRegion()
def OnPaint(self, evt): w_global, h = self.Size if 0 in self.Size: return low_slider_pos = self.low_slider.GetPosition()[0] + s_off high_slider_pos = self.high_slider.GetPosition()[0] + s_off global_scale = self.global_extents[1] - self.global_extents[ 0] # value scale of the global data if global_scale == 0: local_x0 = 0 local_x1 = w_global w_local = w_global else: local_x0 = ( self.local_extents[0] - self.global_extents[0] ) / global_scale * w_global # x pos (pixels) to start drawing the local color bar local_x1 = ( self.local_extents[1] - self.global_extents[0] ) / global_scale * w_global # x pos (pixels) to stop drawing the local color bar w_local = local_x1 - local_x0 # pixel width of the local color bar w0 = int(max(low_slider_pos, local_x0) - local_x0) w1 = int(local_x1 - min(high_slider_pos, local_x1)) # create array of values to be used for the color bar if self.clipmode == 'rescale': a1 = np.array([]) if w0 > 0: a1 = np.zeros(w0) a2 = np.arange(abs( min(high_slider_pos, local_x1) - max(low_slider_pos, local_x0)), dtype=float) / (min(high_slider_pos, local_x1) - max(low_slider_pos, local_x0)) * 255 a3 = np.array([]) if w1 > 0: a3 = np.ones(w1) if len(a1) > 0 and len(a3) > 0: a = np.hstack([a1, a2, a3]) else: a = a2 elif self.clipmode == 'clip': a = np.arange(w_local, dtype=float) / w_local a[:w0] = 0. if w1 >= 1: a[-w1:] = 1. # draw the color bar dc = wx.PaintDC(self) dc.Clear() dc.SetPen(wx.Pen((0, 0, 0))) dc.DrawLine(0, (h - 14) / 2, local_x0, (h - 14) / 2) for x, v in enumerate(a): v = int(v) color = np.array(self.cm(v)) * 255 dc.SetPen(wx.Pen(color)) dc.DrawLine(x + local_x0, 0, x + local_x0, h - 14) dc.SetPen(wx.Pen((0, 0, 0))) dc.DrawLine(local_x1, (h - 14) / 2, w_global, (h - 14) / 2) # draw value axis if self.ticks <= 1: return font = dc.GetFont() font.SetPixelSize((6, 12)) dc.SetFont(font) for t in range(self.ticks): xpos = t * w_global / (self.ticks - 1.) val = t * (self.global_extents[1] - self.global_extents[0]) / ( self.ticks - 1) + self.global_extents[0] dc.DrawLine(xpos, 6, xpos, h - 14) textpos = xpos - xpos / w_global * dc.GetFullTextExtent( self.labelformat % (val), font)[0] dc.DrawText(self.labelformat % (val), textpos, h - 13)
def SetThickness(self, num): """Set a new line thickness and make a matching pen""" self.thickness = num self.pen = wx.Pen(self.colour, self.thickness, wx.SOLID) self.Notify()
def draw_tree_connections(self, grid, dc, rect, row, col, is_selected=False): node = grid.get_row_as_node(row) if hasattr(grid, 'show_tree_connections'): if node: node_depth = node.get_depth() icon_spacing = self.get_tree_icon_spacing() tree_margin = self.get_tree_margin_left() pen_lines = wx.Pen(self.get_tree_connections_color(), style=wx.PENSTYLE_DOT) top_point = wx.Point(*rect.TopLeft) bottom_point = wx.Point(*rect.BottomLeft) offset = (icon_spacing + tree_margin) * 0.5 top_point.x += offset top_point.y += 2 bottom_point.x += offset last_node = False sibling = node.get_next_sibling() has_sibling = bool(sibling) if not has_sibling or (node_depth > sibling.node_depth): last_node = True depth_parent_node = node.get_parent() line_depths = range(node_depth + 1) # Draw a vertical line for each depth level. Additionally drawing a # horizontal line for same level siblings. for i in line_depths: dc.SetPen(pen_lines) center = (bottom_point.y - top_point.y) * 0.5 new_bottom = top_point.y + center depth_parent_node = node for n in range(len(line_depths) - i - 1): if depth_parent_node: depth_parent_node = depth_parent_node.get_parent() if (i == node_depth) and last_node: # draw a l-shape to indicate the last item in the tree dc.DrawLine(top_point.x, top_point.y, bottom_point.x, new_bottom) elif ( i == node_depth ) and has_sibling and node_depth == sibling.get_depth(): dc.DrawLine(top_point.x, top_point.y, bottom_point.x, bottom_point.y) elif depth_parent_node and ( i == depth_parent_node.get_depth( ) ) and \ depth_parent_node.get_next_sibling( ) and \ ( i == depth_parent_node.get_next_sibling( ).get_depth( ) ): dc.DrawLine(top_point.x, top_point.y, bottom_point.x, bottom_point.y) if node_depth == i: dc.DrawLine(top_point.x, new_bottom, bottom_point.x + (icon_spacing * 0.5), new_bottom) top_point.x += icon_spacing bottom_point.x += icon_spacing
def SetColour(self, colour): """Set a new colour and make a matching pen""" self.colour = colour self.pen = wx.Pen(self.colour, self.thickness, wx.SOLID) self.Notify()
def MakeHistogramBmp(self, size=None): # need to expand the number of points to fill the client size... if self.histogram is None: return if size is None: w, h = self.GetClientSize() else: w, h = size if w <= 0: return if h <= 0: return # short circuit if we've been provided with a histogram image already if self.histo_image is not None: # resize image and make a bitmap buffer = self.histo_image.Scale(w, h).ConvertToBitmap() else: n_bins = self.histogram.shape[0] # scale the histogram (used for the tooltip) indexes = (np.arange(w, dtype=np.float) * float(n_bins) / float(w)).astype(np.int) self.histogram_scaled = np.take(self.histogram, indexes) rect_list = np.zeros((n_bins, 4)) w_rect = int(float(w) / (n_bins)) missing = w - w_rect * n_bins hist = self.histogram / self.histogram_max * h y = h x = 0 for i in range(n_bins): w_temp = w_rect if missing > 0: w_temp += 1 missing -= 1 rect_list[i, :] = [x, h - hist[i], w_temp, h] x += w_temp # White image, black columns, will use black as the mask buffer = wx.EmptyBitmapRGBA(w, h, 255, 255, 255, 255) dc = wx.BufferedDC(None, buffer) dc.SetPen(wx.Pen("BLACK", 1)) dc.SetBrush(wx.Brush("BLACK")) dc.DrawRectangleList(rect_list) dc.EndDrawing() # This avoids the following error: # wx._core.PyAssertionError: C++ assertion "!bitmap.GetSelectedInto()" failed # at ..\..\src\msw\bitmap.cpp(1509) in wxMask::Create(): # bitmap can't be selected in another DC del dc mask = wx.Mask(buffer, wx.BLACK) buffer.SetMask(mask) self.bmp_histogram = buffer
def OnDraw(self, dc): self.flag = True sz = dc.GetSize() dc.SetPen(wx.Pen('blue', 3)) dc.DrawLine(0, 0, sz.width, sz.height)
def MakeSnapshot(self, maxColumns=1337): if self.FVsnapshot: del self.FVsnapshot tbmp = wx.EmptyBitmap(16, 16) tdc = wx.MemoryDC() tdc.SelectObject(tbmp) font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT) tdc.SetFont(font) columnsWidths = [] for i in xrange(len(self.DEFAULT_COLS)): columnsWidths.append(0) sFit = service.Fit.getInstance() try: fit = sFit.getFit(self.activeFitID) except: return if fit is None: return slotMap = {} for slotType in Slot.getTypes(): slot = Slot.getValue(slotType) slotMap[slot] = fit.getSlotsFree(slot) < 0 padding = 2 isize = 16 headerSize = max(isize, tdc.GetTextExtent("W")[0]) + padding * 2 maxWidth = 0 maxRowHeight = isize rows = 0 for id, st in enumerate(self.mods): for i, col in enumerate(self.activeColumns): if i > maxColumns: break name = col.getText(st) if not isinstance(name, basestring): name = "" nx, ny = tdc.GetTextExtent(name) imgId = col.getImageId(st) cw = 0 if imgId != -1: cw += isize + padding if name != "": cw += nx + 4 * padding if imgId == -1 and name == "": cw += isize + padding maxRowHeight = max(ny, maxRowHeight) columnsWidths[i] = max(columnsWidths[i], cw) rows += 1 render = wx.RendererNative.Get() #Fix column widths (use biggest between header or items) for i, col in enumerate(self.activeColumns): if i > maxColumns: break name = col.columnText imgId = col.imageId if not isinstance(name, basestring): name = "" opts = wx.HeaderButtonParams() if name != "": opts.m_labelText = name if imgId != -1: opts.m_labelBitmap = wx.EmptyBitmap(isize, isize) width = render.DrawHeaderButton(self, tdc, (0, 0, 16, 16), sortArrow=wx.HDR_SORT_ICON_NONE, params=opts) columnsWidths[i] = max(columnsWidths[i], width) tdc.SelectObject(wx.NullBitmap) maxWidth = padding * 2 for i in xrange(len(self.DEFAULT_COLS)): if i > maxColumns: break maxWidth += columnsWidths[i] mdc = wx.MemoryDC() mbmp = wx.EmptyBitmap(maxWidth, (maxRowHeight) * rows + padding * 4 + headerSize) mdc.SelectObject(mbmp) mdc.SetBackground( wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))) mdc.Clear() mdc.SetFont(font) mdc.SetTextForeground( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)) cx = padding for i, col in enumerate(self.activeColumns): if i > maxColumns: break name = col.columnText imgId = col.imageId if not isinstance(name, basestring): name = "" opts = wx.HeaderButtonParams() opts.m_labelAlignment = wx.ALIGN_LEFT if name != "": opts.m_labelText = name if imgId != -1: bmp = col.bitmap opts.m_labelBitmap = bmp width = render.DrawHeaderButton( self, mdc, (cx, padding, columnsWidths[i], headerSize), wx.CONTROL_CURRENT, sortArrow=wx.HDR_SORT_ICON_NONE, params=opts) cx += columnsWidths[i] brush = wx.Brush(wx.Colour(224, 51, 51)) pen = wx.Pen(wx.Colour(224, 51, 51)) mdc.SetPen(pen) mdc.SetBrush(brush) cy = padding * 2 + headerSize for id, st in enumerate(self.mods): cx = padding if slotMap[st.slot]: mdc.DrawRectangle(cx, cy, maxWidth - cx, maxRowHeight) for i, col in enumerate(self.activeColumns): if i > maxColumns: break name = col.getText(st) if not isinstance(name, basestring): name = "" imgId = col.getImageId(st) tcx = cx if imgId != -1: self.imageList.Draw(imgId, mdc, cx, cy, wx.IMAGELIST_DRAW_TRANSPARENT, False) tcx += isize + padding if name != "": nx, ny = mdc.GetTextExtent(name) rect = wx.Rect() rect.top = cy rect.left = cx + 2 * padding rect.width = nx rect.height = maxRowHeight + padding mdc.DrawLabel(name, rect, wx.ALIGN_CENTER_VERTICAL) tcx += nx + padding cx += columnsWidths[i] cy += maxRowHeight mdc.SelectObject(wx.NullBitmap) self.FVsnapshot = mbmp
def _drawObject(self, robj): """Draw given object to the device The object is defined as robject() from vedit.h. :param robj: object to be rendered :return: 1 on success :return: -1 on failure (vector feature marked as dead, etc.) """ if not self.dc or not self.dcTmp: return -1 Debug.msg(4, "_drawObject(): line=%d type=%d npoints=%d", robj.fid, robj.type, robj.npoints) brush = None if robj.type == TYPE_AREA and self._isSelected( Vect_get_area_centroid(self.poMapInfo, robj.fid)): pdc = self.dcTmp pen = wx.TRANSPARENT_PEN brush = wx.TRANSPARENT_BRUSH dcId = 1 self.topology['highlight'] += 1 if not self._drawSelected: return elif robj.type != TYPE_AREA and self._isSelected(robj.fid): pdc = self.dcTmp if self.settings['highlightDupl'][ 'enabled'] and self._isDuplicated(robj.fid): pen = wx.Pen(self.settings['highlightDupl']['color'], self.settings['lineWidth'], wx.SOLID) else: pen = wx.Pen(self.settings['highlight'], self.settings['lineWidth'], wx.SOLID) dcId = 1 self.topology['highlight'] += 1 if not self._drawSelected: return else: pdc = self.dc pen, brush = self._definePen(robj.type) dcId = 0 pdc.SetPen(pen) if brush: pdc.SetBrush(brush) if robj.type & (TYPE_POINT | TYPE_CENTROIDIN | TYPE_CENTROIDOUT | TYPE_CENTROIDDUP | TYPE_NODEONE | TYPE_NODETWO | TYPE_VERTEX): # -> point if dcId > 0: if robj.type == TYPE_VERTEX: dcId = 3 # first vertex elif robj.type & (TYPE_NODEONE | TYPE_NODETWO): if self.firstNode: dcId = 1 self.firstNode = False else: dcId = self.lastNodeId for i in range(robj.npoints): p = robj.point[i] if dcId > 0: pdc.SetId(dcId) dcId += 2 self._drawCross(pdc, p) else: if dcId > 0 and self._drawSegments: self.fisrtNode = True self.lastNodeId = robj.npoints * 2 - 1 dcId = 2 # first segment i = 0 while i < robj.npoints - 1: point_beg = wx.Point(robj.point[i].x, robj.point[i].y) point_end = wx.Point(robj.point[i + 1].x, robj.point[i + 1].y) # set unique id & set bbox for each segment pdc.SetId(dcId) pdc.SetPen(pen) pdc.SetIdBounds(dcId - 1, Rect(point_beg.x, point_beg.y, 0, 0)) pdc.SetIdBounds(dcId, wx.RectPP(point_beg, point_end)) pdc.DrawLine(point_beg.x, point_beg.y, point_end.x, point_end.y) i += 1 dcId += 2 pdc.SetIdBounds( dcId - 1, Rect(robj.point[robj.npoints - 1].x, robj.point[robj.npoints - 1].y, 0, 0)) else: points = list() for i in range(robj.npoints): p = robj.point[i] points.append(wx.Point(p.x, p.y)) if robj.type == TYPE_AREA: pdc.DrawPolygon(points) else: pdc.DrawLines(points)
def setUp(self): self.renderer = wx.GraphicsRenderer.GetDefaultRenderer() self.pen = wx.Pen(wx.Colour(0, 0, 0)) self.testControl = self.renderer.CreatePen(self.pen)
def SetColor(self, c): col = copy.copy(c) if c == cad.Color(255, 255, 255): col = cad.Color(0, 0, 0) pen = wx.Pen(col.ref(), self.scale + 0.99) self.GetDC().SetPen(pen)
def __DrawButton(self): """Draw the button""" # TODO using a buffered paintdc on windows with the nobg style # causes lots of weird drawing. So currently the use of a # buffered dc is dissabled for this style. if PB_STYLE_NOBG & self._style: dc = wx.PaintDC(self) else: dc = wx.AutoBufferedPaintDCFactory(self) gc = wx.GCDC(dc) # Setup dc.SetBrush(wx.TRANSPARENT_BRUSH) gc.SetBrush(wx.TRANSPARENT_BRUSH) gc.SetFont(self.Font) dc.SetFont(self.Font) gc.SetBackgroundMode(wx.TRANSPARENT) # The background needs some help to look transparent on # on Gtk and Windows if wx.Platform in ['__WXGTK__', '__WXMSW__']: gc.SetBackground(self.GetBackgroundBrush(gc)) gc.Clear() # Calc Object Positions width, height = self.GetSize() if wx.Platform == '__WXGTK__': tw, th = dc.GetTextExtent(self.Label) else: tw, th = gc.GetTextExtent(self.Label) txt_y = max((height - th) // 2, 1) if self._state['cur'] == PLATE_HIGHLIGHT: gc.SetTextForeground(self._color['htxt']) gc.SetPen(wx.TRANSPARENT_PEN) self.__DrawHighlight(gc, width, height) elif self._state['cur'] == PLATE_PRESSED: gc.SetTextForeground(self._color['htxt']) if wx.Platform == '__WXMAC__': pen = wx.Pen(GetHighlightColour(), 1, wx.PENSTYLE_SOLID) else: pen = wx.Pen(AdjustColour(self._color['press'], -80, 220), 1) gc.SetPen(pen) self.__DrawHighlight(gc, width, height) txt_x = self.__DrawBitmap(gc) if wx.Platform == '__WXGTK__': dc.DrawText(self.Label, txt_x + 2, txt_y) else: gc.DrawText(self.Label, txt_x + 2, txt_y) self.__DrawDropArrow(gc, width - 10, (height // 2) - 2) else: if self.IsEnabled(): gc.SetTextForeground(self.GetForegroundColour()) else: txt_c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT) gc.SetTextForeground(txt_c) # Draw bitmap and text if self._state['cur'] != PLATE_PRESSED: txt_x = self.__DrawBitmap(gc) if wx.Platform == '__WXGTK__': dc.DrawText(self.Label, txt_x + 2, txt_y) else: gc.DrawText(self.Label, txt_x + 2, txt_y) self.__DrawDropArrow(gc, width - 10, (height // 2) - 2)
def _on_paint(self, evt=None): '''Handler for paint events. ''' if not self.timepoints: evt.Skip() return PAD = self.PAD + self.ICON_SIZE / 2.0 ICON_SIZE = self.ICON_SIZE MIN_X_GAP = self.MIN_X_GAP TIC_SIZE = self.TIC_SIZE FONT_SIZE = self.FONT_SIZE MAX_TIMEPOINT = self.timepoints[-1] WIGGEL_NUM = 100 self.hover_timepoint = None self.curr_note_tag = None self.on_note_icon_add() #self.current_atag = None #self.on_attach_icon_add() dc = wx.BufferedPaintDC(self) dc.Clear() dc.BeginDrawing() w_win, h_win = (float(self.Size[0]), float(self.Size[1])) if self.time_x: if MAX_TIMEPOINT == 0: px_per_time = 1 else: px_per_time = max((w_win - PAD * 2.0) / MAX_TIMEPOINT, MIN_X_GAP) else: px_per_time = 1 if len(self.timepoints) == 1: x_gap = 1 else: x_gap = max(MIN_X_GAP, (w_win - PAD * 2) / (len(self.timepoints) - 1)) # y pos of line y = h_win - PAD - FONT_SIZE[1] - TIC_SIZE - 1 def icon_hover(mouse_pos, icon_pos, icon_size): '''returns whether the mouse is hovering over an icon ''' if mouse_pos is None: return False MX, MY = mouse_pos X, Y = icon_pos return (X - icon_size / 2.0 < MX < X + icon_size / 2.0 and Y - icon_size / 2.0 < MY < Y + icon_size / 2.0) # draw the timeline if self.time_x: dc.DrawLine(PAD, y, px_per_time * MAX_TIMEPOINT + PAD, y) else: dxs = range(WIGGEL_NUM + 1) dxs = [float(dx) / WIGGEL_NUM for dx in dxs] x = PAD for i, timepoint in enumerate(self.timepoints): if i > 0: n = math.sqrt(((self.timepoints[i] - self.timepoints[i - 1] ))) #instead of log can use square root ys = [ 5 * (math.sin( (math.pi) * dx)) * math.sin(2 * math.pi * dx * n) for dx in dxs ] # 10 is px height fow wiggles can change it for p, dx in enumerate(dxs[:-1]): dc.DrawLine(x + x_gap * dxs[p], y + ys[p], x + x_gap * dxs[p + 1], y + ys[p + 1]) x += x_gap font = dc.Font font.SetPixelSize(FONT_SIZE) dc.SetFont(font) # draw the ticks for i, timepoint in enumerate(self.timepoints): # if data acquisition is the only event in this timepoint skip it #evt_categories = list(set([exp.get_tag_stump(ev.get_welltag(), 1) for ev in self.events_by_timepoint[timepoint]])) #if all(evt_categories[0] == cat and cat == 'DataAcquis' for cat in evt_categories): #continue # x position of timepoint on the line if self.time_x: x = timepoint * px_per_time + PAD else: x = i * x_gap + PAD if (self.cursor_pos is not None and x - ICON_SIZE / 2 < self.cursor_pos[0] < x + ICON_SIZE / 2): dc.SetPen(wx.Pen(wx.BLACK, 3)) self.hover_timepoint = timepoint else: dc.SetPen(wx.Pen(wx.BLACK, 1)) # Draw tic marks dc.DrawLine(x, y - TIC_SIZE, x, y + TIC_SIZE) # Draw the note/attachment icon above the tick note_tags = [ tag for tag in meta.global_settings if (tag.startswith('Notes') or tag.startswith('Attachments')) and exp.get_tag_attribute(tag) == str(timepoint) ] for i, note_tag in enumerate(note_tags): if exp.get_tag_type(note_tag) == 'Notes': bmp = icons.note.Scale( ICON_SIZE, ICON_SIZE, quality=wx.IMAGE_QUALITY_HIGH).ConvertToBitmap() if exp.get_tag_type(note_tag) == 'Attachments': bmp = icons.clip.Scale( ICON_SIZE, ICON_SIZE, quality=wx.IMAGE_QUALITY_HIGH).ConvertToBitmap() dc.DrawBitmap(bmp, x - ICON_SIZE / 2.0, y - ((i + 1) * ICON_SIZE) - TIC_SIZE - 1) if icon_hover(self.cursor_pos, (x - ICON_SIZE / 2.0, y - ((i + 1) * ICON_SIZE) - TIC_SIZE - 1), ICON_SIZE): self.curr_note_tag = note_tag # draw the timepoint beneath the line time_string = exp.format_time_string(timepoint) wtext = FONT_SIZE[0] * len(time_string) htext = FONT_SIZE[1] dc.DrawText(time_string, x - wtext / 2.0, y + TIC_SIZE + 1) dc.DrawLine(x, y + TIC_SIZE + 1 + htext, x, h_win) # extension of tick towards the lineage panel dc.EndDrawing()
def _color_box(self, tw, th, y, category): go = GraphObject(x=tw + OP, y=y, w=th, h=th) go.brush_color = wx.Brush(wx.Colour(*category.color)) go.pen_color = wx.Pen(wx.Colour(*darken_color(category.color))) return go
def _on_paint(self, evt=None): '''Handler for paint events. ''' if self.nodes_by_timepoint == {}: evt.Skip() return t0 = time() #PAD = self.PAD + self.NODE_R PAD = self.PAD + self.ICON_SIZE NODE_R = self.NODE_R SM_NODE_R = self.SM_NODE_R MIN_X_GAP = self.MIN_X_GAP MIN_Y_GAP = self.MIN_Y_GAP FLASK_GAP = self.FLASK_GAP MAX_TIMEPOINT = self.timepoints[0] timepoints = self.timepoints nodes_by_tp = self.nodes_by_timepoint self.current_node = None # Node with the mouse over it w_win, h_win = (float(self.Size[0]), float(self.Size[1])) if self.time_x: if timepoints[0] == 0: px_per_time = 1 else: px_per_time = max( (w_win - PAD * 2 - FLASK_GAP) / MAX_TIMEPOINT, MIN_X_GAP) else: px_per_time = 1 if len(nodes_by_tp) == 2: x_gap = 1 else: # calculate the number of pixels to separate each generation timepoint x_gap = max(MIN_X_GAP, (w_win - PAD * 2 - FLASK_GAP) / (len(nodes_by_tp) - 2)) if len(nodes_by_tp[timepoints[0]]) == 1: y_gap = MIN_Y_GAP else: # calcuate the minimum number of pixels to separate nodes on the y axis y_gap = max(MIN_Y_GAP, (h_win - PAD * 2) / (len(nodes_by_tp[MAX_TIMEPOINT]) - 1)) nodeY = { } # Store y coords of children so we can calculate where to draw the parents Y = PAD X = w_win - PAD dc = wx.BufferedPaintDC(self) dc.Clear() dc.BeginDrawing() #dc.SetPen(wx.Pen("BLACK",1)) def hover(mouse_pos, node_pos, node_r): '''returns whether the mouse is hovering over a node mouse_pos - the mouse position node_pos - the node position node_r - the node radius ''' if mouse_pos is None: return False MX, MY = mouse_pos X, Y = node_pos return (X - node_r < MX < X + node_r and Y - node_r < MY < Y + node_r) # Iterate from leaf nodes up to the root, and draw R->L, Top->Bottom for i, t in enumerate(timepoints): if t == -1: # for the root node which is not shown X = PAD elif self.time_x: X = PAD + FLASK_GAP + t * px_per_time x_gap = PAD + FLASK_GAP + timepoints[i - 1] * px_per_time - X else: X = PAD + FLASK_GAP + (len(timepoints) - i - 2) * x_gap # Draw longitudinal time lines if t != -1: dc.SetPen(wx.Pen('#E1E2ED', 1, wx.DOT)) dc.DrawLine(X, 0, X, h_win) # LEAF NODES if i == 0: for node in sorted(nodes_by_tp[t], key=self.order_nodes): ancestor_tags = self.get_ancestral_tags(node) node_tags = node.get_tags() stateRGB = meta.getStateRGB( [tags for tags in reversed(ancestor_tags)] + node_tags ) # reverse the ancestal line so that it become progeny + curr node if node_tags: eventRGB = meta.getEventRGB( node_tags[0] ) #get all event tags for the passed node and returns the colour associated with the last event** Need to change else: eventRGB = (255, 255, 255, 100) empty_path = False # whether this path follows a harvesting event_status = False # whether any event occured to this node if len(node.get_tags()) > 0: # Event occurred dc.SetBrush(wx.Brush(eventRGB)) dc.SetPen(wx.Pen(stateRGB, 3)) event_status = True else: # No event if eventRGB == (255, 255, 255, 100) and stateRGB == (255, 255, 255, 100): dc.SetBrush(wx.Brush(wx.WHITE)) dc.SetPen(wx.Pen(wx.WHITE)) if 'Transfer|Harvest' in self.get_ancestral_tags(node): empty_path = True if hover(self.cursor_pos, (X, Y), self.NODE_R): # MouseOver if event_status: dc.SetPen(wx.Pen(stateRGB, 1)) self.current_node = node else: # No MouseOver if event_status: dc.SetPen(wx.Pen(stateRGB, 3)) if not empty_path and event_status: #dc.DrawCircle(X, Y, NODE_R) #evt_categories = list(set([exp.get_tag_stump(tag, 1) for tag in node.get_tags()])) #if all(evt_categories[0] == cat and cat == 'DataAcquis' for cat in evt_categories): if (node_tags[0].startswith('Transfer|Seed') and meta.get_field( 'Transfer|Seed|CellLineInstance|' + exp.get_tag_instance(node_tags[0])) is not None): event = 'CellLine' else: event = exp.get_tag_event(node_tags[0]) #dc.DrawBitmap(meta.getEventIcon(16.0, event), X - 16.0 / 2.0, Y - 16.0 / 2.0) dc.DrawBitmap(meta.getEventIcon(self.ICON_SIZE, event), X - self.ICON_SIZE / 2.0, Y - self.ICON_SIZE / 2.0) ## dc.DrawText(str(node.get_tags()), X, Y+NODE_R) nodeY[node.id] = Y Y += y_gap # INTERNAL NODES else: for node in sorted(nodes_by_tp[t], key=self.order_nodes): ancestor_tags = self.get_ancestral_tags(node) children_tags = self.get_children_tags(node, 2) node_tags = node.get_tags() stateRGB = meta.getStateRGB( [tags for tags in reversed(ancestor_tags)] + node_tags ) # reverse the ancestal line so that it become progeny + curr node if node_tags: eventRGB = meta.getEventRGB( node_tags[0] ) #get all event tags for the passed node and returns the colour associated with the last event** Need to change else: eventRGB = (255, 255, 255, 100) empty_path = False # whether this path follows a harvesting event_status = False # whether this node has event children_status = False # whether the children nodes have any events associated if children_tags: children_status = True ys = [] for child in node.get_children(): ys.append(nodeY[child.id]) Y = (min(ys) + max(ys)) / 2 if len(node.get_tags()) > 0: #Event occurred dc.SetBrush(wx.Brush(eventRGB)) dc.SetPen(wx.Pen(stateRGB, 3)) event_status = True else: #No event if eventRGB == (255, 255, 255, 100) and stateRGB == (255, 255, 255, 100): dc.SetBrush(wx.Brush(wx.WHITE)) dc.SetPen(wx.Pen(wx.WHITE)) else: if children_status: #dc.SetBrush(wx.Brush(wx.BLACK)) #dc.SetPen(wx.Pen(wx.BLACK)) dc.SetBrush(wx.Brush('#D1CDCF')) dc.SetPen(wx.Pen('#D1CDCF')) else: dc.SetBrush(wx.Brush(wx.WHITE)) dc.SetPen(wx.Pen(wx.WHITE)) if 'Transfer|Harvest' in self.get_ancestral_tags(node): empty_path = True if hover(self.cursor_pos, (X, Y), self.NODE_R): # MouseOver if event_status: dc.SetPen(wx.Pen(stateRGB, 1)) self.current_node = node self.SetToolTipString(self.ShowTooltipsInfo()) #print self.current_node.get_tags() #print self.current_node.get_well_ids() else: # No MouseOver if event_status: dc.SetPen(wx.Pen(stateRGB, 3)) #if t == -1: #dc.DrawRectangle(X-NODE_R, Y-NODE_R, NODE_R*2, NODE_R*2) #else: if not empty_path: if event_status: if (node_tags[0].startswith('Transfer|Seed') and meta.get_field( 'Transfer|Seed|CellLineInstance|' + exp.get_tag_instance(node_tags[0])) is not None): event = 'CellLine' else: event = exp.get_tag_event(node_tags[0]) dc.DrawBitmap( meta.getEventIcon(self.ICON_SIZE, event), X - self.ICON_SIZE / 2.0, Y - self.ICON_SIZE / 2.0) else: #dc.DrawCircle(X-NODE_R,Y, SM_NODE_R) # draws the node slightly left hand side on the furcation point #dc.SetBrush(wx.Brush(stateRGB)) dc.DrawCircle(X, Y, SM_NODE_R) #dc.DrawText(str(node.get_tags()), X, Y+NODE_R) # DRAW LINES CONNECTING THIS NODE TO ITS CHILDREN dc.SetBrush(wx.Brush('#FAF9F7')) dc.SetPen(wx.Pen(wx.BLACK, 1)) #dc.SetPen(wx.Pen('#D1CDCF')) #dc.SetPen(wx.Pen(stateRGB)) harvest_tag = False for tag in node.get_tags(): if tag.startswith('Transfer|Harvest'): harvest_tag = tag # for children of this node check whether furhter event had occured to them if not do not draw the line for child in node.get_children(): if harvest_tag: # TODO: improve performance by caching reseed # events from the previous timepoint for nn in nodes_by_tp[timepoints[i - 1]]: for tag in nn.get_tags(): if (tag.startswith( 'Transfer|Seed' ) and meta.get_field( 'Transfer|Seed|HarvestInstance|' + exp.get_tag_instance(tag)) == exp.get_tag_instance(harvest_tag)): #dc.SetPen(wx.Pen('#948BB3', 1, wx.SHORT_DASH)) dc.SetPen( wx.Pen(wx.BLACK, 1, wx.SHORT_DASH)) dc.DrawLine(X + NODE_R, Y, X + x_gap - NODE_R, nodeY[nn.id]) else: if not empty_path: if event_status: if children_status: dc.DrawLine(X + NODE_R, Y, X + x_gap - NODE_R, nodeY[child.id]) else: if children_status and stateRGB != ( 255, 255, 255, 100): #dc.SetPen(wx.Pen('#D1CDCF')) dc.SetPen(wx.Pen(wx.BLACK)) #dc.SetPen(wx.Pen(stateRGB)) dc.DrawLine(X, Y, X + x_gap, nodeY[child.id]) nodeY[node.id] = Y # Draw time slider insync with the slider in the Bench if self.timepoint_cursor is not None: timepoints = meta.get_timeline().get_unique_timepoints() if timepoints and len(timepoints) > 1: px_per_ti = (w_win - PAD * 2 - FLASK_GAP) / (len(timepoints) - 1) if self.timepoint_cursor <= max( timepoints) and self.timepoint_cursor >= min( timepoints): ti = bisect.bisect_left(timepoints, self.timepoint_cursor) time_interval = timepoints[ti] - timepoints[ti - 1] adjusted_factor = px_per_ti / time_interval X = PAD + FLASK_GAP + px_per_ti * ( ti - 1) + (self.timepoint_cursor - timepoints[ti - 1]) * adjusted_factor elif self.timepoint_cursor > max( timepoints ): # after adding new 24hr to the timeline and start to hover X = PAD + FLASK_GAP + px_per_ti * (len(timepoints) - 1) penclr = wx.Colour(178, 34, 34, wx.ALPHA_TRANSPARENT) dc.SetPen(wx.Pen('Blue', 3)) dc.DrawLine(X, 0, X, h_win) dc.EndDrawing()
def DrawPoints(self, view, dc): dx = 0 dy = 0 aN = SLICE_AXIS_LUT[self.do.slice] tolN = TOL_AXIS_LUT[self.do.slice] pos = [self.do.xp, self.do.yp, self.do.zp] if self.showPoints and ('filter' in dir(self) or len(self.points) > 0): if 'filter' in dir(self): t = self.filter['t'] #prob safe as int x = self.filter['x'] / self.voxelsize[0] y = self.filter['y'] / self.voxelsize[1] xb, yb, zb = self._calcVisibleBounds() IFoc = (x >= xb[0]) * (y >= yb[0]) * (t >= zb[0]) * ( x < xb[1]) * (y < yb[1]) * (t < zb[1]) pFoc = numpy.vstack((x[IFoc], y[IFoc], t[IFoc])).T if self.pointMode == 'splitter': pCol = self.filter['gFrac'][IFoc] > .5 pNFoc = [] #intrinsic points elif len(self.points) > 0: pointTol = self.pointTolNFoc[self.pointMode] IFoc = abs(self.points[:, aN] - pos[aN]) < 1 INFoc = abs(self.points[:, aN] - pos[aN]) < pointTol[tolN] pFoc = self.points[IFoc] pNFoc = self.points[INFoc] if self.pointMode == 'splitter': pCol = self.pointColours[IFoc] if self.pointMode == 'splitter': if 'chroma' in dir(self): dx = self.chroma.dx.ev( pFoc[:, 0] * 1e3 * self.voxelsize[0], pFoc[:, 1] * 1e3 * self.voxelsize[1]) / (1e3 * self.voxelsize[0]) dy = self.chroma.dy.ev( pFoc[:, 0] * 1e3 * self.voxelsize[0], pFoc[:, 1] * 1e3 * self.voxelsize[1]) / (1e3 * self.voxelsize[1]) else: dx = 0 * pFoc[:, 0] dy = 0 * pFoc[:, 0] if 'chroma' in dir(self): dxn = self.chroma.dx.ev( pNFoc[:, 0] * 1e3 * self.voxelsize[0], pNFoc[:, 1] * 1e3 * self.voxelsize[1]) / (1e3 * self.voxelsize[0]) dyn = self.chroma.dy.ev( pNFoc[:, 0] * 1e3 * self.voxelsize[0], pNFoc[:, 1] * 1e3 * self.voxelsize[1]) / (1e3 * self.voxelsize[1]) else: dxn = 0 * pNFoc[:, 0] dyn = 0 * pNFoc[:, 0] dc.SetBrush(wx.TRANSPARENT_BRUSH) ps = self.pointSize if self.showAdjacentPoints: dc.SetPen(wx.Pen(wx.TheColourDatabase.FindColour('BLUE'), 1)) if self.pointMode == 'splitter': for p, dxi, dyi in zip(pNFoc, dxn, dyn): self._drawBoxPixelCoords(dc, p[0], p[1], p[2], ps, ps, ps) self._drawBoxPixelCoords( dc, p[0] - dxi, 0.5 * self.do.ds.shape[1] + p[1] - dyi, p[2], ps, ps, ps) else: for p in pNFoc: self._drawBoxPixelCoords(dc, p[0], p[1], p[2], ps, ps, ps) pGreen = wx.Pen(wx.TheColourDatabase.FindColour('GREEN'), 1) pRed = wx.Pen(wx.TheColourDatabase.FindColour('RED'), 1) dc.SetPen(pGreen) if self.pointMode == 'splitter': for p, c, dxi, dyi in zip(pFoc, pCol, dx, dy): if c: dc.SetPen(pGreen) else: dc.SetPen(pRed) self._drawBoxPixelCoords(dc, p[0], p[1], p[2], ps, ps, ps) self._drawBoxPixelCoords( dc, p[0] - dxi, 0.5 * self.do.ds.shape[1] + p[1] - dyi, p[2], ps, ps, ps) else: for p in pFoc: self._drawBoxPixelCoords(dc, p[0], p[1], p[2], ps, ps, ps) dc.SetPen(wx.NullPen) dc.SetBrush(wx.NullBrush)
def OnPaint(self, evt): w, h = self.GetSize() dc = self.dcref(self) gc = wx.GraphicsContext_Create(dc) dc.Clear() gc.SetBrush(wx.Brush(self.backColour, wx.SOLID)) # Draw background gc.SetPen(wx.Pen("#777777", width=self.borderWidth, style=wx.SOLID)) gc.DrawRoundedRectangle(0, 0, w - 1, h - 1, 3) dc.SetFont( wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, face=FONT_FACE)) dc.SetTextForeground(CONTROLSLIDER_TEXT_COLOUR) # Draw text label reclab = wx.Rect(0, 1, w, 9) dc.DrawLabel(self.label, reclab, wx.ALIGN_CENTER_HORIZONTAL) # Draw knob handle val = tFromValue(self.value, self.minvalue, self.maxvalue) * 0.8 ph = val * 6.2831853072 - 4.2839899822 # (3 * math.pi / 2.2) X = math.cos(ph) * 14.23025 # math.sqrt(.1) * 45 Y = math.sin(ph) * 14.23025 gc.SetBrush(wx.Brush(self.knobColour, wx.SOLID)) gc.SetPen(wx.Pen(self.colours[self.mode], width=2, style=wx.SOLID)) self.knobPointPos = (X + 25, Y + 35) R = math.sqrt(X * X + Y * Y) gc.DrawEllipse(25 - R, 35 - R, R * 2, R * 2) gc.StrokeLine(25, 35, X + 25, Y + 35) dc.SetFont( wx.Font(CONTROLSLIDER_FONT, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, face=FONT_FACE)) # Highlight text for keyboard input if self.selected: gc.SetBrush(wx.Brush(CONTROLSLIDER_SELECTED_COLOUR, wx.SOLID)) gc.SetPen(wx.Pen(CONTROLSLIDER_SELECTED_COLOUR, self.borderWidth)) gc.DrawRoundedRectangle(2, 55, w - 4, 12, 2) # Draw text value if self.selected and self.new: val = self.new else: if self.integer: val = '%d' % self.GetValue() else: val = self.floatPrecision % self.GetValue() dc.SetTextForeground(CONTROLSLIDER_TEXT_COLOUR) dc.DrawLabel(val, wx.Rect(0, 55, w, 14), wx.ALIGN_CENTER) # Midi ctl and automation window handle if self.drawBottomPart: dc.SetFont( wx.Font(CONTROLSLIDER_FONT, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, face=FONT_FACE)) if self.midictl is not None: dc.DrawLabel("M : %d" % self.midictl, wx.Rect(5, 72, 41, 11), wx.ALIGN_CENTER_VERTICAL) else: dc.DrawLabel("M :...", wx.Rect(5, 72, 41, 11), wx.ALIGN_CENTER_VERTICAL) if self.autoPlay: gc.SetBrush(wx.Brush("#55DD55")) else: gc.SetBrush(wx.Brush("#333333", wx.TRANSPARENT)) if self.showEdit: tri = [(w - 14, 72), (w - 6, 72), (w - 10, 80), (w - 14, 72)] else: tri = [(w - 14, 72), (w - 14, 80), (w - 6, 76), (w - 14, 72)] gc.SetPen(wx.Pen("#333333", 1.5)) gc.DrawLines(tri) evt.Skip()
def UpdateDrawing(self, force=False): now = time.time() if (not force and now - self._lastDraw < 1.0) or self._backBuffer is None: return self._lastDraw = now dc = wx.MemoryDC() dc.SelectObject(self._backBuffer) dc.Clear() dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)) w, h = self.GetSizeTuple() bgLinePen = wx.Pen('#A0A0A0') tempPen = wx.Pen('#FF4040') tempSPPen = wx.Pen('#FFA0A0') tempPenBG = wx.Pen('#FFD0D0') bedTempPen = wx.Pen('#4040FF') bedTempSPPen = wx.Pen('#A0A0FF') bedTempPenBG = wx.Pen('#D0D0FF') #Draw the background up to the current temperatures. x0 = 0 t0 = [0] * len(self._points[0][0]) bt0 = 0 tSP0 = 0 btSP0 = 0 for temp, tempSP, bedTemp, bedTempSP, t in self._points: x1 = int(w - (now - t)) for x in xrange(x0, x1 + 1): for n in xrange(0, len(temp)): t = float(x - x0) / float(x1 - x0 + 1) * (temp[n] - t0[n]) + t0[n] dc.SetPen(tempPenBG) dc.DrawLine(x, h, x, h - (t * h / 300)) bt = float(x - x0) / float(x1 - x0 + 1) * (bedTemp - bt0) + bt0 dc.SetPen(bedTempPenBG) dc.DrawLine(x, h, x, h - (bt * h / 300)) t0 = temp bt0 = bedTemp tSP0 = tempSP btSP0 = bedTempSP x0 = x1 + 1 #Draw the grid for x in xrange(w, 0, -30): dc.SetPen(bgLinePen) dc.DrawLine(x, 0, x, h) tmpNr = 0 for y in xrange(h - 1, 0, -h * 50 / 300): dc.SetPen(bgLinePen) dc.DrawLine(0, y, w, y) dc.DrawText(str(tmpNr), 0, y - dc.GetFont().GetPixelSize().GetHeight()) tmpNr += 50 dc.DrawLine(0, 0, w, 0) dc.DrawLine(0, 0, 0, h) #Draw the main lines x0 = 0 t0 = [0] * len(self._points[0][0]) bt0 = 0 tSP0 = [0] * len(self._points[0][0]) btSP0 = 0 for temp, tempSP, bedTemp, bedTempSP, t in self._points: x1 = int(w - (now - t)) for x in xrange(x0, x1 + 1): for n in xrange(0, len(temp)): t = float(x - x0) / float(x1 - x0 + 1) * (temp[n] - t0[n]) + t0[n] tSP = float(x - x0) / float(x1 - x0 + 1) * ( tempSP[n] - tSP0[n]) + tSP0[n] dc.SetPen(tempSPPen) dc.DrawPoint(x, h - (tSP * h / 300)) dc.SetPen(tempPen) dc.DrawPoint(x, h - (t * h / 300)) bt = float(x - x0) / float(x1 - x0 + 1) * (bedTemp - bt0) + bt0 btSP = float(x - x0) / float(x1 - x0 + 1) * (bedTempSP - btSP0) + btSP0 dc.SetPen(bedTempSPPen) dc.DrawPoint(x, h - (btSP * h / 300)) dc.SetPen(bedTempPen) dc.DrawPoint(x, h - (bt * h / 300)) t0 = temp bt0 = bedTemp tSP0 = tempSP btSP0 = bedTempSP x0 = x1 + 1 del dc self.Refresh(eraseBackground=False) self.Update() if len(self._points) > 0 and (time.time() - self._points[0][4]) > w + 20: self._points.pop(0)
def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0, 0), size=(28, 150), outFunction=None, outLinValue=False, backColour=None): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=pos, size=size, style=wx.NO_BORDER | wx.WANTS_CHARS | wx.EXPAND) self.parent = parent if backColour: self.backgroundColour = backColour else: self.backgroundColour = BACKGROUND_COLOUR self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(self.backgroundColour) self.midiBackgroundColour = None self.knobSize = 11 self.knobHalfSize = 5 self.sliderWidth = size[0] - 23 self.meterWidth = 8 self.meterHeight = 0 self.meterOffset = 30 self.outLinValue = outLinValue self.outFunction = outFunction self.SetRange(minvalue, maxvalue) self.selected = False self.propagate = False self.midictl = None self.label = '' self.new = '' if init != None: self.SetValue(init, False) else: self.SetValue(minvalue, False) self.clampPos() self.amplitude = self.last_amplitude = 0.0 self.greybrush = wx.Brush("#444444") self.selectbrush = wx.Brush("#CCCCCC") self.selectpen = wx.Pen("#CCCCCC") self.textrect = wx.Rect(0, size[1] - 29, size[0], 16) self.hlrect = wx.Rect(0, size[1] - 28, size[0], 13) self.midirect = wx.Rect(0, size[1] - 16, size[0], 16) self.needBackground = True self.backBitmap = None self.createKnobBitmap() self.createMeterBitmap() self.Bind(wx.EVT_LEFT_DOWN, self.MouseDown) self.Bind(wx.EVT_LEFT_UP, self.MouseUp) self.Bind(wx.EVT_LEFT_DCLICK, self.DoubleClick) self.Bind(wx.EVT_MOTION, self.MouseMotion) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnResize) self.Bind(wx.EVT_KEY_DOWN, self.keyDown) self.Bind(wx.EVT_KILL_FOCUS, self.LooseFocus) if sys.platform in ['win32', 'linux2']: self.font = wx.Font(6, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, face="Monospace") else: self.font = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, face="Monospace")
def Draw(self, pdc): """ Draws all the sectors of L{PieCtrl}. :param `dc`: an instance of `wx.DC`. """ w, h = self.GetSize() self._canvasDC.BeginDrawing() self._canvasDC.SetBackground(wx.WHITE_BRUSH) self._canvasDC.Clear() if self._background != wx.NullBitmap: for ii in xrange(0, w, self._background.GetWidth()): for jj in xrange(0, h, self._background.GetHeight()): self._canvasDC.DrawBitmap(self._background, ii, jj) else: self._canvasDC.SetBackground(wx.Brush(self._backcolour)) self._canvasDC.Clear() if len(self._series) > 0: if self._angle <= pi/2: self.DrawParts(self._canvasDC, 0, int(self._height*cos(self._angle)), w, h) else: self.DrawParts(self._canvasDC, 0, 0, w, h) points = [[0, 0]]*4 triangle = [[0, 0]]*3 self._canvasDC.SetPen(wx.Pen(wx.BLACK)) angles = self.GetPartAngles() angleindex = 0 self._canvasDC.SetBrush(wx.Brush(wx.Colour(self._series[angleindex].GetColour().Red(), self._series[angleindex].GetColour().Green(), self._series[angleindex].GetColour().Blue()))) changeangle = False x = 0.0 while x <= 2*pi: changeangle = False if angleindex < len(angles): if x/pi*180.0 >= angles[angleindex+1]: changeangle = True x = angles[angleindex+1]*pi/180.0 points[0] = points[1] px = int(w/2*(1+cos(x+self._rotationangle))) py = int(h/2-sin(self._angle)*h/2*sin(x+self._rotationangle)-1) points[1] = [px, py] triangle[0] = [w / 2, h / 2] triangle[1] = points[0] triangle[2] = points[1] if x > 0: self._canvasDC.SetBrush(wx.Brush(self._series[angleindex].GetColour())) oldPen = self._canvasDC.GetPen() self._canvasDC.SetPen(wx.Pen(self._series[angleindex].GetColour())) self._canvasDC.DrawPolygon([wx.Point(pts[0], pts[1]) for pts in triangle]) self._canvasDC.SetPen(oldPen) if changeangle: angleindex = angleindex + 1 x = x + 0.05 x = 2*pi points[0] = points[1] px = int(w/2 * (1+cos(x+self._rotationangle))) py = int(h/2-sin(self._angle)*h/2*sin(x+self._rotationangle)-1) points[1] = [px, py] triangle[0] = [w / 2, h / 2] triangle[1] = points[0] triangle[2] = points[1] self._canvasDC.SetBrush(wx.Brush(self._series[angleindex].GetColour())) oldPen = self._canvasDC.GetPen() self._canvasDC.SetPen(wx.Pen(self._series[angleindex].GetColour())) self._canvasDC.DrawPolygon([wx.Point(pts[0], pts[1]) for pts in triangle]) self._canvasDC.SetPen(oldPen) angleindex = 0 x = 0.0 while x <= 2*pi: changeangle = False if angleindex < len(angles): if x/pi*180 >= angles[angleindex+1]: changeangle = True x = angles[angleindex+1]*pi/180 points[0] = points[1] points[3] = points[2] px = int(w/2 * (1+cos(x+self._rotationangle))) py = int(h/2-sin(self._angle)*h/2*sin(x+self._rotationangle)-1) points[1] = [px, py] points[2] = [px, int(py+self._height*cos(self._angle))] if w > 0: curColour = wx.Colour(self._series[angleindex].GetColour().Red()*(1.0-float(px)/w), self._series[angleindex].GetColour().Green()*(1.0-float(px)/w), self._series[angleindex].GetColour().Blue()*(1.0-float(px)/w)) if not self._showedges: self._canvasDC.SetPen(wx.Pen(curColour)) self._canvasDC.SetBrush(wx.Brush(curColour)) if sin(x+self._rotationangle) < 0 and sin(x-0.05+self._rotationangle) <= 0 and x > 0: self._canvasDC.DrawPolygon([wx.Point(pts[0], pts[1]) for pts in points]) if changeangle: angleindex = angleindex + 1 x = x + 0.05 x = 2*pi points[0] = points[1] points[3] = points[2] px = int(w/2 * (1+cos(x+self._rotationangle))) py = int(h/2-sin(self._angle)*h/2*sin(x+self._rotationangle)-1) points[1] = [px, py] points[2] = [px, int(py+self._height*cos(self._angle))] if w > 0: curColour = wx.Colour(self._series[angleindex].GetColour().Red()*(1.0-float(px)/w), self._series[angleindex].GetColour().Green()*(1.0-float(px)/w), self._series[angleindex].GetColour().Blue()*(1.0-float(px)/w)) if not self._showedges: self._canvasDC.SetPen(wx.Pen(curColour)) self._canvasDC.SetBrush(wx.Brush(curColour)) if sin(x+self._rotationangle) < 0 and sin(x-0.05+self._rotationangle) <= 0: self._canvasDC.DrawPolygon([wx.Point(pts[0], pts[1]) for pts in points]) if self._angle <= pi/2: self.DrawParts(self._canvasDC, 0, 0, w, h) else: self.DrawParts(self._canvasDC, 0, int(self._height*cos(self._angle)), w, h) self._canvasDC.EndDrawing() pdc.Blit(0, 0, w, h, self._canvasDC, 0, 0) self._legend.RecreateBackground(self._canvasDC)
def RandomPen(self): c = random.choice(colours) t = random.randint(1, 4) if not self.pen_cache.has_key((c, t)): self.pen_cache[(c, t)] = wx.Pen(c, t) return self.pen_cache[(c, t)]
def OnMenuPaint(self, event): paint = wx.PaintDC(self.MenuPanel) paint.SetPen(wx.Pen('#000000')) paint.SetBrush(wx.Brush('#dd2222')) paint.DrawRoundedRectangle(self.Mx1, self.My1, self.wdt, self.ht, 10)
def DrawPOV(self, dc): # draw the guage as a maxed circle in the center of this window. w, h = self.GetClientSize() diameter = min(w, h) xorigin = (w - diameter) / 2 yorigin = (h - diameter) / 2 xcenter = xorigin + diameter / 2 ycenter = yorigin + diameter / 2 # our 'raster'. dc.SetBrush(wx.Brush(wx.WHITE)) dc.DrawCircle(xcenter, ycenter, diameter / 2) dc.SetBrush(wx.Brush(wx.BLACK)) dc.DrawCircle(xcenter, ycenter, 10) # fancy decorations dc.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH)) dc.DrawLine(xorigin, ycenter, xorigin + diameter, ycenter) dc.DrawLine(xcenter, yorigin, xcenter, yorigin + diameter) if self.stick: if self.avail: pos = -1 # use the appropriate function to get the POV position if self.fourDir: pos = self.stick.GetPOVPosition() if self.cts: pos = self.stick.GetPOVCTSPosition() # trap invalid values if 0 <= pos <= 36000: vector = 30 else: vector = 0 # rotate CCW by 90 so that 0 is up. pos = (pos / 100) - 90 # Normalize if pos < 0: pos = pos + 360 # Stolen from wx.lib.analogclock :-) radiansPerDegree = math.pi / 180 pointX = int(round(vector * math.cos(pos * radiansPerDegree))) pointY = int(round(vector * math.sin(pos * radiansPerDegree))) # normalise value to match our actual center. nx = pointX + xcenter ny = pointY + ycenter # Draw the line dc.SetPen(wx.Pen(wx.BLUE, 2)) dc.DrawLine(xcenter, ycenter, nx, ny) # And a little thing to show the endpoint dc.SetBrush(wx.Brush(wx.BLUE)) dc.DrawCircle(nx, ny, 8)