Package: pgljupyter
pgljupyterPlantGL&L-Pyjupyter widgetsCurrently supports openalea.lpy>=3.9.0 and openalea.plantgl>=3.14.0 from conda channel'fredboudon'.Quick ExamplesPlantGLsimple PlantGL shapes - spheres@nbviewerL-Pya tree model - leuwenberg@nbviewerplot magic - leuwenberg@nbviewerchampignon@nbviewermagics with scalar parameters - broccoli@nbviewermagics with curve parameters - sweep surface@nbviewerUsagefrompgljupyterimportSceneWidget,LsystemWidgetSceneWidgetRenderer for PlantGL Scenes, Shapes, GeometriesArguments:arg0list | plantgl.Shape | plantgl.Scene: a list of shapes or scenes or a single objectpositiontuple (float, float, float): x, y, z position of arg0 (default (0, 0, 0))scalefloat: scale factor for arg0 (default 1)size_displaytuple (int, int): width and height of the canvas (minimum 400)size_worldfloat: extend on the 3D scene in all directionsExample:fromopenalea.plantgl.allimportScene,SpherefrompgljupyterimportSceneWidgets=Scene([Sphere()])sw=SceneWidget(s)swTutorial:Display of spheres@nbviewerLsystemWidgetRenderer for lpy.Lstrings derived from lpy.Lsystem codeArguments:arg0string: file name / path of lpy code fileunitstring enum: the unit used in the Lsystem model ('m', 'dm', 'cm', 'mm', default 'm')scalefloat: scale factor for arg0 (default 1)animatebool: ifTrueruns animation automaticallysize_displaytuple (int, int): width and height of the canvas (minimum 400)size_worldfloat: extend on the 3D scene in all directionsImportant property/methods:editor: display an editor of the graphical parametersget_lstring(self): return the lstring corresponding to the current step of the simulation display in the widget.get_namespace(self): return the namespace of variables of the simulationExample:frompgljupyterimportLsystemWidgetlw=LsystemWidget('myfile.lpy')lwlw.editorTutorial:Display of the simulation of a lpy file :@nbviewer%%lpyA cell magic to inline L-Py code in a notebookArguments:--size,-sint,int: same assize_display--world,-wfloat: same assize_world--unit,-uenum: same asunit--params,-pLsystemParameters: name of LsystemParameters instance--animate,-aTrue: runs animation automatically--extended-editor,-eFalse: show/hide all parameter controlsExample:# activated by importing pgljupyterimportpgljupyter%%lpy-ucmfromopenalea.plantgl.allimport*Axiom:;(1)+(10)_(2)F(10);(0)@g(Paraboloid(10,10,2,False))derivationlength:100production:F(x)-->F(x+0.2)@g(p)-->@g(Paraboloid(p.radius+0.15,p.height+0.2,2,False))_(x)-->_(x+0.02)Example with graphical parameters:# activated by importing pgljupyterimportpgljupyterfromopenalea.lpy.lsysparametersimportLsystemParameterslp=LsystemParameters()lp.add_scalar(name='a',value=1,minvalue=0,maxvalue=100)lp.add_function(name='b')# default graphical function created%%lpy-plpAxiom:SetGuide(b,a)F(a)Tutorials:simple L-systems@nbviewergraphical scalar parameters - broccoli@nbviewergraphical curve parameters - sweep surface@nbviewer%lpy_plotA line magic to plot all derivation steps of an Lsystem on a square planeArguments:arg0, string: L-Py file--size,-sint,int: width and hight of the canvas--cell,-cfloat: size of cell for a single derivation step--derive,-dint[,int[,int]]: start, stop, step derivationExample:# activated by importing pgljupyterimportpgljupyter%lpy_plotmyfile.lpyTutorial:Display of the simulation from a lpy file :@nbviewerInstallationInstall with pip - inside conda environmentSome examples also requirematplotlib,xarray-simlabandrpy2.condacreate-y-npgl-cfredboudon-cconda-forge\openalea.lpyjupyterlabipywidgetspipcondaactivatepgl
pipinstallpgljupyterDevelopment installinstall lpy, plantgl, jupyterlab, widgets and widgetsextensionmambaenvcreate-fenvironment-dev.yml
condaactivatepgljupyter-devinstall emsdk:https://emscripten.org/docs/getting_started/downloads.htmlgitclonehttps://github.com/emscripten-core/emsdk.gitcdemsdk
./emsdkinstall2.0.29
./emsdkactivate2.0.29source./emsdk_env.shcd..get pgljupyter sourcegitclonehttps://github.com/jvail/plantgl-jupyter.gitcdplantgl-jupyterfetch plantgl and install pgljs depsgitsubmoduleupdate--init--recursivecdsrc/pgljs
npminstallcd../..install pgljupyter deps and build (requires activated emsdk i.e. source ./emsdk_env.sh)npminstall
npmrunbuild:all
pipinstall-e.
jupyterlabextensiondevelop.--overwriterun labjupyterlab--notebook-dir=./examplesDevelopment uninstallpipuninstallpgljupyterIn development mode, you will also need to remove the symlink created byjupyter labextension developcommand. To find its location, you can runjupyter labextension listto figure out where thelabextensionsfolder is located. Then you can remove the symlink namedpgljupyterwithin that folder.