예제 #1
0
    def __init__(self):
        self.vtype = np.dtype([('a_curr',      'f4', 3),
                               ('a_texcoord',  'f4', 2)])
        self.utype = np.dtype([('fg_color',    'f4', 4),
                               ('length',      'f4', 1),
                               ('linewidth',   'f4', 1),
                               ('antialias',   'f4', 1),
                               ('caps',        'f4', 2)])
        Collection.__init__(self, self.vtype, self.utype)
        dsize = self.vbuffer._dsize
        a_curr = self.vbuffer.attribute('a_curr')
        a_texcoord = self.vbuffer.attribute('a_texcoord')
        a_index = self.vbuffer.attribute('a_index')
        a_next = VertexAttribute(
            'a_next', a_curr.count, a_curr.gltype, a_curr.stride, a_curr.offset)
        a_prev = VertexAttribute(
            'a_prev', a_curr.count, a_curr.gltype, a_curr.stride, a_curr.offset)
        self.attributes.extend([a_prev, a_next])
        a_index.offset    += 2*dsize
        a_curr.offset     += 2*dsize
        a_texcoord.offset += 2*dsize
        a_next.offset     += 4*dsize

        shaders = os.path.join(os.path.dirname(__file__),'.')
        vertex_shader= os.path.join( shaders, 'lines.vert')
        fragment_shader= os.path.join( shaders, 'lines.frag')
        self.shader = Shader( open(vertex_shader).read(),
                              open(fragment_shader).read() )
예제 #2
0
 def __init__(self, dash_atlas=None):
     self.vtype = np.dtype([('a_position', 'f4', 2), ('a_segment', 'f4', 2),
                            ('a_angles', 'f4', 2), ('a_tangents', 'f4', 4),
                            ('a_texcoord', 'f4', 2)])
     self.utype = np.dtype([('color', 'f4', 4), ('translate', 'f4', 2),
                            ('scale', 'f4', 1), ('rotate', 'f4', 1),
                            ('linewidth', 'f4', 1), ('antialias', 'f4', 1),
                            ('linecaps', 'f4', 2), ('linejoin', 'f4', 1),
                            ('miter_limit', 'f4', 1), ('length', 'f4', 1),
                            ('dash_phase', 'f4', 1),
                            ('dash_period', 'f4', 1),
                            ('dash_index', 'f4', 1), ('dash_caps', 'f4', 2),
                            ('closed', 'f4', 1)])
     Collection.__init__(self, self.vtype, self.utype)
     shaders = os.path.join(os.path.dirname(__file__), 'shaders')
     vertex_shader = os.path.join(shaders, 'dash-lines-2D.vert')
     fragment_shader = os.path.join(shaders, 'dash-lines-2D.frag')
     #fragment_shader= os.path.join( shaders, 'test.frag')
     if dash_atlas is None:
         self.dash_atlas = DashAtlas()
     else:
         self.dash_atlas = dash_atlas
     self.shader = Shader(
         open(vertex_shader).read(),
         open(fragment_shader).read())
예제 #3
0
    def __init__(self, dash_atlas=None):
        self.dash_atlas = dash_atlas
        self.vtype = np.dtype([('a_center', 'f4', 2),
                               ('a_texcoord', 'f4', 2)])
        self.utype = np.dtype([('fg_color', 'f4', 4),
                               ('bg_color', 'f4', 4),
                               ('translate', 'f4', 2),
                               ('scale', 'f4', 1),
                               ('rotate', 'f4', 1),
                               ('radius', 'f4', 1),
                               ('linewidth', 'f4', 1),
                               ('antialias', 'f4', 1),
                               ('dash_phase', 'f4', 1),
                               ('dash_period', 'f4', 1),
                               ('dash_index', 'f4', 1),
                               ('dash_caps', 'f4', 2)])
        Collection.__init__(self, self.vtype, self.utype)

        if dash_atlas is None:
            self.dash_atlas = DashAtlas()
        else:
            self.dash_atlas = dash_atlas

        shaders = os.path.join(os.path.dirname(__file__),'shaders')
        vertex_shader= os.path.join( shaders, 'circles.vert')
        fragment_shader= os.path.join( shaders, 'circles.frag')

        self.shader = Shader( open(vertex_shader).read(),
                              open(fragment_shader).read() )
예제 #4
0
    def __init__(self):
        self.vtype = np.dtype([('a_curr', 'f4', 3), ('a_texcoord', 'f4', 2)])
        self.utype = np.dtype([
            ('fg_color', 'f4', 4), ('length', 'f4', 1), ('linewidth', 'f4', 1),
            ('antialias', 'f4', 1), ('dash_phase', 'f4', 1),
            ('dash_period', 'f4', 1), ('dash_index', 'f4', 1),
            ('dash_caps', 'f4', 2)
        ])
        Collection.__init__(self, self.vtype, self.utype)
        self.dash_atlas = DashAtlas()

        dsize = self.vbuffer._dsize
        a_curr = self.vbuffer.attribute('a_curr')
        a_texcoord = self.vbuffer.attribute('a_texcoord')
        a_index = self.vbuffer.attribute('a_index')
        a_next = VertexAttribute('a_next', a_curr.count, a_curr.gltype,
                                 a_curr.stride, a_curr.offset)
        a_prev = VertexAttribute('a_prev', a_curr.count, a_curr.gltype,
                                 a_curr.stride, a_curr.offset)
        self.attributes.extend([a_prev, a_next])
        a_index.offset += 2 * dsize
        a_curr.offset += 2 * dsize
        a_texcoord.offset += 2 * dsize
        a_next.offset += 4 * dsize

        shaders = os.path.join(os.path.dirname(__file__), '.')
        vertex_shader = os.path.join(shaders, 'dash-lines.vert')
        fragment_shader = os.path.join(shaders, 'dash-lines.frag')
        self.shader = Shader(
            open(vertex_shader).read(),
            open(fragment_shader).read())
예제 #5
0
파일: artist.py 프로젝트: dignan/telemote
    def __init__(self, base):
        Collection.__init__(self, Artist)

        self.base = base
        self.model = base.model

        self.populate()
예제 #6
0
 def __init__(self, pid, stats=True, auth=None, def_name=None, cache=False):
     # set project
     self._cfile = Ipy.CCH_DIR + '/' + pid + '.json'
     project = None
     if cache and os.path.isfile(self._cfile):
         # try load from cache if given
         try:
             project = json.load(open(self._cfile, 'rU'))
             if Ipy.DEBUG:
                 sys.stdout.write(
                     "project %s loaded from cached file (%s)\n" %
                     (pid, self._cfile))
         except:
             pass
     if project is None:
         # load from api
         project = self._get_project(pid, auth)
         if project and cache and os.path.isdir(Ipy.CCH_DIR):
             # save to cache if given
             try:
                 json.dump(project, open(self._cfile, 'w'))
                 if Ipy.DEBUG:
                     sys.stdout.write(
                         "project %s saved to cached file (%s)\n" %
                         (mgid, self._cfile))
             except:
                 pass
     if project is not None:
         for key, val in project.iteritems():
             setattr(self, key, val)
     else:
         self.id = pid
         self.name = None
         return
     # hack to get variable name
     if def_name == None:
         try:
             (filename, line_number, function_name,
              text) = traceback.extract_stack()[-2]
             def_name = text[:text.find('=')].strip()
         except:
             pass
     self.defined_name = def_name
     # call collection init - from cache if given
     Collection.__init__(self,
                         self.mgids(),
                         stats=stats,
                         auth=auth,
                         def_name=self.defined_name,
                         cache=cache)
예제 #7
0
 def __init__(self):
     self.vtype = np.dtype([('a_position', 'f4', 2), ('a_segment', 'f4', 2),
                            ('a_angles', 'f4', 2), ('a_tangents', 'f4', 4),
                            ('a_texcoord', 'f4', 2)])
     self.utype = np.dtype([('color', 'f4', 4), ('translate', 'f4', 2),
                            ('scale', 'f4', 1), ('rotate', 'f4', 1),
                            ('linewidth', 'f4', 1), ('antialias', 'f4', 1),
                            ('length', 'f4', 1), ('closed', 'f4', 1)])
     Collection.__init__(self, self.vtype, self.utype)
     shaders = os.path.join(os.path.dirname(__file__), 'shaders')
     vertex_shader = os.path.join(shaders, 'raw-lines-2D.vert')
     fragment_shader = os.path.join(shaders, 'raw-lines-2D.frag')
     self.shader = Shader(
         open(vertex_shader).read(),
         open(fragment_shader).read())
예제 #8
0
    def __init__(self, shell):
        Collection.__init__(self, Source)

        self.shell = shell
        self.sources = {}
        self.sources_rev = {}
        self.source_id = 0

        self.add_source(self.shell.props.library_source)

        pm = self.shell.get_playlist_manager()

        for pl in pm.get_playlists():
            self.add_source(pl)

        pm.connect('playlist-added', self.on_playlist_added)
예제 #9
0
파일: source.py 프로젝트: dignan/telemote
    def __init__(self, shell):
        Collection.__init__(self, Source)

        self.shell = shell
        self.sources = {}
        self.sources_rev = {}
        self.source_id = 0

        self.add_source(self.shell.props.library_source)

        pm = self.shell.get_playlist_manager()

        for pl in pm.get_playlists():
            self.add_source(pl)

        pm.connect('playlist-added', self.on_playlist_added)
예제 #10
0
 def __init__(self):
     self.vtype = np.dtype([('a_center',    'f4', 3),
                            ('a_texcoord',  'f4', 2)])
     self.utype = np.dtype([('fg_color',    'f4', 4),
                            ('bg_color',    'f4', 4),
                            ('translate',   'f4', 3),
                            ('scale',       'f4', 1),
                            ('radius',      'f4', 1),
                            ('linewidth',   'f4', 1),
                            ('antialias',   'f4', 1)])
     Collection.__init__(self, self.vtype, self.utype)
     shaders = os.path.join(os.path.dirname(__file__),'.')
     vertex_shader= os.path.join( shaders, 'scatter.vert')
     fragment_shader= os.path.join( shaders, 'scatter.frag')
     self.shader = Shader( open(vertex_shader).read(),
                           open(fragment_shader).read() )
예제 #11
0
 def __init__(self, dash_atlas = None):
     self.vtype = np.dtype( [('a_texcoord', 'f4', 2)] )
     self.utype = np.dtype( [('translate',        'f4', 2),
                             ('scale',            'f4', 1),
                             ('rotate',           'f4', 1),
                             ('major_grid',       'f4', 2),
                             ('minor_grid',       'f4', 2),
                             ('major_tick_size',  'f4', 2),
                             ('minor_tick_size',  'f4', 2),
                             ('major_grid_color', 'f4', 4),
                             ('minor_grid_color', 'f4', 4),
                             ('major_tick_color', 'f4', 4),
                             ('minor_tick_color', 'f4', 4),
                             ('major_grid_width', 'f4', 1),
                             ('minor_grid_width', 'f4', 1),
                             ('major_tick_width', 'f4', 1),
                             ('minor_tick_width', 'f4', 1),
                             ('size',             'f4', 2),
                             ('offset',           'f4', 2),
                             ('zoom',             'f4', 1),
                             ('antialias',        'f4', 1),
                             ('major_dash_phase', 'f4', 1),
                             ('minor_dash_phase', 'f4', 1),
                             ('major_dash_index', 'f4', 1),
                             ('major_dash_period','f4', 1),
                             ('major_dash_caps',  'f4', 2),
                             ('minor_dash_period','f4', 1),
                             ('minor_dash_index', 'f4', 1),
                             ('minor_dash_caps',  'f4', 2)
                             ] )
     self.gtype = np.dtype( [('name', 'f4', (1024,4))] )
     Collection.__init__(self, self.vtype, self.utype)
     if dash_atlas is None:
         self.dash_atlas = DashAtlas()
     else:
         self.dash_atlas = dash_atlas
     shaders = os.path.join(os.path.dirname(__file__),'shaders')
     vertex_shader= os.path.join( shaders, 'grid.vert')
     fragment_shader= os.path.join( shaders, 'grid.frag')
     self.shader = Shader( open(vertex_shader).read(),
                           open(fragment_shader).read() )
     self._gbuffer = DynamicBuffer( self.gtype )
     self._gbuffer_shape = [0,4*1024]
     self._gbuffer_id = 0
예제 #12
0
파일: project.py 프로젝트: paczian/ipy-mkmq
 def __init__(self, pid, metadata=True, stats=True, auth=None, def_name=None, cache=False, reset_cache=False):
     # set project
     self.cache = Ipy.NB_DIR+'/'+pid if cache else None
     project = None
     # hack to get variable name
     if def_name == None:
         try:
             (filename,line_number,function_name,text)=traceback.extract_stack()[-2]
             def_name = text[:text.find('=')].strip()
         except:
             pass
     self.defined_name = def_name        
     # reset cache if asked
     if reset_cache and os.path.isdir(self.cache):
         shutil.rmtree(self.cache)
     # make cache dir
     if self.cache and (not os.path.isdir(self.cache)):
         os.mkdir(self.cache)
     # try load from cached
     if self.cache and os.path.isdir(self.cache) and os.path.isfile(self.cache+'/'+pid+'.json'):
         try:
             project = json.load(open(self.cache+'/'+pid+'.json', 'rU'))
             sys.stdout.write("project '%s' loaded from cache %s\n"%(self.defined_name, pid))
         except:
             pass
     # load from api
     if project is None:
         project = self._get_project(pid, metadata, auth)
         if project and self.cache and os.path.isdir(self.cache):
             # cache it if dir given and not loaded from file
             try:
                 json.dump(project, open(self.cache+'/'+pid+'.json', 'w'))
                 sys.stdout.write("project '%s' saved to cache %s\n"%(self.defined_name, pid))
             except:
                 pass
     if project is None:
         self.id = pid
         self.name = None
         return
     for key, val in project.iteritems():
         setattr(self, key, val)
     # call collection init - from cache if given
     Collection.__init__(self, self.mgids(), metadata=metadata, stats=stats, auth=auth, def_name=self.defined_name, cache=self.cache)
예제 #13
0
파일: project.py 프로젝트: MG-RAST/ipy-mkmq
 def __init__(self, pid, auth=None, def_name=None, cache=False):
     # set project
     self._cfile = Ipy.CCH_DIR+'/'+pid+'.json'
     project = None
     if cache and os.path.isfile(self._cfile):
         # try load from cache if given
         try:
             project = json.load(open(self._cfile, 'rU'))
             if Ipy.DEBUG:
                 sys.stdout.write("project %s loaded from cached file (%s)\n"%(pid, self._cfile))
         except:
             pass
     if project is None:
         # load from api
         project = self._get_project(pid, auth)
         if project and cache and os.path.isdir(Ipy.CCH_DIR):
             # save to cache if given
             try:
                 json.dump(project, open(self._cfile, 'w'))
                 if Ipy.DEBUG:
                     sys.stdout.write("project %s saved to cached file (%s)\n"%(pid, self._cfile))
             except:
                 pass
     if project is not None:
         for key, val in project.iteritems():
             setattr(self, key, val)
     else:
         self.id = pid
         self.name = None
         return
     # hack to get variable name
     if def_name == None:
         try:
             (filename,line_number,function_name,text)=traceback.extract_stack()[-2]
             def_name = text[:text.find('=')].strip()
         except:
             pass
     self.defined_name = def_name
     # call collection init - from cache if given
     Collection.__init__(self, self.mgids(), auth=auth, def_name=self.defined_name, cache=cache)
예제 #14
0
 def __init__(self, storage, data=None, subs=None, table=None):
     Collection.__init__(self, storage, table)
     Model.__init__(self, data, subs)
예제 #15
0
 def __init__(self):
     Collection.__init__(self)
예제 #16
0
    def __init__(self, base):
        Collection.__init__(self, Album)

        self.base = base

        self.populate()
예제 #17
0
 def __init__(self, storage, data=None, subs=None, table=None):
     Collection.__init__(self, storage, table)
     Model.__init__(self, data, subs)
예제 #18
0
파일: album.py 프로젝트: jessevdk/telemote
    def __init__(self, base):
        Collection.__init__(self, Album)

        self.base = base

        self.populate()