Пример #1
0
def export_lpy_controls(controls, filename):
    """
    :param controls: [('name', interface, value)] ex: [('i', IInt(min=0, max=100), 1)]
    """

    from openalea.lpy.gui.objectmanagers import get_managers

    # from openalea.plantgl.oaplugins.interfaces import IMaterialList, IPatch, IQuantisedFunction, ICurve2D
    managers = get_managers()
    interface2manager = {
        "IPatch": managers["NurbsPatch"],
        "IQuantisedFunction": managers["Function"],
        "ICurve2D": managers["Curve2D"],
    }

    visuobjects = []
    for name, interface, value in controls:
        manager = interface2manager.get(interface.__class__.__name__, None)
        if manager:
            print "Export " + name + " ..."
            value.name = str(name)
            visuobjects.append((manager, value))

    visualparameters = ({}, visuobjects)

    from openalea.lpy.simu_environ import getInitialisationCode

    code = getInitialisationCode(visualparameters=[visualparameters])

    f = open(filename, "w")
    f.write(code)
    f.close()
Пример #2
0
def export_lpy_controls(controls, filename):
    """
    :param controls: [('name', interface, value)] ex: [('i', IInt(min=0, max=100), 1)]
    """

    from openalea.lpy.gui.objectmanagers import get_managers
    #from openalea.plantgl.oaplugins.interfaces import IMaterialList, IPatch, IQuantisedFunction, ICurve2D
    managers = get_managers()
    interface2manager = {
        'IPatch': managers['NurbsPatch'],
        'IQuantisedFunction': managers['Function'],
        'ICurve2D': managers['Curve2D']
    }

    visuobjects = []
    for name, interface, value in controls:
        manager = interface2manager.get(interface.__class__.__name__, None)
        if manager:
            print 'Export ' + name + ' ...'
            value.name = str(name)
            visuobjects.append((manager, value))

    visualparameters = ({}, visuobjects)

    from openalea.lpy.simu_environ import getInitialisationCode

    code = getInitialisationCode(visualparameters=[visualparameters])

    f = open(filename, 'w')
    f.write(code)
    f.close()
Пример #3
0
 def getFutureInitialisationCode(self,withall=True):
     from openalea.lpy.simu_environ import getInitialisationCode
     if self.fname and len(self.fname) > 0:
         reference_dir = os.path.abspath(os.path.dirname(self.getStrFname()))
     else :
         reference_dir = None
     return getInitialisationCode(self.lsystem.context(),
                                  self.scalars,
                                  self.visualparameters,
                                  self.desc_items,
                                  simplified = not withall,
                                  keepCode_1_0_Compatibility= self.keepCode_1_0_Compatibility,
                                  referencedir=reference_dir)
Пример #4
0
        else:
            description = None

        # translate lsystem code
        lpycode = translate_l_code(
            file(join(project, lfile)).read(), vlpyinitconfig)

        # add view file
        if vfiles:
            if lpycode.index('endlsystem') == -1:
                lpycode += '\nebdlsystem\n\n'
            lpycode += lpyvcode

        # translate environ
        init_txt = se.getInitialisationCode(l,
                                            credits=description,
                                            visualparameters=panels)
        return lpycode + init_txt
    else:
        return translate_l_code(file(fname).read())


def help():
    return 'Usage: cpfg2lpy project[.l] [output.lpy]\nHelp: This utility try to translate cpfg code and parameter in lpy. A simple cpfg lsystem file can be passed or an entire directory project.'


def main():
    import sys
    if len(sys.argv) < 2:
        print help()
        return
Пример #5
0
        if descfile:
            description = {"__description__": open(join(project, descfile)).read()}
        else:
            description = None

        # translate lsystem code
        lpycode = translate_l_code(file(join(project, lfile)).read(), vlpyinitconfig)

        # add view file
        if vfiles:
            if lpycode.index("endlsystem") == -1:
                lpycode += "\nebdlsystem\n\n"
            lpycode += lpyvcode

        # translate environ
        init_txt = se.getInitialisationCode(l, credits=description, visualparameters=panels)
        return lpycode + init_txt
    else:
        return translate_l_code(file(fname).read())


def help():
    return "Usage: cpfg2lpy project[.l] [output.lpy]\nHelp: This utility try to translate cpfg code and parameter in lpy. A simple cpfg lsystem file can be passed or an entire directory project."


def main():
    import sys

    if len(sys.argv) < 2:
        print help()
        return