============== View hierarchy ============== Now that the application is set up with a window it can use for rendering, let's take a closer look at the pipeline for how rendering is accomplished. The geometry and associated attributes of any HNP scene are stored in an internal database. This database is organized into a hierarchical scene graph which dictates how rendering takes place. While the scene graph itself is a low-level data structure, HNP provides higher level abstractions which facilitate viewing and scene manipulation. These higher level components make up the `view hierarchy `_. Four classes work together as nested containers to provide this functionality: .. raw:: html .. image:: images/view_hierarchy.png The objects which correspond to the classes listed above are all created using the static class `HPS::Factory `_. For example, continuing from the last code snippet, we can see the `View `_ being created and immediately attached to the `Canvas `_: .. literalinclude:: /source/CHPSView.cpp :language: c :start-after: //! [attach_view] :end-before: //! [attach_view] `HPS::Canvas `_, `HPS:Layout `_, and `HPS::Model `_ are created in a similar way. All of these are static functions: .. code-block:: cpp HPS::Canvas myCanvas = HPS::Factory::CreateCanvas() HPS::Layout myLayout = HPS::Factory::CreateLayout() HPS::Model myModel = HPS::Factory::CreateModel() Additionally, each view hierarchy object has a function to attach children, which binds the hierarchy together. For example: .. code-block:: cpp canvas.AttachLayout(myLayout); myLayout.AttachViewFront(myView); myView.AttachModel(myModel); See the HPS `Programming Guide `_ and `API reference `_ for more information. Note that in the example above, the `HPS::Layout `_ wasn't used because there is only a single `View `_ which takes the whole window (this shortcut is made available since this is such a common situation). In this case, a `View `_ can be attached directly to a `Canvas `_, but if you have multiple views, you'll need to you a `Layout `_ to arrange them correctly inside the window. The last part of the view hierarchy, the `HPS::Model `_, is a branch of the scene graph which contains the geometry that is to be rendered in the window whenever an update is triggered. To trigger an update, simply call `HPS::Canvas::Update `_. We'll look at the `HPS::Model `_ object in the next section.