Ejemplo n.º 1
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self, parent, -1)
        self.init = False
        self.context = glcanvas.GLContext(self)

        # Initial mouse position.
        self.lastx = self.x = 30
        self.lasty = self.y = 30
        self.size = None
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
Ejemplo n.º 2
0
 def __init__(self, parent, devices, monitors, names):
     """Initialise canvas properties and useful variables."""
     super().__init__(parent, -1,
                      attribList=[wxcanvas.WX_GL_RGBA,
                                  wxcanvas.WX_GL_DOUBLEBUFFER,
                                  wxcanvas.WX_GL_DEPTH_SIZE, 16, 0])
     GLUT.glutInit()
     self.init = False
     self.context = wxcanvas.GLContext(self)
     self.monitors = monitors
     self.devices = devices
     self.names = names
     self.start = (0, 0)
     # Bind events to the canvas
     self.Bind(wx.EVT_SIZE, self.on_size)
Ejemplo n.º 3
0
    def __init__(self, parent):
        self.parent = parent

        self.width = 560
        self.height = 560

        glcanvas.GLCanvas.__init__(self, parent, -1)
        glutInit(sys.argv)

        self.init = False
        self.context = glcanvas.GLContext(self)

        # initial mouse position
        self.lastmousex = self.mousex = 30
        self.lastmousey = self.mousey = 30
        self.size = None
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        self.Bind(wx.EVT_SIZE, self.updateSize)

        self.atoms = []
        self.atoms_type = {}

        self.viewMode = 'all'
        self.viewLayer = 0
        self.layersX = {}
        self.layersY = {}
        self.layersZ = {}

        self.colorDirection = 'x'
        self.maxColor = 0

        self.playStatus = 'stop'

        self.currentT = 0

        self.playTimer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.play, self.playTimer)

        self.restartPosition()

        wx.CallAfter(self.updateSize, {})
Ejemplo n.º 4
0
 def __init__(self, parent):
     self.seg_breaks = list()
     glcanvas.GLCanvas.__init__(self, parent, -1)
     self.init = False
     self.context = glcanvas.GLContext(self)
     self.start_time = time.time()
     self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
     # initial mouse position
     self.rx, self.ry = self.last_rx, self.last_ry = (0, 0)
     self.tx, self.ty = self.last_tx, self.last_ty = (0, 0)
     self.size = None
     self.zpos = -1000  # y position
     self.Bind(wx.EVT_SIZE, self.OnSize)
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
     pub.subscribe(self.myListener, "panelListener")
Ejemplo n.º 5
0
        def __init__(self, parent):
            self._parent = 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.GetParent(),
                                       style=wx.WANTS_CHARS | wx.CLIP_CHILDREN,
                                       attribList=attribList)
            self.SetSize((1, 1))
            self._context = glcanvas.GLContext(self)
            self._color_texture = None
            self._bitmap = None

            wx.EVT_PAINT(self, self.__onPaint)
            wx.EVT_ERASE_BACKGROUND(self, self.__onEraseBackground)
Ejemplo n.º 6
0
    def __init__(self, parent: wx.Window):
        attribs = (glcanvas.WX_GL_CORE_PROFILE, glcanvas.WX_GL_RGBA,
                   glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24)
        super().__init__(parent,
                         -1,
                         size=parent.GetClientSize(),
                         attribList=attribs)
        self._context = glcanvas.GLContext(self)  # setup the OpenGL context
        self.SetCurrent(self._context)
        self.context_identifier = str(
            uuid.uuid4())  # create a UUID for the context. Used to get shaders
        self._gl_texture_atlas = glGenTextures(
            1)  # Create the atlas texture location
        self._setup_opengl()  # set some OpenGL states

        self._transformation_matrix: Optional[numpy.ndarray] = None
Ejemplo n.º 7
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self, parent, -1)
        self.init = False
        self.context = glcanvas.GLContext(self)

        self.lastx = self.x = 30
        self.lasty = self.y = 30
        self.size = None

        self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
Ejemplo n.º 8
0
    def __init__(self,
                 parent,
                 size=wx.DefaultSize,
                 style=0,
                 originLeftBottom=None):
        wxgl.GLCanvas.__init__(self, parent, -1, style=style, size=size)

        self.error = None
        self.doViewportChange = True

        self.x00 = 0  #-.5
        self.y00 = 0  #-.5
        self.x0 = None  # call center() in OnPaint -- self.x00
        self.y0 = None  # call center() in OnPaint -- self.y00
        self.scale = 1.
        self.aspectRatio = 1.
        self.rot = 0.
        self.zoomChanged = True  # trigger a first placing of image
        self.sizeChanged = True
        self.keepCentered = True

        self.pixelGrid_state = 0  # 0-off, 1-everyPixel, 2- every 10 pixels

        self.GLinit = False
        self.context = wxgl.GLContext(self)  # 20141124 cocoa

        self.moreGlLists = []
        self.moreGlLists_enabled = []
        self.moreMaster_enabled = 1
        self.moreGlLists_dict = {}  # map 'name' to list of idx in moreGlLists
        # a given idx can be part of multiple 'name' entries
        # a given name entry can contain a given idx only once
        self.moreGlLists_nameBlacklist = set()
        self.moreGlLists_NamedIdx = {
        }  # map str to int or None -- this is helpful for reusing Idx for "changing" gllists
        # if name (type str) wasn't used before, it defaults to None (20080722)

        self.moreGlListReuseIdx = None

        self.wheelFactor = 2**(1 / 3.
                               )  #1.189207115002721 # >>> 2 ** (1./4)  # 2
        self.mouse_last_x, self.mouse_last_y = 0, 0  # in case mouseIsDown happens without preceeding mouseDown

        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        parent.Bind(wx.EVT_MOVE, self.OnMove)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel)
Ejemplo n.º 9
0
    def __init__(self, parent):
        """
        Initialize the canvas for drawing and get a context, for indicating 
        which canvas is currently in use.
        """
        glcanvas.GLCanvas.__init__(self, parent, id=wx.ID_ANY)

        self.init = False
        self.context = glcanvas.GLContext(self)
        self.size = None

        # Diminish flicker
        self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

        # Handle events
        self.Bind(wx.EVT_SIZE, self.OnSize)  # Resizing the window
        self.Bind(wx.EVT_PAINT, self.OnPaint)  # Draw on canvas
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    def __init__(self, parent):

        attribList = (
            glcanvas.WX_GL_RGBA,  # RGBA
            glcanvas.WX_GL_DOUBLEBUFFER,  # Double Buffered
            glcanvas.WX_GL_DEPTH_SIZE,
            16)  # 24 bit

        super().__init__(parent,
                         -1,
                         attribList=attribList,
                         style=wx.DEFAULT_FRAME_STYLE)

        self.verbose = False
        self.debug = False

        self._isInit = False
        self._isInitGL = False
        self._isOnDraw = False
        self._isOnPaint = False
        self._isOnSize = False

        self._init_pubsub()

        self.context = glcanvas.GLContext(self)
        # Create graphics context from it
        #gc = wx.GraphicsContext.Create(self.context)

        self.SetMinSize((10, 10))

        # initial mouse position
        self.lastx = self.x = 30
        self.lasty = self.y = 30
        self.size = None
        #self.Bind(wx.EVT_ERASE_BACKGROUND,self.OnEraseBackground)

        self.Bind(wx.EVT_SIZE, self.OnReSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_CHAR, self.OnKeyDown)

        # self.Bind(wx.EVT_LEFT_DOWN,  self.OnMouseLeftDown)
        # self.Bind(wx.EVT_LEFT_UP,    self.OnMouseUp)
        # self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)
Ejemplo n.º 12
0
    def __init__(self, parent, manager=None):
        attribList = attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24)
        glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribList)
        self.init = False
        self.context = glcanvas.GLContext(self)
        self.manager = self.manager = Manager() if manager is None else manager
        self.size = None

        self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.lastx, self.lasty = None, None
        self.update = True
Ejemplo n.º 13
0
    def __init__(self, parent, manager=None, **kwargs):
        # Create the canvas
        #glcanvas.GLCanvas.__init__(self, *args, **kwargs)
        #glcanvas.GLCanvas.__init__(self, parent, -1)
        attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER,
                      glcanvas.WX_GL_DEPTH_SIZE, 24)  # 24 bit
        #         attribList = attribs = (glcanvas.WX_GL_CORE_PROFILE, glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24)
        glcanvas.GLCanvas.__init__(self,
                                   parent,
                                   -1,
                                   attribList=attribList,
                                   **kwargs)

        if haveManager:
            if manager is not None:
                self.manager = manager
                manager.canvas = self
            else:
                print('Initializing manager')
                self.manager = Manager(self)
        else:
            self.manager = None

        # --- Data
        self.mainframe = parent
        self.init = False
        self.context = glcanvas.GLContext(self)
        self.animate = False
        # Initial mouse position.
        self.lastx = self.x = 30
        self.lasty = self.y = 30
        self.size = None
        #         self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

        # Set the event handlers.
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_RIGHT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
Ejemplo n.º 14
0
 def __init__(self, parent):
     glcanvas.GLCanvas.__init__(self,
                                parent,
                                -1,
                                attribList=[
                                    glcanvas.WX_GL_RGBA,
                                    glcanvas.WX_GL_DOUBLEBUFFER,
                                    glcanvas.WX_GL_DEPTH_SIZE, 24
                                ])
     self.context = glcanvas.GLContext(self)
     self.Bind(wx.EVT_PAINT, self.OnPaint)
     self.Bind(wx.EVT_SIZE, self.OnSize)
     self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
     self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
     self.Bind(wx.EVT_MENU, self.OnMenu, None, 10000, 12000)
     self.viewport = wx.GetApp().Viewport()
     self.Resize()
     self.paint_callbacks = []
     self.context_menu_enabled = True
Ejemplo n.º 15
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self,
                                   parent,
                                   -1,
                                   size=(290, 275),
                                   pos=(5, 40))

        self.init = False
        self.screen_quad_vao = 0
        self.shader = None

        # opengl canvas for pattern table
        self.context = glcanvas.GLContext(self)
        self.SetCurrent(self.context)

        self.__screen_tex = np.zeros((128, 128, 3))
        self.Bind(wx.EVT_PAINT, self.OnPaint)

        self.InitGL()
Ejemplo n.º 16
0
    def __init__(self, *k, **kw):
        kw['attribList'] = (glcanvas.WX_GL_SAMPLES, 4)
        super(Vehicle, self).__init__(*k, **kw)

        self.context = glcanvas.GLContext(self)
        self.vehicle_wavefront = None

        self.script = None
        self.script_command = 0
        self.script_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnScriptTimer, self.script_timer)

        self.angvel = None
        self.desired_quaternion = None
        self.attitude_callback = None

        self.actuation_state = None
        self.actuation_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnActuationTimer, self.actuation_timer)
Ejemplo n.º 17
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self, parent, -1)

        self.init = False
        self.aspect_ratio = 1
        self._parent = parent
        self.vertex_shader = self.LoadShaderFromPath(TRIANGLE_VERTEX_SHADER_PATH)
        self.fragment_shader = self.LoadShaderFromPath(TRIANGLE_FRAGMENT_SHADER_PATH)
        self.rotate = True
        self.rotate_y = Matrix44.identity()

        #Contexto do Canvas
        self.context = glcanvas.GLContext(self)
        self.SetCurrent(self.context)

        glClearColor(0.0, 0.0, 0.0, 0.0)

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnResize)
Ejemplo n.º 18
0
 def __init__(self, parent, ID, prj, zoom=8):
     #glcanvas.GLCanvas.__init__(self,parent,attribList=(glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER))
     glcanvas.GLCanvas.__init__(self,
                                parent,
                                -1,
                                attribList=[
                                    glcanvas.WX_GL_RGBA,
                                    glcanvas.WX_GL_DOUBLEBUFFER,
                                    WX_GL_DEPTH_SIZE, 16, 0, 0
                                ])
     self.context = glcanvas.GLContext(self)
     self.init = False
     self.mdl = None
     self.calllist = None
     self.calllistm = None
     self.SetCursor(wx.Cursor(wx.CURSOR_PENCIL))
     self._parent = parent
     self.xSize = 0
     self.ySize = 0
     self.xScroll = 0
     self.yScroll = 0
     self.zScroll = 12
     self.xRot = -40
     self.yRot = 40
     self.vm = 0
     self.prj = prj
     self.zoom = zoom
     self.setLayer(prj.activeLayer)
     self.lclk = False
     #
     self.Bind(wx.EVT_MOUSEWHEEL, self.wheel)
     self.Bind(wx.EVT_PAINT, self.repaint)
     self.Bind(wx.EVT_SIZE, self.resize)
     self.Bind(wx.EVT_WINDOW_DESTROY, self.cleanup)
     self.Bind(wx.EVT_KEY_DOWN, self.keydown)
     self.Bind(wx.EVT_SET_FOCUS, self.sfocus)
     self.Bind(wx.EVT_KILL_FOCUS, self.kfocus)
     self.Bind(wx.EVT_LEFT_DOWN, self.leftclick)
     self.Bind(wx.EVT_LEFT_UP, self.leftunclick)
     self.Bind(wx.EVT_MOTION, self.motion)
     self.Bind(wx.EVT_ERASE_BACKGROUND, self.erase)
     self._focus = False
     self.drawing = False
Ejemplo n.º 19
0
    def __init__(self, parent, thisSettingsObj):
        glcanvas.GLCanvas.__init__(self, parent, -1)
        self.context = glcanvas.GLContext(self)

        self.CurrentGLIm = np.zeros((512, 512, 4), dtype=np.uint8)
        self.DisplayIm = np.zeros((512, 512, 4), dtype=np.uint8)

        self.SettingsObj = thisSettingsObj
        self.size = None
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightMouse)

        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
        self.ClearLogs()

        #Zoom and Pan
        self.CursorType = 'none'

        self.zoom = 1.0
        self.Zooming = False
        self.MouseDrag = False

        self.offsetx = 0
        self.xstart = 0
        self.xstop = 512
        self.istart = 0
        self.istop = 512

        self.offsety = 0
        self.ystart = 0
        self.ystop = 512
        self.jstart = 0
        self.jstop = 512

        self.xdragStart = 0
        self.ydragStart = 0
        self.xzoomStart = 0
        self.yzoomStart = 0
Ejemplo n.º 20
0
    def __init__(self, parent):
        # the nes resolution is 256 x 240 - we are making it 2.5x bigger
        glcanvas.GLCanvas.__init__(self,
                                   parent,
                                   -1,
                                   size=(640, 600),
                                   pos=(4, 4))
        self.init = False
        self.screen_quad_vao = 0
        self.shader = None
        self.context = glcanvas.GLContext(self)
        self.SetCurrent(self.context)
        glClearColor(0.1, 0.15, 0.1, 1.0)

        self.__screen_tex = np.zeros((240, 256, 3))

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

        self.InitGL()
Ejemplo n.º 21
0
    def __init__(self, parent, id, pos, size):
        """Initialise canvas properties and useful variables."""
        super().__init__(parent, -1, pos=pos, size=size,
                         attribList=[wxcanvas.WX_GL_RGBA,
                                     wxcanvas.WX_GL_DOUBLEBUFFER,
                                     wxcanvas.WX_GL_DEPTH_SIZE, 16, 0])
        GLUT.glutInit()
        self.init = False
        self.context = wxcanvas.GLContext(self)

        # Initialise variables for panning
        self.pan_x = 0
        self.pan_y = 0

        # Initialise variables for zooming
        self.zoom = 1

        # Bind events to the canvas
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.Bind(wx.EVT_SIZE, self.on_size)
Ejemplo n.º 22
0
 def __init__(self, parent, realParent):
     attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER,
                   glcanvas.WX_GL_DEPTH_SIZE, 24,
                   glcanvas.WX_GL_STENCIL_SIZE, 8)
     glcanvas.GLCanvas.__init__(self, parent, attribList=attribList)
     self.parent = realParent
     self.context = glcanvas.GLContext(self)
     wx.EVT_PAINT(self, self.OnPaint)
     wx.EVT_SIZE(self, self.OnSize)
     wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
     wx.EVT_LEFT_DOWN(self, self.OnMouseLeftDown)
     wx.EVT_MOTION(self, self.OnMouseMotion)
     wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
     self.yaw = 30
     self.pitch = 60
     self.zoom = self.parent.machineSize.x / 2 + 10
     self.offsetX = 0
     self.offsetY = 0
     self.view3D = False
     self.allowDrag = False
Ejemplo n.º 23
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self, parent, -1)
        self.init = False
        self.context = glcanvas.GLContext(self)

        # initial mouse position
        self.lastx = self.x = 0
        self.lasty = self.y = 0
        self.size = None
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)

        tree = octree_1.Octree("ball.stl")
        self.bounding_box = tree.bounding_box
        tree.traverse()
        self.voxelBoxes = tree.voxelBoxes
Ejemplo n.º 24
0
    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)
Ejemplo n.º 25
0
	def __init__(self, parent, wid=-1, buildarea=(200, 200, 100), pos=wx.DefaultPosition,
				 size=(600, 600), style=0, mainwindow=None):
		attribList = (glcanvas.WX_GL_RGBA,  # RGBA
					  glcanvas.WX_GL_DOUBLEBUFFER,  # Double Buffered
					  glcanvas.WX_GL_DEPTH_SIZE, 24)  # 24 bit

		glcanvas.GLCanvas.__init__(self, parent, wid, size=size, style=style, pos=pos, attribList=attribList)
		self.parent = parent
		self.log = self.parent.log
		self.init = False
		self.context = glcanvas.GLContext(self)

		# initial mouse position
		self.lastx = self.x = 0
		self.lasty = self.y = 0
		self.anglex = self.angley = self.anglez = 0
		self.transx = self.transy = 0
		self.resetView = True
		self.light0Pos = [0, 50, 150]
		self.light1Pos = [0, -50, 150]
		self.size = None
		self.vertexPositions = None
		
		self.clientwidth = size[0]
		self.drawGrid = False
		self.stlObject = None
		self.zoom = 1.0
		self.buildarea = buildarea
		
		self.setGridArrays()

		self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
		self.Bind(wx.EVT_SIZE, self.OnSize)
		self.Bind(wx.EVT_PAINT, self.OnPaint)
		self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
		self.Bind(wx.EVT_LEFT_DCLICK, self.OnMouseDouble)
		self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
		self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)
		self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel)
		self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp)
		self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
Ejemplo n.º 26
0
    def __init__(self, parent, *args, **kwargs):
        """create the canvas """
        kwargs['attribList'] = (
            glcanvas.WX_GL_RGBA,
            glcanvas.WX_GL_DOUBLEBUFFER,
            glcanvas.WX_GL_MIN_ALPHA,
            8,
        )
        super(Canvas, self).__init__(parent, *args, **kwargs)
        self.context = glcanvas.GLContext(self)

        self.shader_prog = None
        self.vao_id = None
        self.vbo_id = None
        self.sample_texture = None
        self.tex_uniform = None

        self.finished_init = False
        # execute self.onPaint whenever the parent frame is repainted
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.Bind(wx.EVT_SIZE, self.on_size)
Ejemplo n.º 27
0
    def __init__(self, parent):
        glcanvas.GLCanvas.__init__(self, parent, -1)
        self.init = False
        self.context = glcanvas.GLContext(self)
        # initial mouse position
        self.lastx = self.x = 0
        self.lasty = self.y = 0
        self.size = None
        self.last_scale = 0.0
        self.scale = 0.0
        self.xrot = self.lastrotx = 0.0
        self.yrot = self.lastroty = 0.0
        self.display_list_id = None

        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
Ejemplo n.º 28
0
    def __init__(self, parent, name, carlist, **kwargs):
        attribs = [
            WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_SAMPLE_BUFFERS, GL_TRUE,
            WX_GL_DEPTH_SIZE, 16, 0, 0
        ]
        glcanvas.GLCanvas.__init__(self,
                                   parent,
                                   -1,
                                   attribList=attribs,
                                   **kwargs)
        self.init = False
        self.ispovinit = False
        self.name = name
        self.carlist = carlist
        self.context = glcanvas.GLContext(self)
        self.size = self.GetClientSize()
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

        print self.name, 'fin init'
Ejemplo n.º 29
0
    def __init__(self, parent: wx.Window):
        display_attributes = wx.glcanvas.GLAttributes()
        display_attributes.PlatformDefaults().MinRGBA(
            8, 8, 8, 8).DoubleBuffer().Depth(24).EndList()
        super().__init__(parent,
                         display_attributes,
                         size=parent.GetClientSize())
        self._projection = [70.0, 4 / 3, 0.1, 10000.0]
        context_attributes = wx.glcanvas.GLContextAttrs()
        context_attributes.CoreProfile().OGLVersion(
            3, 3).Robust().ResetIsolation().EndList()
        self._context = glcanvas.GLContext(
            self, ctxAttrs=context_attributes)  # setup the OpenGL context
        self.SetCurrent(self._context)
        self._context_identifier = str(
            uuid.uuid4())  # create a UUID for the context. Used to get shaders
        self._gl_texture_atlas = glGenTextures(
            1)  # Create the atlas texture location
        self._setup_opengl()  # set some OpenGL states

        self._transformation_matrix: Optional[numpy.ndarray] = None
Ejemplo n.º 30
0
    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

        #old     wx.EVT_PAINT(self, self._on_gui_paint)
        self.Bind(wx.EVT_PAINT, self._on_gui_paint)
        self.Bind(wx.EVT_SIZE, self._on_size)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self._on_erase_background)
        self.Bind(wx.EVT_LEFT_DOWN, self._on_gui_mouse_down)
        self.Bind(wx.EVT_LEFT_DCLICK, self._on_gui_mouse_down)
        self.Bind(wx.EVT_LEFT_UP, self._on_gui_mouse_up)
        self.Bind(wx.EVT_RIGHT_DOWN, self._on_gui_mouse_down)
        self.Bind(wx.EVT_RIGHT_DCLICK, self._on_gui_mouse_down)
        self.Bind(wx.EVT_RIGHT_UP, self._on_gui_mouse_up)
        self.Bind(wx.EVT_MIDDLE_DOWN, self._on_gui_mouse_down)
        self.Bind(wx.EVT_MIDDLE_DCLICK, self._on_gui_mouse_down)
        self.Bind(wx.EVT_MIDDLE_UP, self._on_gui_mouse_up)
        self.Bind(wx.EVT_MOTION, self._on_gui_mouse_motion)
        self.Bind(wx.EVT_KEY_DOWN, self._on_gui_key_down)
        self.Bind(wx.EVT_KEY_UP, self._on_gui_key_up)
        self.Bind(wx.EVT_KILL_FOCUS, self._on_focus_lost)
        self.Bind(wx.EVT_IDLE, self._on_idle)