Beispiel #1
0
    def createWidgets(self):
        self.img = wx.Image(
            os.path.join(self.images_path, 'Luminous Space.png'),
            wx.BITMAP_TYPE_ANY)

        width = self.img.GetWidth()
        height = self.img.GetHeight()

        imgRatio = 1.0 * width / height
        xWin = self.imageBox.Size[0]
        yWin = self.imageBox.Size[1]

        factor = 1
        width = factor * xWin
        height = factor * xWin / imgRatio

        self.img = self.img.Scale(round(width), round(height))

        self.imageCtrl = wx.StaticBitmap(self.imageBox, wx.ID_ANY,
                                         wx.Bitmap(self.img))
        self.vbox.Add(self.imageCtrl, 0, wx.ALL, 5)

        # self.imageCtrl.Bind(wx.EVT_PAINT, self.OnPaint)
        self.imageCtrl.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.imageCtrl.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.imageCtrl.Bind(wx.EVT_MOTION, self.OnMouseMove)

        self.startPos = None
        self.overlay = wx.Overlay()
Beispiel #2
0
 def test_overlay1(self):
     o = wx.Overlay()
     dc = wx.ClientDC(self.frame)
     odc = wx.DCOverlay(o, dc)
     odc.Clear()
     del odc
     o.Reset()
Beispiel #3
0
 def __init__(self, parent):
     self.size = (1267, 712)
     self.user_scale = 1
     super(Canvas, self).__init__(parent,
                                  size=self.size,
                                  style=wx.BORDER_RAISED)
     self.SetBackgroundColour((0, 0, 0))
     self.FitInside()
     self.SetScrollRate(1, 1)
     self.coord = []
     self.color = (0, 0, 0)
     self.last_color = (0, 0, 0)
     self.pen_width = 1
     self.init_drawing()
     self.prepare_buffer()
     self.Bind(wx.EVT_LEFT_DOWN, self.on_down)
     self.Bind(wx.EVT_LEFT_UP, self.on_up)
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.t = wx.Timer(self)
     self.t_shape = wx.Timer(self)
     self.Bind(wx.EVT_TIMER, self.button_timer, self.t)
     self.Bind(wx.EVT_TIMER, self.shape_timer, self.t_shape)
     self.Bind(wx.EVT_LEAVE_WINDOW, self.mouse_leave_window)
     self.overlay = wx.Overlay()
     self.rect = ()
    def __init__(self, device_manager):
        super().__init__(parent=None, title='Location Tracker')

        self.SetSize((WINDOW_WIDTH, WINDOW_HEIGHT))
        self.SetTitle('DWM1001 Location Tracker Demo')
        self.Centre()

        img = wx.Image(FLOOR_PLAN_IMAGE, wx.BITMAP_TYPE_ANY)
        self.bitmap_img = img.ConvertToBitmap()

        self.floor_plan_img = wx.StaticBitmap(
            self, -1, self.bitmap_img, (10, 5),
            (self.bitmap_img.GetWidth(), self.bitmap_img.GetHeight()))
        self.floor_plan_img.Bind(wx.EVT_MOTION, self.imgctrl_on_mousemove)

        self.status_bar = wx.StatusBar(self, -1, wx.STB_ELLIPSIZE_END,
                                       "defaultstatusbar")
        self.status_bar.SetStatusText("X={0}, Y={1}".format(0, 0))
        self.SetStatusBar(self.status_bar)

        self.anchors = dict()
        self.tag = None
        self.overlay = wx.Overlay()
        self.previous_loc_updates = list()
        self.loc_update_index = 0

        worker = LocationTrackerWorker(self, device_manager)
        worker.start()

        self.Show()
        self.Bind(LOC_RECEIVED_EVNT, self.on_location_received)
        self.anc1_pos = [0, 0]
        self.anc2_pos = [-0.7, 0.0]
        self.anc3_pos = [-0.35, 0.7]
Beispiel #5
0
 def start_docking(self, event_window, drag_window, event):
     # Capture the mouse and save the starting posiiton for the rubber-band
     event_window.CaptureMouse()
     event_window.SetFocus()
     self.event_window = event_window
     self.drag_window = BitmapPopup(drag_window, event.GetPosition())
     self.overlay = wx.Overlay()
     self.overlay.Reset()
     self.create_docking_rectangles(self.event_window)
 def __init__(self, parent):
     super(OverlayPanel, self).__init__(parent)
     self.overlay = wx.Overlay()
     self.permRect = None
     self.selectionStart = None
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
     self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
     self.Bind(wx.EVT_MOTION, self.OnMotion)
Beispiel #7
0
    def __init__(self, *args, **kw):
        wx.Panel.__init__(self, *args, **kw)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMove)

        self.startPos = None
        self.overlay = wx.Overlay()
Beispiel #8
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 name=wx.ControlNameStr):

        # Disallow borders
        style &= ~(wx.BORDER_DEFAULT | wx.BORDER_SIMPLE | wx.BORDER_SUNKEN) & \
                 ~(wx.BORDER_RAISED | wx.BORDER_STATIC | wx.BORDER_THEME)

        # Disallow TAB_TRAVERSAL
        style &= ~wx.TAB_TRAVERSAL

        style |= wx.BORDER_NONE
        style |= wx.WANTS_CHARS

        # Set initial buffer - This must be performed before calling __init__
        # on the parent class
        self._buffer = _TextBuffer()

        # Initial scroll position - required for best client size, which is
        # called upon window creation. Set to buffer index 0
        self._scrollPos = 0

        super().__init__(parent, id, pos, size, style, name)

        self.SetFont(
            wx.Font(pointSize=13,
                    family=wx.FONTFAMILY_TELETYPE,
                    style=wx.FONTSTYLE_NORMAL,
                    weight=wx.FONTWEIGHT_LIGHT))

        # Set initial colouring
        back = self.GetBackgroundColour()
        self.SetBackgroundColour(self.GetForegroundColour())
        self.SetForegroundColour(back)

        # This will be our text selection overlay
        self._overlay = wx.Overlay()

        # Set up scrolling
        self.EnableScrolling(True, True)

        self.Bind(wx.EVT_PAINT, self._OnPaint)
        self.Bind(wx.EVT_SIZE, self._OnSize)
        self.Bind(wx.EVT_SCROLLWIN, self._OnScroll)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self._OnEraseBackground)

        self.Bind(wx.EVT_LEFT_DOWN, self._OnMouseDown)
        self.Bind(wx.EVT_MOTION, self._OnMouseMove)
        self.Bind(wx.EVT_LEFT_UP, self._OnMouseUp)

        self._OnSize(None)
Beispiel #9
0
    def __init__(self, parent, id=-1):
        ## Any data the Draw() function needs must be initialized before
        ## calling BufferedWindow.__init__, as it will call the Draw
        ## function.
        BufferedWindow.__init__(self, parent, id)

        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_MOTION, self.OnMove)

        self.StartMove = None

        self.overlay = wx.Overlay()
 def initUI(self):
     #panel = wx.Panel(self)
     
     sizer = wx.GridBagSizer(1, 2)
     
     # Add the top toolbar with the control buttons
     toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
     
     toolbar.AddSimpleTool(1, wx.Image('ui/stock_open.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Open the directory containing the sample images', '')
     self.Bind(wx.EVT_TOOL, self.toolbarOpen, id=1)
     toolbar.AddSimpleTool(2, wx.Image('ui/stock_save.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Save', '')
     self.Bind(wx.EVT_TOOL, self.toolbarSave, id=2)
     toolbar.AddSeparator()
     toolbar.AddSimpleTool(3, wx.Image('ui/stock_undo.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Undo last marking', '')
     self.Bind(wx.EVT_TOOL, self.toolbarUndo, id=3)
     toolbar.AddSimpleTool(4, wx.Image('ui/stock_clear.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Clear', '')
     self.Bind(wx.EVT_TOOL, self.toolbarClear, id=4)
     toolbar.AddSeparator()
     toolbar.AddSimpleTool(5, wx.Image('ui/stock_left_arrow.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Previous image', '')
     self.Bind(wx.EVT_TOOL, self.toolbarPrev, id=5)
     toolbar.AddSimpleTool(6, wx.Image('ui/stock_negative.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Set image as negative', '')
     self.Bind(wx.EVT_TOOL, self.toolbarNegative, id=6)
     toolbar.AddSimpleTool(7, wx.Image('ui/stock_right_arrow.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Next image', '')
     self.Bind(wx.EVT_TOOL, self.toolbarNext, id=7)
     toolbar.AddSeparator()
     toolbar.AddSimpleTool(8, wx.Image('ui/stock_preferences.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Preferences', '')
     toolbar.AddSimpleTool(9, wx.Image('ui/stock_info.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'About', '')
     self.Bind(wx.EVT_TOOL, self.toolbarInfo, id=9)
     toolbar.AddSimpleTool(10, wx.Image('ui/stock_exit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Exit', '')
     self.Bind(wx.EVT_TOOL, self.toolbarExit, id=10)
     toolbar.Realize()
     sizer.Add(toolbar, pos=(0,0), border=5, flag=wx.EXPAND)
     
     self.image = wx.StaticBitmap(self, bitmap=wx.EmptyBitmap(320, 240), pos=(0, 0))
     # Bind mouse actions on the image
     self.image.Bind(wx.EVT_MOUSE_EVENTS, self.imageMouseEvent)
     sizer.Add(self.image, pos=(1, 0), flag=wx.ALL, border=0)
     
     # Ask user to save when closing the application
     self.Bind(wx.EVT_CLOSE, self.onClose)
     
     # Overlay to draw on top of the picture
     self.overlay = wx.Overlay()
     
     # Only the image part in the user interface should be resizable
     sizer.AddGrowableCol(0)
     sizer.AddGrowableRow(1)
     
     self.SetSizerAndFit(sizer)
     self.Layout()
Beispiel #11
0
 def __init__(self, parent):
     wx.ScrolledWindow.__init__(self, parent)
     self.SetScrollRate(5, 5)
     self.LeftClickFlag = 0
     self.RightClickFlag = 0
     self.CurrPos = 0
     #self.Bind(wx.EVT_SCROLLWIN_THUMBTRACK, self.OnScroll)
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick)
     self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick)
     #ADD MOUSE DRAG EVENT TO REPLACE SCROLLING
     self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
     self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
     self.overlay = wx.Overlay()
Beispiel #12
0
    def __init__(self, parent, id, title, mplayer):
        wx.Frame.__init__(self, parent, id, title, size=wx.DisplaySize())
        self.panel = wx.Panel(self)
        self.overlay = wx.Overlay()
        sp = wx.StandardPaths.Get()
        self.currentFolder = sp.GetDocumentsDir()
        self.currentVolume = 50
        self.create_menu()
        # create sizers
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        controlSizer = self.build_controls()
        sliderSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.mplayer = mpc.MplayerCtrl(self.panel, -1, mplayer)
        self.playbackSlider = wx.Slider(self.panel, size=wx.DefaultSize)
        sliderSizer.Add(self.playbackSlider, 1, wx.ALL | wx.EXPAND, 5)

        # create volume control
        self.volumeCtrl = wx.Slider(self.panel,
                                    style=wx.SL_VERTICAL | wx.SL_INVERSE,
                                    size=(-1, 50))
        self.volumeCtrl.SetRange(0, 100)
        self.volumeCtrl.SetValue(self.currentVolume)
        self.volumeCtrl.Bind(wx.EVT_SLIDER, self.on_set_volume)
        controlSizer.Add(self.volumeCtrl, 0, wx.ALL, 5)

        # create track counter
        self.trackCounter = wx.StaticText(self.panel, label="0:00:00")
        sliderSizer.Add(self.trackCounter, 0, wx.ALL | wx.CENTER, 7)

        # set up playback timer
        self.playbackTimer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_update_playback, self.playbackTimer)

        # bind playback slider to playback timer?
        # self.playbackSlider.Bind(wx.EVT_SLIDER, self.on_set_time)

        mainSizer.Add(self.mplayer, 1, wx.ALL | wx.EXPAND, 5)
        mainSizer.Add(sliderSizer, 0, wx.ALL | wx.EXPAND, 5)
        mainSizer.Add(controlSizer, 0, wx.ALL | wx.CENTER, 5)
        self.panel.SetSizer(mainSizer)

        self.panel.Bind(mpc.EVT_MEDIA_STARTED, self.on_media_started)
        self.panel.Bind(mpc.EVT_MEDIA_FINISHED, self.on_media_finished)
        self.panel.Bind(mpc.EVT_PROCESS_STARTED, self.on_process_started)
        self.panel.Bind(mpc.EVT_PROCESS_STOPPED, self.on_process_stopped)

        self.Show()
        self.panel.Layout()
Beispiel #13
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MainView.__init__
        kwds["style"] = kwds.get("style",
                                 0) | wx.TAB_TRAVERSAL | wx.WANTS_CHARS
        wx.Panel.__init__(self, *args, **kwds)
        self.SetDoubleBuffered(True)

        self.matrix = ZMatrix()
        self.identity = ZMatrix()
        self.matrix.Reset()
        self.identity.Reset()
        self.previous_window_position = None
        self.previous_scene_position = None
        self.popup_window_position = None
        self.popup_scene_position = None
        self._Buffer = None
        self.dirty = False

        self.__set_properties()
        self.__do_layout()
        self.overlay = wx.Overlay()

        self.grid = None
        self.guide_lines = None

        self.laserpath = [(0, 0, 0, 0)] * 1000
        self.laserpath_index = 0

        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase)

        self.Bind(wx.EVT_MOTION, self.on_mouse_move)
        self.move_function = self.move_pan
        self.Bind(wx.EVT_MOUSEWHEEL, self.on_mousewheel)
        self.Bind(wx.EVT_MIDDLE_DOWN, self.on_mouse_middle_down)
        self.Bind(wx.EVT_MIDDLE_UP, self.on_mouse_middle_up)
        self.Bind(wx.EVT_LEFT_DCLICK, self.on_mouse_double_click)

        self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_mouse_down)
        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_mouse_down)
        self.Bind(wx.EVT_LEFT_UP, self.on_left_mouse_up)
        self.Bind(wx.EVT_ENTER_WINDOW,
                  lambda event: self.SetFocus())  # Focus follows mouse.
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.project = None
        self.renderer = None
        self.background_brush = wx.Brush("Grey")
Beispiel #14
0
 def __init__(self, window):
     super(_DynamicSashWindowImpl, self).__init__()
     self.m_window = window
     self.m_add_child_target = self
     self.m_container = None
     self.m_parent = None
     self.m_top = self
     self.m_child = [None, None]
     self.m_leaf = None
     self.m_dragging = _DSR_NONE
     self.m_split = _DSR_NONE
     self.m_drag_x = -1
     self.m_drag_y = -1
     if _isMac:
         self.m_overlay = wx.Overlay()
         self.DrawSash = self.DrawSash_overlay
Beispiel #15
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.BORDER,
                 name="ShapeCanvas"):
        """Default class constructor.

        Default class constructor.

        :param `parent`: parent window
        :param integer `id`: window identifier. A value of -1 indicates a default value
        :param `pos`: the control position. A value of (-1, -1) indicates a default position,
         chosen by either the windowing system or wxPython, depending on platform
        :param `size`: the control size. A value of (-1, -1) indicates a default size,
         chosen by either the windowing system or wxPython, depending on platform
        :param integer `style`: the underlying :class:`wx.Window` style
        :param str `name`: the window name

        :type parent: :class:`wx.Window`
        :type pos: tuple or :class:`wx.Point`
        :type size: tuple or :class:`wx.Size`

        """
        wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name)

        self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

        self._shapeDiagram = None
        self._dragState = NoDragging
        self._draggedShape = None
        self._oldDragX = 0
        self._oldDragY = 0
        self._firstDragX = 0
        self._firstDragY = 0
        self._checkTolerance = True

        self._Overlay = wx.Overlay()
        self._Buffer = wx.Bitmap(10, 10)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvent)
Beispiel #16
0
    def __init__(self):
        self.patientData = []
        self.patient = None  # This might not be used
        self.horizontalPath = None  # Path of horizontal image
        self.verticalPath = None  # Path of vertical image
        self.heightRatio = None
        self.widthRatio = None
        self.rRatio = None
        self.lRatio = None

        self.hRightPath = None
        self.hLeftPath = None
        self.vRightPath = None
        self.vLeftPath = None

        # These bitmaps are needed to draw on, can't draw on img Ctrls
        self.hBitMap = None
        self.vBitMap = None

        self.hlBitMap = None
        self.hrBitMap = None
        self.vlBitMap = None
        self.vrBitMap = None

        # Images to make bitmaps out of, will store original image for resets
        self.hImg = None
        self.vImg = None

        self.hlImg = None
        self.hrImg = None
        self.vlImg = None
        self.vrImg = None

        # Coordinates for user input in tuple
        # set of tuples for horizontal and vertical, outer tuple is (left eye, right eye)
        # inner tuple is (Top Left X, Top Left Y, Bot Right X, Bot Right Y)
        self.hcoors = [[0, 0, 0, 0], [0, 0, 0, 0]]
        self.vcoors = [[0, 0, 0, 0], [0, 0, 0, 0]]

        # For drawing and only for drawing
        self.startX = 0
        self.startY = 0
        self.overlay = wx.Overlay()
Beispiel #17
0
    def mouse_down(self, evt): 
        "Get the selected object and store start position"
        if DEBUG: print "down!"
        if (not evt.ControlDown() and not evt.ShiftDown()) or evt.AltDown():
            for obj in self.selection:
                # clear marker
                if obj.sel_marker:
                    obj.sel_marker.show(False)
                    obj.sel_marker.destroy()
                    obj.sel_marker = None
            self.selection = []  # clear previous selection

        wx_obj = evt.GetEventObject()

        if wx_obj.Parent is None or evt.AltDown():
            if not evt.AltDown():
                evt.Skip()
            # start the rubberband effect (multiple selection using the mouse) 
            self.current = wx_obj
            self.overlay = wx.Overlay()
            self.pos = evt.GetPosition() 
            self.parent.wx_obj.CaptureMouse()
            #if self.inspector and hasattr(wx_obj, "obj"):
            #    self.inspector.inspect(wx_obj.obj)  # inspect top level window
            #self.dclick = False
        else:
            # create the selection marker and assign it to the control
            obj = wx_obj.obj
            self.overlay = None
            if DEBUG: print wx_obj
            sx, sy = wx_obj.ScreenToClient(wx_obj.GetPositionTuple())
            dx, dy = wx_obj.ScreenToClient(wx.GetMousePosition())
            self.pos = wx_obj.ScreenToClient(wx.GetMousePosition())
            self.start = (sx - dx, sy - dy)
            self.current = wx_obj
            if DEBUG: print "capture..."
            # do not capture on TextCtrl, it will fail (blocking) at least in gtk
            # do not capture on wx.Notebook to allow selecting the tabs
            if not isinstance(wx_obj, wx.Notebook):
                self.parent.wx_obj.CaptureMouse()
            self.select(obj, keep_selection=True)
Beispiel #18
0
    def __init__(self, parent, selector=Crosshair):
        wx.ScrolledWindow.__init__(self, parent, -1)

        # Settings
        self.background_color = wx.Colour(160, 160, 160)
        self.use_checkerboard = True
        self.checkerboard_box_size = 8
        self.checkerboard_color = wx.Colour(96, 96, 96)
        self.max_zoom = 16.0
        self.min_zoom = 0.0625

        # internal storage
        self.orig_img = None
        self.img = None
        self.scaled_bmp = None
        self.width = 0
        self.height = 0
        self.zoom = 1.0
        self.crop = None

        # hacks
        self.just_scrolled = False

        # cursors
        self.default_cursor = wx.CURSOR_ARROW
        self.save_cursor = None

        self.Bind(wx.EVT_PAINT, self.OnPaint)

        # selectors and related storage
        self.use_selector = None
        self.selector = None
        self.selector_event_callback = None
        self.overlay = wx.Overlay()
        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvent)

        self.setSelector(selector)
Beispiel #19
0
    def __init__(self, parent, file_path):
        wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.CLIP_CHILDREN)
        self.background = wx.Brush(self.GetBackgroundColour())
        self.start_pos = None
        self.end_pos = None
        self.overlay = wx.Overlay()
        self.parent = parent
        self.objects = {
            ImageUtil.ID_CAR_CALIBRATION: [],
            ImageUtil.ID_AXLE_X_CALIBRATION: [],
            ImageUtil.ID_AXLE_Y_CALIBRATION: [],
            ImageUtil.ID_RAIL_Y_CALIBRATION: [],
            ImageUtil.ID_OUTLINE_CALIBRATION: [],
            ImageUtil.ID_NEW_AXLE_CALIBRATION: [],
            ImageUtil.ID_B_LABEL: [],
            ImageUtil.ID_P_LABEL: [],
            ImageUtil.ID_G_LABEL: [],
            ImageUtil.ID_NONE: []
        }
        self.zoom_ratio = 0
        self.unit_ratio = 0.25
        self.show_pos = 0, 0
        self.to_show = wx.Bitmap(file_path)
        self.draw_mode = ImageUtil.ID_NONE
        list = [
            "请选择",
            "车厢标定",
            "车轴标定",
            "铁轨标定",
            "轮廓标定",
            "调整车轴",
            "添加车轴",
            "分类标签",
            "目标检测标签",
            "分割标签"
        ]
        self.move_start_pos = None
        self.move_end_pos = None
        self.diff = 0, 0
        self.last_background_image_pos = None
        self.funcs = wx.ComboBox(self, -1, choices=list,
                                 size=(150, -1),
                                 style=wx.CB_READONLY)
        self.funcs.SetSelection(0)
        self.funcs.SetToolTip('选择功能')
        self.overlayPenWidth = wx.SpinCtrl(self, -1, value='',
                                           size=(75, -1),
                                           style=wx.SP_ARROW_KEYS,
                                           min=1, max=24, initial=1)
        self.overlayPenWidth.SetToolTip('线宽')

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.funcs, 0, wx.ALL, 5)
        sizer.Add(self.overlayPenWidth, 0, wx.ALL, 5)
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(sizer, 0)
        box.Add((1, 1), 1)

        self.SetSizer(box)
        self.bind_event()
        self.on_size()
Beispiel #20
0
    def __init__(self, parent, file_path=None):
        wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.CLIP_CHILDREN)
        self.background = wx.Brush(self.GetBackgroundColour())
        self.start_pos = None
        self.end_pos = None
        self.overlay = wx.Overlay()
        self.parent = parent
        self.objects = {
            ImageUtil.ID_CAR_CALIBRATION: [],
            ImageUtil.ID_AXLE_X_CALIBRATION: [],
            ImageUtil.ID_AXLE_Y_CALIBRATION: [],
            ImageUtil.ID_RAIL_Y_CALIBRATION: [],
            ImageUtil.ID_OUTLINE_CALIBRATION: [],
            ImageUtil.ID_NEW_AXLE_CALIBRATION: [],
            ImageUtil.ID_B_LABEL: [],
            ImageUtil.ID_P_LABEL: [],
            ImageUtil.ID_G_LABEL: [],
            ImageUtil.ID_NONE: []
        }
        self.zoom_ratio = 0
        self.unit_ratio = 0.25
        self.show_pos = 0, 0
        if file_path is not None:
            self.to_show = wx.Bitmap(file_path)
        else:
            self.to_show = None
        self.draw_mode = ImageUtil.ID_NONE
        view_object = [
            "车厢",
            "车轴中心",
            "铁轨",
            "轮廓",
            "车轴",
            "分类标签",
            "目标检测标签",
            "分割标签"
        ]
        self.move_end_pos = self.move_start_pos = 0, 0
        self.diff = 0, 0
        self.macro_diff = 0, 0
        self.dragable = False
        self.last_background_image_pos = None
        self.filter = PopupControl.PopControl(self, 2, view_object, self, -1, pos=(30, 30))
        # self.funcs = wx.ComboBox(self, -1, choices=list,
        #                          size=(150, -1),
        #                          style=wx.CB_READONLY)
        # self.funcs.SetSelection(0)
        # self.funcs.SetToolTip('选择功能')
        # self.overlayPenWidth = wx.SpinCtrl(self, -1, value='',
        #                                    size=(75, -1),
        #                                    style=wx.SP_ARROW_KEYS,
        #                                    min=1, max=24, initial=1)
        # self.overlayPenWidth.SetToolTip('线宽')

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.filter, 0, wx.ALL, 5)
        # sizer.Add(self.overlayPenWidth, 0, wx.ALL, 5)
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(sizer, 0)
        box.Add((1, 1), 1)

        self.SetSizer(box)
        self.bind_event()
        self.on_size()
Beispiel #21
0
 def __init__(self):
     if self.useOverlay:
         self.overlay = wx.Overlay()
 def OnLeftDown(self, evt):
     self.CaptureMouse()
     self.overlay = wx.Overlay()
     self.selectionStart = evt.Position
Beispiel #23
0
 def press(self, event):
     if self._active == 'ZOOM':
         self.wxoverlay = wx.Overlay()
Beispiel #24
0
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.CLIP_CHILDREN)

        ## self.SetDoubleBuffered(True)

        self.background = wx.Brush(self.GetBackgroundColour())
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        #--Rubberband Overlay
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMove)
        self.startPos = None
        self.endPos = None
        self.overlay = wx.Overlay()

        self.cropbitmap = wx.Bitmap('bitmaps/cropshot24x20.png')
        self.honeyBitmap = wx.Bitmap('bitmaps/honeycomb300.png')

        self.wxPenStylesDict = OrderedDict([
            ('Solid', wx.PENSTYLE_SOLID),
            ('Dot', wx.PENSTYLE_DOT),
            ('Long Dash', wx.PENSTYLE_LONG_DASH),
            ('Short Dash', wx.PENSTYLE_SHORT_DASH),
            ('Dot Dash', wx.PENSTYLE_DOT_DASH),
            ('User Dash', wx.PENSTYLE_USER_DASH),
            ('Transparent', wx.PENSTYLE_TRANSPARENT),
            #('Stipple'             , wx.PENSTYLE_STIPPLE),
            ('BDiagonal Hatch', wx.PENSTYLE_BDIAGONAL_HATCH),
            ('CrossDiag Hatch', wx.PENSTYLE_CROSSDIAG_HATCH),
            ('FDiagonal Hatch', wx.PENSTYLE_FDIAGONAL_HATCH),
            ('Cross Hatch', wx.PENSTYLE_CROSS_HATCH),
            ('Horizontal Hatch', wx.PENSTYLE_HORIZONTAL_HATCH),
            ('Vertical Hatch', wx.PENSTYLE_VERTICAL_HATCH),
        ])

        list = []
        for key, value in self.wxPenStylesDict.items():
            list.append(key)
        self.penstylesCombo = wx.ComboBox(self,
                                          -1,
                                          choices=list,
                                          size=(150, -1),
                                          style=wx.CB_READONLY)
        self.penstylesCombo.SetSelection(0)
        self.penstylesCombo.SetToolTip('Pen Style')

        self.overlayPenWidth = wx.SpinCtrl(self,
                                           -1,
                                           value='',
                                           size=(75, -1),
                                           style=wx.SP_ARROW_KEYS,
                                           min=1,
                                           max=24,
                                           initial=1)
        self.overlayPenWidth.SetToolTip('Pen Width')

        from wx.lib.colourselect import ColourSelect
        self.overlayPenColor = ColourSelect(self, -1, colour=wx.BLUE)
        self.overlayPenColor.SetToolTip('Pen Color')

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.penstylesCombo, 0, wx.ALL, 5)
        sizer.Add(self.overlayPenWidth, 0, wx.ALL, 5)
        sizer.Add(self.overlayPenColor, 0, wx.ALL, 5)
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(sizer, 0)
        box.Add((1, 1), 1)

        self.SetSizer(box)

        self.OnSize()