Example #1
0
    def update_list(self):
        cfg = win_data.config_get_all()
        self.list.DeleteAllItems()
        empty = True
        for i in range(12):
            if (cfg.has_key(i)):
                index = self.list.InsertStringItem(sys.maxint, "%02d" % i)
                self.list.SetStringItem(index, 1, cfg[i][0])
                self.list.SetStringItem(index, 2, cfg[i][1])
                empty = False

        self.list.resize_columns()
Example #2
0
    def update_list(self):
        cfg = win_data.config_get_all()
        self.list.DeleteAllItems()
        empty = True
        for i in range(12):
            if (cfg.has_key(i)):
                index = self.list.InsertStringItem(sys.maxint, "%02d" % i)
                self.list.SetStringItem(index, 1, cfg[i][0])
                self.list.SetStringItem(index, 2, cfg[i][1])
                empty = False

        self.list.resize_columns()
Example #3
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)
Example #4
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)