예제 #1
0
 def draw(self,dc):
     if self.visible in ['on','yes']:
         color = get_color(self.outline_color)
         weight = self.outline_weight
         size = self.size
         fill_color = get_color(self.fill_color)
         fill_style = fill_style_map[self.fill_style]
         symbol = self.symbol
         dc.SetPen(wx.wxPen(color,weight))
         dc.SetBrush(wx.wxBrush(fill_color,fill_style))
         self._drawmarkers(dc, self.scaled, symbol, size)
         dc.SetPen(wx.wxNullPen)
         dc.SetBrush(wx.wxNullBrush)
예제 #2
0
 def changeDropTarget(self, new):
     bmp = self._dropTargetRead(new)
     w1, h1 = self.dropTarget.GetWidth(), self.dropTarget.GetHeight()
     w, h = bmp.GetWidth(), bmp.GetHeight()
     x1, y1 = int((w1 - w) / 2.0), int((h1 - h) / 2.0)
     bbdata = wx.wxMemoryDC()
     bbdata.SelectObject(self.dropTarget)
     bbdata.SetPen(wx.wxTRANSPARENT_PEN)
     bbdata.SetBrush(wx.wxBrush(wx.wxSystemSettings_GetColour(wx.wxSYS_COLOUR_MENU), wx.wxSOLID))
     bbdata.DrawRectangle(0, 0, w1, h1)
     bbdata.SetPen(wx.wxBLACK_PEN)
     bbdata.SetBrush(wx.wxTRANSPARENT_BRUSH)
     bbdata.DrawRectangle(x1 - 1, y1 - 1, w + 2, h + 2)
     bbdata.DrawBitmap(bmp, x1, y1, True)
     try:
         self.dropTargetRefresh()
     except:
         pass
예제 #3
0
 def save(self,path,image_type):
     w,h = self.GetSizeTuple()
     bitmap = wx.wxEmptyBitmap(w,h)
     dc = wx.wxMemoryDC()
     dc.SelectObject(bitmap)
     #self.update()
     # The background isn't drawn right without this cluge.
     #fill_color = get_color(self.background_color)
     fill_color = get_color('white')
     dc.SetPen(wx.wxPen(fill_color))
     dc.SetBrush(wx.wxBrush(fill_color)) #how to handle transparency???
     dc.DrawRectangle(0,0,w,h)
     dc.SetPen(wx.wxNullPen)
     dc.SetBrush(wx.wxNullBrush)
     # end cluge
     self.draw(dc)
     image = wx.wxImageFromBitmap(bitmap)
     wx.wxInitAllImageHandlers()
     image.SaveFile(path,image_type_map[image_type])
예제 #4
0
 def changeDropTarget(self, new):
     bmp = self._dropTargetRead(new)
     w1, h1 = self.dropTarget.GetWidth(), self.dropTarget.GetHeight()
     w, h = bmp.GetWidth(), bmp.GetHeight()
     x1, y1 = int((w1 - w) / 2.0), int((h1 - h) / 2.0)
     bbdata = wx.wxMemoryDC()
     bbdata.SelectObject(self.dropTarget)
     bbdata.SetPen(wx.wxTRANSPARENT_PEN)
     bbdata.SetBrush(
         wx.wxBrush(wx.wxSystemSettings_GetColour(wx.wxSYS_COLOUR_MENU),
                    wx.wxSOLID))
     bbdata.DrawRectangle(0, 0, w1, h1)
     bbdata.SetPen(wx.wxBLACK_PEN)
     bbdata.SetBrush(wx.wxTRANSPARENT_BRUSH)
     bbdata.DrawRectangle(x1 - 1, y1 - 1, w + 2, h + 2)
     bbdata.DrawBitmap(bmp, x1, y1, True)
     try:
         self.dropTargetRefresh()
     except:
         pass
예제 #5
0
    def draw_graph_area(self,dc=None):
        if not dc: dc = wx.wxClientDC(self)
        self.layout_data() # just to check how real time plot would go...

        gb = self.graph_box
        #clear the plot area
        # SHOULD SET PEN HERE TO FILL BACKGROUND WITH CORRECT COLOR
        fill_color = get_color('white')
        dc.SetPen(wx.wxPen(fill_color))
        dc.SetBrush(wx.wxBrush(fill_color))
        # NEEDED FOR REAL-TIME PLOTTING
        dc.DrawRectangle(gb.left(),gb.top(),
                         gb.width()+1,gb.height()+1)
        #needed to make sure images stay within bounds
        ##dc.SetClippingRegion(gb.left()-1,gb.top()-1,
        ##                     gb.width()+2,gb.height()+2)  # mod by GAP 26092003
        dc.SetClippingRegion(int(gb.left()-1),int(gb.top()-1),
                             int(gb.width()+2),int(gb.height()+2))
        # draw images
        self.image_list.draw(dc)
        dc.DestroyClippingRegion()
        # draw axes lines and tick marks
        t1 = time.clock()
        for axis in self.axes:
            axis.draw_lines(dc)
        #for axis in self.axes:
        #    axis.draw_grid_lines(dc)
        #for axis in self.axes:
        #    axis.draw_ticks(dc)
        t2 = time.clock()
        #print 'lines:', t2 - t1
        #draw border
        t1 = time.clock(); self.border.draw(dc); t2 = time.clock()
        #print 'border:', t2 - t1
        # slightly larger clipping area so that marks
        # aren't clipped on edges
        # should really clip markers and lines separately
        # draw lines
        self.line_list.clip_box(self.graph_box)
        self.line_list.draw(dc)
예제 #6
0
 def draw(self, dc):
     # drawing rectangle!
     dc.SetBrush(wx.wxBrush(wx.wxColour(192, 192, 192), wx.wxSOLID))
     dc.DrawRectangle(self._position[0], self._position[1], self._size[0],
                      self._size[1])
예제 #7
0
    def draw(self, dc):
        normal_colour = (192, 192, 192)
        selected_colour = (255, 0, 246)
        blocked_colour = (16, 16, 16)

        colour = normal_colour

        if self.selected:
            colour = [
                selected_colour[i] * 0.5 + colour[i] * 0.5 for i in range(3)
            ]

        if self.blocked:
            colour = [
                blocked_colour[i] * 0.5 + colour[i] * 0.5 for i in range(3)
            ]

        colour = tuple([int(i) for i in colour])

        blockFillColour = wx.wxColour(*colour)

        #         # we're going to alpha blend a purplish sheen if this glyph is active
        #         if self.selected:
        #             # sheen: 255, 0, 246
        #             # alpha-blend with 192, 192, 192 with alpha 0.5 yields
        #             #  224, 96, 219
        #             blockFillColour = wx.wxColour(224, 96, 219)
        #         else:
        #             blockFillColour = wx.wxColour(192, 192, 192)

        # default pen and font
        dc.SetBrush(wx.wxBrush(blockFillColour, wx.wxSOLID))
        dc.SetPen(wx.wxPen('BLACK', 1, wx.wxSOLID))
        dc.SetFont(wx.wxNORMAL_FONT)

        # calculate our size
        # the width is the maximum(textWidth + twice the horizontal border,
        # all ports, horizontal borders and inter-port borders added up)
        maxPorts = max(self._numInputs, self._numOutputs)
        portsWidth = 2 * coGlyph._horizBorder + \
                     maxPorts * coGlyph._pWidth + \
                     (maxPorts - 1 ) * coGlyph._horizSpacing

        # determine maximum textwidth and height
        tex = 0
        tey = 0

        for l in self._labelList:
            temptx, tempty = dc.GetTextExtent(l)

            if temptx > tex:
                tex = temptx

            if tempty > tey:
                tey = tempty

        # this will be calculated with the max width, so fine
        textWidth = tex + 2 * coGlyph._horizBorder

        self._size = (max(textWidth, portsWidth),
                      tey * len(self._labelList) + 2 * coGlyph._vertBorder)

        # draw the main rectangle
        dc.DrawRectangle(self._position[0], self._position[1], self._size[0],
                         self._size[1])

        #dc.DrawRoundedRectangle(self._position[0], self._position[1],
        #                        self._size[0], self._size[1], radius=5)

        initY = self._position[1] + coGlyph._vertBorder
        for l in self._labelList:
            dc.DrawText(l, self._position[0] + coGlyph._horizSpacing, initY)
            initY += tey

        # then the inputs
        horizOffset = self._position[0] + coGlyph._horizBorder
        horizStep = coGlyph._pWidth + coGlyph._horizSpacing
        connBrush = wx.wxBrush("GREEN")
        disconnBrush = wx.wxBrush("RED")

        for i in range(self._numInputs):
            brush = [disconnBrush, connBrush][bool(self.inputLines[i])]
            self.drawPort(dc, brush,
                          (horizOffset + i * horizStep, self._position[1]))

        lx = self._position[1] + self._size[1] - coGlyph._pHeight
        for i in range(self._numOutputs):
            brush = [disconnBrush, connBrush][bool(self.outputLines[i])]
            self.drawPort(dc, brush, (horizOffset + i * horizStep, lx))
예제 #8
0
 def draw(self, dc):
     # drawing rectangle!
     dc.SetBrush(wx.wxBrush(wx.wxColour(192,192,192), wx.wxSOLID))
     dc.DrawRectangle(self._position[0], self._position[1],
                      self._size[0], self._size[1])
예제 #9
0
    def draw(self, dc):
        normal_colour = (192, 192, 192)
        selected_colour = (255, 0, 246)
        blocked_colour = (16, 16, 16)

        colour = normal_colour

        if self.selected:
            colour = [selected_colour[i] * 0.5 + colour[i] * 0.5
                      for i in range(3)]

        if self.blocked:
            colour = [blocked_colour[i] * 0.5 + colour[i] * 0.5
                      for i in range(3)]

        colour = tuple([int(i) for i in colour])

        blockFillColour = wx.wxColour(*colour)

        
#         # we're going to alpha blend a purplish sheen if this glyph is active
#         if self.selected:
#             # sheen: 255, 0, 246
#             # alpha-blend with 192, 192, 192 with alpha 0.5 yields
#             #  224, 96, 219
#             blockFillColour = wx.wxColour(224, 96, 219)
#         else:
#             blockFillColour = wx.wxColour(192, 192, 192)
        
        # default pen and font
        dc.SetBrush(wx.wxBrush(blockFillColour, wx.wxSOLID))
        dc.SetPen(wx.wxPen('BLACK', 1, wx.wxSOLID))
        dc.SetFont(wx.wxNORMAL_FONT)
        
        # calculate our size
        # the width is the maximum(textWidth + twice the horizontal border,
        # all ports, horizontal borders and inter-port borders added up)
        maxPorts = max(self._numInputs, self._numOutputs)
        portsWidth = 2 * coGlyph._horizBorder + \
                     maxPorts * coGlyph._pWidth + \
                     (maxPorts - 1 ) * coGlyph._horizSpacing

        # determine maximum textwidth and height
        tex = 0
        tey = 0

        for l in self._labelList:
            temptx, tempty = dc.GetTextExtent(l)

            if temptx > tex:
                tex = temptx

            if tempty > tey:
                tey = tempty
        
        # this will be calculated with the max width, so fine
        textWidth = tex + 2 * coGlyph._horizBorder
        
        self._size = (max(textWidth, portsWidth),
                      tey * len(self._labelList) + 2 * coGlyph._vertBorder)

        # draw the main rectangle
        dc.DrawRectangle(self._position[0], self._position[1],
                         self._size[0], self._size[1])

        #dc.DrawRoundedRectangle(self._position[0], self._position[1],
        #                        self._size[0], self._size[1], radius=5)

        initY = self._position[1] + coGlyph._vertBorder
        for l in self._labelList:
            dc.DrawText(l,
                        self._position[0] + coGlyph._horizSpacing,
                        initY)
            initY += tey

        # then the inputs
        horizOffset = self._position[0] + coGlyph._horizBorder
        horizStep = coGlyph._pWidth + coGlyph._horizSpacing
        connBrush = wx.wxBrush("GREEN")
        disconnBrush = wx.wxBrush("RED")
        
        for i in range(self._numInputs):
            brush = [disconnBrush, connBrush][bool(self.inputLines[i])]
            self.drawPort(dc, brush,
                          (horizOffset + i * horizStep,
                           self._position[1]))

        lx = self._position[1] + self._size[1] - coGlyph._pHeight
        for i in range(self._numOutputs):
            brush = [disconnBrush, connBrush][bool(self.outputLines[i])]
            self.drawPort(dc, brush,
                          (horizOffset + i * horizStep,
                           lx))