예제 #1
0
    def RefreshCursor(self, dc=None):
        if self:
            if dc is None:
                dc = wx.BufferedDC(wx.ClientDC(self.Canvas.canvas),
                                   self.Canvas._Buffer)

            # Erase previous time cursor if drawn
            if self.LastCursor is not None:
                self.DrawCursor(dc, *self.LastCursor)

            # Draw new time cursor
            if self.CursorIdx is not None:
                self.LastCursor = self.Datas[self.CursorIdx]
                self.DrawCursor(dc, *self.LastCursor)
예제 #2
0
 def InitBuffer(self):
     """因为采用双缓存,所以要对缓存进行初始化
     """
     size = self.GetClientSize()
     self.buffer = wx.EmptyBitmap(size.width, size.height)
     dc = wx.BufferedDC(None, self.buffer)
     #dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
     if GSSCONF["CANV_BACKGROUND_COLOR"]:
         dc.SetBackground(wx.Brush(GSSCONF["CANV_BACKGROUND_COLOR"]))
     dc.Clear()
     self.PrepareDC(dc)
     #self.DrawLines(dc)
     self.Draw(dc)
     self.rd = 0
예제 #3
0
    def onMotion(self, event):
        ''' Called when the mouse is in motion. If the left button is
            dragging then draw a line from the last event position to the
            current one. Save the coordinants for redraws. '''
        if event.Dragging() and event.LeftIsDown():
            dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
            # dc.SetLogicalOriginPoint(event.GetPotitionTuple())

            currentPosition = event.GetPositionTuple()
            lineSegment = self.previousPosition + currentPosition
            self.drawLines(
                dc, (self.currentColour, self.currentThickness, [lineSegment]))
            self.currentLine.append(lineSegment)
            self.previousPosition = currentPosition
예제 #4
0
	def drawChart(self):
		# PIL can draw only 1-width ellipse (or is there a width=...?)
		self.drawCircles()

#		if self.options.houses:
		self.drawHouses(self.chart.houses, self.rBase, self.rInner)

		#Convert to PIL (truetype-font is not supported in wxPython)
		wxImag = self.buffer.ConvertToImage()
		self.img = Image.new('RGB', (wxImag.GetWidth(), wxImag.GetHeight()))
		self.img.fromstring(wxImag.GetData())
		self.draw = ImageDraw.Draw(self.img)

		self.drawHouseNames(self.rHouse)

		#Convert back from PIL
		wxImg = wx.EmptyImage(self.img.size[0], self.img.size[1])
		wxImg.SetData(self.img.tostring())
		self.buffer = wx.BitmapFromImage(wxImg)
		self.bdc = wx.BufferedDC(None, self.buffer)

		self.drawAscMC(self.rBase, self.rASCMC, self.rArrow)

		#calc shift of planets (in order to avoid overlapping)
		self.pshift = self.arrange(self.chart.planets.planets, self.chart.fortune, self.rPlanet)
		#PIL doesn't want to show short lines
		self.drawPlanetLines(self.pshift, self.chart.planets.planets, self.chart.fortune, self.rInner, self.rLLine, self.rAsp, self.rLLine2)
		if self.chart2 != None:
			self.pshift2 = self.arrange(self.chart2.planets.planets, self.chart2.fortune, self.rOuterPlanet)
			self.drawPlanetLines(self.pshift2, self.chart2.planets.planets, self.chart2.fortune, self.r30, self.rOuterLine)

		#Convert to PIL (truetype-font is not supported in wxPython)
		wxImag = self.buffer.ConvertToImage()
		self.img = Image.new('RGB', (wxImag.GetWidth(), wxImag.GetHeight()))
		self.img.fromstring(wxImag.GetData())
		self.draw = ImageDraw.Draw(self.img)

		self.drawPlanets(self.chart, self.pshift, self.rPlanet, self.rRetr)
		if self.chart2 != None:
			self.drawPlanets(self.chart2, self.pshift2, self.rOuterPlanet, self.rOuterRetr, True)

#		if self.options.positions:
#			self.drawAscMCPos()

		wxImg = wx.EmptyImage(self.img.size[0], self.img.size[1])
		wxImg.SetData(self.img.tostring())
		self.buffer = wx.BitmapFromImage(wxImg)

		return self.buffer
예제 #5
0
    def OnOpen(self, evt):
        dialog = wx.lib.imagebrowser.ImageDialog(None)
        if dialog.ShowModal() == wx.ID_OK:
            self.directory = dialog.GetFile()
            self.Bind(wx.EVT_PAINT, self.OnPaint)
            self.flag = 1
            try:
                # image = wx.Image(self.directory, wx.BITMAP_TYPE_ANY)
                # self.bitmap.SetBitmap(image.ConvertToBitmap())
                jpg = wx.Image(self.directory,
                               wx.BITMAP_TYPE_ANY).ConvertToBitmap()
                self.img = jpg
                dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
                dc.DrawBitmap(jpg, 20, 35, False)
            except Exception as e:
                print(e)
                wx.MessageBox(u"图片格式错误", u"ERROR", wx.OK | wx.ICON_INFORMATION,
                              self)
                self.directory = self.available
                if self.available == " ":
                    self.flag = 0
            else:
                self.available = self.directory
                # self.bitmap.SetPosition((20, 40))

        self.str.SetLabel(u"图像文件:" + self.available)
        # self.str.SetFont(wx.Font(10, wx.DECORATIVE, wx.NORMAL, wx.BOLD))
        if self.flag == 1:
            self.image = wx.Image(self.directory, wx.BITMAP_TYPE_ANY)

            w = self.image.GetWidth()
            h = self.image.GetHeight()

            # 根据图片大小调整窗口大小
            self.resize_win(w, h)

            # 初始化输入框的值
            self.w_text.SetValue(str(w))
            self.h_text.SetValue(str(h))

            # self.bitmap.SetBitmap(self.image.ConvertToBitmap())
            # self.bitmap.SetPosition((20, 35))

            # Left down & up
            # self.bitmap.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
            # self.bitmap.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)

        dialog.Destroy()
        self.Refresh()
예제 #6
0
    def OnLeftButtonEvent(self, event):
        if self.IsAutoScrolling():
            self.StopAutoScrolling()

        if event.LeftDown():
            self.SetFocus()
            self.SetXY(event)
            self.curLine = []
            self.CaptureMouse()
            self.drawing = True

        elif event.Dragging() and self.drawing:
            if BUFFERED:
                # If doing buffered drawing we'll just update the
                # buffer here and then refresh that portion of the
                # window.  Then the system will send an event and that
                # portion of the buffer will be redrawn in the
                # EVT_PAINT handler.
                dc = wx.BufferedDC(None, self.buffer)
            else:
                # otherwise we'll draw directly to a wx.ClientDC
                dc = wx.ClientDC(self)
                self.PrepareDC(dc)

            dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4))
            coords = (self.x, self.y) + self.ConvertEventCoords(event)
            self.curLine.append(coords)
            dc.DrawLine(*coords)
            self.SetXY(event)

            if BUFFERED:
                # figure out what part of the window to refresh, based
                # on what parts of the buffer we just updated
                x1, y1, x2, y2 = dc.GetBoundingBox()
                x1, y1 = self.CalcScrolledPosition(x1, y1)
                x2, y2 = self.CalcScrolledPosition(x2, y2)
                # make a rectangle
                rect = wx.Rect()
                rect.SetTopLeft((x1, y1))
                rect.SetBottomRight((x2, y2))
                rect.Inflate(2, 2)
                # refresh it
                self.RefreshRect(rect)

        elif event.LeftUp() and self.drawing:
            self.lines.append(self.curLine)
            self.curLine = []
            self.ReleaseMouse()
            self.drawing = False
예제 #7
0
파일: histpanel.py 프로젝트: zhuzhs/imagepy
 def draw(self):        
     # get client device context buffer
     dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
     dc.Clear()
     # w, h = self.GetClientSize()
 
     # the main draw process 
     print("drawing histogram")
     dc.SetPen(wx.Pen((100,100,100), width=1, style=wx.SOLID))    
     if not self.hist is None:
         for i in range(256):
             dc.DrawLine(i,80,i,80-self.hist[i])            
     dc.SetPen(wx.Pen((0,0,0), width=1, style=wx.SOLID))
     dc.DrawLine(self.x1, 80, self.x2, 0)
     dc.DrawLines([(0,0),(255,0),(255,80),(0,80),(0,0)])
예제 #8
0
    def preview_handler(self, event, image_name, image_dict, temp_bitmap,
                        show_dlg):

        self.input_name = image_name[self.threshold_choice1.GetSelection()]
        self.threshold_yuzhi = self.threshold_slider1.GetValue()
        self.threshold_max = self.threshold_slider2.GetValue()
        self.threshold_method = eval(
            self.THRESHOLD_NAME[self.threshold_choice2.GetSelection()])
        ret, temp_image = cv2.threshold( image_dict[ self.input_name ], self.threshold_yuzhi, self.threshold_max, \
        self.threshold_method )
        cv2.imwrite('temp.bmp', temp_image)
        temp_image = cv2.imread('temp.bmp')
        temp_bitmap.CopyFromBuffer(temp_image)
        dc = wx.BufferedDC(wx.ClientDC(show_dlg), temp_bitmap)
        dc.DrawBitmap(temp_bitmap, 0, 0)
예제 #9
0
 def execute_handler( self, event ):
     #import system_task and execute according the ID
     handle_interpreter.handle_explain( self.system_task, self.image_dict )
     #initialize the variable
     self.image_heigth, self.image_width = self.image_dict['image_original'].shape[:2]
     self.temp_bitmap = wx.Bitmap.FromBuffer( self.image_width, self.image_heigth, self.image_dict['image_original'] )
     self.show_dlg = wx.Dialog( self, title = 'Catchimage', size = ( self.image_width + 6, self.image_heigth + 29 ) )
     cv2.imwrite( 'temp.bmp',  self.image_dict[ self.image_name[ len( self.image_name ) - 1 ] ] )
     self.temp_image = cv2.imread( 'temp.bmp' )
     self.temp_bitmap.CopyFromBuffer( self.temp_image )
     #draw the image
     dc = wx.BufferedDC( wx.ClientDC( self.show_dlg ), self.temp_bitmap )
     dc.DrawBitmap(self.temp_bitmap, 0, 0)
     #show the image
     self.show_dlg.Show(1)
예제 #10
0
    def OnTimer(self, event):
        if self.World is not None:
            # Graphics Update
            self.bdc = wx.BufferedDC(self.cdc, self.bmp)
            self.gcdc = wx.GCDC(self.bdc)
            self.gcdc.Clear()

            self.gcdc.SetPen(wx.Pen('white'))
            self.gcdc.SetBrush(wx.Brush('white'))
            self.gcdc.DrawRectangle(0, 0, 640, 640)

            for ag in [self.World.A]:
                ag.Draw(self.gcdc)
            self.World.BBox.Draw(self.gcdc)
            self.World.Course.Draw(self.gcdc)
예제 #11
0
    def __getClientDC(self):
	if self.IsDoubleBuffered():
           dc=wx.ClientDC(self)
	else:
	   dc=wx.BufferedDC(wx.ClientDC(self))
        dc.Clear()

        font=wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.SetPointSize(11)
	dc.SetFont(font)

        brush=dc.GetBrush()
        brush.SetColour(colours.borderGradient1)
        dc.SetBackground(brush)
	return dc
    def DrawNetwork(self):
        # erase buffer
        dc = wx.BufferedDC(None,self.buffer)
        dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
        dc.Clear()

        # compute grid size for network
        size = self.GetClientSize()
        netsize = (self.network.max_x+1,self.network.max_y+1)
        grid = min(size[0]/netsize[0],size[1]/netsize[1])
        xoffset = (size[0] - (netsize[0]-1)*grid)/2
        yoffset = (size[1] - (netsize[1]-1)*grid)/2
        self.transform = (grid, (xoffset,yoffset))

        self.network.draw(dc,self.transform)
예제 #13
0
 def OnMotion(self, event):
     """
     Called when the mouse is in motion.  If the left button is
     dragging then draw a line from the last event position to the
     current one.  Save the coordinants for redraws.
     """
     if event.Dragging() and event.LeftIsDown():
         dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
         #dc.BeginDrawing()
         dc.SetPen(self.pen)
         pos = event.GetPosition()
         coords = (self.pos.x, self.pos.y, pos.x, pos.y)
         self.curLine.append(coords)
         dc.DrawLine(*coords)
         self.pos = pos
예제 #14
0
 def draw(self):
     ox, oy = self.offset
     dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
     dc.Clear()
     dc.SetPen(wx.Pen((100, 100, 100), width=1, style=wx.SOLID))
     dc.SetBrush(wx.Brush((0, 0, 0), wx.BRUSHSTYLE_TRANSPARENT))
     arr = np.zeros((10, 256, 3), dtype=np.uint8)
     arr[:] = self.cmap
     bmp = wx.Bitmap.FromBuffer(256, 10, memoryview(arr))
     dc.DrawBitmap(bmp, 0 + ox, 0 + oy)
     dc.DrawRectangle(0 + ox, 0 + oy, 256, 10)
     poly = np.array([(0, 0), (-5, 5), (5, 5), (0, 0)])
     polys = [poly + (ox + i[0], oy + 10) for i in self.pts]
     brushes = [wx.Brush(i[1:]) for i in self.pts]
     dc.DrawPolygonList(polys, brushes=brushes)
예제 #15
0
파일: canvas.py 프로젝트: shuxin/imagepy
    def update(self):
        print '---'
        if self.ips == None: return
        lay(self.box, self.imgbox)
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)

        dc.BeginDrawing()
        dc.Clear()
        self.bmp.SetData(np.getbuffer(self.ips.lookup()))
        self.draw_image(dc, self.bmp, self.imgbox, self.scales[self.scaleidx])
        if self.ips.roi != None:
            self.ips.roi.draw(dc, self.to_panel_coor)
        if self.ips.mark != None:
            self.ips.mark.draw(dc, self.to_panel_coor)
        dc.EndDrawing()
예제 #16
0
 def FlashingCursor(self, odc):
     bmp = wx.EmptyBitmap(max(1, self.bw), max(1, self.bh))
     dc = wx.BufferedDC(odc, bmp)
     if dc.Ok():
         dc.SetFont(self.font)
         dc.SetBackgroundMode(wx.SOLID)
         dc.SetTextBackground(self.bgColor)
         dc.SetTextForeground(self.fgColor)
         dc.SetBrush(wx.Brush(self.bgColor))
         dc.Clear()
         dc.DrawRectangle(0, 0, self.bw, self.bh)
         for line in range(0, self.sh):
             self.DrawLine(line, dc)
         if self.turn == 1:
             self.DrawCursor(dc)
예제 #17
0
    def Refresh(self):
        """
        Overriden base wx.Window method. Forces an immediate
        recalculation and redraw of all clock elements.
        """

        size = self.GetClientSize()
        if size.x < 1 or size.y < 1:
            return
        self.Freeze()
        self.RecalcCoords(size)
        self.DrawBox()
        dc = wx.BufferedDC(wx.ClientDC(self), self.GetClientSize())
        self.DrawHands(dc)
        self.Thaw()
예제 #18
0
    def face_detection(self, evt):
        import face_detection as detection
        face = detection.face_detection(self.directory)

        print(face)

        self.rect_Lpoint = (face[0][0], face[0][1])
        self.rect_Rpoint = (face[0][0] + face[0][2], face[0][1] + face[0][3])

        jpg = wx.Image('face.jpg', wx.BITMAP_TYPE_ANY).ConvertToBitmap()

        self.img = jpg
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.DrawBitmap(jpg, 20, 35, False)
        return
예제 #19
0
    def __init__(self, parent, stick):

        self.stick = stick
        size = (100, 100)

        wx.Panel.__init__(self, parent, -1, size=size)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)

        self.buffer = wx.EmptyBitmap(*size)
        dc = wx.BufferedDC(None, self.buffer)
        self.DrawFace(dc)
        self.DrawJoystick(dc)
예제 #20
0
    def __init__(self, chrt, size, opts, bw):
        self.chart = chrt
        self.options = opts
        self.w, self.h = size
        self.bw = bw
        self.buffer = wx.EmptyBitmap(self.w, self.h)
        self.bdc = wx.BufferedDC(None, self.buffer)
        self.chartsize = min(self.w, self.h)
        self.maxradius = self.chartsize / 2
        self.center = wx.Point(self.w / 2, self.h / 2)

        self.symbolSize = self.maxradius / 16
        self.smallSize = self.maxradius / 18
        self.fontSize = self.symbolSize
        self.fntMorinus = ImageFont.truetype(common.common.symbols,
                                             self.symbolSize)
        self.fntMorinusSmall = ImageFont.truetype(common.common.symbols,
                                                  self.smallSize)
        self.fntText = ImageFont.truetype(common.common.abc, self.fontSize)
        self.fntTextSmall = ImageFont.truetype(common.common.abc,
                                               3 * self.fontSize / 4)
        self.fntTextSmaller = ImageFont.truetype(common.common.abc,
                                                 self.fontSize / 2)
        self.signs = common.common.Signs1
        if not self.options.signs:
            self.signs = common.common.Signs2
        self.deg_symbol = u'\u00b0'

        self.SPACE = self.fontSize / 5
        self.LINE_HEIGHT = (self.SPACE + self.fontSize + self.SPACE)

        self.clrs = (self.options.clrdomicil, self.options.clrexal,
                     self.options.clrperegrin, self.options.clrcasus,
                     self.options.clrexil)
        self.hsystem = {
            'P': mtexts.txts['HSPlacidus'],
            'K': mtexts.txts['HSKoch'],
            'R': mtexts.txts['HSRegiomontanus'],
            'C': mtexts.txts['HSCampanus'],
            'E': mtexts.txts['HSEqual'],
            'W': mtexts.txts['HSWholeSign'],
            'X': mtexts.txts['HSAxial'],
            'M': mtexts.txts['HSMorinus'],
            'H': mtexts.txts['HSHorizontal'],
            'T': mtexts.txts['HSPagePolich'],
            'B': mtexts.txts['HSAlcabitus'],
            'O': mtexts.txts['HSPorphyrius']
        }
예제 #21
0
    def draw(self):
        l, t, r, b = 35, 35, 15, 35
        w = self.width - l - r
        h = self.height - t - b
        if self.data is None: return
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.Clear()

        left, low, right, high = self.extent
        self.draw_coord(dc, w, h, l, t, r, b)
        for xs, ys, c, lw in self.data:
            ys = h + t - (ys - low) * (h / (high - low))
            xs = l + (xs - left) * (1.0 / (right - left) * w)
            pts = list(zip(xs, ys))
            dc.SetPen(wx.Pen(c, width=lw, style=wx.SOLID))
            dc.DrawLines(pts)
예제 #22
0
		def on_add_handler(self, evt):
				selections = self.tree_panel.get_selections()
				for select in selections:
						print select.path
						self.load_image(select.path)
				print self.bmps
				print 'aa', selections
				self.work_panel.SetSize(self.bmps[0].Size)
				self.work_panel.SetMinSize(self.bmps[0].Size)
				self.work_panel.SetMaxSize(self.bmps[0].Size)
				self.buffer = wx.Bitmap(self.bmps[0].Size[0], self.bmps[0].Size[1])
				dc = wx.BufferedDC(None, self.buffer, wx.BUFFER_VIRTUAL_AREA)  
				dc.SetBackground(self.brush)
				dc.Clear()
				for bp in self.bmps:
						dc.DrawBitmap(bp, 0, 0, True)
예제 #23
0
    def draw(self, update=False):
        if update:
            dc = wx.ClientDC(self.toppanel)
            dc = wx.BufferedDC(dc, self.toppanel.GetSize())
        else:
            dc = wx.PaintDC(self.toppanel)

        # background
        bmp = cw.cwpy.rsrc.dialogs["CAUTION"]
        csize = self.toppanel.GetClientSize()
        cw.util.fill_bitmap(dc, bmp, csize)

        for header in self.list:
            self.draw_card(dc, header)

        return dc
예제 #24
0
    def Draw(self, odc):
        '''Draw background, lines and cursor.'''

        bmp = wx.EmptyBitmap(max(1, self.maxWidth), max(1, self.maxHeight))
        dc = wx.BufferedDC(odc, bmp)
        if dc.Ok():
            dc.SetFont(self.font)
            dc.SetBackgroundMode(wx.SOLID)
            dc.SetTextBackground(self.bgColor)
            dc.SetTextForeground(self.fgColor)
            dc.SetBrush(wx.Brush(self.bgColor))
            dc.Clear()
            dc.DrawRectangle(0, 0, self.maxWidth, self.maxHeight)
            self.DrawLines(dc)
            if self.turn == 1:
                self.DrawCursor(dc)
예제 #25
0
    def Draw(self, odc=None):
        if not odc:
            odc = wx.ClientDC(self)

        dc = wx.BufferedDC(odc)
        s = self.scroll_source
        if dc.IsOk():
            dc.SetFont(s.settings_obj.header_font)
            dc.SetBackgroundMode(wx.SOLID)
            dc.SetTextBackground(s.settings_obj.col_header_bg_color)
            dc.SetTextForeground(s.settings_obj.text_color)
            dc.SetBackground(wx.Brush(s.settings_obj.col_header_bg_color))
            dc.Clear()
            for cell, num_cells, header in self.scroll_source.table.get_col_labels(
                    s.sx):
                self.DrawHorzText(header, cell, num_cells, dc)
예제 #26
0
    def OnPaint(self, evt):
        if self.draw_flag == True:
            self.bitmap = snap4wx(self.mmc)

            pdc = wx.BufferedDC(wx.PaintDC(self))
            try:
                dc = wx.GCDC(pdc)
            except:
                dc = pdc
            dc.Clear()
            dc.DrawBitmap(self.bitmap, 0, 0, True)

            set_color(dc, 255, 0, 0, 64)
            draw_circle(dc, self.pos, r=2)

            self.Refresh(False)
예제 #27
0
    def Draw(self, odc=None):
        if not odc:
            odc = wx.ClientDC(self)

        dc = wx.BufferedDC(odc)
        if dc.IsOk():
            dc.SetFont(self.font)
            dc.SetBackgroundMode(wx.SOLID)
            dc.SetTextBackground(self.bgColor)
            dc.SetTextForeground(self.fgColor)
            dc.Clear()
            for line in range(self.sy, self.sy + self.sh):
                self.DrawLine(line, dc)
            if len(self.lines) < self.sh + self.sy:
                self.DrawEofMarker(dc)
            self.DrawCursor(dc)
예제 #28
0
    def ReDraw(self):
        """Force screen redraw, e.g., when option is changed."""
        self.drawing = True
        if BUFFERED:
            cdc = wx.ClientDC(self)
            self.PrepareDC(cdc)
            dc = wx.BufferedDC(cdc, self.buffer)
            dc.Clear()
        else:
            dc = wx.ClientDC(self)
            self.PrepareDC(dc)

        dc.BeginDrawing()
        self.DoDrawing(dc)
        dc.EndDrawing()
        self.drawing = False
예제 #29
0
    def Draw(self, odc):
        '''Draw background, lines and cursor.'''

        bmp = wx.EmptyBitmap(max(1, self.bw), max(1, self.bh))
        dc = wx.BufferedDC(odc, bmp)
        if dc.Ok():
            dc.SetFont(self.font)
            dc.SetBackgroundMode(wx.SOLID)
            dc.SetTextBackground(self.bgColor)
            dc.SetTextForeground(self.fgColor)
            dc.SetBrush(wx.Brush(self.bgColor))
            dc.Clear()
            dc.DrawRectangle(0, 0, self.bw, self.bh)
            for line in range(0, self.sh):
                self.DrawLine(line, dc)
            self.DrawCursor(dc)
예제 #30
0
    def OnMotion(self, event):
        """ Called when the mouse is in motion"""
        x, y = event.GetX(), event.GetY()
        self.display_xy_on_status(x, y)

        # prepare DC for brushing drawing
        tmp_buffer = wx.EmptyBitmap(self.bufferWidth, self.bufferHeight)
        tmp_dc = wx.BufferedDC(None, tmp_buffer)
        tmp_dc.Clear()

        if event.Dragging() and event.LeftIsDown() and self.isMouseDrawing:
            # while mouse is down and moving
            x0, y0 = self.mouse_start_pos
            if self.map_operation_type == stars.MAP_OP_PAN:
                delta_px = -x0 + x
                delta_py = -y0 + y
                tmp_dc.DrawBitmap(self.drawing_backup_buffer, delta_px,
                                  delta_py)
                self.buffer = tmp_buffer
                self.Refresh(False)
                #self.RefreshRect(wx.Rect(0,0,self.bufferWidth,self.bufferHeight))
            else:
                # drawing the selection rectangular box
                # this works for both SELECT/ZOOM
                self.current_region = (x0, y0, x, y)
                tmp_dc.DrawBitmap(self.drawing_backup_buffer, 0, 0)
                self.draw_mouse_select_box(tmp_dc, x0, y0, x, y)
                self.buffer = tmp_buffer
                self.Refresh(False)
                #self.RefreshRect(wx.Rect(0,0,self.bufferWidth,self.bufferHeight))

        elif self.isBrushing == True:
            if self.brushing_height != None and self.brushing_width !=None \
               and (self.brushing_height > 0 or self.brushing_width >0):
                if self.drawing_backup_buffer:
                    tmp_dc.DrawBitmap(self.drawing_backup_buffer, 0, 0)
                    if self.brushing_height > 0 or self.brushing_width > 0:
                        x0, y0 = x - self.brushing_width, y - self.brushing_height
                        self.current_region = (x0, y0, x, y)
                        self.draw_mouse_select_box(tmp_dc, x0, y0, x, y)
                        self.buffer = tmp_buffer
                        self.Refresh(False)
                        #self.RefreshRect(wx.Rect(0,0,self.bufferWidth,self.bufferHeight))
            else:
                if not self.map_operation_type == stars.MAP_OP_BRUSHING:
                    # prevent CMD+Tab combined keys (switch app in MAC)
                    self.reset_map_operator()