290 likes | 413 Views
Easy Studierstube Applications with a little help from OpenInventor. Gerhard Reitmayr Vienna University of Technology. Stb application requirements. User interface design needs iterative development. Need to be adapted to different user interface modalities. Demos need to be kept alive !
E N D
Easy Studierstube Applicationswith a little help from OpenInventor Gerhard Reitmayr Vienna University of Technology
Stb application requirements • User interface design needs iterative development. • Need to be adapted to different user interface modalities. • Demos need to be kept alive ! • Reuse of application features is very desirable.
User interface components icon 3D window PIP widgets pen content
Structure of an application Application Widgets Different modalities SoMyContextKit Reuse this ? Scene graph Different presentation styles
Skeleton of an application SoApplicationKit { contextKit SomeApplication { templatePipSheet Separator { # your PIP sheet widgets } windowGroup Group { # content and windows ! } # all kinds of application # specific fields } }
Use the file format ! • Let your application become an understandable part of an OIV file. • Use fields as inputs and outputs of applications. • Build scene graphs in the OIV file instead of in code. • Try to write all applications as pure OIV nodekits !
Fields as inputs/outputs • Connecting to widgets • Callbacks tie you to the type of widget • Lower abstraction used then necessarye.g. observe 3 buttons instead of a 3 valued state variable. • Use fields that represent exactly the state the application needs. • Output states as fields allows simple change of presentation.
OIV: Observing changes • Sensors are the callbacks of OIV ! • SoFieldSensor • Only one field per sensor • Not ref counted > take care yourself • SoNodeSensor • Reports changes on node / sub scene graph • Beware of node fields
Scene graphs as parameters • Use node fields • As templates for complex scene graphs • Use parts • For scene graphs that need traversal • Use conventions • Node type, e.g. set a texture to be picked up by geometry in the graph • Search for a given name, type and change its fields
Parameterized scene graphs • Using context sensitive traversal • New element SoContextElement • Maps int -> int • Context[3] = 2 • Context[-5] = NIL • SoContext to modify context during traversal • SoContextSwitch (…) • Modify traversal depending on context
Context Example Group Context2->1 Context2->0 ContextSwitchindex[2] Geometry Colorgreen Colorred
OIV : NodeKits - concept • A nodekit represents a tightly integrated template scene graph with meaning to the developer. • We get • Fixed scene graph • Represented by a node • Internal connections • OIV interface of fields and children
Nodekit structure Root node Private parts Public parts SoTrackedArtifaktKit
OIV : setUpConnections • Central method to establish connections within a nodekit. • Signals nodekit when the structure changes. • Important for • Correct loading of applications • Distributed OpenInventor
Navigation app - 2 • DEF NavKit NavigationContext { • waypoint ["Karlskirche",… ] • waypointPosition [0 1 0,… ] • edge [1,… ] • numEdge [3,… ] • userPosition = SoTrakEngine{}.translation • destination = USE waypointList.selected • path [“Karlskirche”,… ] • edgeIndex [1,2,3] nodeIndex [2,3,5,10] • templatePipSheet SoPipSheetKit {…} • windowGroup So3DSeparator {…} • }
Thank you • ?
SoClassLoader • Load OIV classes from within a file ! classLoader SoClassLoader { className "MyOIVNode" fileName "../somewhere/mynodes" } MyOIVNode { … }
Timing issues • Delayed execution • SoOneShotSensor • SoAlarmSensor • Repeated actions • SoTimeSensor • SoIdleSensor
Stb Applications • Applications are OpenInventor nodekits • Subclasses of SoContextKit • Implementation as shared library (dll,so) • Additional callback API for • User specific data • Distribution
Writing STB applications • SoApplicationKit • SoClassLoader • SoContextKit • templatePipSheet • windowGroup
Interfacing SoContextKit • Use fields as interface • Avoid connections based on names, pointers, etc • Special patterns for multi user applications • Use localized search
PIP - personal interaction panel System Sheet App 1 PipSheet PIP PipSheet 1 App 2 User PipSheet 2
PIP Komponenten window tab system tab sheet tab
Remedy – OpenInventor • A set of guidelines to • Structure application API • Structure data flow in application • Modularize applications • OpenInventor can support us here !
Beispiel : hello world SoApplicationKit { contextKit SoContextKit { windowGroup DEF Hello Group { Material {diffuseColor 0.9 0.95 0.3} Scale {scaleFactor 0.1 0.1 0.1} Font { size 1 } Text3 { string ["Hello", "World !"] justification CENTER parts ALL } } templatePipSheet USE Hello } }
Guidelines • Data driven implementation • Store all data in fields or children • React to changes and update internal and dependent state • > Very flexible • > Highly reusable components
Lifetime of an application Loading SoMyAppKit checkPipGeometry()checkWindowGeometry() checkPipConnections()checkPipMasterMode() focusChange() windowEventCB() Initialisation per user Interaction