2.3 Working with
the Model
Your application logic is
now ready to interact with Views and create or edit
the associated model information (segments and geometry)
as necessary. The HBaseModel
object can be accessed from the HBaseView
object by calling HBaseView::GetModel()
Additionally, the key of the top level segment associated
with the HBaseModel object
can be directly accessed by calling HBaseView::GetModelKey().
For each View in the application,
you can use the HBaseView::GetSceneKey()
method to access the Scene segment, and include whatever
parts of the Model data that you would like to see in
the View by using HC_Include_Segment()
function.
Once you are comfortable
with the way Includes work between your Models and Views,
you can explore more advanced functions such as Conditional_Include
and Conditional_Style. These functions allow you to
have greater control over how and when segments are
included in your View.
2.4 Exporting
Model Information
When it comes time
to exporting your application data, there are generally
two ways of dealing with the graphics information stored
in your Models and Views.
A. Exporting
only Model information
This is a good approach
if you are not concerned about retaining view information,
and involves writing out information beginning with
the Model object’s segment. This means that only
the ‘raw’ graphical information that represents
the model is exported, and any View information that
exists at export time is lost. Reading applications
would need to reset View attributes from scratch.
B. Exporting
both View and Model information
This is a good approach
if you wish to preserve View information, and involves
exporting the View attributes beginning at the ‘Scene’
segment, along with the raw model information. This
gives other applications the ability to see ‘saved’
views. (Perhaps it was desirable to capture several
views which showed the model from different angles or
represented zoom/detail views that depicted a sub-area
of the model.)
However, the reading
application would need to have special logic to properly
handle this view information. If it did not, then the
application’s View settings might have no affect
and the model could appear ‘frozen’. (This
is because the View settings in the file might include
a HOOPS Camera, and a higher-level camera set in the
application would take no affect due to the nature of
HOOPS’ attribute inheritance. The lower level
camera ‘wins’.) Therefore, if you are exporting
to your own custom file format and also develop the
reading applications, then you should ensure that the
View information is correctly processed. This typically
would involve querying it, removing it from the Model,
and resetting it in the View.
If the data is being
exported to a HOOPS Stream File (HSF), then you should
can store the initial camera setting by using the HSF
specification’s TKE_View
opcode. This stores a camera as a separately identifiable
entity in the HSF file, and thus enables HSF reading
applications to separate the View from the Model. Note,
if the name of the TKE_View
is ‘default’ then the protocol in HSF reading
applications is that they honor that camera as the initial
camera when the model is first loaded.