def __init__(self, parent, id=wx.ID_ANY, eventTarget=None): canvas.L5RCanvas.__init__(self, parent, id) self.eventTarget = eventTarget or self self.gameState = None self.player = None self.isLocal = False self.markerPos = None self.markerOffset = (0, 0) self.attachMarker = None self.texBorderFrame = self.LoadTexture( os.path.join(locationsettings.data_dir, "images/border2.png")) self.texAttach = self.LoadTexture( os.path.join(locationsettings.data_dir, "images/border3.png")) wx.EVT_LEFT_DOWN(self, self.OnLeftMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnDoubleClick) wx.EVT_RIGHT_DOWN(self, self.OnRightMouseDown) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) wx.EVT_MIDDLE_DOWN(self, self.OnMouseWheelDown) self.SetDropTarget( dragdrop.CardDropTarget(self.OnDragData, self.OnDragOver, self.OnDragLeave)) self.texToken = {} self.texMarker = {} self.contextCard = None self.hoverCard = None self.pfHeight = DEFAULT_PLAYFIELD_HEIGHT self.background = PlayfieldCanvasBackground()
def __init__(self, parent): wx.Panel.__init__(self, parent) wx.EVT_SIZE(self, self.OnSize) wx.EVT_IDLE(self, self.OnIdle) wx.EVT_MOVE(self, self.OnMove) wx.EVT_SET_FOCUS(self, self.OnFocus) wx.EVT_KILL_FOCUS(self, self.OnLostFocus) wx.EVT_MAXIMIZE(self, self.OnMaximize) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) #~ wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_RIGHT_DOWN(self, self.OnRightDown) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_RIGHT_UP(self, self.OnRightUp) wx.EVT_MIDDLE_UP(self, self.OnMiddleUp) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_KEY_DOWN(self, self.OnKeyDown) self._3dDisplay = None self._inited = False self.DynaZoom = False self.DynaRotate = False self.DynaPan = False self.dragStartPos = None self._drawbox = None self._selection = None if sys.platform == 'win32': self.Init3dViewer()
def _on_close(self, event): # Might be scrollbars or other native components under # us that are generating this event if event.GetWindow() == self.control: self._gc = None wx.EVT_ERASE_BACKGROUND(self.control, None) wx.EVT_PAINT(self.control, None) wx.EVT_SIZE(self.control, None) wx.EVT_LEFT_DOWN(self.control, None) wx.EVT_LEFT_UP(self.control, None) wx.EVT_LEFT_DCLICK(self.control, None) wx.EVT_MIDDLE_DOWN(self.control, None) wx.EVT_MIDDLE_UP(self.control, None) wx.EVT_MIDDLE_DCLICK(self.control, None) wx.EVT_RIGHT_DOWN(self.control, None) wx.EVT_RIGHT_UP(self.control, None) wx.EVT_RIGHT_DCLICK(self.control, None) wx.EVT_MOTION(self.control, None) wx.EVT_ENTER_WINDOW(self.control, None) wx.EVT_LEAVE_WINDOW(self.control, None) wx.EVT_MOUSEWHEEL(self.control, None) wx.EVT_KEY_DOWN(self.control, None) wx.EVT_KEY_UP(self.control, None) wx.EVT_CHAR(self.control, None) wx.EVT_WINDOW_DESTROY(self.control, None) self.control.SetDropTarget(None) self.control = None self.component.cleanup(self) self.component.parent = None self.component.window = None self.component = None return
def OnCreate(self, doc, flags): if len(doc.GetFilename()) == 0: wx.MessageBox(_("Cannot create a new image file.\n%s has no paint capability.") % wx.GetApp().GetAppName(), _("New Image File"), wx.OK | wx.ICON_EXCLAMATION) return False try: self._bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap() except: wx.MessageBox(_("Error loading '%s'. %s") % (doc.GetPrintableName(), sys.exc_value), _("Open Image File"), wx.OK | wx.ICON_EXCLAMATION) return False frame = wx.GetApp().CreateDocumentFrame(self, doc, flags) panel = wx.Panel(frame, -1) self._ctrl = wx.StaticBitmap(panel, -1, self._bitmap, (0,0), (self._bitmap.GetWidth(), self._bitmap.GetHeight())) wx.EVT_LEFT_DOWN(self._ctrl, self.OnFocus) wx.EVT_LEFT_DCLICK(self._ctrl, self.OnFocus) wx.EVT_RIGHT_DOWN(self._ctrl, self.OnFocus) wx.EVT_RIGHT_DCLICK(self._ctrl, self.OnFocus) wx.EVT_MIDDLE_DOWN(self._ctrl, self.OnFocus) wx.EVT_MIDDLE_DCLICK(self._ctrl, self.OnFocus) panel.SetClientSize(self._bitmap.GetSize()) frame.SetClientSize(panel.GetSize()) self.Activate() return True
def __init__(self, parent): attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList = attribList) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0,0)) self._shownError = False self._context = glcanvas.GLContext(self) self._glButtonsTexture = None self._glRobotTexture = None self._buttonSize = 64 self._animationList = [] self.glReleaseList = [] self._refreshQueued = False self._idleCalled = False wx.EVT_PAINT(self, self._OnGuiPaint) wx.EVT_SIZE(self, self._OnSize) wx.EVT_ERASE_BACKGROUND(self, self._OnEraseBackground) wx.EVT_LEFT_DOWN(self, self._OnGuiMouseDown) wx.EVT_LEFT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_LEFT_UP(self, self._OnGuiMouseUp) wx.EVT_RIGHT_DOWN(self, self._OnGuiMouseDown) wx.EVT_RIGHT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_RIGHT_UP(self, self._OnGuiMouseUp) wx.EVT_MIDDLE_DOWN(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_DCLICK(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_UP(self, self._OnGuiMouseUp) wx.EVT_MOTION(self, self._OnGuiMouseMotion) wx.EVT_CHAR(self, self._OnGuiKeyChar) wx.EVT_KILL_FOCUS(self, self.OnFocusLost) wx.EVT_IDLE(self, self._OnIdle)
def __init__(self, parent, image, glCanvas, do, chan=0, zdim=2): wx.Panel.__init__(self, parent, -1, size=parent.Size) self.image = image self.glCanvas = glCanvas self.do = do self.chan = chan self.zdim = zdim wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_KEY_DOWN(self, self.OnKeyPress) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MIDDLE_UP(self, self.OnMiddleUp) wx.EVT_MOTION(self, self.OnMotion) self.selecting = False self.panning = False self.do.WantChangeNotification.append(self.Refresh)
def __init__(self, parent, id, shapes=None, **kwds): wx.glcanvas.GLCanvas.__init__(self, parent, id, **kwds) self.parent = parent self.camera = Camera() self.init = False self.lastx = self.x = 30 self.lasty = self.y = 30 self.create_menu() wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_MIDDLE_DOWN(self, self.OnMouseDown) wx.EVT_RIGHT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_MIDDLE_UP(self, self.OnMouseUp) wx.EVT_RIGHT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMotion) self.popup_menu = 0 self.color = (0., 0., 0.) #black #self.color = (1.,1.,1.) #white self.dlist = None self.measure = False self.sketching = False self.shapes = shapes self.left_button_click = True self.middle_button_click = True self.right_button_click = True self.beginx, self.beginy = 0, 0 return
def __init__(self, parent=None, id=-1, title='Title', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN): """Create a Frame instance. """ # Create the actual window (a wx Frame) self._wx = wx.Frame(parent, id, title, pos, size, style) self._keys = keys.Keys() self._keys.attach(self) # Set up the wx main menu bar self._menu_id_manager = idmanager.IDManager(10) menubar = wx.MenuBar() self._wx.SetMenuBar(menubar) self._menu = None self.CreateStatusBar() wx.EVT_LEFT_DOWN(self, self.onLeftDown) wx.EVT_LEFT_UP(self, self.onLeftUp) wx.EVT_MIDDLE_DOWN(self, self.onMiddleDown) wx.EVT_MIDDLE_UP(self, self.onMiddleUp) wx.EVT_RIGHT_DOWN(self, self.onRightDown) wx.EVT_RIGHT_UP(self, self.onRightUp)
def _CreateCanvas(self, parent): self._canvas = ogl.ShapeCanvas(parent) wx.EVT_LEFT_DOWN(self._canvas, self.OnLeftClick) wx.EVT_LEFT_UP(self._canvas, self.OnLeftUp) wx.EVT_MOTION(self._canvas, self.OnLeftDrag) wx.EVT_LEFT_DCLICK(self._canvas, self.OnLeftDoubleClick) wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed) # need this otherwise mouse clicks don't set focus to this view wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus) wx.EVT_SET_FOCUS(self._canvas, self.OnFocus) self._canvas.SetScrollbars(20, 20, self._maxWidth / 20, self._maxHeight / 20) self._canvas.SetBackgroundColour(self._backgroundColor) self._diagram = ogl.Diagram() self._canvas.SetDiagram(self._diagram) self._diagram.SetCanvas(self._canvas) self._canvas.SetFont(NORMALFONT)
def setupCallbacks(self): """Setup various callbacks for this context Binds most of the wxPython event types to callbacks on this object, which allows interactive sub-classes to easily manage the bindings without needing any wxPython-specific logic. """ if not self.init: self.init = 1 # Bind the wxPython background erase event # Without this binding, the canvas will tend to flicker wx.EVT_ERASE_BACKGROUND(self, self.wxOnEraseBackground) # Handle resizing of the window wx.EVT_SIZE(self, self.wxOnSize) # Handle requests to display this canvas wx.EVT_PAINT(self, self.wxOnPaint) # Handle keyboard events... wx.EVT_KEY_DOWN(self, self.wxOnKeyDown) wx.EVT_KEY_UP(self, self.wxOnKeyUp) wx.EVT_CHAR(self, self.wxOnCharacter) # Handle mouse events... wx.EVT_LEFT_DOWN(self, self.wxOnMouseButton) wx.EVT_RIGHT_DOWN(self, self.wxOnMouseButton) wx.EVT_MIDDLE_DOWN(self, self.wxOnMouseButton) wx.EVT_LEFT_UP(self, self.wxOnMouseButton) wx.EVT_RIGHT_UP(self, self.wxOnMouseButton) wx.EVT_MIDDLE_UP(self, self.wxOnMouseButton) wx.EVT_MOTION(self, self.wxOnMouseMove) if hasattr(self, 'OnIdle'): wx.EVT_IDLE(self, self.wxOnIdle)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = BBox3D() self.unionbbox = BBox3D() random.seed() #Face mesh variables and manipulation variables self.mesh1 = None self.mesh1Dist = None self.mesh1DistLoaded = False self.mesh2 = None self.mesh2DistLoaded = False self.mesh2Dist = None self.mesh3 = None #Holds the transformations of the best iteration in ICP self.transformations = [] self.savingMovie = False self.movieIter = 0 self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = False self.displayMeshNormals = False self.displayPrincipalAxes = False self.vertexColors = np.zeros(0) self.cutPlane = None self.displayCutPlane = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[1, 1, 1], [-1, -1, -1]]) random.seed() #Point cloud and playing information self.displayCount = 0 self.SampleDelays = np.array([]) self.NFrames = 0 self.currFrame = 0 self.PointClouds = [] self.Playing = False self.PlayIDX = 0 self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion) #self.initGL() #Load in candide mesh information and store in an index buffer fin = open('candideFaces.txt', 'r') self.candideIndices = np.array([[int(a) for a in x.split()] for x in fin.readlines()], dtype=np.int32) self.candideFaces = vbo.VBO(candideIndices, target=GL_ELEMENT_ARRAY_BUFFER) fin.close() fin = open('candideTexCoords.txt', 'r') self.texCoords = vbo.VBO( np.array([[float(a) for a in x.split()] for x in fin.readlines()], dtype=np.float32)) fin.close() self.texID = -1
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.x, self.size.y) #self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = BBox3D() self.unionbbox = BBox3D() random.seed() #State variables for saving screenshots self.filepath = None self.rotfilePrefix = "Rotation" self.rotstartAngle = -50 self.rotendAngle = 50 self.rotangleInc = 5 self.rotAngle = 0 self.zCenter = 0 #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.meshPrincipalAxes = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = False self.displayMeshNormals = False self.displayPrincipalAxes = False self.useLighting = False self.useTexture = True self.vertexColors = np.zeros(0) self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, takeScreenshots, screenshotsPrefix="", rotationAngle=0): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent self.takeScreenshots = takeScreenshots print "Taking screenshots: %s" % self.takeScreenshots self.screenshotCounter = 1 self.screenshotsPrefix = screenshotsPrefix self.rotationAngle = rotationAngle #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = BBox3D() self.unionbbox = BBox3D() random.seed() #Face mesh variables and manipulation variables self.faceMesh = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = False self.displayMeshNormals = False self.vertexColors = np.zeros(0) self.cutPlane = None self.displayCutPlane = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, mainControl, parent, id): wx.Notebook.__init__(self, parent, id) # nb = wx.PreNotebook() # self.PostCreate(nb) MiscEventSourceMixin.__init__(self) self.mainControl = mainControl self.mainControl.getMiscEvent().addListener(self) self.currentPresenter = None self.presenters = [] self.mruTabIndex = [] self.tabSwitchByKey = 0 # 2: Key hit, notebook change not processed; # 1: Key hit, nb. change processed # 0: Processing done self.currentPresenterProxyEvent = ProxyMiscEvent(self) # Last presenter for which a context menu was shown self.lastContextMenuPresenter = None self.runningPageChangedEvent = False # res = xrc.XmlResource.Get() # self.docPagePresContextMenu = res.LoadMenu("MenuDocPagePresenterTabPopup") self.tabDragCursor = wx.StockCursor(wx.CURSOR_HAND) self.tabDragging = wx.NOT_FOUND # wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), # self.OnNotebookPageChanged) self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNotebookPageChanged) wx.EVT_KEY_UP(self, self.OnKeyUp) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_CONTEXT_MENU(self, self.OnContextMenu) wx.EVT_SET_FOCUS(self, self.OnFocused) wx.EVT_KILL_FOCUS(self, self.OnKillFocus) # EVT_AFTER_FOCUS(self, self.OnAfterFocus) wx.EVT_MENU(self, GUI_ID.CMD_CLOSE_THIS_TAB, self.OnCloseThisTab) wx.EVT_MENU(self, GUI_ID.CMD_CLOSE_CURRENT_TAB, self.OnCloseCurrentTab) wx.EVT_MENU(self, GUI_ID.CMD_THIS_TAB_SHOW_SWITCH_EDITOR_PREVIEW, self.OnCmdSwitchThisEditorPreview) wx.EVT_MENU(self, GUI_ID.CMD_GO_NEXT_TAB, self.OnGoTab) wx.EVT_MENU(self, GUI_ID.CMD_GO_PREVIOUS_TAB, self.OnGoTab) wx.EVT_MENU(self, GUI_ID.CMD_CLIPBOARD_COPY_URL_TO_THIS_WIKIWORD, self.OnCmdClipboardCopyUrlToThisWikiWord)
def __init__(self, parent, ID, mainControl): EnhancedListControl.__init__(self, parent, ID, style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.mainControl = mainControl self.InsertColumn(0, _(u"Page Name"), width=100) self.InsertColumn(1, _(u"Visited"), width=100) colConfig = self.mainControl.getConfig().get( "main", "wikiWideHistory_columnWidths", u"100,100") self.setColWidthsByConfigString(colConfig) # self.updatingThreadHolder = Utilities.ThreadHolder() self.mainControl.getMiscEvent().addListener(self) self.layerVisible = True self.sizeVisible = True # False if this window has a size # that it can't be read (one dim. less than 5 pixels) self.ignoreOnChange = False self.historyOverviewSink = wxKeyFunctionSink( (("changed wiki wide history", self.onUpdateNeeded), )) self.__sinkApp = wxKeyFunctionSink( (("options changed", self.onUpdateNeeded), ), wx.GetApp().getMiscEvent(), self) if not self.mainControl.isMainWindowConstructed(): # Install event handler to wait for construction self.__sinkMainFrame = wxKeyFunctionSink( (("constructed main window", self.onConstructedMainWindow), ), self.mainControl.getMiscEvent(), self) else: self.onConstructedMainWindow(None) wx.EVT_CONTEXT_MENU(self, self.OnContextMenu) wx.EVT_WINDOW_DESTROY(self, self.OnDestroy) # wx.EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated) wx.EVT_SIZE(self, self.OnSize) # wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleButtonDown) wx.EVT_MENU(self, GUI_ID.CMD_WIKI_WIDE_HISTORY_DELETE_ALL, self.OnCmdDeleteAll) self.onWikiStateChanged(None)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.bbox = BBox3D() #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayBoundary = False self.displayMeshVertices = True self.displayVertexNormals = False self.displayFaceNormals = False self.useLighting = True self.useTexture = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, coverSong, SSMPlot): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.coverSong = coverSong self.SSMPlot = SSMPlot #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[1, 1, 1], [-1, -1, -1]]) #Set up OpenGL vertex buffer for points and colors self.YVBO = vbo.VBO(np.array(self.coverSong.Y, dtype='float32')) self.YColorsVBO = vbo.VBO( np.array(self.coverSong.YColors, dtype='float32')) #Point cloud and playing information self.DrawEdges = False self.Playing = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[1, 1, 1], [-1, -1, -1]]) random.seed() #Point cloud and playing information self.displayCount = 0 self.SampleDelays = np.array([]) self.NFrames = 0 self.currFrame = 0 self.PointClouds = [] self.Playing = False self.PlayIDX = 0 self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attrib_list = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList=attrib_list) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0, 0)) self._shown_error = False self._context = glcanvas.GLContext(self) self._button_size = 64 self._animation_list = [] self.gl_release_list = [] self._refresh_queued = False self._idle_called = False wx.EVT_PAINT(self, self._on_gui_paint) wx.EVT_SIZE(self, self._on_size) wx.EVT_ERASE_BACKGROUND(self, self._on_erase_background) wx.EVT_LEFT_DOWN(self, self._on_gui_mouse_down) wx.EVT_LEFT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_LEFT_UP(self, self._on_gui_mouse_up) wx.EVT_RIGHT_DOWN(self, self._on_gui_mouse_down) wx.EVT_RIGHT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_RIGHT_UP(self, self._on_gui_mouse_up) wx.EVT_MIDDLE_DOWN(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_DCLICK(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_UP(self, self._on_gui_mouse_up) wx.EVT_MOTION(self, self._on_gui_mouse_motion) wx.EVT_KEY_DOWN(self, self._on_gui_key_down) wx.EVT_KEY_UP(self, self._on_gui_key_up) wx.EVT_KILL_FOCUS(self, self._on_focus_lost) wx.EVT_IDLE(self, self._on_idle)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList = attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Skeleton animation variables self.skeleton = Skeleton() self.animator = SkeletonAnimator(self.skeleton) self.animationState = 0 self.animating = False #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = np.array([[-1, -1, -1], [1, 1, 1]]) random.seed() self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, usernameList): wx.ScrolledWindow.__init__(self, parent) # load the map image and prepare a DC for it mapImageFile = os.path.normpath( os.path.join(MEDIAROOT, "images/map.jpg")) mapImage = wx.Image(mapImageFile, wx.BITMAP_TYPE_JPEG) self.mapBitmap = wx.BitmapFromImage(mapImage) self.bmpDC = wx.MemoryDC() mapImageFile = os.path.normpath( os.path.join(MEDIAROOT, "images/map-quarter.jpg")) mapImage = wx.Image(mapImageFile, wx.BITMAP_TYPE_JPEG) self.mapBitmapSmall = wx.BitmapFromImage(mapImage) self.bmpDC.SelectObject(self.mapBitmapSmall) self.zoomLevel = 2 self.pushpinOffset = (-8, 35) # configure scrollbars self.SetVirtualSize( (self.mapBitmapSmall.GetWidth(), self.mapBitmapSmall.GetHeight())) self.SetScrollRate(10, 10) self.maskColour = wx.Colour(10, 10, 10) self.pen = wx.Pen(wx.BLACK, 3, wx.SOLID) self.brush = wx.Brush(wx.WHITE, wx.SOLID) self.bgBrush = wx.Brush(self.maskColour, wx.SOLID) self.pushpinDC = wx.MemoryDC() self.labelsShown = False self.playerLoc = [] self.pushpins = [] self.pushpinBackgrounds = [] self.pushpinsDrawn = [] self.labels = [] for i in range(6): self.playerLoc.append(0) filename = os.path.normpath( os.path.join(MEDIAROOT, "images/pin" + str(i) + ".png")) pushpinImage = wx.Image(filename, wx.BITMAP_TYPE_ANY) pushpinImage.SetMaskColour( 255, 0, 242) # the purplish colour is not to be drawn pushpinBitmap = wx.BitmapFromImage(pushpinImage) self.pushpins.append(pushpinBitmap) pushpinBackBmp = wx.EmptyBitmap(pushpinBitmap.GetWidth(), pushpinBitmap.GetHeight(), -1) self.pushpinBackgrounds.append(pushpinBackBmp) self.labels.append( TextPanel(self, " " + usernameList[i][:20] + " ", 10, wx.SIMPLE_BORDER)) self.labels[i].Hide() self.labels[i].SetBackgroundColour(wx.Colour(220, 220, 220)) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) # scroll the map on middle or right button drag wx.EVT_MIDDLE_DOWN(self, self.handleMiddleOrRightMouse) wx.EVT_RIGHT_DOWN(self, self.handleMiddleOrRightMouse) wx.EVT_MOTION(self, self.handleMoveMouse) wx.EVT_LEFT_DCLICK(self, self.propagateDClick)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.GUIState = STATE_NORMAL self.GUISubstate = SUBSTATE_NONE self.parent = parent #Camera state variables self.size = self.GetClientSize() self.camera = MouseSphericalCamera(self.size.x, self.size.y) #self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False self.bbox = BBox3D() self.unionbbox = BBox3D() random.seed() #State variables for saving screenshots self.rotfilePrefix = "Rotation" self.rotstartAngle = -50 self.rotendAngle = 50 self.rotangleInc = 5 self.rotAngle = 0 self.lightPhi = 0 self.lightTheta = 0 self.lightIter = 0 #State variables for laplacian mesh operations self.laplacianConstraints = { } #Elements will be key-value pairs (idx, Point3D(new position)) self.laplaceCurrentIdx = -1 self.eigvalues = np.zeros(0) self.eigvectors = np.zeros(0) #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.meshPrincipalAxes = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = False self.displayMeshNormals = False self.displayPrincipalAxes = False self.useLighting = True self.useTexture = True self.vertexColors = np.zeros(0) self.PRSTPlaneMesh = None self.PRSTPointPairs = [] self.cutPlane = None self.displayCutPlane = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribs) self.context = glcanvas.GLContext(self) self.setText = False self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.initiallyResized = False random.seed() #GUI State Variables self.GUIState = STATE_INTRO self.GUISubstate = -1 #Head Mesh self.headMesh = PolyMesh() self.headMesh.loadFile('NotreDameMedium.off') self.headMeshLowres = PolyMesh() self.headMeshLowres.loadFile('NotreDameLowres.off') self.styrofoamHead = PolyMesh() self.styrofoamHead.loadFile('StyrofoamHead.off') self.rotAngle = 0 self.zoom = 0 self.rotCount = 0 self.timelineCount = 0 #User's face self.userMesh = None self.colorUserMesh = None #ICP state variables self.ICPTransformation = np.zeros(0) self.ICPMutex = Lock() self.ICPThread = None self.bbox = self.headMesh.getBBox() self.camera.centerOnBBox(self.bbox, theta=-math.pi / 2, phi=math.pi / 2) self.zCenter = (self.bbox.zmax + self.bbox.zmin) / 2.0 self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion) self.initGL()
def __init__(self, parent, ID, *args, **kw): # miscellaneous protected variables self._CurrentRenderer = None self._CurrentCamera = None self._CurrentZoom = 1.0 self._CurrentLight = None self._ViewportCenterX = 0 self._ViewportCenterY = 0 self._Picker = vtkCellPicker() self._PickedActor = None self._PickedProperty = vtkProperty() self._PickedProperty.SetColor(1, 0, 0) self._PrePickedProperty = None # these record the previous mouse position self._LastX = 0 self._LastY = 0 # the current interaction mode (Rotate, Pan, Zoom, etc) self._Mode = None self._ActiveButton = None # private attributes self.__OldFocus = None # used by the LOD actors self._DesiredUpdateRate = 15 self._StillUpdateRate = 0.0001 # First do special handling of some keywords: # stereo, position, size, width, height, style stereo = 0 if 'stereo' in kw: if kw['stereo']: stereo = 1 del kw['stereo'] position = wx.DefaultPosition if 'position' in kw: position = kw['position'] del kw['position'] size = wx.DefaultSize if 'size' in kw: size = kw['size'] del kw['size'] if 'width' in kw and 'height' in kw: size = (kw['width'], kw['height']) del kw['width'] del kw['height'] # wxWANTS_CHARS says to give us e.g. TAB # wxNO_FULL_REPAINT_ON_RESIZE cuts down resize flicker under GTK style = wx.WANTS_CHARS | wx.NO_FULL_REPAINT_ON_RESIZE if 'style' in kw: style = style | kw['style'] del kw['style'] # the enclosing frame must be shown under GTK or the windows # don't connect together properly l = [] p = parent while p: # make a list of all parents l.append(p) p = p.GetParent() l.reverse() # sort list into descending order for p in l: p.Show() # initialize the wxWindow baseClass.__init__(self, parent, ID, position, size, style) # create the RenderWindow and initialize it self._RenderWindow = vtkRenderWindow() try: self._RenderWindow.SetSize(size.width, size.height) except AttributeError: self._RenderWindow.SetSize(size[0], size[1]) if stereo: self._RenderWindow.StereoCapableWindowOn() self._RenderWindow.SetStereoTypeToCrystalEyes() self.__Created = 0 # Tell the RenderWindow to render inside the wxWindow. if self.GetHandle(): self.__Created = 1 self._RenderWindow.SetWindowInfo(str(self.GetHandle())) # refresh window by doing a Render wx.EVT_PAINT(self, self.OnPaint) # turn off background erase to reduce flicker wx.EVT_ERASE_BACKGROUND(self, lambda e: None) # Bind the events to the event converters wx.EVT_RIGHT_DOWN(self, self._OnButtonDown) wx.EVT_LEFT_DOWN(self, self._OnButtonDown) wx.EVT_MIDDLE_DOWN(self, self._OnButtonDown) wx.EVT_RIGHT_UP(self, self._OnButtonUp) wx.EVT_LEFT_UP(self, self._OnButtonUp) wx.EVT_MIDDLE_UP(self, self._OnButtonUp) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_ENTER_WINDOW(self, self._OnEnterWindow) wx.EVT_LEAVE_WINDOW(self, self._OnLeaveWindow) wx.EVT_CHAR(self, self.OnChar) wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_KEY_UP(self, self.OnKeyUp) wx.EVT_SIZE(self, self._OnSize) wx.EVT_MOVE(self, self.OnMove) wx.EVT_SET_FOCUS(self, self.OnSetFocus) wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
def OnCreate(self, doc, flags): config = wx.ConfigBase_Get() windowLoc = self._service.GetEmbeddedWindowLocation() if windowLoc == FLOATING_MINIFRAME: pos = config.ReadInt(self._service.GetServiceName() + "FrameXLoc", -1), config.ReadInt( self._service.GetServiceName() + "FrameYLoc", -1) # make sure frame is visible screenWidth = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X) screenHeight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) if pos[0] < 0 or pos[0] >= screenWidth or pos[1] < 0 or pos[ 1] >= screenHeight: pos = wx.DefaultPosition size = wx.Size( config.ReadInt(self._service.GetServiceName() + "FrameXSize", -1), config.ReadInt(self._service.GetServiceName() + "FrameYSize", -1)) title = _(self._service.GetServiceName()) if wx.GetApp().GetDocumentManager().GetFlags( ) & wx.lib.docview.DOC_SDI and wx.GetApp().GetAppName(): title = title + " - " + wx.GetApp().GetAppName() frame = wx.MiniFrame(wx.GetApp().GetTopWindow(), -1, title, pos=pos, size=size, style=wx.CLOSE_BOX | wx.CAPTION | wx.SYSTEM_MENU) wx.EVT_CLOSE(frame, self.OnCloseWindow) elif wx.GetApp().IsMDI(): self._embeddedWindow = wx.GetApp().GetTopWindow( ).GetEmbeddedWindow(windowLoc) frame = self._embeddedWindow else: pos = config.ReadInt(self._service.GetServiceName() + "FrameXLoc", -1), config.ReadInt( self._service.GetServiceName() + "FrameYLoc", -1) # make sure frame is visible screenWidth = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X) screenHeight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) if pos[0] < 0 or pos[0] >= screenWidth or pos[1] < 0 or pos[ 1] >= screenHeight: pos = wx.DefaultPosition size = wx.Size( config.ReadInt(self._service.GetServiceName() + "FrameXSize", -1), config.ReadInt(self._service.GetServiceName() + "FrameYSize", -1)) title = _(self._service.GetServiceName()) if wx.GetApp().GetDocumentManager().GetFlags( ) & wx.lib.docview.DOC_SDI and wx.GetApp().GetAppName(): title = title + " - " + wx.GetApp().GetAppName() frame = wx.GetApp().CreateDocumentFrame(self, doc, flags, pos=pos, size=size) frame.SetTitle(title) if config.ReadInt( self._service.GetServiceName() + "FrameMaximized", False): frame.Maximize(True) wx.EVT_CLOSE(frame, self.OnCloseWindow) self.SetFrame(frame) sizer = wx.BoxSizer(wx.VERTICAL) windowLoc = self._service.GetEmbeddedWindowLocation() if self._embeddedWindow or windowLoc == FLOATING_MINIFRAME: if (self._service.GetEmbeddedWindowLocation() == wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOM): if ServiceView.bottomTab == None: ServiceView.bottomTab = wx.Notebook( frame, wx.NewId(), (0, 0), (100, 100), wx.LB_DEFAULT, "Bottom Tab") wx.EVT_RIGHT_DOWN(ServiceView.bottomTab, self.OnNotebookRightClick) wx.EVT_MIDDLE_DOWN(ServiceView.bottomTab, self.OnNotebookMiddleClick) sizer.Add(ServiceView.bottomTab, 1, wx.TOP | wx.EXPAND, 4) def OnFrameResize(event): ServiceView.bottomTab.SetSize( ServiceView.bottomTab.GetParent().GetSize()) frame.Bind(wx.EVT_SIZE, OnFrameResize) # Factor this out. self._control = self._CreateControl(ServiceView.bottomTab, wx.NewId()) if self._control != None: ServiceView.bottomTab.AddPage( self._control, self._service.GetServiceName()) ServiceView.bottomTab.Layout() else: # Factor this out. self._control = self._CreateControl(frame, wx.NewId()) sizer.Add(self._control) else: # Factor this out. self._control = self._CreateControl(frame, wx.NewId()) sizer.Add(self._control, 1, wx.EXPAND, 0) frame.SetSizer(sizer) frame.Layout() self.Activate() return True
def __init__(self, parent): attriblist = [ wx.glcanvas.WX_GL_RGBA, wx.glcanvas.WX_GL_STENCIL_SIZE, 8, wx.glcanvas.WX_GL_DOUBLEBUFFER, 16 ] GLCanvas.__init__(self, parent, -1, attribList=attriblist) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MIDDLE_UP(self, self.OnMiddleUp) wx.EVT_RIGHT_DOWN(self, self.OnMiddleDown) wx.EVT_RIGHT_UP(self, self.OnMiddleUp) wx.EVT_MOTION(self, self.OnMouseMove) wx.EVT_KEY_DOWN(self, self.OnKeyPress) #wx.EVT_MOVE(self, self.OnMove) self.gl_context = wx.glcanvas.GLContext(self) self.nVertices = 0 self.IScale = [1.0, 1.0, 1.0] self.zeroPt = [0, 1.0 / 3, 2.0 / 3] self.cmap = pylab.cm.hsv self.clim = [0, 1] self.alim = [0, 1] self.displayMode = '2D' #3DPersp' #one of 3DPersp, 3DOrtho, 2D self.wireframe = False self.parent = parent self.pointSize = 5 #default point size = 5nm #self.pixelsize = 5./800 #self.xmin =0 #self.xmax = self.pixelsize*self.Size[0] #self.ymin = 0 #self.ymax = self.pixelsize*self.Size[1] self.scaleBarLength = 1000 self.scaleBarOffset = (10, 10) #pixels from corner self.scaleBarDepth = 10.0 #pixels self.scaleBarColour = [1, 1, 0] self.centreCross = False self.LUTDraw = True self.mode = 'triang' self.colouring = 'area' self.drawModes = { 'triang': GL_TRIANGLES, 'quads': GL_QUADS, 'edges': GL_LINES, 'points': GL_POINTS } self.c = numpy.array([1, 1, 1]) self.a = numpy.array([1, 1, 1]) self.zmin = -10 self.zmax = 10 self.angup = 0 self.angright = 0 self.vecUp = numpy.array([0, 1, 0]) self.vecRight = numpy.array([1, 0, 0]) self.vecBack = numpy.array([0, 0, 1]) self.xc = 0 self.yc = 0 self.zc = 0 self.zc_o = 0 self.sx = 100 self.sy = 100 self.scale = 1 self.stereo = False self.eye_dist = .01 self.dragging = False self.panning = False self.edgeThreshold = 20 self.selectionSettings = SelectionSettings() self.selectionDragging = False self.layers = [] self.overlays = [] self.messageOverlay = MessageOverlay() self.overlays.append(self.messageOverlay) self.wantViewChangeNotification = WeakSet() self.pointSelectionCallbacks = [] return
def __init__(self, parent, wid=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, **traits): AbstractWindow.__init__(self, **traits) self._timer = None self._mouse_captured = False # Due to wx wonkiness, we don't reliably get cursor position from # a wx KeyEvent. Thus, we manually keep track of when we last saw # the mouse and use that information instead. These coordinates are # in the wx coordinate space, i.e. pre-self._flip_y(). self._last_mouse_pos = (0, 0) # Create the delegate: self.control = control = self._create_control(parent, wid, pos, size) # Set up the 'erase background' event handler: wx.EVT_ERASE_BACKGROUND(control, self._on_erase_background) # Set up the 'paint' event handler: wx.EVT_PAINT(control, self._paint) wx.EVT_SIZE(control, self._on_size) # Set up mouse event handlers: wx.EVT_LEFT_DOWN(control, self._on_left_down) wx.EVT_LEFT_UP(control, self._on_left_up) wx.EVT_LEFT_DCLICK(control, self._on_left_dclick) wx.EVT_MIDDLE_DOWN(control, self._on_middle_down) wx.EVT_MIDDLE_UP(control, self._on_middle_up) wx.EVT_MIDDLE_DCLICK(control, self._on_middle_dclick) wx.EVT_RIGHT_DOWN(control, self._on_right_down) wx.EVT_RIGHT_UP(control, self._on_right_up) wx.EVT_RIGHT_DCLICK(control, self._on_right_dclick) wx.EVT_MOTION(control, self._on_mouse_move) wx.EVT_ENTER_WINDOW(control, self._on_window_enter) wx.EVT_LEAVE_WINDOW(control, self._on_window_leave) wx.EVT_MOUSEWHEEL(control, self._on_mouse_wheel) # Handle key up/down events: wx.EVT_KEY_DOWN(control, self._on_key_pressed) wx.EVT_KEY_UP(control, self._on_key_released) wx.EVT_CHAR(control, self._on_character) # Attempt to allow wxPython drag and drop events to be mapped to # Enable drag events: # Handle window close and cleanup wx.EVT_WINDOW_DESTROY(control, self._on_close) if PythonDropTarget is not None: control.SetDropTarget(LessSuckyDropTarget(self)) self._drag_over = [] # In some cases, on the Mac at least, we never get an initial EVT_SIZE # since the initial size is correct. Because of this we call _on_size # here to initialize our bounds. self._on_size(None) return
def __init__(self, presenter, parent, ID): wx.html.HtmlWindow.__init__(self, parent, ID) self.presenter = presenter self.presenterListener = wxKeyFunctionSink(( ("loaded current wiki page", self.onLoadedCurrentWikiPage), ("reloaded current doc page", self.onReloadedCurrentPage), ("opened wiki", self.onOpenedWiki), ("closing current wiki", self.onClosingCurrentWiki) ), self.presenter.getMiscEvent()) self.__sinkApp = wxKeyFunctionSink(( ("options changed", self.onOptionsChanged), ), wx.GetApp().getMiscEvent()) self.__sinkDocPage = wxKeyFunctionSink(( ("updated wiki page", self.onUpdatedWikiPage), ("changed live text", self.onChangedLiveText) ), self.presenter.getCurrentDocPageProxyEvent()) self.visible = False self.outOfSync = True # HTML content is out of sync with live content self.counterResizeIgnore = 0 # How often to ignore a size event self.deferredScrollPos = None # Used by scrollDeferred() self.currentLoadedWikiWord = None self.anchor = None # Name of anchor to jump to when view gets visible self.contextHref = None # Link href on which context menu was opened # TODO Should be changed to presenter as controller self.exporterInstance = PluginManager.getExporterTypeDict( self.presenter.getMainControl(), False)[u"html_single"][0]\ (self.presenter.getMainControl()) self._DEFAULT_FONT_SIZES = self.presenter.getMainControl().presentationExt.INTHTML_FONTSIZES # TODO More elegantly self.exporterInstance.exportType = u"html_previewWX" self.exporterInstance.styleSheet = u"" self.exporterInstance.tempFileSet = TempFileSet() self._updateTempFilePrefPath() self.exporterInstance.setWikiDocument( self.presenter.getWikiDocument()) self.exporterInstance.setLinkConverter( LinkConverterForPreview(self.presenter.getWikiDocument())) wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_KEY_UP(self, self.OnKeyUp) wx.EVT_SIZE(self, self.OnSize) wx.EVT_MENU(self, GUI_ID.CMD_CLIPBOARD_COPY, self.OnClipboardCopy) wx.EVT_MENU(self, GUI_ID.CMD_SELECT_ALL, lambda evt: self.SelectAll()) wx.EVT_MENU(self, GUI_ID.CMD_ZOOM_IN, lambda evt: self.addZoom(1)) wx.EVT_MENU(self, GUI_ID.CMD_ZOOM_OUT, lambda evt: self.addZoom(-1)) wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_THIS, self.OnActivateThis) wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_NEW_TAB_THIS, self.OnActivateNewTabThis) wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_NEW_TAB_BACKGROUND_THIS, self.OnActivateNewTabBackgroundThis) wx.EVT_MENU(self, GUI_ID.CMD_ACTIVATE_NEW_WINDOW_THIS, self.OnActivateNewWindowThis) wx.EVT_MENU(self, GUI_ID.CMD_OPEN_CONTAINING_FOLDER_THIS, self.OnOpenContainingFolderThis) self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) wx.EVT_LEFT_DCLICK(self, self.OnLeftDClick) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) wx.EVT_MOTION(self, self.OnMouseMotion)
def __init__(self, parent): attriblist = [ wx.glcanvas.WX_GL_RGBA, wx.glcanvas.WX_GL_STENCIL_SIZE, 8, wx.glcanvas.WX_GL_DOUBLEBUFFER, 16 ] GLCanvas.__init__(self, parent, -1, attribList=attriblist) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_UP(self, self.OnLeftUp) wx.EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MIDDLE_UP(self, self.OnMiddleUp) wx.EVT_MOTION(self, self.OnMouseMove) wx.EVT_KEY_DOWN(self, self.OnKeyPress) #wx.EVT_MOVE(self, self.OnMove) self.gl_context = wx.glcanvas.GLContext(self) self.init = 0 self.nVertices = 0 self.IScale = [1.0, 1.0, 1.0] self.zeroPt = [0, 1.0 / 3, 2.0 / 3] self.cmap = pylab.cm.hsv self.clim = [0, 1] self.alim = [0, 1] self.wireframe = False self.parent = parent self.pointSize = 5 #default point size = 5nm self.pixelsize = 5. / 800 self.xmin = 0 self.xmax = self.pixelsize * self.Size[0] self.ymin = 0 self.ymax = self.pixelsize * self.Size[1] self.scaleBarLength = 200 self.scaleBarOffset = (20.0, 20.0) #pixels from corner self.scaleBarDepth = 10.0 #pixels self.scaleBarColour = [1, 1, 0] self.mode = 'triang' self.colouring = 'area' self.drawModes = { 'triang': GL_TRIANGLES, 'quads': GL_QUADS, 'edges': GL_LINES, 'points': GL_POINTS } self.c = numpy.array([1, 1, 1]) self.a = numpy.array([1, 1, 1]) self.zmin = -10 self.zmax = 10 self.angup = 0 self.angright = 0 self.vecUp = numpy.array([0, 1, 0]) self.vecRight = numpy.array([1, 0, 0]) self.vecBack = numpy.array([0, 0, 1]) self.xc = 0 self.yc = 0 self.zc = 0 self.scale = 1 self.stereo = True self.eye_dist = .1 self.dragging = False self.panning = False self.edgeThreshold = 200 self.layers = [] return