Difference between revisions of "Org.simantics.scenegraph.loader"

From Developer Documents
Jump to navigation Jump to search
Line 10: Line 10:
 
Key features are
 
Key features are
  
* Procedural properties and structure (via Layer0 Values)
+
* Procedural properties and structure (via Layer0 Values and the runtime context resource)
* Reusable scene graph components
+
* Reusable scene graph components (via Variable context)
 
* Support for multiple implementations of the same semantic model
 
* Support for multiple implementations of the same semantic model
  

Revision as of 07:11, 1 November 2011

org.simantics.scenegraph.loader (SVN) is a set of utilities for loading and automatically updating structural org.simantics.scenegraph (SVN) models defined in org.simantics.scenegraph.ontology (SVN) .

Overview

The main goal of the scenegraph loader is to move the definition of scene graphs from code into the semantic data model. The main functionality is

  • Instantiation of a scene graph structure from semantic graph with automatic change listening
  • Automatic synchronization of scene graph node properties from semantic graph

Key features are

  • Procedural properties and structure (via Layer0 Values and the runtime context resource)
  • Reusable scene graph components (via Variable context)
  • Support for multiple implementations of the same semantic model

Usage

Loader

The main entrypoint is org.simantics.scenegraph.loader.ScenegraphLoaderProcess. The public load methods are used to create a scene graph given a structural configuration resource and a runtime context resource.

ScenegraphLoaderProcess can be extended to customize

  • The creation of the root node for the resulting scene graph
  • The node loading logic. Standard node loading uses the adapter org.simantics.scenegraph.loader.ScenegraphLoader bound to node configuration resources.

Scene graph structure

Standard scene graph node loader

A common node loading logic is defined in org.simantics.scenegraph.loader.StandardScenegraphLoader. The loader receives a target class to instantiate and goes on to listen changes in all graph-defined properties. The loader expects the instantiated node to implement org.simantics.scenegraph.loader.LoaderNode which provides a generic method getPropertyFunction for transferring values into the node.

Implementation of LoaderNode is supported by ScenegraphLoaderUtils in e.g. getMethodPropertyFunction which uses reflection to call a specifically named method of the node in a specific thread each time a value changes.

Runtime context resource

The loader evaluates all properties of the nodes in Variable context, where the variable represents the flattened tree structure of the scene graph. The variable is a standard graph-based implementation org.simantics.scenegraph.loader.ScenegraphVariable with an additional adapter class org.simantics.scenegraph.loader.ScenegraphContext, which gives access to the runtime context resource. The context can be used in property evaluation for e.g.

  • Performing computations based on external input e.g. workspace selection
  • Performing computations based on location e.g. diagram composite instance in a structural model.

Standard utilities for property value functions are collected in org.simantics.scenegraph.loader.ScenegraphLoaderUtils.