当前位置: 首页>>代码示例>>Python>>正文


Python Layout.loadini方法代码示例

本文整理汇总了Python中pylayers.gis.layout.Layout.loadini方法的典型用法代码示例。如果您正苦于以下问题:Python Layout.loadini方法的具体用法?Python Layout.loadini怎么用?Python Layout.loadini使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylayers.gis.layout.Layout的用法示例。


在下文中一共展示了Layout.loadini方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Simul

# 需要导入模块: from pylayers.gis.layout import Layout [as 别名]
# 或者: from pylayers.gis.layout.Layout import loadini [as 别名]
class Simul(SimulationRT):
    """

    Attributes
    ----------
    config  : config parser instance
    sim_opt : dictionary of configuration option for simulation
    ag_opt : dictionary of configuration option for agent
    lay_opt : dictionary of  configuration option for layout
    meca_opt : dictionary of  configuration option for mecanic
    net_opt : dictionary of  configuration option for network
    loc_opt : dictionary of  configuration option for localization
    save_opt : dictionary of  configuration option for save
    sql_opt : dictionary of  configuration option for sql

    Notes
    ------
     All the prvious dictionnary are obtained from the chosen simulnet.ini file
    in the project directory

    """
    def __init__(self):
        SimulationRT.__init__(self)
        self.initialize()
        self.config = ConfigParser.ConfigParser()
        self.config.read(pyu.getlong('simulnet.ini','ini'))
        self.sim_opt = dict(self.config.items('Simulation'))
        self.lay_opt = dict(self.config.items('Layout'))
        self.meca_opt = dict(self.config.items('Mechanics'))
        self.net_opt = dict(self.config.items('Network'))
        self.loc_opt = dict(self.config.items('Localization'))
        self.save_opt = dict(self.config.items('Save'))
        self.sql_opt = dict(self.config.items('Mysql'))

        self.verbose = str2bool(self.sim_opt['verbose'])
        if str2bool(self.net_opt['ipython_nb_show']):
            self.verbose = False
        self.roomlist=[]

    def create_layout(self):
        """
        Create Layout in Simpy the_world thantks to Tk backend

        """

        self.the_world = world(width=float(self.lay_opt['the_world_width']), height=float(self.lay_opt['the_world_height']), scale=float(self.lay_opt['the_world_scale']))

        # tk = self.the_world.tk
        # canvas, x_, y_ = tk.canvas, tk.x_, tk.y_
        # canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='white')

        _filename = self.lay_opt['filename']
        #sl=Slab.SlabDB(self.lay_opt['slab'],self.lay_opt['slabmat'])
        #G1   = Graph.Graph(sl=sl,filename=_filename)
        self.L = Layout()
        if _filename.split('.')[1] == 'str':
            self.L.loadstr(_filename)
        elif _filename.split('.')[1] == 'str2':
            self.L.loadstr2(_filename)
        elif _filename.split('.')[1] == 'ini':
            self.L.loadini(_filename)


        try:
            self.L.dumpr()
            print 'Layout graphs are loaded from ',basename,'/struc'
        except:
        #self.L.sl = sl
        #self.L.loadGr(G1)
            print 'This is the first time your use this layout file.\
            Layout graphs are curently being built, it may take few minutes.'
            self.L.buildGt()
            self.L.buildGr()
            self.L.buildGw()
            self.L.buildGv()
            self.L.buildGi()
            self.L.dumpw()
        x_offset = 0  # float(self.lay_opt['x_offset'])
        y_offset = 0  # float(self.lay_opt['y_offset'])
        for ks in self.L.Gs.pos.keys():
            self.L.Gs.pos[ks] = (self.L.Gs.pos[ks][0] +
                                 x_offset, self.L.Gs.pos[ks][1] + y_offset)
        for ks in self.L.Gr.pos.keys():
            self.L.Gr.pos[ks] = (self.L.Gr.pos[ks][0] +
                                 x_offset, self.L.Gr.pos[ks][1] + y_offset)
        for ks in self.L.Gw.pos.keys():
            self.L.Gw.pos[ks] = (self.L.Gw.pos[ks][0] +
                                 x_offset, self.L.Gw.pos[ks][1] + y_offset)

        #
        # Create Layout
        #
        walls = self.L.thwall(0, 0)
        for wall in walls:
            points = []
            # for point in wall:
            #          points.append(x_(point[0]))
            #          points.append(y_(point[1]))
            #      canvas.create_polygon(points, fill='maroon', outline='black')
            for ii in range(0, len(wall) - 1):
#.........这里部分代码省略.........
开发者ID:mlaaraie,项目名称:pylayers,代码行数:103,代码来源:simulnet.py


注:本文中的pylayers.gis.layout.Layout.loadini方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。