========================== Segment and model browsers ========================== The segment browser is a visual representation of the in-memory `scene graph database `_. Activate it by clicking the "Segment Browser" icon in the ribbon menu. .. image:: images/segment_browser.png At the top left corner of the segment browser window, you'll notice a drop down list which contains the four view hierarchy components discussed earlier. By selecting the "Canvas" menu item and expanding its tree, you'll see how the view hierarchy is organized in memory. You'll also see the various `attributes `_, `portfolios `_, `includes `_, and `geometry `_ at various locations in the tree. .. image:: images/segment_browser_with_view_hierarchy.png You can build a similar segment browser tree using the `HPS::SceneTree `_ and `HPS::SceneTreeItem `_ classes. These classes have members related to the HNP API and act as base classes when creating a segment tree in a GUI toolkit. The MFC Sandbox implementation can be used as an example. In the sandbox, ``CDockablePane`` is the MFC base class behind the segment browser window. In *CHPSSegmentBrowserPane.h*, you'll see ``CHPSSegmentBrowserPane`` derives that base class and also has a reference to the view hierarchy drop-down menu, the ``MFCSceneTree`` object itself, and others: .. literalinclude:: /source/CHPSSegmentBrowserPane.h :language: c :start-after: //! [CHPSSegmentBrowserPane] :end-before: //! [CHPSSegmentBrowserPane] In our implementation, `HPS::SceneTree `_ is the parent of ``MFCSceneTree``, which has its own GUI-dependent code. Similarly, ``MFCSceneTreeItem`` derives from `HPS::SceneTreeItem `_. In this way, the HNP-specfic code can be integrated into any system with a similar GUI control. If you happen to be building an MFC application, you can use this example as a starting point in your own code. If you're using another GUI toolkit, you would need to subclass and implement child classes using `HPS::SceneTree `_ and `HPS::SceneTreeItem `_ as starting points. Then you'd write code for you GUI to create the various capabilities you plan to implement. For example, to highlight an item in the tree, you'd do something like this: .. literalinclude:: /source/CHPSModelBrowserPane.cpp :language: c :start-after: //! [OnHighlight] :end-before: //! [OnHighlight] Model browser ------------- The model browser is similar to the segment browser discussed previously, but it works on CAD models and their associated data. The class structure is similar - `HPS::ComponentTree `_ is used like `HPS::SceneTree `__, and `HPS::ComponentTreeItem `_ is used like `HPS::SceneTreeItem `_. Notice that when you load a non-CAD model, the model browser is empty because there is no CAD data to display. But when you load a CAD model, both the segment browser and the model browser are populated. This is because the CAD model's geometry becomes part of the the segment tree but the other CAD data is remains separate. The model browser is used to view that additional data easily. .. image:: images/segment_browser_and_model_browser.png The segment and model browsers do correspond with one another. For example, in the image below, the body is highlighted orange and the two entries in the model and segment browsers are bolded: .. image:: images/correspond.png