User Tools

Site Tools


01_user_documentation:05_object:11_wrapped_graphs:01_graphobjects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
01_user_documentation:05_object:11_wrapped_graphs:01_graphobjects [2026/09/22 10:45] – created Tim01_user_documentation:05_object:11_wrapped_graphs:01_graphobjects [2026/09/23 15:25] (current) – groimp
Line 1: Line 1:
 ====== GraphObject ====== ====== GraphObject ======
  
-A read only wrappedGraph that can be used as a resource similar to a shader or an image+A read only wrappedGraph that can be used as a resource similar to a shader or an image. 
 + 
 +===== UI management ===== 
 + 
 +GraphObject are managed through the [[..:..:03_interacting_with_groimp:02_panels:02_explorers:15_graph_objects|graph objects explorer]].  
 +They can be imported from all formats otherwise supported in GroIMP and the Graph structure in the background will be stored in the format of the importation. So if a qsm file was imported in the GraphObject explorer it is added as a qsm file to the project and read as a graph the first time its needed. 
 + 
 +A GraphObject can be viewed in 2D and 3D by selecting it in the explorer and pressing view3d or view2d in the attribute editor. The changes done in the views will only last until the project is reloaded, since the graph structure is read only. 
 + 
 +===== RGG ===== 
 + 
 +Each GraphObject added to the explorer can be referenced from RGG using the function ''graphobject("<name>")''. This function returns an GraphObjectRef object and can be used to interact with the loaded graph structure. 
 + 
 +==== Load as instance ==== 
 + 
 +If a GraphObjectRef or a GraphObject is added to a RGG production it will automatically return an instance of the graph structure, similar to an instantiation rule. 
 + 
 +This code fore example will display the entire tree.qsm file but adds only one node to the graph. 
 +<code java> 
 +protected void init()[ 
 + Axiom ==> graphobject("tree.qsm"); 
 +] 
 +</code> 
 +  
 +This works in any RGG production e.g. replacement- or instantiation-rules. 
 + 
 +==== cloning the graph ==== 
 + 
 +It is also possible to use the GraphObject as  source for the graph structure, in this case the ''cloneGraph();'' function is used.  
 + 
 +For example this code will add all shoots from the tree.qsm as cylinders to the graph.  
 +<code java> 
 +protected void init()[ 
 + Axiom ==> graphobject("tree.qsm").cloneGraph(); 
 +] 
 +</code> 
 + 
 +The cloned objects are fully independent from the original GrpahObject. 
 + 
 + 
 +==== Querying the graph ==== 
 + 
 +It is possible to query the GraphObject or the GraphObjectRef in the same way as the project graph to retrieve information. This can be useful to compare or adjust the project to a imported structure. 
 +The Syntax for this queries is similar to the one on the main Graph.  
 +For example to count the number of shoots on GrpahObject called tree.qsm: 
 + 
 +<code java> 
 +println(count(graphobject("tree.qsm").(*F*)); 
 +</code> 
 + 
 +The query it self, the part in the ''(*...*)'' brackets is identical and only the graph that it is applied on is specified before hand. 
 + 
 +It would also be possible to use this to assign values: 
 + 
 +<code java> 
 +graphobject("tree.qsm").(*F*)[diameter] =2; 
 +</code> 
 + 
 +But once again this is read only so it will not be stored when the project is closed. 
 + 
01_user_documentation/05_object/11_wrapped_graphs/01_graphobjects.1790073902.txt.gz · Last modified: (external edit)