示例#1
0
    def compute_bmap(self, name, x, bric_id):
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)
            
        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        x += bmap.GetWidth()
        return x
示例#2
0
    def compute_bmap(self, name, x, bric_id):
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)

        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        x += bmap.GetWidth()
        return x
示例#3
0
    def on_paint(self, event):
        #print "Paint"
        dc = wx.PaintDC(self)
        self.DoPrepareDC(dc)
        x_size = dc.GetSize()[0]
        x = 5
        y = 5
        self.locations = []
        self.group_locations = []
        
        for i in range(len(self.groups)):
            if (self.group_expanded[i]):

                b = self.group_bmaps[i][0]
                dc.DrawBitmap(b, x, y, True)
                rect = wx.Rect(x,y,b.GetWidth(), b.GetHeight())
                self.group_locations.append((rect, i))
            
                y += self.group_bmaps[i][0].GetSize()[1] * 1.5
            
                for n,i,b,sb,db, p in self.items[self.groups[i]]:
                    if (not win_data.enabled_on_pallete(self.name, n)):
                        dc.DrawBitmap(db, x, y, True)
                    else:
                        if (win_data.selection_check(self.name, n, -1)):
                            dc.DrawBitmap(sb, x, y, True)
                        else:
                            dc.DrawBitmap(b, x, y, True)
                        rect = wx.Rect(x,y,b.GetWidth(), b.GetHeight())
                        self.locations.append((rect, n, sb))

                    y = y + b.GetHeight() + 5

                y = (y - 5) + (self.group_bmaps[i][0].GetHeight() * 0.5)

            else:
                b = self.group_bmaps[i][1]
                dc.DrawBitmap(b, x, y, True)
                rect = wx.Rect(x,y,b.GetWidth(), b.GetHeight())
                self.group_locations.append((rect, i))
            
                y += self.group_bmaps[i][1].GetSize()[1] * 1.5
            
                

        y += 24

        self.max_size = wx.Size(120, y)

        self.SetVirtualSize((120, y))
示例#4
0
    def draw_bmap(self, dc, name, x, cl, bric_id):
        # **BED** scale bitmap if needed
        #print "Drawing:", name, "x:",x, "cl:", cl, "bric_id:", bric_id

        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)

        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        y = cl - bmap.GetHeight() / 2

        dc.DrawBitmap(bmap, x, y, True)
        x += bmap.GetWidth()
        return (x, bmap.GetSize())
示例#5
0
    def draw_bmap(self, dc, name, x, cl, bric_id):
        # **BED** scale bitmap if needed
        #print "Drawing:", name, "x:",x, "cl:", cl, "bric_id:", bric_id
        
        if (name == "new_event"):
            bmap = bric_data.get_new_bmap(False)
        elif (name == 'If'):
            if_var = win_data.program().get_bric_if_variant(bric_id)
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_if_bmap(if_var, True)
            else:
                bmap = bric_data.get_if_bmap(if_var, False)
            
        else:
            if (win_data.selection_check('pwork', None, bric_id)):
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_SELECTED)
            else:
                bmap = bric_data.get_bric_bmap(name, bric_data.BRIC_NORMAL)

        y = cl - bmap.GetHeight()/2
            
        dc.DrawBitmap(bmap, x, y, True)
        x += bmap.GetWidth()
        return (x, bmap.GetSize())
示例#6
0
    def on_paint(self, event):
        #print "Paint"
        dc = wx.PaintDC(self)
        self.DoPrepareDC(dc)
        x_size = dc.GetSize()[0]
        x = 5
        y = 5
        self.locations = []
        self.group_locations = []

        for i in range(len(self.groups)):
            if (self.group_expanded[i]):

                b = self.group_bmaps[i][0]
                dc.DrawBitmap(b, x, y, True)
                rect = wx.Rect(x, y, b.GetWidth(), b.GetHeight())
                self.group_locations.append((rect, i))

                y += self.group_bmaps[i][0].GetSize()[1] * 1.5

                for n, i, b, sb, db, p in self.items[self.groups[i]]:
                    if (not win_data.enabled_on_pallete(self.name, n)):
                        dc.DrawBitmap(db, x, y, True)
                    else:
                        if (win_data.selection_check(self.name, n, -1)):
                            dc.DrawBitmap(sb, x, y, True)
                        else:
                            dc.DrawBitmap(b, x, y, True)
                        rect = wx.Rect(x, y, b.GetWidth(), b.GetHeight())
                        self.locations.append((rect, n, sb))

                    y = y + b.GetHeight() + 5

                y = (y - 5) + (self.group_bmaps[i][0].GetHeight() * 0.5)

            else:
                b = self.group_bmaps[i][1]
                dc.DrawBitmap(b, x, y, True)
                rect = wx.Rect(x, y, b.GetWidth(), b.GetHeight())
                self.group_locations.append((rect, i))

                y += self.group_bmaps[i][1].GetSize()[1] * 1.5

        y += 24

        self.max_size = wx.Size(120, y)

        self.SetVirtualSize((120, y))
示例#7
0
    def on_paint(self, event):
        dc = wx.PaintDC(self)
        self.DoPrepareDC(dc)

        dc.SetBackground(wx.Brush("white", wx.SOLID))
        dc.SetUserScale(self.zoom, self.zoom)
        dc.Clear()

        # paint mb first
        mb = device_data.get_mb_bmap()
        dc.DrawBitmap(mb, self.mb_origin[0], self.mb_origin[1], True)

        self.locations_full = []
        self.locations_empty = []

        overlay = None
        # now the current configuration
        cfg = win_data.config_get_all()
        for i in range(12):
            if (cfg.has_key(i)):
                dtype = cfg[i][0]
                orient = 0

                if (i in [1, 4, 7, 10] and (dtype == "Motor A" or dtype == "Motor B")):
                    orient = win_data.config_orient_from_loc(i)
                    if (orient == 1):
                        image_index_base = 2
                    else:
                        image_index_base = 4
                else:
                    image_index_base = 0


                if (win_data.selection_check('cwork', None, i)):
                    overlay = device_data.get_overlay_bmap(i)
                    image = device_data.get_fullsize_image(dtype, image_index_base + 1)
                else:
                    image = device_data.get_fullsize_image(dtype, image_index_base)

            else:
                dtype = None
                image = None
                offset = (0, 0)
                size = self.hit_size


            x,y = self.centres[i]
            if (i in [5, 6, 7]):
                if (image):
                    # no rotation needed
                    b = wx.BitmapFromImage(image)
                    size = b.GetSize()
                    offset = (0, 10)

                if (dtype == 'Motor A'):
                    if (i == 7  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                        size = b.GetSize()
                        x,y = self.centres[8]
                        x = x - offset[1]-90
                        y = y + size[1] - self.hit_size[1]*4
                    else:
                        x = x - self.hit_size[0]/2
                        if (i == 7):
                            y = y -size[1]+offset[1]+90
                        else:
                            y = y - size[1] + offset[1]

                elif (dtype == 'Motor B'):
                    if (i == 7  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                        size = b.GetSize()
                        x,y = self.centres[8]
                        x = x - offset[1]-90
                        y = y + size[1] - self.hit_size[1]*4.5
                    else:
                        x = x - size[0] + self.hit_size[0]*1.5
                        if (i == 7):
                            y = y -size[1]+offset[1]+90
                        else:
                            y = y - size[1] + offset[1]

                else:
                    x = x - (size[0]/2) + offset[0]
                    y = y - (size[1]) + offset[1]

            elif (i in [2, 3, 4]):
                if (image):
                    # -90 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                    size = b.GetSize()
                    offset = (10, 0)

                if (dtype == 'Motor A'):
                    if (i == 4  and orient < 0):
                        b = wx.BitmapFromImage(image)
                        size = b.GetSize()
                        x,y = self.centres[5]
                        x = x - self.hit_size[0]*1.5
                        y = y - size[1] + self.hit_size[1]*1 +offset[1]
                    else:

                        y = y - size[1] + self.hit_size[1]/2
                        if (i == 4):
                            x = x -size[0]+offset[0]+90
                        else:
                            x = x - size[0]+offset[0]

                elif (dtype == 'Motor B'):
                    if (i == 4  and orient < 0):
                        b = wx.BitmapFromImage(image)
                        size = b.GetSize()
                        x,y = self.centres[5]
                        x = x - self.hit_size[0]*2
                        y = y - size[1] + self.hit_size[1]*1 +offset[1]
                    else:
                        y = y - size[1] + self.hit_size[1]
                        if (i == 4):
                            x = x -size[0]+offset[0]+90
                        else:
                            x = x - size[0]+offset[0]

                else:
                    x = x - (size[0]) + offset[0]
                    y = y - (size[1]/2) + offset[1]

            elif (i in [8, 9, 10]):
                if (image):
                    # +90 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                    size = b.GetSize()
                    offset = (-10, 0)


                if (dtype == 'Motor A'):
                    if (i == 10  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                        size = b.GetSize()
                        x,y = self.centres[11]
                        x = x - self.hit_size[0]*1 + offset[1]
                        y = y - 90 + offset[0]
                    else:

                        y = y + size[1] - self.hit_size[1]*3
                        if (i == 10):
                            x = x +offset[0]-90
                        else:
                            x = x +offset[0]

                elif (dtype == 'Motor B'):
                    if (i == 10  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                        size = b.GetSize()
                        x,y = self.centres[11]
                        x = x - self.hit_size[0]*0.5 + offset[1]
                        y = y - 90 + offset[0]
                    else:
                        y = y - size[1] + self.hit_size[1]*1.5
                        if (i == 10):
                            x = x +offset[0]-90
                        else:
                            x = x +offset[0]

                else:
                    x = x + offset[0]
                    y = y - (size[1]/2) + offset[1]

            else:
                if (image):
                    # 180 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                    size = b.GetSize()
                    offset = (0, -10)


                if (dtype == 'Motor A'):
                    if (i == 1  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                        size = b.GetSize()
                        x,y = self.centres[2]
                        x = x - size[0] + self.hit_size[0]
                        y = y - 90 + offset[1]
                    else:

                        x = x - self.hit_size[0]*2
                        if (i == 1):
                            y = y +offset[1]-90
                        else:
                            y = y + offset[1]

                elif (dtype == 'Motor B'):
                    if (i == 1  and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                        size = b.GetSize()
                        x,y = self.centres[2]
                        x = x - size[0] + self.hit_size[0]
                        y = y - 90 + + self.hit_size[1]*0.5 + offset[1]
                    else:
                        x = x - size[0] + self.hit_size[0]*1
                        if (i == 1):
                            y = y +offset[1]-90
                        else:
                            y = y + offset[1]

                else:
                    x = x - (size[0]/2) + offset[0]
                    y = y + offset[1]

            if (image):
                dc.DrawBitmap(b, x, y, True)
                self.locations_full.append((i, cfg[i][0], wx.Rect(x, y, size[0], size[1])))
            else:
                self.locations_empty.append((i, wx.Rect(x, y, size[0], size[1])))

        if (not overlay):
            overlay = device_data.get_overlay_bmap()

        dc.DrawBitmap(overlay, self.mb_origin[0], self.mb_origin[1], True)

        self.SetVirtualSize(self.window_size)
示例#8
0
    def on_paint(self, event):
        dc = wx.PaintDC(self)
        self.DoPrepareDC(dc)

        dc.SetBackground(wx.Brush("white", wx.SOLID))
        dc.SetUserScale(self.zoom, self.zoom)
        dc.Clear()

        # paint mb first
        mb = device_data.get_mb_bmap()
        dc.DrawBitmap(mb, self.mb_origin[0], self.mb_origin[1], True)

        self.locations_full = []
        self.locations_empty = []

        overlay = None
        # now the current configuration
        cfg = win_data.config_get_all()
        for i in range(12):
            if (cfg.has_key(i)):
                dtype = cfg[i][0]
                orient = 0

                if (i in [1, 4, 7, 10]
                        and (dtype == "Motor A" or dtype == "Motor B")):
                    orient = win_data.config_orient_from_loc(i)
                    if (orient == 1):
                        image_index_base = 2
                    else:
                        image_index_base = 4
                else:
                    image_index_base = 0

                if (win_data.selection_check('cwork', None, i)):
                    overlay = device_data.get_overlay_bmap(i)
                    image = device_data.get_fullsize_image(
                        dtype, image_index_base + 1)
                else:
                    image = device_data.get_fullsize_image(
                        dtype, image_index_base)

            else:
                dtype = None
                image = None
                offset = (0, 0)
                size = self.hit_size

            x, y = self.centres[i]
            if (i in [5, 6, 7]):
                if (image):
                    # no rotation needed
                    b = wx.BitmapFromImage(image)
                    size = b.GetSize()
                    offset = (0, 10)

                if (dtype == 'Motor A'):
                    if (i == 7 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                        size = b.GetSize()
                        x, y = self.centres[8]
                        x = x - offset[1] - 90
                        y = y + size[1] - self.hit_size[1] * 4
                    else:
                        x = x - self.hit_size[0] / 2
                        if (i == 7):
                            y = y - size[1] + offset[1] + 90
                        else:
                            y = y - size[1] + offset[1]

                elif (dtype == 'Motor B'):
                    if (i == 7 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                        size = b.GetSize()
                        x, y = self.centres[8]
                        x = x - offset[1] - 90
                        y = y + size[1] - self.hit_size[1] * 4.5
                    else:
                        x = x - size[0] + self.hit_size[0] * 1.5
                        if (i == 7):
                            y = y - size[1] + offset[1] + 90
                        else:
                            y = y - size[1] + offset[1]

                else:
                    x = x - (size[0] / 2) + offset[0]
                    y = y - (size[1]) + offset[1]

            elif (i in [2, 3, 4]):
                if (image):
                    # -90 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                    size = b.GetSize()
                    offset = (10, 0)

                if (dtype == 'Motor A'):
                    if (i == 4 and orient < 0):
                        b = wx.BitmapFromImage(image)
                        size = b.GetSize()
                        x, y = self.centres[5]
                        x = x - self.hit_size[0] * 1.5
                        y = y - size[1] + self.hit_size[1] * 1 + offset[1]
                    else:

                        y = y - size[1] + self.hit_size[1] / 2
                        if (i == 4):
                            x = x - size[0] + offset[0] + 90
                        else:
                            x = x - size[0] + offset[0]

                elif (dtype == 'Motor B'):
                    if (i == 4 and orient < 0):
                        b = wx.BitmapFromImage(image)
                        size = b.GetSize()
                        x, y = self.centres[5]
                        x = x - self.hit_size[0] * 2
                        y = y - size[1] + self.hit_size[1] * 1 + offset[1]
                    else:
                        y = y - size[1] + self.hit_size[1]
                        if (i == 4):
                            x = x - size[0] + offset[0] + 90
                        else:
                            x = x - size[0] + offset[0]

                else:
                    x = x - (size[0]) + offset[0]
                    y = y - (size[1] / 2) + offset[1]

            elif (i in [8, 9, 10]):
                if (image):
                    # +90 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90(clockwise=True))
                    size = b.GetSize()
                    offset = (-10, 0)

                if (dtype == 'Motor A'):
                    if (i == 10 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                        size = b.GetSize()
                        x, y = self.centres[11]
                        x = x - self.hit_size[0] * 1 + offset[1]
                        y = y - 90 + offset[0]
                    else:

                        y = y + size[1] - self.hit_size[1] * 3
                        if (i == 10):
                            x = x + offset[0] - 90
                        else:
                            x = x + offset[0]

                elif (dtype == 'Motor B'):
                    if (i == 10 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                        size = b.GetSize()
                        x, y = self.centres[11]
                        x = x - self.hit_size[0] * 0.5 + offset[1]
                        y = y - 90 + offset[0]
                    else:
                        y = y - size[1] + self.hit_size[1] * 1.5
                        if (i == 10):
                            x = x + offset[0] - 90
                        else:
                            x = x + offset[0]

                else:
                    x = x + offset[0]
                    y = y - (size[1] / 2) + offset[1]

            else:
                if (image):
                    # 180 rotation needed
                    b = wx.BitmapFromImage(image.Rotate90().Rotate90())
                    size = b.GetSize()
                    offset = (0, -10)

                if (dtype == 'Motor A'):
                    if (i == 1 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                        size = b.GetSize()
                        x, y = self.centres[2]
                        x = x - size[0] + self.hit_size[0]
                        y = y - 90 + offset[1]
                    else:

                        x = x - self.hit_size[0] * 2
                        if (i == 1):
                            y = y + offset[1] - 90
                        else:
                            y = y + offset[1]

                elif (dtype == 'Motor B'):
                    if (i == 1 and orient < 0):
                        b = wx.BitmapFromImage(image.Rotate90(clockwise=False))
                        size = b.GetSize()
                        x, y = self.centres[2]
                        x = x - size[0] + self.hit_size[0]
                        y = y - 90 + +self.hit_size[1] * 0.5 + offset[1]
                    else:
                        x = x - size[0] + self.hit_size[0] * 1
                        if (i == 1):
                            y = y + offset[1] - 90
                        else:
                            y = y + offset[1]

                else:
                    x = x - (size[0] / 2) + offset[0]
                    y = y + offset[1]

            if (image):
                dc.DrawBitmap(b, x, y, True)
                self.locations_full.append(
                    (i, cfg[i][0], wx.Rect(x, y, size[0], size[1])))
            else:
                self.locations_empty.append(
                    (i, wx.Rect(x, y, size[0], size[1])))

        if (not overlay):
            overlay = device_data.get_overlay_bmap()

        dc.DrawBitmap(overlay, self.mb_origin[0], self.mb_origin[1], True)

        self.SetVirtualSize(self.window_size)