def init_gl(self): print('creating Frame') self.window = wx.Frame ( parent=None, id=wx.ID_ANY, title=self.title, style=wx.DEFAULT_FRAME_STYLE|wx.WS_EX_PROCESS_IDLE ) print('creating GLCanvas') self.canvas = glcanvas.GLCanvas ( self.window, glcanvas.WX_GL_RGBA ) print('creating GLContext') self.context = glcanvas.GLContext(self.canvas) self.canvas.SetFocus() self.window.SetSize ( (self.renderer.window_size[0], self.renderer.window_size[1]) ) print('showing Frame') self.window.Show(True) print('calling SetTopWindow') self.SetTopWindow(self.window) self.Bind ( wx.EVT_CHAR, self.OnChar ) self.canvas.Bind ( wx.EVT_SIZE, self.OnCanvasSize ) self.canvas.Bind ( wx.EVT_PAINT, self.OnCanvasPaint ) wx.IdleEvent.SetMode ( wx.IDLE_PROCESS_SPECIFIED ) self.Bind ( wx.EVT_IDLE, self.OnIdle ) print('making context current') self.canvas.SetCurrent ( self.context ) self.renderer.init_gl()
def __init__(self, parent, title, gllock, size=DefaultSize): super(GLSubWindow, self).__init__(parent, size=size) # OpenGL mutex lock self.gllock = gllock # OpenGL canvas self.canvas = glcanvas.GLCanvas( self, attribList=(glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 0), size=size) # No GL context for now. Must be created after window is shown self.context = None # Binds # Close bypass self.Bind(EVT_CLOSE, self.onClose) # GL canvas binds self.canvas.Bind(EVT_PAINT, self.onPaint) self.canvas.Bind(EVT_SIZE, self.onResize) # Set title self.SetTitle(title) # Set minimum size self.SetMinSize(self.GetSize()) # Save size self.canvasSize = self.canvas.GetClientSize()
def __init__(self, title='WxWindow', id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name='frame'): style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE super(Window, self).__init__(None, id, title, pos, size, style, name) attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit self.canvas = glcanvas.GLCanvas(self, attribList=attribList) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent) self.Show()
def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): # Forcing a no full repaint to stop flickering style = style | wx.NO_FULL_REPAINT_ON_RESIZE #call super function super(GLPanel, self).__init__(parent, id, pos, size, style) #init gl canvas data self.GLinitialized = False attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # Create the canvas self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.canvas = glcanvas.GLCanvas(self, attribList=attribList) self.sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(self.sizer) #self.sizer.Fit(self) self.Layout() # bind events self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent)
def __init__(self, parent, game, size=wx.DefaultSize): self.canvas = None for i in wx.GetApp().artub_frame.alive_editors: if hasattr(i, "canvas"): self.canvas = glcanvas.GLCanvasWithContext( parent, i.canvas.GetContext(), -1, size=size, style=wx.ALWAYS_SHOW_SB | wx.VSCROLL | wx.HSCROLL) break if not self.canvas: Animation.pool.clear() self.canvas = glcanvas.GLCanvas(parent, -1, \ size = size, style = wx.ALWAYS_SHOW_SB | wx.VSCROLL | wx.HSCROLL, \ attribList = [glcanvas.WX_GL_RGBA, \ glcanvas.WX_GL_DOUBLEBUFFER, \ glcanvas.WX_GL_STENCIL_SIZE, 8]) self.parent = parent self.init = False # initial mouse position self.lastx = self.x = 30 self.lasty = self.y = 30 wx.EVT_ERASE_BACKGROUND(self.canvas, self.OnEraseBackground) self.canvas.Bind(wx.EVT_PAINT, self.OnPaint) self.canvas.Bind(wx.EVT_IDLE, self.OnIdle) self.game = game import platform if platform.system() == 'Darwin': self.mac = True
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name='frame'): # # Forcing a specific style on the window. # Should this include styles passed? style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE super(GLFrame, self).__init__(parent, id, title, pos, size, style, name) self.GLinitialized = False attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # # Create the canvas self.canvas = glcanvas.GLCanvas(self, attribList=attribList) # # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent)
def OnInit(self): rsrc = xrc.XmlResource(RSRC_FILE) self.frame = rsrc.LoadFrame(None, "FRAME") self.frame.Show() self.img_panel = xrc.XRCCTRL(self.frame, "PANEL") box = wx.BoxSizer(wx.VERTICAL) self.img_panel.SetSizer(box) self.img_wind = wxvideo.GLCanvas(self.img_panel, -1) box.Add(self.img_wind, 1, wx.EXPAND) self.img_panel.SetAutoLayout(True) self.img_panel.Layout() wx.EVT_LEFT_DOWN(self.img_wind, self.MouseClick) #self.img_wind.Bind(wx.EVT_LEFT_DOWN,self.MouseClick) #self.filename = '/home/kristin/FLIES/data/walking_arena/movie20071009_155327.sbfmf' #self.movie = movies.Movie(self.filename,True) #imd,stamp = self.movie.get_frame( 1 ) #print 'imd = ' + str(imd) #print 'minv = ' + str(nx.min(imd)) #im8 = imagesk.double2mono8(imd) #print 'im8 = ' + str(im8) #print 'minv = ' + str(nx.min(im8)) #print 'im8.shape = ' + str(im8.shape) #im8 = nx.zeros((1024,1024),dtype=nx.uint8) #self.img_wind.update_image_and_drawings('camera',im8,format='MONO8') return True
def __init__(self, parent, focus): super().__init__(parent) self.failed = False attrib_list = [ glcanvas.WX_GL_MAJOR_VERSION, 3, glcanvas.WX_GL_MINOR_VERSION, 2, glcanvas.WX_GL_CORE_PROFILE, glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_SAMPLES, 16 ] self.sizer = wx.BoxSizer(wx.VERTICAL) self.canvas = glcanvas.GLCanvas(self, attribList=attrib_list) self.context = glcanvas.GLContext(self.canvas) self._renderer = IconRenderer(self.context) self._icon = None self._icon_sys = None self.canvas.Bind(wx.EVT_PAINT, self.paint) self.sizer.Add(self.canvas, wx.EXPAND, wx.EXPAND) self.SetSizer(self.sizer) #self.config = config = mymcsup.icon_config() #config.animate = True self._camera_dragging_rotation = False self._camera_dragging_offset = False self._last_mouse_pos = None self._animate_icon = False self._timer = None self._animation_start_time = time.time() self.lighting_id = self.ID_CMD_LIGHT_ICON self.background_id = self.ID_CMD_BACKGROUND_ICON self.menu = wx.Menu() self.append_menu_options(self, self.menu) self.set_lighting(self.lighting_id) self.set_background(self.ID_CMD_BACKGROUND_ICON) self.reset_camera() self.set_animate(False) self.Bind(wx.EVT_CONTEXT_MENU, self.evt_context_menu) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.evt_mouse_left_down) self.canvas.Bind(wx.EVT_LEFT_UP, self.evt_mouse_left_up) self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.evt_mouse_middle_down) self.canvas.Bind(wx.EVT_MIDDLE_UP, self.evt_mouse_middle_up) self.canvas.Bind(wx.EVT_MOTION, self.evt_mouse_motion) self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.evt_mouse_wheel)
def __init__(self, data, parent, id, *args, **kwargs): global DEFAULT_WIN_SIZE from spectral import settings self.kwargs = kwargs self.size = kwargs.get('size', DEFAULT_WIN_SIZE) self.title = kwargs.get('title', 'Hypercube') # # Forcing a specific style on the window. # Should this include styles passed? style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE wx.Frame.__init__(self, parent, id, self.title, wx.DefaultPosition, wx.Size(*self.size), style, kwargs.get('name', 'Hypercube')) self.gl_initialized = False attribs = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, settings.WX_GL_DEPTH_SIZE) self.canvas = glcanvas.GLCanvas(self, attribList=attribs, size=self.size) self.canvas.context = wx.glcanvas.GLContext(self.canvas) # These members can be modified before calling the show method. self.clear_color = tuple(kwargs.get('background', (0., 0., 0.))) \ + (1.,) self.win_pos = (100, 100) self.fovy = 60. self.znear = 0.1 self.zfar = 10.0 self.target_pos = [0.0, 0.0, 0.0] self.camera_pos_rtp = [7.0, 45.0, 30.0] self.up = [0.0, 0.0, 1.0] self.hsi = data self.cubeHeight = 1.0 self.rotation = [-60, 0, -30] self.distance = -5 self.light = False self.texturesLoaded = False self.mouse_handler = MouseHandler(self) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) self.canvas.Bind(wx.EVT_SIZE, self.on_resize) self.canvas.Bind(wx.EVT_PAINT, self.on_paint) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.mouse_handler.left_down) self.canvas.Bind(wx.EVT_LEFT_UP, self.mouse_handler.left_up) self.canvas.Bind(wx.EVT_MOTION, self.mouse_handler.motion) self.canvas.Bind(wx.EVT_CHAR, self.on_char)
def __init__(self, parent, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, antialias_samples = 0): # Full repaint should not be a performance problem #TODO: test on windows, tested in Ubuntu style = style | wx.FULL_REPAINT_ON_RESIZE self.GLinitialized = False self.mview_initialized = False attribList = [glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24 # 24 bit ] if antialias_samples > 0 and hasattr(glcanvas, "WX_GL_SAMPLE_BUFFERS"): attribList += (glcanvas.WX_GL_SAMPLE_BUFFERS, 1, glcanvas.WX_GL_SAMPLES, antialias_samples) attribList.append(0) if BASE_CLASS is glcanvas.GLCanvas: super().__init__(parent, wx.ID_ANY, attribList, pos, size, style) self.canvas = self else: super().__init__(parent, wx.ID_ANY, pos, size, style) self.canvas = glcanvas.GLCanvas(self, wx.ID_ANY, attribList, pos, size, style) self.width = self.height = None self.context = glcanvas.GLContext(self.canvas) self.rot_lock = Lock() self.basequat = [0, 0, 0, 1] self.zoom_factor = 1.0 self.angle_z = 0 self.angle_x = 0 self.gl_broken = False # bind events self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) if self.canvas is not self: self.Bind(wx.EVT_SIZE, self.OnScrollSize) # do not focus parent (panel like) but its canvas self.SetCanFocus(False) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) # In wxWidgets 3.0.x there is a clipping bug during resizing # which could be affected by painting the container # self.Bind(wx.EVT_PAINT, self.processPaintEvent) # Upgrade to wxPython 4.1 recommended self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent) self.canvas.Bind(wx.EVT_SET_FOCUS, self.processFocus) self.canvas.Bind(wx.EVT_KILL_FOCUS, self.processKillFocus)
def __createWXGLCanvas(self): """Create a dummy ``wx.glcanvas.GLCanvas`` instance which is to be used to create a context. Assigns the canvas to an attributed called ``__canvas``. """ import wx.glcanvas as wxgl log.debug('Creating temporary wx.GLCanvas') # There's something wrong with wxPython's # GLCanvas (on OSX at least) - the pixel # format attributes have to be set on the # *first* GLCanvas that is created - # setting them on subsequent canvases will # have no effect. But if you set them on # the first canvas, all canvases that are # subsequently created will inherit the # same properties. attribs = [wxgl.WX_GL_RGBA, wxgl.WX_GL_DOUBLEBUFFER, wxgl.WX_GL_STENCIL_SIZE, 4, wxgl.WX_GL_DEPTH_SIZE, 24, 0, 0] # GLCanvas initialisation with an attribute # list fails when running in a nomachine-like # remote desktop session. No idea why. try: self.__canvas = wxgl.GLCanvas(self.__parent, attribList=attribs) self.__canvas.SetSize((0, 0)) # Creating without attribute list works ok # though. This does mean that we don't have # control over depth/stencil buffer sizes, # under these remote desktop environments. except: self.__canvas = wxgl.GLCanvas(self.__parent) self.__canvas.SetSize((0, 0)) self.__canvas.Show(True)
def initWindow(self): # 2 if self.fullScreen: self.size = self.app.size = wx.GetDisplaySize() if sys.platform == 'darwin': # correct on mac? because of the nmenu and status bar self.framesize = self.size[0], self.size[1] + 25 # 22 #+15 elif sys.platform == 'win32': # windows etc... self.framesize = self.size[0] + 8, self.size[ 1] + 46 # 54 only menu else: # i guess it is linux self.framesize = self.size[0], self.size[ 1] + 27 # 27 with menu, 54 with status bar on linux ## print self.size , self.app.size, self.framesize self.frame = self.frameClass(self.app, None, -1, self.caption, self.pos, self.framesize) # init if sys.platform == 'darwin': self.canvas = glcanvas.GLCanvas(self.frame, -1, self.pos, self.frame.GetClientSize()) else: self.canvas = glcanvas.GLCanvas( self.frame, -1, self.pos, self.size) #, name=self.caption) self.canvas.Bind(wx.EVT_PAINT, self.OnPaint) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) # dummy def OnCloseWindow(evt): self.t.Stop() self.frame.Destroy() self.frame.Bind(wx.EVT_CLOSE, OnCloseWindow) self.glsize = self.canvas.GetSize( ) # passed to glOrtho in engine initialisation self.frame.doFrame(self.canvas) if self.fullScreen: self.frame.ShowFullScreen(1) self.SetTopWindow(self.frame) self.frame.Show()
def __init__(self, *args, **kwargs): BaseCanvasBackend.__init__(self, *args) title, size, position, show, vsync, resize, dec, fs, parent, context, \ = self._process_backend_kwargs(kwargs) # Deal with context if not context.istaken: context.take('wx', self) self._gl_attribs = _set_config(context.config) self._gl_context = None # set for real once we know self._canvas elif context.istaken == 'wx': self._gl_attribs = context.backend_canvas._gl_attribs self._gl_context = context.backend_canvas._gl_context else: raise RuntimeError('Different backends cannot share a context.') style = (wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLIP_CHILDREN) style |= wx.NO_BORDER if not dec else wx.RESIZE_BORDER self._init = False Frame.__init__(self, parent, wx.ID_ANY, title, position, size, style) if not resize: self.SetSizeHints(size[0], size[1], size[0], size[1]) if fs is not False: if fs is not True: logger.warning('Cannot specify monitor number for wx ' 'fullscreen, using default') self._fullscreen = True else: self._fullscreen = False _wx_app.SetTopWindow(self) self._canvas = glcanvas.GLCanvas(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0, 'GLCanvas', self._gl_attribs) if self._gl_context is None: self._gl_context = glcanvas.GLContext(self._canvas) self._canvas.Raise() self._canvas.SetFocus() self._vispy_set_title(title) self._size = None self.Bind(wx.EVT_SIZE, self.on_resize) self._canvas.Bind(wx.EVT_PAINT, self.on_paint) self._canvas.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self._canvas.Bind(wx.EVT_KEY_UP, self.on_key_up) self._canvas.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_event) self.Bind(wx.EVT_CLOSE, self.on_close) self._size_init = size self._vispy_set_visible(show)
def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, antialias_samples=0): # Forcing a no full repaint to stop flickering style = style | wx.NO_FULL_REPAINT_ON_RESIZE super(wxGLPanel, self).__init__(parent, id, pos, size, style) self.GLinitialized = False self.mview_initialized = False attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit if antialias_samples > 0 and hasattr(glcanvas, "WX_GL_SAMPLE_BUFFERS"): attribList += (glcanvas.WX_GL_SAMPLE_BUFFERS, 1, glcanvas.WX_GL_SAMPLES, antialias_samples) self.width = None self.height = None self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.canvas = glcanvas.GLCanvas(self, attribList=attribList) self.context = glcanvas.GLContext(self.canvas) self.sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizerAndFit(self.sizer) self.rot_lock = Lock() self.basequat = [0, 0, 0, 1] self.zoom_factor = 1.0 self.angle_z = 0 self.angle_x = 0 self.gl_broken = False # bind events self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent)
def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.GLinitialized = False attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # Create the canvas self.canvas = glcanvas.GLCanvas(self, attribList=attribList) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self._doEraseBackground) self.canvas.Bind(wx.EVT_SIZE, self._doSize) self.canvas.Bind(wx.EVT_PAINT, self._doPaint)
def __init__(self, parent, *args, **kwargs): """Create the DemoPanel.""" wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = parent # Sometimes one can use inline Comments self.is_on_draw = False #def __init__(self, parent, id, title, pos=wx.DefaultPosition, # size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, # name='frame'): # # Forcing a specific style on the window. # Should this include styles passed? # style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE # super(GLFrame, self).__init__(parent, id, title, pos, size, style, name) self.GLinitialized = False attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit # # Create the canvas self.canvas = glcanvas.GLCanvas(self, attribList=attribList) # # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.processEraseBackgroundEvent) self.canvas.Bind(wx.EVT_SIZE, self.processSizeEvent) self.canvas.Bind(wx.EVT_PAINT, self.processPaintEvent) # Sizer = wx.BoxSizer(wx.VERTICAL) Sizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL, 5) self.SetSizerAndFit(Sizer)
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name='glframe'): style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE super(GLFrame, self).__init__(parent, id, title, pos, size, style, name) self.GLinitialised = False attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) self.canvas = glcanvas.GLCanvas(self, attribList=attribList) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.canvas.Bind(wx.EVT_SIZE, self.OnSize) self.canvas.Bind(wx.EVT_PAINT, self.OnPaint)
def __init__(self, parent, focus): super().__init__(parent) self.failed = False def make_attrib_list(samples): return [ glcanvas.WX_GL_MAJOR_VERSION, 3, glcanvas.WX_GL_MINOR_VERSION, 2, glcanvas.WX_GL_CORE_PROFILE, glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_SAMPLES, samples ] attrib_list = None samples = 16 while samples >= 1: al = make_attrib_list(samples) if glcanvas.GLCanvas.IsDisplaySupported(al): attrib_list = al break samples = samples // 2 if attrib_list is None: print( "Failed to initialize OpenGL. 3D Icon Display will not be available." ) self.failed = True return self.sizer = wx.BoxSizer(wx.VERTICAL) self.canvas = glcanvas.GLCanvas(self, attribList=attrib_list) self.context = glcanvas.GLContext(self.canvas) self._renderer = IconRenderer(self.context) self._icon = None self._icon_sys = None self.canvas.Bind(wx.EVT_PAINT, self.paint) self.sizer.Add(self.canvas, wx.EXPAND, wx.EXPAND) self.SetSizer(self.sizer) #self.config = config = mymcsup.icon_config() #config.animate = True self._camera_dragging_rotation = False self._camera_dragging_offset = False self._last_mouse_pos = None self._animate_icon = False self._timer = None self._animation_start_time = time.time() self.lighting_id = self.ID_CMD_LIGHT_ICON self.background_id = self.ID_CMD_BACKGROUND_ICON self.menu = wx.Menu() self.append_menu_options(self, self.menu) self.set_lighting(self.lighting_id) self.set_background(self.ID_CMD_BACKGROUND_ICON) self.reset_camera() self.set_animate(False) self.Bind(wx.EVT_CONTEXT_MENU, self.evt_context_menu) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.evt_mouse_left_down) self.canvas.Bind(wx.EVT_LEFT_UP, self.evt_mouse_left_up) self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.evt_mouse_middle_down) self.canvas.Bind(wx.EVT_MIDDLE_UP, self.evt_mouse_middle_up) self.canvas.Bind(wx.EVT_MOTION, self.evt_mouse_motion) self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.evt_mouse_wheel)
try:
def __init__(self, data, parent, id, *args, **kwargs): global DEFAULT_WIN_SIZE self.kwargs = kwargs self.size = kwargs.get('size', DEFAULT_WIN_SIZE) self.title = kwargs.get('title', 'ND Window') # # Forcing a specific style on the window. # Should this include styles passed? style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE super(NDWindow, self).__init__(parent, id, self.title, wx.DefaultPosition, wx.Size(*self.size), style, self.title) self.gl_initialized = False attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, settings.WX_GL_DEPTH_SIZE) self.canvas = glcanvas.GLCanvas(self, attribList=attribs) self.canvas.context = wx.glcanvas.GLContext(self.canvas) self._have_glut = False self.clear_color = (0, 0, 0, 0) self.show_axes_tf = True self.point_size = 1.0 self._show_unassigned = True self._refresh_display_lists = False self._click_tolerance = 1 self._display_commands = [] self._selection_box = None self._rgba_indices = None self.mouse_panning = False self.win_pos = (100, 100) self.fovy = 60. self.znear = 0.1 self.zfar = 10.0 self.target_pos = [0.0, 0.0, 0.0] self.camera_pos_rtp = [7.0, 45.0, 30.0] self.up = [0.0, 0.0, 1.0] self.quadrant_mode = None self.mouse_handler = MouseHandler(self) # Set the event handlers. self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.on_erase_background) self.Bind(wx.EVT_SIZE, self.on_resize) self.canvas.Bind(wx.EVT_PAINT, self.on_paint) self.canvas.Bind(wx.EVT_LEFT_DOWN, self.mouse_handler.left_down) self.canvas.Bind(wx.EVT_LEFT_UP, self.mouse_handler.left_up) self.canvas.Bind(wx.EVT_MOTION, self.mouse_handler.motion) self.canvas.Bind(wx.EVT_CHAR, self.on_char) self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.right_click) self.canvas.Bind(wx.EVT_CLOSE, self.on_event_close) self.data = data self.classes = kwargs.get('classes', np.zeros(data.shape[:-1], np.int)) self.features = kwargs.get('features', list(range(6))) self.labels = kwargs.get('labels', list(range(data.shape[-1]))) self.max_menu_class = int(np.max(self.classes.ravel() + 1)) from matplotlib.cbook import CallbackRegistry self.callbacks = CallbackRegistry()