Esempio n. 1
0
    def setup_zones_and_locations(self):
        mb_x,mb_y = device_data.get_mb_bmap().GetSize()
##        if (self.zoom != 1.0):
##            mb_x *= self.zoom
##            mb_y *= self.zoom

        dev_x,dev_y = (mb_x/3,mb_y/3)
        mb_l = mb_x
        mb_r = mb_x * 2
        mb_t = mb_y
        mb_b = mb_y * 2

        self.mb_origin = [mb_l, mb_t]
        self.mb_size = (mb_x, mb_y)
        self.hit_size = (dev_x, dev_y)
        self.window_size = (mb_x*3, mb_y*3)

        self.centres = [(mb_l+(mb_x/2), mb_b),      # 0
                   (mb_l+(dev_x/2), mb_b),          # 1
                   (mb_l, mb_b - (dev_y/2)),        # 2
                   (mb_l, mb_b - (mb_y/2)),         # 3
                   (mb_l, mb_t + (dev_y/2)),        # 4
                   (mb_l+(dev_x/2), mb_t),          # 5
                   (mb_l+(mb_x/2), mb_t),           # 6
                   (mb_r-(dev_x/2), mb_t),          # 7
                   (mb_r, mb_t+(dev_y/2)),          # 8
                   (mb_r, mb_t+(mb_y/2)),           # 9
                   (mb_r, mb_b-(dev_y/2)),          # 10
                   (mb_r-(dev_x/2), mb_b),          # 11
                   ]
Esempio n. 2
0
    def setup_zones_and_locations(self):
        mb_x, mb_y = device_data.get_mb_bmap().GetSize()
        ##        if (self.zoom != 1.0):
        ##            mb_x *= self.zoom
        ##            mb_y *= self.zoom

        dev_x, dev_y = (mb_x / 3, mb_y / 3)
        mb_l = mb_x
        mb_r = mb_x * 2
        mb_t = mb_y
        mb_b = mb_y * 2

        self.mb_origin = [mb_l, mb_t]
        self.mb_size = (mb_x, mb_y)
        self.hit_size = (dev_x, dev_y)
        self.window_size = (mb_x * 3, mb_y * 3)

        self.centres = [
            (mb_l + (mb_x / 2), mb_b),  # 0
            (mb_l + (dev_x / 2), mb_b),  # 1
            (mb_l, mb_b - (dev_y / 2)),  # 2
            (mb_l, mb_b - (mb_y / 2)),  # 3
            (mb_l, mb_t + (dev_y / 2)),  # 4
            (mb_l + (dev_x / 2), mb_t),  # 5
            (mb_l + (mb_x / 2), mb_t),  # 6
            (mb_r - (dev_x / 2), mb_t),  # 7
            (mb_r, mb_t + (dev_y / 2)),  # 8
            (mb_r, mb_t + (mb_y / 2)),  # 9
            (mb_r, mb_b - (dev_y / 2)),  # 10
            (mb_r - (dev_x / 2), mb_b),  # 11
        ]
Esempio n. 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)
Esempio n. 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)