Beispiel #1
0
 def __init__(self, systemtype, parent=None):
     QtGui.QWidget.__init__(self)
     self.ui = MainWindow.Ui_MainWindow()
     self.ui.setupUi(self)
     self.listMinima = [
                        self.ui.listWidget,
                        self.ui.listMinima1,
                        self.ui.listMinima2,
                        self.ui.listFrom
                        ]
     self.systemtype = systemtype
     self.NewSystem()
     self.transition=None
     
     #try to load the pymol viewer.  
     self.usepymol = True
     try:
         from pymol_viewer import PymolViewer
         self.pymolviewer = PymolViewer(self.system.load_coords_pymol)
     except (ImportError or NotImplementedError):
         self.usepymol = False
         #note: glutInit() must be called exactly once.  pymol calls it
         #during pymol.finish_launching(), so if we call it again it will
         #give an error. On the other hand, if we're not using pymol we 
         #must call it.
         from OpenGL.GLUT import glutInit
         glutInit()
def start_pyasteroids():
    random.seed()

    import sys
    from OpenGL.GLUT import glutInit
    glutInit(sys.argv)

    app = QApplication(argv)

    # Game state
    Player()

    # Load the config files in memory
    ConfigManager()

    # Add the custom fonts to the Qt database
    FontManager()

    # Creates the window (GLWidget is created there)
    win = AsteroidsMainWindow()

    # Pop-up the window
    win.show()

    # Faster processing
    try:
        import psyco
    except:
        print 'You currently do not have the Psyco module in your PYTHONPATH.'
        print 'It is highly advisable to install it for a much better gaming performance.'
        print 'Official site: http://psyco.sourceforge.net/'

    # Gives control to Qt
    app.exec_()
Beispiel #3
0
def glut_context():
    from OpenGL.GLUT import glutInit, glutCreateWindow, glutHideWindow
    glutInit()
    context = glutCreateWindow('Hidden window for OpenGL context')
    glutHideWindow()
    logger.debug('glut context created')
    yield context
Beispiel #4
0
def main():
    moons = [Moon(pos) for pos in d12_input]
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
    glutInitWindowSize(800, 800)
    glutInitWindowPosition(350, 200)
    glutCreateWindow('name')
    glClearColor(0., 0., 0., 1.)
    glShadeModel(GL_SMOOTH)
    glEnable(GL_CULL_FACE)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_LIGHTING)
    lightZeroPosition = [10., 4., 10., 1.]
    lightZeroColor = [0.8, 1.0, 0.8, 1.0]
    glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition)
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor)
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1)
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05)
    glEnable(GL_LIGHT0)
    glutDisplayFunc(lambda: display_scene(moons))
    glutTimerFunc(0, timer, 0)
    glMatrixMode(GL_PROJECTION)
    gluPerspective(40., 1., 1., 40.)
    glMatrixMode(GL_MODELVIEW)
    gluLookAt(0, -10, 10, 0, 0, 0, 0, 1, 0)
    glPushMatrix()
    glutMainLoop()
Beispiel #5
0
def start_pyasteroids():
    random.seed()
    
    import sys
    from OpenGL.GLUT import glutInit
    glutInit(sys.argv)
    
    app = QApplication(argv)
    
    # Game state
    Player()
    
    # Load the config files in memory 
    ConfigManager()
    
    # Add the custom fonts to the Qt database
    FontManager()

    # Creates the window (GLWidget is created there)
    win = AsteroidsMainWindow()

    # Pop-up the window
    win.show()

    # Faster processing
    try:
        import psyco
    except:
        print 'You currently do not have the Psyco module in your PYTHONPATH.'
        print 'It is highly advisable to install it for a much better gaming performance.'
        print 'Official site: http://psyco.sourceforge.net/'

    # Gives control to Qt
    app.exec_()
Beispiel #6
0
    def __init__(self,
                 title,
                 width=1024,
                 height=768,
                 background_color=color.Smoke):
        self.base_width = width
        self.base_height = height

        glutInit(sys.argv)
        glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
        glutInitWindowSize(width, height)
        glutInitWindowPosition((self.screen_width - width) // 2,
                               (self.screen_height - height) // 2)
        glutCreateWindow(title)

        glutKeyboardFunc(self.handle_key)
        glutDisplayFunc(self._draw)
        glutIdleFunc(self.handle_idle)
        glutMouseFunc(self.handle_mouse)
        glutSpecialFunc(self.handle_special_key)
        glutReshapeFunc(self.handle_reshape)

        glEnable(GL_DEPTH_TEST)

        if background_color is not None:
            self.fill_color(*color.Smoke, 1.)
Beispiel #7
0
 def init_interface(self):
     """ initialize the window and register the render function """
     glutInit()
     glutInitWindowSize(640, 480)
     glutCreateWindow("3D Modeller")
     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
     glutDisplayFunc(self.render)
Beispiel #8
0
    def create_window(self, params):
        if self.__glut_window is None:
            # init GLUT !
            pymt_logger.debug('WinGlut: GLUT initialization')
            glutInit('')
            glutInitDisplayMode(
                GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH |
                GLUT_MULTISAMPLE | GLUT_STENCIL | GLUT_ACCUM)

            # create the window
            self.__glut_window = glutCreateWindow('pymt')

        # register all callbcaks
        glutReshapeFunc(self._glut_reshape)
        glutMouseFunc(self._glut_mouse)
        glutMotionFunc(self._glut_mouse_motion)
        glutKeyboardFunc(self._glut_keyboard)

        # update window size
        glutShowWindow()
        self.size = params['width'], params['height']
        if params['fullscreen']:
            pymt_logger.debug('WinGlut: Set window to fullscreen mode')
            glutFullScreen()

        super(MTWindowGlut, self).create_window(params)
Beispiel #9
0
    def create_window(self, params):
        if self.__glut_window is None:
            # init GLUT !
            pymt_logger.debug('WinGlut: GLUT initialization')
            glutInit('')
            if 'PYMT_GLUT_UNITTEST' in os.environ:
                glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE)
            else:
                glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA
                                    | GLUT_DEPTH | GLUT_MULTISAMPLE
                                    | GLUT_STENCIL | GLUT_ACCUM)

            # create the window
            self.__glut_window = glutCreateWindow('pymt')

        # register all callbcaks
        glutReshapeFunc(self._glut_reshape)
        glutMouseFunc(self._glut_mouse)
        glutMotionFunc(self._glut_mouse_motion)
        glutKeyboardFunc(self._glut_keyboard)

        # update window size
        glutShowWindow()
        self.size = params['width'], params['height']
        if params['fullscreen']:
            pymt_logger.debug('WinGlut: Set window to fullscreen mode')
            glutFullScreen()

        super(MTWindowGlut, self).create_window(params)
Beispiel #10
0
 def init_interface(self):
     """ initialize the window and register the render function """
     glutInit()
     glutInitWindowSize(640, 480)
     glutCreateWindow("3D Modeller")
     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
     glutDisplayFunc(self.render)
Beispiel #11
0
 def init_interface(self):
     """ 初始化窗口并注册渲染函数 """
     glutInit()
     glutInitWindowSize(640, 480)
     glutCreateWindow("python-three-body by lovememo")
     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
     #注册窗口渲染函数
     glutDisplayFunc(self.render)
 def init_interface(self):
     """ 初始化窗口并注册渲染函数 """
     glutInit()
     glutInitWindowSize(640, 480)
     glutCreateWindow(b"3D Modeller")
     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
     #注册窗口渲染函数
     glutDisplayFunc(self.render)
Beispiel #13
0
    def __init_display(self):
        """Initialize the viewport with specified size."""
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH)
        glutInitWindowSize(*self.__size)

        glutInitWindowPosition(0, 0)
        glutInit(sys.argv)
        glutCreateWindow(b"Morphable face model")
Beispiel #14
0
    def init_interface(self):

        glutInit()
        glutInitWindowSize(640, 480)
        glutCreateWindow(b"3D Modeller")
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
        #register render function
        glutDisplayFunc(self.render)
Beispiel #15
0
    def __init_display(self):
        """Initialize the viewport with specified size."""
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH)
        glutInitWindowSize(*self.__size)

        glutInitWindowPosition(0, 0)
        glutInit(sys.argv)
        glutCreateWindow(b"Morphable face model")
Beispiel #16
0
    def __init__(self, parent, dataModel, rotation=True, **keywords):
        super(Torus5dGLWidget, self).__init__(parent, rotation=rotation)

        if not boxfish_glut_initialized:
            boxfish_glut_initialzed = True
            glutInit()

        def kwarg(name, default_value):
            setattr(self, name, keywords.get(name, default_value))

        self.parent = parent
        self.dataModel = None

        # Note:  axis refers to which axis we're looking down in the 3d torus
        #   view.  The axis we're looking down in the overview (the 4th dimension)
        #   is the last value in the tuple (w, h, d) for each axis in [0, 1, 2, 3] below
        self.axis = 0  # Which axis the display should look down (default A)
        self.axis_index = 0  # Which horizontal and veritcal axis (default B, C)
        self.axis_map = { 0: [(1,2,3), (1,3,2), (2,3,1)], 1: [(0,2,3), (0,3,2), (2,3,0)], \
            2: [(0,1,3), (0,3,1), (1,3,0)], 3: [(0,1,2), (0,2,1), (1,2,0)]}

        # Constants for MiniMaps - user cannot modify
        self.node_size = 0.2
        self.node_pack_factor = 3.5  # How close to each link is (1.5 is .5 box space)
        self.gap = 2

        # Constants for Main View, user modifies link_width, e-link length (figure out)
        self.link_width = 4.  # 24
        self.link_pack_factor = 1  # 8.4
        # self.gap above
        self.elink_offset_center_x = 0.5  # 0.7
        self.elink_offset_center_y = 0.45  # 0.7
        self.elink_offset_diagonal_x = 0.4  # 2.2
        self.elink_offset_diagonal_y = 1.5  # 5.55

        self.outOfRangeOpacity = 0.07

        #self.gap = 10 * self.node_size * self.node_pack_factor # Spacing between successive cylinders

        kwarg("default_node_color", (0.2, 0.2, 0.2, 0.3))
        kwarg("node_cmap", self.parent.agent.requestScene("nodes").color_map)

        kwarg("default_link_color", (0.2, 0.2, 0.2, 0.3))
        kwarg("link_cmap", self.parent.agent.requestScene("links").color_map)

        # Color map bound changing
        self.delta = 0.05
        self.lowerBoundLinks = 0.
        self.upperBoundLinks = 1.
        self.lowerBoundNodes = 0.
        self.upperBoundNodes = 1.

        # Directions in which coords are laid out on the axes
        self.axis_directions = np.array([1, -1, -1])

        self.setDataModel(dataModel)
        self.clearNodes()
        self.clearLinks()
Beispiel #17
0
    def init(self):
        glutInit(sys.argv)
        glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE)
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
        glutCreateWindow('Main Window')
        glutDisplayFunc(self.display)
        glutKeyboardFunc(self.keyboard)

        glutMainLoop()
Beispiel #18
0
    def create_display(width=WIDTH, height=HEIGHT) -> int:
        glutInit([])
        glutInitWindowSize(width, height)
        window_id = glutCreateWindow('Test window title')
        glutHideWindow()

        glViewport(0, 0, width, height)

        return window_id
Beispiel #19
0
 def init_interface(self):
     ''' 初始化窗口并注册 渲染函数 '''
     glutInit()
     glutInitWindowSize(640, 480)
     glutInitWindowPosition(200, 200)
     glutCreateWindow(b"3D Modeller")
     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
     # 注册窗口函数
     glutDisplayFunc(self.render)
Beispiel #20
0
def _test_for_opengl():
    try:
        # from OpenGL.GLUT import glutInit
        glutInit()
    except Exception as e:
        print >> sys.stderr, e
        print 'failure'
    else:
        print 'success'
Beispiel #21
0
def init():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
    glutInitWindowSize(*WINDOW_SIZE)
    glutInitWindowPosition(50, 50)
    glutCreateWindow("PyGLSnake")
    glClearColor(
        *(ELEMENT_TYPES[0] + [255])
    )  #All our colors are 3-ints, this one needs alpha channel too so we just tack it on
    gluOrtho2D(0, WINDOW_SIZE[0], WINDOW_SIZE[1], 0)
Beispiel #22
0
def run(title='QT Window', simulation=None, trackball=None,
        step_callback=None, keyboard_callback=None, cls=PyDartQtWindow):
    glutInit(())
    app = QtGui.QApplication([title])
    w = cls(title, simulation)
    w.setTrackball(trackball)
    w._step_callback = step_callback
    w._keyboard_callback = keyboard_callback
    w.show()
    app.exec_()
Beispiel #23
0
    def __init__(self):
        GladeWrapper.__init__(self, "plugins/basic/gui.glade", "wi_measurements", "window")
        self.window.hide()
        self.init_callbacks(self.__class__)

        labels_chain2 = ["distances",
            "label_12", "distance_12"
        ]
        labels_chain3 = ["angles", "distances_to_line",
            "label_23", "distance_23",
            "label_123", "angle_123",
            "label_1_23", "distance_1_23",
        ]
        labels_chain_only3 = [
            "label_12_3", "distance_12_3",
        ]
        labels_chain4 = [
            "dihedral_angles", "out_of_plane_angles",
            "distances_to_plane", "distances_between_lines",
            "label_34", "distance_34",
            "label_234", "angle_234",
            "label_123_234", "angle_123_234",
            "label_12_234", "angle_12_234",
            "label_123_34", "angle_123_34",
            "label_1_234", "distance_1_234",
            "label_123_4", "distance_123_4",
            "label_23_4", "distance_23_4",
            "label_12_34", "distance_12_34",
        ]
        labels_chain_closed = [
            "label_31", "distance_31",
            "label_231", "angle_231",
            "label_312", "angle_312",
            "label_31_2", "distance_31_2",
        ]

        self.init_proxies(
            labels_chain2 + labels_chain3 + labels_chain_only3 + labels_chain4 +
            labels_chain_closed
        )
        self.labels_chain2 = [self.__dict__[label] for label in labels_chain2]
        self.labels_chain3 = [self.__dict__[label] for label in labels_chain3]
        self.labels_chain_only3 = [self.__dict__[label] for label in labels_chain_only3]
        self.labels_chain4 = [self.__dict__[label] for label in labels_chain4]
        self.labels_chain_closed = [self.__dict__[label] for label in labels_chain_closed]

        context.application.action_manager.connect("action-started", self.on_action_started)
        context.application.action_manager.connect("action-ends", self.on_action_ended)
        context.application.action_manager.connect("action-cancels", self.on_action_ended)

        self.model_objects = []
        self.points = []
        self.vectors = []

        glutInit([])
Beispiel #24
0
def main(path=None):
    glutInit(sys.argv)

    if sys.platform == 'darwin':
        if not path:
            path = dialog()

    if not path:
        sys.exit(0)

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
    glutInitWindowPosition(0, 0)
    glutInitWindowSize(730, 650)

    win = glutCreateWindow(b'MIDI Player')

    (width, height, img) = read_image(join(dirname(__file__), 'mixer.ppm'))
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
    texture = glGenTextures(1)
    glBindTexture(GL_TEXTURE_2D, texture)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
                 GL_UNSIGNED_BYTE, img)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

    glMatrixMode(GL_TEXTURE)
    glLoadIdentity()
    glScale(1 / width, 1 / height, 1)

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(0, 730, 0, 650, 0, 1)

    player = Player(win, path, width, height)

    glutDisplayFunc(player.display_func)
    glutKeyboardFunc(player.keyboard_func)
    glutMouseFunc(player.mouse_func)
    glutMotionFunc(player.motion_func)
    glutIdleFunc(player.process_events)

    submenus = []
    for instrument in range(128):
        if instrument % 8 == 0:
            submenus.append([
                families[instrument // 8],
                glutCreateMenu(player.change_instrument)
            ])
        glutAddMenuEntry(instruments[instrument].encode('ascii'), instrument)
    glutCreateMenu(player.change_instrument)
    for family, submenu in submenus:
        glutAddSubMenu(family.encode('ascii'), submenu)
    glutAttachMenu(GLUT_RIGHT_BUTTON)

    glutMainLoop()
Beispiel #25
0
def main(path=None):
    glutInit(sys.argv)

    if sys.platform == 'darwin':
        if not path:
            path = dialog()

    if not path:
        sys.exit(0)

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
    glutInitWindowPosition(0, 0)
    glutInitWindowSize(730, 650)

    win = glutCreateWindow(b'MIDI Player')

    (width, height, img) = read_image('mixer.ppm')
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1)

    rbo = c_uint(int(glGenRenderbuffersEXT(1)))
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rbo)
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, width, height)

    fbo = c_uint(int(glGenFramebuffersEXT(1)))
    glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo)
    glFramebufferRenderbufferEXT(GL_READ_FRAMEBUFFER_EXT,
                                 GL_COLOR_ATTACHMENT0_EXT,
                                 GL_RENDERBUFFER_EXT, rbo)

    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo)
    glClear(GL_COLOR_BUFFER_BIT)
    glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, img)
    glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)

    player = Player(win, path, width, height)

    glutDisplayFunc(player.display_func)
    glutKeyboardFunc(player.keyboard_func)
    glutMouseFunc(player.mouse_func)
    glutMotionFunc(player.motion_func)
    glutIdleFunc(player.process_events)

    submenus = []
    for instrument in range(128):
        if instrument % 8 == 0:
            submenus.append([families[instrument // 8],
                             glutCreateMenu(player.change_instrument)])
        glutAddMenuEntry(instruments[instrument].encode('ascii'), instrument)
    glutCreateMenu(player.change_instrument)
    for family, submenu in submenus:
        glutAddSubMenu(family.encode('ascii'), submenu)
    glutAttachMenu(GLUT_RIGHT_BUTTON)

    glutMainLoop()
Beispiel #26
0
def _verify_glut_init():
    # According to the documentation, just checking bool(glutInit) is supposed to be enough
    # However on Windows with no GLUT DLL that can still pass, even if calling the method throws a null function error.
    if bool(glutInit):
        try:
            glutInit()
            return True
        except NullFunctionError as _:
            pass

    return False
Beispiel #27
0
def main(path=None):
    glutInit(sys.argv)

    if sys.platform == 'darwin':
        if not path:
            path = dialog()

    if not path:
        sys.exit(0)

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
    glutInitWindowPosition(0, 0)
    glutInitWindowSize(730, 650)

    win = glutCreateWindow(b'MIDI Player')

    (width, height, img) = read_image(join(dirname(__file__), 'mixer.ppm'))
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
    texture = glGenTextures(1)
    glBindTexture(GL_TEXTURE_2D, texture)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
                 GL_RGB, GL_UNSIGNED_BYTE, img)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

    glMatrixMode(GL_TEXTURE)
    glLoadIdentity()
    glScale(1/width, 1/height, 1)

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(0, 730, 0, 650, 0, 1)

    player = Player(win, path, width, height)

    glutDisplayFunc(player.display_func)
    glutKeyboardFunc(player.keyboard_func)
    glutMouseFunc(player.mouse_func)
    glutMotionFunc(player.motion_func)
    glutIdleFunc(player.process_events)

    submenus = []
    for instrument in range(128):
        if instrument % 8 == 0:
            submenus.append([families[instrument // 8],
                             glutCreateMenu(player.change_instrument)])
        glutAddMenuEntry(instruments[instrument].encode('ascii'), instrument)
    glutCreateMenu(player.change_instrument)
    for family, submenu in submenus:
        glutAddSubMenu(family.encode('ascii'), submenu)
    glutAttachMenu(GLUT_RIGHT_BUTTON)

    glutMainLoop()
Beispiel #28
0
def main():
    from OpenGL.GLUT import glutInit, glutInitDisplayMode, GLUT_DOUBLE, GLUT_RGBA
    from ModelViewWindow import GLUTWindow, View

    glutInit()
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA)
    #TODO -------- COPY CODE FROM LSystem.py ----------
    ''' Replace the following L-system speicfication with the one you did
    in LSystem.py '''
    # L-system specification
    TorchPlant = {'init' : 'X',
               'rule' : 'X->F-[[X]+X]+F[+FXL]-XL;F->FF',
               'depth': 5, 'angle': 25, 'growth_factor': .5,
               'init_angle_axis':{'angle':90, 'axis': [0, 0, 1]},
              }
    '''
    ModelList is a convenient way to add all the models with their position
    in a python list of dictionaries which can be used by the GardenScene class.
    NOTE that using this is optional. If you want you can add all the transformation
    code in GardenScene.draw_scene()
    '''
    ModelList = [{'pos':[0, 0, 0], 'model': LSystem(TorchPlant)},
                ]
    #--------------------------------------------------

    #TODO ---------------- BEGIN SOLUTION -----------------

    '''
    Represent the terrain using a Bicubic patch. Replace the
    control points below with the control points for your terrain.
    '''
    control_points = np.zeros((16, 3))
    control_points[:,0] = np.transpose([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])
    control_points[:,1] = np.transpose([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3])
    control_points[:,2] = np.transpose([0, 2, 2, 3, 0, 2, 2, 3, 0, 2, 2, 3, 0, 2, 2, 3])
    BCPatch = BicubicPatch(control_points)
    # ------------ END SOLUTION ------------------------
    # main camera
    cam_spec = {'eye' : [0, 4.5, 4], 'center' : [0, 2, 0], 'up' : [0, 1, 0],
                 'fovy': 40, 'aspect': 1.0, 'near' : 0.1, 'far' : 100.0}

    cam = FlythroughCamera(GardenScene(BCPatch, ModelList),
                           cam_spec, HermiteCurve())
    GLUTWindow('Garden Scene', cam, window_size = (640 * 1.2, 480), window_pos = (320, 0))

    # external camera
    cam_spec2 = {'eye' : [5, 5, 5], 'center' : [0, 1, 0], 'up' : [0, 1, 0],
                 'fovy': 60, 'aspect': 1.0, 'near' : 0.1, 'far' : 200.0}
    external_cam = View(cam, cam_spec2)
    GLUTWindow("External Camera View", external_cam, window_size = (640 * 1.2, 480), window_pos = (320, 520))

    glutMainLoop()
Beispiel #29
0
    def init_opengl(self, width, height, x, y):
        glutInit()
        glutInitWindowPosition(x, y)
        glutInitWindowSize(width, height)
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE)
        glutCreateWindow("Rainbow Alga")
        glutDisplayFunc(self.render)
        glutIdleFunc(self.render)
        glutReshapeFunc(self.resize)

        glutMouseFunc(self.mouse)
        glutMotionFunc(self.drag)
        glutKeyboardFunc(self.keyboard)
        glutSpecialFunc(self.special_keyboard)

        glClearDepth(1.0)
        glClearColor(0.0, 0.0, 0.0, 0.0)
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 3000)
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)


        # Lighting
        light_ambient = (0.0, 0.0, 0.0, 1.0)
        light_diffuse = (1.0, 1.0, 1.0, 1.0)
        light_specular = (1.0, 1.0, 1.0, 1.0)
        light_position = (-100.0, 100.0, 100.0, 0.0)

        mat_ambient = (0.7, 0.7, 0.7, 1.0)
        mat_diffuse = (0.8, 0.8, 0.8, 1.0)
        mat_specular = (1.0, 1.0, 1.0, 1.0)
        high_shininess = (100)

        glEnable(GL_LIGHT0)
        glEnable(GL_NORMALIZE)
        glEnable(GL_COLOR_MATERIAL)
        glEnable(GL_LIGHTING)

        glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient)
        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
        glLightfv(GL_LIGHT0, GL_SPECULAR,  light_specular)
        glLightfv(GL_LIGHT0, GL_POSITION, light_position)

        glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient)
        glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse)
        glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular)
        glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess)

        # Transparency
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Beispiel #30
0
def create_window(winname, size=(800, 600), display=None, resize=None):
    glutInit(argv)
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
    glutInitWindowSize(size[0], size[1])
    glutCreateWindow(winname.encode('ascii'))

    if display is not None:
        display_func = _display_wrapper(display)
        glutDisplayFunc(display_func)
        glutIdleFunc(display_func)

    if resize is not None:
        glutReshapeFunc(resize)
Beispiel #31
0
def run():
    global window
    glutInit(sys.argv)

    # Select type of Display mode:   
    #  Double buffer 
    #  RGBA color
    # Alpha components supported 
    # Depth buffer
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
    
    # get a 640 x 480 window
    resolution = get_state()["camera"]["resolution"]
    glutInitWindowSize(int(resolution[0]), int(resolution[1]))
    
    # the window starts at the upper left corner of the screen 
    glutInitWindowPosition(0, 0)
    
    # Okay, like the C version we retain the window id to use when closing, but for those of you new
    # to Python (like myself), remember this assignment would make the variable local and not global
    # if it weren't for the global declaration at the start of main.
    window = glutCreateWindow("Waffle")

       # Register the drawing function with glut, BUT in Python land, at least using PyOpenGL, we need to
    # set the function pointer and invoke a function to actually register the callback, otherwise it
    # would be very much like the C version of the code.    
    glutDisplayFunc(DrawGLScene)
    
    # Uncomment this line to get full screen.
    # glutFullScreen()

    # When we are doing nothing, redraw the scene.
    glutIdleFunc(idleFunc)
    
    # Register the function called when our window is resized.
    glutReshapeFunc(ReSizeGLScene)
    
    # Register the function called when the keyboard is pressed.  
    glutKeyboardFunc(keyDown)
    glutKeyboardUpFunc(keyUp)
    glutMouseFunc(onMouseClick)
    glutMotionFunc(onMouseClickMove)
    glutPassiveMotionFunc(onMouseMove)

    # Initialize our window. 
    InitGL()
    init_world()
    init_interface()

    # Start Event Processing Engine    
    glutMainLoop()
Beispiel #32
0
    def ContextMainLoop(cls, *args, **named):
        """Mainloop for the GLUT testing context"""
        from OpenGL.GLUT import glutInit, glutMainLoop
        # initialize GLUT windowing system
        import sys
        try:
            glutInit(sys.argv)
        except TypeError:
            glutInit(' '.join(sys.argv))

        render = cls(*args, **named)
        if hasattr(render, 'createMenus'):
            render.createMenus()
        return glutMainLoop()
Beispiel #33
0
def run(title='QT Window',
        simulation=None,
        trackball=None,
        step_callback=None,
        keyboard_callback=None,
        cls=PyDartQtWindow):
    glutInit(())
    app = QtGui.QApplication([title])
    w = cls(title, simulation)
    w.setTrackball(trackball)
    w._step_callback = step_callback
    w._keyboard_callback = keyboard_callback
    w.show()
    app.exec_()
Beispiel #34
0
def test():
    from OpenGL.GLUT import glutInit
    import sys
    import pylab as pl

    app = QtGui.QApplication(sys.argv)
    from pele.systems import LJCluster
    pl.ion()
    natoms = 13
    system = LJCluster(natoms)
    system.params.double_ended_connect.local_connect_params.NEBparams.iter_density = 5.
    dbname = "lj%dtest.db" % (natoms,)
    db = system.create_database(dbname)
    
    #get some minima
    if False:
        bh = system.get_basinhopping(database=db)
        bh.run(10)
        minima = db.minima()
    else:
        x1, e1 = system.get_random_minimized_configuration()[:2]
        x2, e2 = system.get_random_minimized_configuration()[:2]
        min1 = db.addMinimum(e1, x1)
        min2 = db.addMinimum(e2, x2)
        minima = [min1, min2]

    
    # connect some of the minima
    nmax = min(3, len(minima))
    m1 = minima[0]
    for m2 in minima[1:nmax]:
        connect = system.get_double_ended_connect(m1, m2, db)
        connect.connect()
    
        
    if True:
        from pele.thermodynamics import get_thermodynamic_information
        get_thermodynamic_information(system, db, nproc=4)
    
    wnd = GraphViewDialog(db, app=app)
#    decrunner = DECRunner(system, db, min1, min2, outstream=wnd.textEdit_writer)
    glutInit()
    wnd.show()
    from PyQt4.QtCore import QTimer
    def start():
        wnd.start()

    QTimer.singleShot(10, start)
    sys.exit(app.exec_()) 
Beispiel #35
0
def test():
    from OpenGL.GLUT import glutInit
    import sys
    import pylab as pl

    app = QtGui.QApplication(sys.argv)
    from pele.systems import LJCluster
    pl.ion()
    natoms = 13
    system = LJCluster(natoms)
    system.params.double_ended_connect.local_connect_params.NEBparams.iter_density = 5.
    dbname = "lj%dtest.db" % (natoms,)
    db = system.create_database(dbname)
    
    #get some minima
    if False:
        bh = system.get_basinhopping(database=db)
        bh.run(10)
        minima = db.minima()
    else:
        x1, e1 = system.get_random_minimized_configuration()[:2]
        x2, e2 = system.get_random_minimized_configuration()[:2]
        min1 = db.addMinimum(e1, x1)
        min2 = db.addMinimum(e2, x2)
        minima = [min1, min2]

    
    # connect some of the minima
    nmax = min(3, len(minima))
    m1 = minima[0]
    for m2 in minima[1:nmax]:
        connect = system.get_double_ended_connect(m1, m2, db)
        connect.connect()
    
        
    if True:
        from pele.thermodynamics import get_thermodynamic_information
        get_thermodynamic_information(system, db, nproc=4)
    
    wnd = GraphViewDialog(db, app=app)
#    decrunner = DECRunner(system, db, min1, min2, outstream=wnd.textEdit_writer)
    glutInit()
    wnd.show()
    from PyQt4.QtCore import QTimer
    def start():
        wnd.start()

    QTimer.singleShot(10, start)
    sys.exit(app.exec_()) 
Beispiel #36
0
 def ContextMainLoop( cls, *args, **named ):
     """Mainloop for the GLUT testing context"""
     from OpenGL.GLUT import glutInit, glutMainLoop
     # initialize GLUT windowing system
     import sys
     try:
         glutInit( sys.argv)
     except TypeError:
         import string
         glutInit( ' '.join(sys.argv))
     
     render = cls( *args, **named)
     if hasattr( render, 'createMenus' ):
         render.createMenus()
     return glutMainLoop()
Beispiel #37
0
 def _initGL(self, extraArgs):
     """initializes OpenGL and creates the Window"""
     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
     glutInitWindowSize(self.size, self.size)
     glutInitWindowPosition(self.initx, self.inity)
     glutInit(extraArgs.split(" "))
     glutCreateWindow(VERSIONSTRING.encode("ascii"))
     glutDisplayFunc(self.Draw)
     glutIdleFunc(glutPostRedisplay)
     glutReshapeFunc(self.Reshape)
     glutKeyboardFunc(self.HandleKeys)
     glutSpecialFunc(self.HandleKeys)
     glutMouseFunc(self.HandleMouse)
     glClearColor(*(self.bgcolor + [0.0]))
     glEnable(GL_LINE_SMOOTH)
     glLineWidth(1.3)
Beispiel #38
0
    def init(self, hide_window):
        # Shift from ARGB to RGBA
        self.color_palette = [((x << 8) & 0xFFFFFFFF) | 0x000000FF
                              for x in self.color_palette]
        self.alphamask = 0x000000FF
        self.color_format = u"RGB"
        self.buffer_dims = (144, 160)

        if not glutInit():
            raise Exception("OpenGL couldn't initialize!")
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
        glutInitWindowSize(*self._scaledresolution)
        glutCreateWindow("PyBoy")
        glutKeyboardFunc(self._key)
        glutKeyboardUpFunc(self._keyUp)
        glutSpecialFunc(self._spec)
        glutSpecialUpFunc(self._specUp)
        self.events = []

        glPixelZoom(self._scale, self._scale)
        glutReshapeFunc(self._glreshape)
        glutDisplayFunc(self._gldraw)

        if hide_window:
            logger.warning("Hiding the window is not supported in OpenGL")
Beispiel #39
0
def main(argv):
    if len(argv) > 2:
        # Start a remote window
        MeshViewerRemote(
            titlebar=argv[1], subwins_vert=int(argv[2]),
            subwins_horz=int(argv[3]), width=int(argv[4]), height=int(argv[5])
        )
    elif len(argv) == 2:
        # Just a test for opengl working
        try:
            from OpenGL.GLUT import glutInit
            glutInit()
        except Exception as e:  # pylint: disable=broad-except
            print >>sys.stderr, e
            print 'failure'
        else:
            print 'success'
Beispiel #40
0
Datei: run.py Projekt: js850/pele
    def __init__(self, app, systemtype, parent=None):
        QtGui.QWidget.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.systemtype = systemtype
        self.transition = None
        self.app = app
        self.double_ended_connect_runs = []
        self.pick_count = 0

        self.minima_selection = MySelection()
        self.on_minimum_1_selected = Signal()
        self.on_minimum_2_selected = Signal()

        # set up the list manager
        self.list_manager = ListViewManager(self)

        # define the system
        self.NewSystem()

        # finish setting up the list manager (this must be done after NewSystem() is called)
        self.list_manager.finish_setup()

        # try to load the pymol viewer.
        try:
            self.usepymol = self.system.params.gui.use_pymol
        except (KeyError, AttributeError):
            self.usepymol = config.getboolean("gui", "use_pymol")
        if self.usepymol:
            try:
                from pymol_viewer import PymolViewer

                self.pymolviewer = PymolViewer(self.system.load_coords_pymol)
            except (ImportError or NotImplementedError):
                self.usepymol = False

        if self.usepymol == False:
            # note: glutInit() must be called exactly once.  pymol calls it
            # during pymol.finish_launching(), so if we call it again it will
            # give an error. On the other hand, if we're not using pymol we
            # must call it.
            from OpenGL.GLUT import glutInit

            glutInit()

        self.bhmanager = None
Beispiel #41
0
def show_OpenGL(csg):
    if not _have_OpenGL:
        raise RuntimeError("PyOpenGL not available")
    renderable = TestRenderable(csg)

    glutInit()
    glutInitWindowSize(640, 480)
    renderable.win_id = glutCreateWindow("CSG Test")
    glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION)
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA)
    glutDisplayFunc(renderable.display)
    glutKeyboardFunc(renderable.keypress)
    glutSpecialFunc(renderable.special_keypress)

    renderable.init()

    glutMainLoop()
Beispiel #42
0
    def __init__(self, app, systemtype, parent=None):
        QtGui.QWidget.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.systemtype = systemtype
        self.transition = None
        self.app = app
        self.double_ended_connect_runs = []
        self.pick_count = 0

        self.minima_selection = MySelection()
        self.on_minimum_1_selected = Signal()
        self.on_minimum_2_selected = Signal()

        # set up the list manager
        self.list_manager = ListViewManager(self)

        # define the system
        self.NewSystem()

        # finish setting up the list manager (this must be done after NewSystem() is called)
        self.list_manager.finish_setup()

        # try to load the pymol viewer.
        try:
            self.usepymol = self.system.params.gui.use_pymol
        except (KeyError, AttributeError):
            self.usepymol = config.getboolean("gui", "use_pymol")
        if self.usepymol:
            try:
                from .pymol_viewer import PymolViewer
                self.pymolviewer = PymolViewer(self.system.load_coords_pymol)
            except (ImportError or NotImplementedError):
                self.usepymol = False

        if not self.usepymol:
            # note: glutInit() must be called exactly once.  pymol calls it
            # during pymol.finish_launching(), so if we call it again it will
            # give an error. On the other hand, if we're not using pymol we
            # must call it.
            from OpenGL.GLUT import glutInit
            glutInit()

        self.bhmanager = None
Beispiel #43
0
def main():
    global texture

    print bool(glutInit)
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
    glutInitWindowSize(500, 500)
    glutInitWindowPosition(0, 0)

    glutCreateWindow("Simple PyOpenGL example")
    glutDisplayFunc(display)
    # glutIdleFunc(animate)
    glutReshapeFunc(reshape)
    glutKeyboardFunc(keyPressed)
    init()

    texture = loadTexture("Results\\EmptyInterface.png")

    glutMainLoop()
Beispiel #44
0
    def init(self):
        # Shift from ARGB to RGBA
        self.color_palette = [((x << 8) & 0xFFFFFFFF) | 0x000000FF for x in self.color_palette]
        self.alphamask = 0x000000FF
        self.color_format = u"RGB"

        glutInit()
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
        glutInitWindowSize(*self._scaledresolution)
        glutCreateWindow("PyBoy")
        glutKeyboardFunc(self._key)
        glutKeyboardUpFunc(self._keyUp)
        glutSpecialFunc(self._spec)
        glutSpecialUpFunc(self._specUp)
        self.events = []

        glPixelZoom(self._scale, self._scale)
        glutReshapeFunc(self._glreshape)
        glutDisplayFunc(self._gldraw)
Beispiel #45
0
    def __init__(self, app, system, nested_sampling):
        QtGui.QWidget.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.app = app
        self.system = system
        self.nested_sampling = nested_sampling

        self.show3d = self.ui.show3d
        self.ui.show3d.setSystem(system)

        self.update_list()

        from OpenGL.GLUT import glutInit
        glutInit()

        self.selected = None
        self.Emax = max([r.energy for r in self.nested_sampling.replicas])
Beispiel #46
0
 def __init__(self, app, system, nested_sampling):
     QtGui.QWidget.__init__(self)
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     
     
     self.app = app
     self.system = system    
     self.nested_sampling = nested_sampling
     
     self.show3d = self.ui.show3d
     self.ui.show3d.setSystem(system)
     
     self.update_list()
     
     from OpenGL.GLUT import glutInit
     glutInit()
     
     self.selected = None
     self.Emax = max([r.energy for r in self.nested_sampling.replicas])
Beispiel #47
0
def main():
    glutInit(sys.argv)

    glutInitDisplayMode(GLUT_DOUBLE)

    glutInitWindowSize(800, 600)

    glutInitWindowPosition(100, 100)

    glutCreateWindow('Particle System')

    fountains = Context()

    glutDisplayFunc(fountains.display)

    glutReshapeFunc(fountains.reshape)

    glEnable(GL_POINT_SMOOTH)

    glutMainLoop()
Beispiel #48
0
    def init(self):
        # Shift from ARGB to RGBA
        self.color_palette = [((x << 8) & 0xFFFFFFFF) | 0x000000FF
                              for x in self.color_palette]
        self.alphamask = 0x000000FF
        self.color_format = u"RGB"

        glutInit()
        glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
        glutInitWindowSize(*self._scaledresolution)
        glutCreateWindow("PyBoy")
        glutKeyboardFunc(self._key)
        glutKeyboardUpFunc(self._keyUp)
        glutSpecialFunc(self._spec)
        glutSpecialUpFunc(self._specUp)
        self.events = []

        glPixelZoom(self._scale, self._scale)
        glutReshapeFunc(self._glreshape)
        glutDisplayFunc(self._gldraw)
Beispiel #49
0
def main():
    from OpenGL.GLUT import glutInit, glutInitDisplayMode,  \
                            glutMainLoop, GLUT_DOUBLE, GLUT_RGBA
    
    from ModelViewWindow import View, GLUTWindow
    
    glutInit()
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA)
    
    cam_spec = {'eye' : [2, 2, 2], 'center' : [0, 0, 0], 'up' : [0, 1, 0], 
                 'fovy': 30, 'aspect': 1.0, 'near' : 0.01, 'far' : 200.0}
    data_points = np.zeros((16, 3))
    data_points[:,0] = np.transpose([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])
    data_points[:,1] = np.transpose([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3])
    data_points[:,2] = np.transpose([0, -2, 2, -3, 0, -2, 2, -3, 0, -2, 2, -3, 0, -2, 2, -3]) 
    
    BCPatch = BicubicPatch(data_points)
    cam = View(BCPatch, cam_spec)    
    GLUTWindow('Bicubic Patch', cam, window_size = (512, 512), window_pos =(520, 0))
    
    glutMainLoop()
Beispiel #50
0
 def __init__ (self, definition = None, **named ):
     # set up double buffering and rgb display mode
     if definition is None:
         definition = contextdefinition.ContextDefinition( **named )
     else:
         for key,value in named.items():
             setattr( definition, key, value )
     self.contextDefinition = definition
     glutInitDisplayMode( self.glutFlagsFromDefinition( definition ) )
     glutInit([])
     if glutInitContextVersion and definition.version[0]:
         glutInitContextVersion(*definition.version)
     if glutInitContextProfile and definition.profile == 'core':
         glutInitContextProfile(GLUT_CORE_PROFILE)
     
     glutInitDisplayMode( self.DISPLAYMODE )
     # set up window size for newly created windows
     apply ( glutInitWindowSize, [int(i) for i in definition.size] )
     # create a new rendering window
     self.windowID = glutCreateWindow( 
         definition.title or 
         self.getApplicationName() 
     )
     Context.__init__ (self, definition)
import struct
import sys

import ModernGL
from OpenGL.GLUT import (
    GLUT_DEPTH, GLUT_DOUBLE, GLUT_RGB, glutCreateWindow, glutDisplayFunc, glutIdleFunc, glutInit, glutInitDisplayMode,
    glutInitWindowSize, glutMainLoop, glutSwapBuffers
)

width, height = 1280, 720

glutInit(sys.argv)
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
glutInitWindowSize(width, height)
glutCreateWindow(b'')

ctx = ModernGL.create_context()

prog = ctx.program(
    ctx.vertex_shader('''
        #version 330

        uniform vec2 WindowSize;

        in vec2 in_vert;
        in vec3 in_color;

        out vec3 v_color;

        void main() {
            v_color = in_color;
Beispiel #52
0
def main():
    from OpenGL.GLUT import glutInit, glutInitDisplayMode, GLUT_DOUBLE, GLUT_RGBA
    from ModelViewWindow import GLUTWindow, View
    
    glutInit()
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA)
    #TODO -------- COPY CODE FROM LSystem.py ----------
    ''' Replace the following L-system speicfication with the one you did
    in LSystem.py '''
    # L-system specification
    Tree1 = {'init' : 'X',
                'rule' : 'X->F[+yX][++PX][-YX]FX;F->FF', # modified from Algorithmic Botany, p.25
                'depth' : 7, 'angle': 25.7, 'growth_factor': .53, 'XZScale': 2,
                'init_angle_axis': {'angle':90, 'axis':[0, 0, 1]},
                } 

    Tree2 = {'init' : 'X',
                'rule' : 'X->wFL[RX][rX[pX]X]X[YX][yX];F->FWF', # adapted from Algorithmic Botany, p.24 + Tree3D
                'depth' : 4, 'angle': 22.5, 'growth_factor': .6,
                'init_angle_axis': {'angle':90, 'axis': [0, 0, 1]},
                }

    Tree3 = {'init' : 'X',
                        'rule' : 'X->BLr[[XL]RyXXL]pBL[PBX]YXL;B->BB', # adapted from Algorithmic Botany, p.25
                        'depth': 4, 'angle': 22.5, 'growth_factor': .55,
                        'init_angle_axis':{'angle':90, 'axis':[0, 0, 1]},
                        }

    '''
    ModelList is a convenient way to add all the models with their position
    in a python list of dictionaries which can be used by the GardenScene class.
    NOTE that using this is optional. If you want you can add all the transformation
    code in GardenScene.draw_scene() 
    '''
    ModelList = [{'pos':[0, 0, 0], 'model': LSystem(Tree1)},
                {'pos': [0, 0, 0], 'model': LSystem(Tree2)},
                {'pos': [0, 0, 0], 'model' :LSystem(Tree3)}
                ]
    #--------------------------------------------------
                
    #TODO ---------------- BEGIN SOLUTION ----------------- 

    '''
    Represent the terrain using a Bicubic patch. Replace the
    control points below with the control points for your terrain.
    '''
    control_points = np.zeros((16, 3))
    # uniform grid with different ranges, as asked
    # note grid is on xz plane, and y gets height values
    control_points[:,0] = np.transpose([0, 0, 0, 0,  2, 2, 2, 2,  4, 4, 4, 4,  6, 6, 6, 6])
    control_points[:,2] = np.transpose([1, 2, 4, 6,  0, 2, 4, 6,  0, 2, 4, 6,  0, 2, 4, 6])
    control_points[:,1] = np.transpose([-1, 0, 2, 1,  1, 1, 0, 0, 0, 2, 3, 1, -1, 0, 1, -1]) 
    BCPatch = BicubicPatch(control_points)
    # ------------ END SOLUTION ------------------------
    # main camera
    cam_spec = {'eye' : [0, 4.5, 4], 'center' : [0, 2, 0], 'up' : [0, 1, 0], 
                 'fovy': 40, 'aspect': 1.0, 'near' : 0.1, 'far' : 100.0}
    
    cam = FlythroughCamera(GardenScene(BCPatch, ModelList), 
                           cam_spec, HermiteCurve())
    GLUTWindow('Garden Scene', cam, window_size = (640 * 1.2, 480), window_pos = (320, 0))
    
    # external camera
    cam_spec2 = {'eye' : [5, 5, 5], 'center' : [0, 1, 0], 'up' : [0, 1, 0], 
                 'fovy': 60, 'aspect': 1.0, 'near' : 0.1, 'far' : 200.0}
    external_cam = View(cam, cam_spec2)
    GLUTWindow("External Camera View", external_cam, window_size = (640 * 1.2, 480), window_pos = (320, 520))
    
    glutMainLoop()
    def process_events():
        app.processEvents()
    
    #setup system
    natoms = 13
    system = LJCluster(natoms)
    system.params.double_ended_connect.local_connect_params.NEBparams.iter_density = 10.
    system.params.double_ended_connect.local_connect_params.NEBparams.image_density = 3.
#    system.params.double_ended_connect.local_connect_params.NEBparams.adaptive_nimages = 5.
    system.params.double_ended_connect.local_connect_params.NEBparams.reinterpolate = 400
    system.params.double_ended_connect.local_connect_params.NEBparams.max_images = 40
    x1, e1 = system.get_random_minimized_configuration()[:2]
    x2, e2 = system.get_random_minimized_configuration()[:2]
    db = Database()
    min1 = db.addMinimum(e1, x1)
    min2 = db.addMinimum(e2, x2)
    
    #setup neb dialog
    wnd = ConnectExplorerDialog(system, app)   
    wnd.show()

    glutInit()

    #initilize the NEB and run it.
    #we have to do it through QTimer because the gui has to 
    #be intitialized first... I don't really understand it 
    from PyQt4.QtCore import QTimer
    QTimer.singleShot(10, start)

    sys.exit(app.exec_()) 
Beispiel #54
0
    def __init__(self, parent, dataModel, rotation = True, **keywords):
        super(Torus5dGLWidget, self).__init__(parent, rotation = rotation)

        if not boxfish_glut_initialized:
            boxfish_glut_initialzed = True
            glutInit()

        def kwarg(name, default_value):
            setattr(self, name, keywords.get(name, default_value))

        self.parent = parent
        self.dataModel = None

        # Note:  axis refers to which axis we're looking down in the 3d torus
        #   view.  The axis we're looking down in the overview (the 4th dimension)
        #   is the last value in the tuple (w, h, d) for each axis in [0, 1, 2, 3] below
        self.axis = 0   # Which axis the display should look down (default A)
        self.axis_index = 0 # Which horizontal and veritcal axis (default B, C)
        self.axis_map = { 0: [(1,2,3), (1,3,2), (2,3,1)], 1: [(0,2,3), (0,3,2), (2,3,0)], \
            2: [(0,1,3), (0,3,1), (1,3,0)], 3: [(0,1,2), (0,2,1), (1,2,0)]}

        # Constants for MiniMaps - user cannot modify
        self.node_size = 0.2
        self.node_pack_factor = 3.5  # How close to each link is (1.5 is .5 box space)
        self.gap = 2
        
        # Constants for Main View, user modifies link_width, e-link length (figure out)      
        self.link_width = 4. # 24
        self.link_pack_factor = 1 # 8.4
        # self.gap above
        self.elink_offset_center_x = 0.5 # 0.7
        self.elink_offset_center_y = 0.45 # 0.7
        self.elink_offset_diagonal_x = 0.4 # 2.2
        self.elink_offset_diagonal_y = 1.5 # 5.55

        self.outOfRangeOpacity = 0.07


        #self.gap = 10 * self.node_size * self.node_pack_factor # Spacing between successive cylinders
        

        kwarg("default_node_color", (0.2, 0.2, 0.2, 0.3))
        kwarg("node_cmap", self.parent.agent.requestScene("nodes").color_map)

        kwarg("default_link_color", (0.2, 0.2, 0.2, 0.3))
        kwarg("link_cmap", self.parent.agent.requestScene("links").color_map)



        # Color map bound changing
        self.delta = 0.05
        self.lowerBoundLinks = 0.
        self.upperBoundLinks = 1.
        self.lowerBoundNodes = 0.
        self.upperBoundNodes = 1.

        # Directions in which coords are laid out on the axes
        self.axis_directions = np.array([1, -1, -1])


        self.setDataModel(dataModel)
        self.clearNodes()
        self.clearLinks()
Beispiel #55
0
"""

By importing this module you agree to call glutInit

"""
from OpenGL.GLUT import glutInit
from sys import argv
glutInit(argv)