コード例 #1
0
ファイル: Navigation.py プロジェクト: tomsqueiroz/TeraMiBand
    def draw_rubberband(self, event, x0, y0, x1, y1):
        # Use an Overlay to draw a rubberband-like bounding box.

        dc = wx.ClientDC(self.canvas)
        odc = wx.DCOverlay(self.wxoverlay, dc)
        odc.Clear()

        # Mac's DC is already the same as a GCDC, and it causes
        # problems with the overlay if we try to use an actual
        # wx.GCDC so don't try it.
        if 'wxMac' not in wx.PlatformInfo:
            dc = wx.GCDC(dc)

        height = self.canvas.figure.bbox.height
        y1 = height - y1
        y0 = height - y0

        if y1 < y0: y0, y1 = y1, y0
        if x1 < y0: x0, x1 = x1, x0

        w = x1 - x0
        h = y1 - y0
        rect = wx.Rect(x0, y0, w, h)

        rubberBandColor = '#C0C0FF'  # or load from config?

        # Set a pen for the border
        color = wx.NamedColour(rubberBandColor)
        dc.SetPen(wx.Pen(color, 1))

        # use the same color, plus alpha for the brush
        r, g, b = color.Get()
        color.Set(r, g, b, 0x60)
        dc.SetBrush(wx.Brush(color))
        dc.DrawRectangleRect(rect)
コード例 #2
0
ファイル: ring_frame.py プロジェクト: rimmartin/cctbx_project
    def _draw_ring_layer(self, dc, data, map_rel):
        """Draw a points layer.

    dc       the device context to draw on
    data     an iterable of point tuples:
             (x, y, place, radius, colour, x_off, y_off, pdata)
    map_rel  points relative to map if True, MUST BE TRUE for lightweight
    Assumes all points are the same colour, saving 100's of ms.
    """

        assert map_rel is True
        if len(data) == 0:
            return
        (lon, lat, place, radius, colour, x_off, y_off, pdata) = data[0]

        scale = 2**self._pyslip.tiles.zoom_level

        # Draw points on map/view, using transparency if implemented.
        try:
            dc = wx.GCDC(dc)
        except NotImplementedError:
            pass
        dc.SetPen(wx.Pen(colour))
        dc.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
        for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
            (x, y) = self._pyslip.ConvertGeo2View((lon, lat))
            dc.DrawCircle(x, y, radius * scale)
コード例 #3
0
    def OnPaint(self, event):
        sz = self.GetClientSize()

        pdc = wx.BufferedPaintDC(self)
        try:
            dc = wx.GCDC(pdc)
        except Exception:
            dc = pdc

        isModalDialogShown = False
        for win in wx.GetTopLevelWindows():
            if isinstance(win, wx.Dialog) and win.IsModal():
                isModalDialogShown = True
                break

        dc.SetBrush(wx.BLACK_BRUSH)
        dc.DrawRectangle(0, 0, sz[0], sz[1])
        if not self.IsEnabled() and not isModalDialogShown:
            # a modal dialog set this window to disabled (not enabled), but
            # this windows is set to disabled if no selection can
            # be made (multiple selected images)
            # this rectangle should only be drawn if this windows is set to
            # disabled programmatically and not when a modal dialog is shown
            dc.SetBrush(
                wx.Brush(wx.Colour(90, 90, 90, 255), wx.HORIZONTAL_HATCH))
            dc.DrawRectangle(0, 0, sz[0], sz[1])
        elif self._imgProxy is not None:
            self.__DrawBitmap(dc)
            self.__DrawSection(dc)

        event.Skip()
コード例 #4
0
  def DoPaint(self):
    '''Realiza el redibujo usual luego de inicializado el control'''
    dc = wx.BufferedPaintDC(self)
    ancho, alto = self.GetSize()
    dc.SetBackground(wx.BLACK_BRUSH)
    
    dc.Clear()

    dc.DrawBitmap(self._bmpDrawCache, 0,0)
    x,y=self.formula.GetPosition()
    self.ShowColourInSB()
    if self._imodo == MODO_FORMULA:
      dc.DrawBitmap(self.formula.bitmap,x,y,1) #el uno indica para usar máscara
    if self._selection !=None:
      if self._selectionBmp !=None:
        x,y=self._selection.pos
        dc.DrawBitmap(self._selectionBmp,x,y,1)
      estilo = wx.PENSTYLE_DOT_DASH
      if self._selectionBmp:
        estilo = wx.PENSTYLE_SHORT_DASH
      normalPen=wx.Pen(self._drawColour, 1, estilo )

      dc.SetBrush(wx.TRANSPARENT_BRUSH)
      dc.SetPen(normalPen)
      self._selection.Draw(dc)
    if self._imodo == MODO_DIBUJO:
        if self._figure !=None:
          pen=wx.Pen(self._drawColour, self._penWidth, wx.PENSTYLE_SOLID )
          # Define un DC que permite el suavizado
          dc = wx.GCDC(dc)
          dc.SetBrush(wx.TRANSPARENT_BRUSH)
          dc.SetPen(pen)
          self._figure.Draw(dc)
コード例 #5
0
    def OnPaint(self, event):
        """Draws the Caption and border around the controls"""
        dc = wx.PaintDC(self)
        gcdc = wx.GCDC(dc)
        gc = gcdc.GetGraphicsContext()

        # Get the working rectangle we can draw in
        rect = self.GetClientRect()

        # Setup the GraphicsContext
        gc.SetPen(wx.TRANSPARENT_PEN)
        rgb = self._color.Get(False)
        alpha = self._color.Alpha() *.2 # fade to transparent
        color2 = wx.Colour(*rgb, alpha=alpha)
        x1, y1 = rect.x, rect.y
        y2 = y1 + rect.height
        gradbrush = gc.CreateLinearGradientBrush(x1, y1,
                                                 x1, y2,
                                                 self._color,
                                                 color2)
        gc.SetBrush(gradbrush)

        # Draw the background
        gc.DrawRoundedRectangle(rect.x, rect.y,
                                rect.width, rect.height,
                                rect.height/2)
        # Use the GCDC to help draw the aa text
        gcdc.DrawLabel(self._label, rect, wx.ALIGN_CENTER)
コード例 #6
0
 def OnPaint(self, event):
     #dc = wx.BufferedPaintDC(self, self.bitmap)
     dc = wx.BufferedPaintDC(self, self.buffer, wx.BUFFER_VIRTUAL_AREA)
     #dc.DrawBitmap(self.bitmap, 0, 0)
     odc = wx.DCOverlay(self.overlay, dc)
     odc.Clear()
     if self.LeftClickFlag == 1:
         dc.SetPen(wx.Pen('red', 1))
         dc.DrawLine(self.LeX, 0, self.LeX, 150)
     if self.RightClickFlag == 1:
         dc.SetPen(wx.Pen('blue', 1))
         dc.DrawLine(self.RiX, 0, self.RiX, 150)
     #Draw a transparent rectangle to emphasize the selected area
     if (self.LeftClickFlag == 1 and self.RightClickFlag == 1
             and self.LeX != self.RiX):
         Colour = wx.Colour(139, 0, 255, 100)  #notice the alpha channel
         brush = wx.Brush(Colour)
         if self.RiX > self.LeX:
             width = self.RiX - self.LeX
             x = self.LeX
         else:
             width = self.LeX - self.RiX
             x = self.RiX
         height = self.bitmap.GetHeight()
         pdc = wx.GCDC(dc)
         pdc.SetBrush(brush)
         pdc.DrawRectangle(x, 0, width, height)
     dc.SetPen(wx.Pen('yellow', 1))
     dc.DrawLine(-self.CalcScrolledPosition(0, 0)[0] + 150, 0,
                 -self.CalcScrolledPosition(0, 0)[0] + 150, 150)
     dc.SetPen(wx.Pen('green', 1))
     dc.DrawLine(self.CurrPos, 0, self.CurrPos, 150)
     del odc
     #SKIP THE DRAWING OF RULER WHICH SEVERELY STUCK THE RENDERING
     event.Skip()
コード例 #7
0
ファイル: palette_old.py プロジェクト: wenlibin02/sk1-wx
    def _on_paint(self, event):
        if not self.palette: return
        height = self.GetSize()[1]
        pdc = wx.PaintDC(self)
        try:
            dc = wx.GCDC(self.pdc)
        except:
            dc = pdc
        dc.BeginDrawing()
        pdc.BeginDrawing()

        w = self.cell_width
        h = self.cell_height
        y = -1 * self.position * h
        for color in self.colors:
            if y > -h and y < height:
                pdc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1))
                pdc.SetBrush(wx.Brush(wx.Colour(*color)))
                pdc.DrawRectangle(0, y, w, h + 1)
            y += h

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
        pdc = dc = None
コード例 #8
0
ファイル: ANT_GUI.py プロジェクト: mengqvist/ANT
	def Draw(self, dc):
		'''
		Method for drawing stuff on self.gcdc.
		This method is responsible for drawing the entire user interface, with the exception of buttons. I add those later.
		'''

		#set up the gcdc
		dc.SetBackground(wx.Brush("White"))
		dc.Clear() # make sure you clear the bitmap!
		self.gcdc = wx.GCDC(dc) #make gcdc from the dc (for use of transparency and antialiasing)

		#make a hidden dc to which features can be drawn in unique colors and later used for hittests. This drawing only exists in memory.
		self.unique_color = (0,0,0)
		self.hidden_dc = wx.MemoryDC()
		self.hidden_dc.SelectObject(wx.EmptyBitmap(self.ClientSize[0], self.ClientSize[1]))
		self.hidden_dc.SetBackground(wx.Brush("White"))
		self.hidden_dc.Clear() # make sure you clear the bitmap!


		#draw amino acids in one of two representations
		if self.properties_layout is True:
			self.Draw_properties()
		else:
			self.Draw_wheel()

		#draw key explaining highlighting colors
		self.Draw_key()

		#draw degenerate nucleotide
		self.Draw_codon()

		#draw graph showing fequency of amino acids encoded
		self.Draw_graph()
コード例 #9
0
ファイル: doctabpanel.py プロジェクト: wenlibin02/sk1-wx
    def _on_paint(self, event):
        w, h = self.panel.GetSize()
        pdc = wx.PaintDC(self.panel)
        try:
            dc = wx.GCDC(pdc)
        except:
            dc = pdc
        dc.BeginDrawing()

        color1 = wx.Colour(0, 0, 0, 10)
        color2 = wx.Colour(0, 0, 0, 0)
        rect = wx.Rect(0, h / 2, w, h / 2)
        dc.GradientFillLinear(rect, color1, color2, nDirection=wx.NORTH)
        rect = wx.Rect(0, 0, w, h / 2)
        dc.GradientFillLinear(rect, color1, color2, nDirection=wx.SOUTH)

        pdc.SetPen(wx.Pen(wx.Colour(*const.UI_COLORS['hover_solid_border']),
                          1))
        pdc.DrawLine(0, h - 1, w, h - 1)
        pdc.DrawLine(0, 0, w, 0)

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
        pdc = dc = None
コード例 #10
0
    def onMapPaint(self, event):
        panel = event.GetEventObject()
        panel_key = None
        for k, v in self.map_panels.iteritems():
            if v == panel:
                panel_key = k
                break

        if panel_key not in self.map_bitmaps:
            return

        pdc = wx.AutoBufferedPaintDC(panel)
        try:
            dc = wx.GCDC(pdc)
        except:
            dc = pdc

        dc.BeginDrawing()

        # Draw background
        dc.DrawBitmap(self.map_bitmaps[panel_key], 0, 0)

        dc.EndDrawing()

        event.Skip()
コード例 #11
0
    def paint_matrix(self, context):

        try:
            dc = wx.GCDC(context)
        except NotImplementedError:
            dc = context

        pen_col = brush_col = self.bg_colour
        dc.SetPen(wx.Pen(pen_col, width=1))
        dc.SetBrush(wx.Brush(brush_col))

        px, py = self.stat_padding
        w, h = self.stat_bmp.Size

        for column in range(self.columns):
            for row in range(self.rows):
                point = px + (column * (w + self.spacing)), py + (row * (h + self.spacing))
                rect = wx.Rect(point, self.stat_size)

                col_val = self.value[column]
                # using Deflate to correct for the extra line width added by DrawRectangle
                # if col_val >= self.rows - row:    # Use this method if only drawing rects (not bmps)
                #     dc.DrawRectangle(rect.Deflate(self.colour_shrink))
                dc.DrawRectangle(rect.Deflate(self.colour_shrink))
                dc.DrawBitmap(self.bmp_pair[col_val >= self.rows - row], point)
コード例 #12
0
ファイル: DynamicLisaMap.py プロジェクト: Libardo1/CAST
    def drawSubView(self, lisa_idx, bufferWidth, bufferHeight, bmp):
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)

        ml = self.moran_locals[lisa_idx]
        # 0 not significant, 1 HH, 2 LL, 3 LH, 4 HL, 5 Neighborless
        sigFlag = ml[2]
        clusterFlag = ml[3]
        lm_sig = np.array(sigFlag)
        lm_q = np.array(clusterFlag)

        id_groups = [[] for i in range(6)]
        for i, sig in enumerate(lm_sig):
            if sig > 0:
                id_groups[lm_q[i]].append(i)
            else:
                id_groups[0].append(i)

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.WHITE#wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.lisa_color_group)
        draw_layer.draw(dc, view)
コード例 #13
0
ファイル: DynamicCalendarMap.py プロジェクト: lixun910/CAST
    def OnLeftDClick(self, event):
        x, y = event.GetX(), event.GetY()

        bDrawDetail = False
        year_idx = -1
        month_idx = -1

        year_idx = self.get_clicked_year(x, y)
        if year_idx >= 0:
            bDrawDetail = True
            self.selected_year = year_idx
        else:
            month_idx = self.get_clicked_month(x, y)
            if month_idx >= 0:
                self.selected_month = month_idx
                bDrawDetail = True

        if bDrawDetail:
            tmpBuffer = wx.EmptyBitmapRGBA(self.bufferWidth, self.bufferHeight,
                                           255, 255, 255, 255)
            dc = wx.BufferedDC(None, tmpBuffer)
            if not 'Linux' in stars.APP_PLATFORM \
               and 'Darwin' != stars.APP_PLATFORM:
                dc = wx.GCDC(dc)
            dc.DrawBitmap(self.buffer, 0, 0)
            dc.SetPen(wx.TRANSPARENT_PEN)
            dc.SetBrush(wx.Brush(wx.Colour(100, 100, 100, 200)))
            dc.DrawRectangle(0, 0, self.bufferWidth, self.bufferHeight)
            if year_idx >= 0:
                self.draw_year_detail(dc, year_idx)
            elif month_idx >= 0:
                self.draw_month_detail(dc, month_idx)
            self.buffer = tmpBuffer
            #dc.Destroy()
            self.Refresh(False)
コード例 #14
0
ファイル: progress.py プロジェクト: rthomas6/sdr_class
    def OnPaint(self, event):
        w, h = self.GetClientSizeTuple()
        delta = min((w - 2) // COLS, (h - 2) // ROWS)
        x_offset = (w - (COLS * delta)) // 2
        y_offset = (h - (ROWS * delta)) // 2
        dc = wx.BufferedPaintDC(self)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()
        dc = wx.GCDC(dc)
        full = delta - 4
        progress = (np.sqrt(self.progress / self.full_count) *
                    full).astype(int)
        for r in range(ROWS):
            y = r * delta + y_offset
            for c in range(COLS):
                x = c * delta + x_offset
                d = progress[r, c]
                if (d > 2) and ((delta - d) % 2 == 1):
                    d -= 1
                gap = (delta - d) // 2 + 1
                if d == full:
                    dc.SetBrush(wx.Brush(self.full_color))
                else:
                    dc.SetBrush(wx.Brush(self.color))

                dc.SetPen(wx.NullPen)
                if d:
                    dc.DrawRectangle(x + gap, y + gap, d + 1, d + 1)

                dc.SetBrush(wx.NullBrush)
                dc.SetPen(wx.Pen(wx.BLACK, 0.5))
                dc.DrawRectangle(x + 2, y + 2, delta - 1, delta - 1)
コード例 #15
0
ファイル: simGUI.py プロジェクト: wongkaiweng/LTLMoP
    def onPaint(self, event=None):
        if self.mapBitmap is None:
            return

        if event is None:
            dc = wx.ClientDC(self.window_1_pane_1)
        else:
            pdc = wx.AutoBufferedPaintDC(self.window_1_pane_1)
            try:
                dc = wx.GCDC(pdc)
            except:
                dc = pdc

        dc.BeginDrawing()

        # Draw background
        dc.DrawBitmap(self.mapBitmap, 0, 0)

        # Draw robot
        if self.robotPos is not None:
            [x,y] = map(lambda x: int(self.mapScale*x), self.robotPos) 
            dc.DrawCircle(x, y, 5)
        if self.markerPos is not None:
            [m,n] = map(lambda m: int(self.mapScale*m), self.markerPos) 
            dc.SetBrush(wx.Brush(wx.RED))
            dc.DrawCircle(m, n, 5)

        # Draw velocity vector of robot (for debugging)
        #dc.DrawLine(self.robotPos[0], self.robotPos[1], 
        #            self.robotPos[0] + self.robotVel[0], self.robotPos[1] + self.robotVel[1])

        dc.EndDrawing()
        
        if event is not None:
            event.Skip()
コード例 #16
0
ファイル: solutionbrowser.py プロジェクト: WMT-EUNICE/proute
    def addSolution(self, vrp, solution, sheet, nodeInfoList):
        # thumbnail creation
        memdc = wx.MemoryDC()
        bitmap = wx.EmptyBitmap(self.thumbnailWidth, self.thumbnailHeight)
        memdc.SelectObject(bitmap)
        dc = wx.GCDC(memdc)
        canvas = wxcanvas.WxThumbnailCanvas(dc,
                                            self.thumbnailWidth,
                                            self.thumbnailHeight)
        sheet.paint(vrp, solution, canvas, thumbnail=True)
        memdc.Destroy()
        self.GetImageList().Add(bitmap)
        # panel creation
        panel = VrpPanel(self,
                         inputData=vrp,
                         solutionData=solution,
                         styleSheet=sheet,
                         nodeInfoList=nodeInfoList)
#         newName = reduce(lambda x, y: x+ y,
#                          [ x if i % 10 != 9 else x + '\n'
#                            for i, x in enumerate(solution.name) ] )
#         print newName
        newName = solution.name if len(solution.name) < 15 \
            else solution.name[:12] + '...' + solution.name[-3:]
        self.AddPage(panel,
                     newName,
                     imageId=self.GetPageCount())
コード例 #17
0
    def _on_paint(self, event):
        w, h = self.panel.GetSize()
        pdc = wx.PaintDC(self.panel)
        try:
            dc = wx.GCDC(pdc)
        except:
            dc = pdc
        dc.BeginDrawing()

        dc.SetBrush(wx.Brush(wx.Colour(*wal.UI_COLORS['bg'])))
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, w, h)

        color1 = wx.Colour(0, 0, 0, 20)
        color2 = wx.Colour(0, 0, 0, 0)
        rect = wx.Rect(0, 0, w / 2, h)
        dc.GradientFillLinear(rect, color1, color2, nDirection=wx.EAST)

        pdc.SetPen(wx.Pen(wx.Colour(*wal.UI_COLORS['hover_solid_border']), 1))
        pdc.DrawLine(0, 0, 0, h)

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
コード例 #18
0
 def OnPaint(self, evt):
     dc = wx.PaintDC(self)
     dc = wx.GCDC(dc)
     dc.SetBackground(self.bkg_brush)
     dc.Clear()
     dc.DrawEllipticArc(100, 200, 200, 200 - self.v_pos, 90, 270)
     dc.DrawLine(100, 100, 100, 300)
コード例 #19
0
ファイル: palette_old.py プロジェクト: wenlibin02/sk1-wx
    def _on_paint(self, event):
        if not self.palette: return
        width = self.GetSize()[0]
        pdc = wx.PaintDC(self)
        try:
            dc = wx.GCDC(self.pdc)
        except:
            dc = pdc
        dc.BeginDrawing()
        pdc.BeginDrawing()

        w = self.cell_width
        h = self.cell_height
        x = -1 * self.position * w
        for color in self.colors:
            if x > -w and x < width:
                pdc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1))
                pdc.SetBrush(wx.Brush(wx.Colour(*color)))
                pdc.DrawRectangle(x, 0, w + 1, h)
            x += w

        if not pdc == dc:
            dc.EndDrawing()
            pdc.EndDrawing()
        else:
            dc.EndDrawing()
        pdc = dc = None
コード例 #20
0
ファイル: stubpanel.py プロジェクト: sk1project/wal
 def _on_paint(self, _event):
     h = self.GetSize()[1]
     pdc = wx.PaintDC(self)
     dc = wx.GCDC(pdc)
     x = 10
     y = h - self.bmp_size[1] - 10
     dc.DrawBitmap(self.bmp, x, y, True)
コード例 #21
0
ファイル: schedule_element.py プロジェクト: KevinLiuTong/map
 def __SwapBuffers(self, canvas):
     self.__buffer, self.__temp_buffer = self.__temp_buffer, self.__buffer
     self.__dc.SelectObject(self.__buffer)
     self.__temp_dc.SelectObject(self.__temp_buffer)
     self.__graphics_dc = wx.GCDC(self.__dc)
     self.__graphics_dc.SetFont(self.__dc.GetFont())
     self.__graphics_dc.SetLogicalScale(canvas.MAX_ZOOM, canvas.MAX_ZOOM)
コード例 #22
0
ファイル: pngscraper.py プロジェクト: tangentstorm/snakeeyes
 def get_dc(self):
     """return the client drawing context"""
     gc = wx.GCDC(wx.ClientDC(self.image))
     ink = wx.Colour(0x99, 0xcc, 0xff, 0x88)
     gc.SetPen(wx.Pen(ink))
     gc.SetBrush(wx.Brush(ink))
     return gc
コード例 #23
0
    def __CreateDiaBmp(self,
                       picIdx,
                       selected=False,
                       highlighted=False,
                       dropIdx=None):
        pic = self.__pictures[picIdx]
        thumbBmp = ImageCache().GetThumbBmp(pic)
        diaRect = self.GetDiaRect(picIdx)
        holeOffset = diaRect.x

        bmp = wx.Bitmap(diaRect.width, diaRect.height)
        diaNo = str(picIdx + 1)
        label = os.path.splitext(os.path.basename(pic.GetFilename()))[0]

        dc = wx.MemoryDC(bmp)
        try:
            dc = wx.GCDC(dc)
        except Exception:
            pass

        if dropIdx is not None:
            diaNo = str(dropIdx + 1)
            dropRect = self.GetDiaRect(dropIdx)

            if dropIdx > picIdx:
                holeOffset = dropRect.right + 1 - diaRect.width

        diaRect.SetX(0)
        self.__DrawDia(dc, diaRect, holeOffset, thumbBmp, diaNo, label,
                       selected, highlighted)
        return bmp
コード例 #24
0
ファイル: mopsy.py プロジェクト: QuantumRich/LTLMoP
    def onPaint(self, event=None):
        if self.mapBitmap is None:
            return

        if event is None:
            dc = wx.ClientDC(self.panel_1)
        else:
            pdc = wx.AutoBufferedPaintDC(self.panel_1)
            try:
                dc = wx.GCDC(pdc)
            except:
                dc = pdc
            else:
                self.panel_1.PrepareDC(pdc)

        self.panel_1.PrepareDC(dc)
        dc.BeginDrawing()

        # Draw background
        dc.DrawBitmap(self.mapBitmap, 0, 0)

        # Draw robot
        if self.current_region is not None:
            [x,
             y] = map(lambda x: int(self.mapScale * x),
                      self.proj.rfi.regions[self.current_region].getCenter())
            dc.DrawCircle(x, y, 5)

        dc.EndDrawing()

        if event is not None:
            event.Skip()
コード例 #25
0
ファイル: mapPanel.py プロジェクト: kai-berlin/RotorCtrlGUI
 def OnDraw(self, event=None):
     dc = wx.PaintDC(self)
     gdc = wx.GCDC(dc)
     (sx, sy) = self.GetSize()
     if (self.firstDraw):
         print(f"Panelsize: {sx}x{sy}")
         self.firstDraw = False
     x0 = 0
     y0 = sy / 2
     dc.SetPen(wx.Pen(wx.BLACK, style=wx.TRANSPARENT))
     dc.DrawRectangle(0, 0, sx, sy)
     (bx, by) = self.mapBmp.GetSize()
     dc.DrawBitmap(self.mapBmp, (sx - bx) / 2, (sy - by) / 2)
     gtx = gdc.GetGraphicsContext()
     gtx.BeginLayer(0.6)
     gdc.SetPen(wx.Pen(wx.BLUE, 5, style=wx.SHORT_DASH))
     DrawAngle(gtx, self.lowerSetpoint, offset=(sx / 2.0, sy / 2.0))
     gdc.SetPen(wx.Pen(wx.BLUE, 5, style=wx.SOLID))
     DrawAngle(gtx, self.lowerPosition, offset=(sx / 2.0, sy / 2.0))
     color = wx.Colour(70, 180, 70)
     gdc.SetPen(wx.Pen(color, 5, style=wx.SHORT_DASH))
     DrawAngle(gtx, self.upperSetpoint, offset=(sx / 2.0, sy / 2.0))
     gdc.SetPen(wx.Pen(color, 5, style=wx.SOLID))
     DrawAngle(gtx, self.upperPosition, offset=(sx / 2.0, sy / 2.0))
     gtx.EndLayer()
     if (self.newSetpoint >= 0):
         gdc.SetPen(wx.Pen(wx.RED, 5, style=wx.SOLID))
         DrawAngle(gtx, self.newSetpoint, offset=(sx / 2.0, sy / 2.0))
コード例 #26
0
ファイル: DynamicLocalG.py プロジェクト: Libardo1/CAST
    def drawSubGiMap(self, idx, bufferWidth, bufferHeight, bmp):
        """
        Draw two relative Gi* maps for current Gi* map
        """
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)

        p_values = self.space_gstar[idx]
        z_values = self.space_gstar_z[idx]

        not_sig = list(np.where(p_values > 0.05)[0])
        sig = set(np.where(p_values <= 0.05)[0])
        hotspots = list(sig.intersection(set(np.where(z_values >= 0)[0])))
        coldspots = list(sig.intersection(set(np.where(z_values < 0)[0])))
        id_groups = [not_sig, hotspots, coldspots]

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.gi_color_group)
        draw_layer.draw(dc, view)

        return bmp
コード例 #27
0
ファイル: ctrlbox.py プロジェクト: Angell1/mycura
    def OnPaint(self, evt):
        """Paint the control"""
        dc = wx.AutoBufferedPaintDCFactory(self)
        gc = wx.GCDC(dc)

        # Setup
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        gc.SetBrush(wx.TRANSPARENT_BRUSH)
        gc.SetFont(self.GetFont())
        gc.SetBackgroundMode(wx.TRANSPARENT)
        gc.Clear()

        # Paint the background
        rect = self.GetClientRect()
        self.DoPaintBackground(gc, rect, self._color, self._color2)

        # Draw the buttons
        # TODO: would be more efficient to just redraw the buttons that
        #       need redrawing.
        npos = SegmentBar.HPAD
        if self.IsVerticalMode():
            npos = SegmentBar.VPAD
        use_labels = self._style & CTRLBAR_STYLE_LABELS
        for idx, button in enumerate(self._buttons):
            npos = self.DoDrawButton(gc, npos, idx,
                                     self._selected == idx,
                                     use_labels)
コード例 #28
0
ファイル: calibrate.py プロジェクト: wmgithub/LTLMoP
    def onPaint(self, event=None):
        if self.mapBitmap is None:
            return

        if event is None:
            dc = wx.ClientDC(self.panel_map)
        else:
            pdc = wx.AutoBufferedPaintDC(self.panel_map)
            try:
                dc = wx.GCDC(pdc)
            except:
                dc = pdc

        dc.BeginDrawing()

        # Draw background
        dc.DrawBitmap(self.mapBitmap, 0, 0)

        # Draw robot
        if self.robotPos is not None:
            [x, y] = map(lambda x: int(self.mapScale * x), self.robotPos)
            dc.DrawCircle(x, y, 15)

        dc.EndDrawing()

        if event is not None:
            event.Skip()
コード例 #29
0
    def draw_rect(self, dc, rect=None, id=ImageUtil.ID_NONE, color=wx.RED, style=wx.PENSTYLE_SOLID):  # 画矩形透明区域
        # dc -> 绘图上下文,必需
        # rect -> wx.Rect类型,由外部传入
        # id -> int类型,标识图形类别
        # color -> 颜色
        # style -> 样式
        if self.start_pos is None or self.end_pos is None:
            return
        try:
            odc = wx.DCOverlay(self.overlay, dc)
            odc.Clear()
            if 'wxMac' not in wx.PlatformInfo:
                dc = wx.GCDC(dc)
            dc.SetPen(wx.Pen(colour=color,
                             width=self.overlayPenWidth.GetValue(),
                             style=style))

            bc = wx.RED
            bc = wx.Colour(bc.red, bc.green, bc.blue, 0x80)
            dc.SetBrush(wx.Brush(bc))
            if rect is None:
                rect = wx.Rect(topLeft=self.start_pos, bottomRight=self.end_pos)
            dc.DrawRectangle(rect)
            self.objects[id].append(rect)

        except Exception as e:
            Util.LOG.error(repr(e))
コード例 #30
0
ファイル: SpaceTimeCluster.py プロジェクト: lixun910/CAST
    def draw3DMap(self, bmp, idx, bufferWidth, bufferHeight):
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)
        view.zoom_extent = self.map_query_region
        subBmpHeight = self.bufferHeight / self.t
        ratio = bufferHeight / float(subBmpHeight)
        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)

        p_values = self.space_gstar[idx]
        z_values = self.space_gstar_z[idx]

        not_sig = list(np.where(p_values > 0.05)[0])
        sig = set(np.where(p_values <= 0.05)[0])
        hotspots = list(sig.intersection(set(np.where(z_values >= 0)[0])))
        coldspots = list(sig.intersection(set(np.where(z_values < 0)[0])))
        id_groups = [not_sig, hotspots, coldspots]

        self.id_groups = id_groups
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.gi_color_group)
        draw_layer.set_edge_color(stars.DEFAULT_MAP_EDGE_COLOR)

        edge_clr = wx.Colour(200, 200, 200, self.opaque)
        draw_layer.set_edge_color(edge_clr)
        draw_layer.draw(dc, view, draw3D=ratio)