The Axis Triad and Navigation Cube assist the user with scene orientation. Both may be enabled and customized using the appropriate control;
myView.GetAxisTriadControl()
myView.GetNavigationCubeControl()
The Navigation Cube labels may be customized. However, the Axis Triad lacks such support at the time of this article.
Instructions
The following describes the process of customizing the labels of the Axis Triad in HPS:
- Using the hps_mfc_sandbox project, add the following function to CHPSView.cpp;
void DoSetAxisText(HPS::SegmentKey seg, const char* text)
{
HPS::SearchResults result;
if (seg.Find(Search::Type::Text, Search::Space::Subsegments, result) > 0)
{
HPS::SearchResultsIterator it = result.GetIterator();
while (it.IsValid())
{
HPS::Key key = it.GetItem();
if (key.Type() == HPS::Type::TextKey)
{
HPS::TextKey sKey = (TextKey)key;
// set other text properties e.g. sKey.SetSize(16, HPS::Text::SizeUnits::Pixels);
sKey.SetText(text);
}
it.Next();
}
}
}
- Next add the following to the User Code 3 method of the
CHPSView
class;
void CHPSView::OnUserCode3()
{
_canvas.GetFrontView().GetAxisTriadControl().SetVisibility(true).SetLocation(HPS::AxisTriadControl::Location::BottomLeft);
_canvas.GetFrontView().GetNavigationCubeControl().SetInteractivity(true);
}
- Additionally, add the following to the User Code 4 method of the
CHPSView
class;
void CHPSView::OnUserCode4()
{
SegmentKey viewSegKey = GetCanvas().GetFrontView().GetSegmentKey();
if (viewSegKey.Type() != HPS::Type::None)
{
SearchResults searchResults;
size_t numResults = viewSegKey.Find(Search::Type::Segment, Search::Space::SubsegmentsAndIncludes, searchResults);
if (numResults > 0)
{
SearchResultsIterator it = searchResults.GetIterator();
while (it.IsValid())
{
Key key = it.GetItem();
SegmentKey segKey(key);
if (segKey.Name() == "hps_axis_triad")
{
SegmentKey hpsAxisKey = segKey;
if (hpsAxisKey.Type() != HPS::Type::None)
{
SegmentKeyArray sub;
hpsAxisKey.ShowSubsegments(sub);
for (size_t i = 0; i < sub.size(); i++)
{
HPS::SegmentKey sk = sub.at(i);
HPS::UTF8 s = sk.Name();
if (s == "x") //X-Axis
{
DoSetAxisText(sk, "A");
}
else if (s == "y") //Y-Axis
{
DoSetAxisText(sk, "B");
}
else if (s == "z") //Z-Axis
{
DoSetAxisText(sk, "C");
}
}
}
}
it.Next();
}
}
}
GetCanvas().UpdateWithNotifier().Wait();
}
- Build and launch the mfc_sandbox
- On the User Code tab, click on the User Code 3 button to enable the Axis Triad
- Click on the User Code 4 button to modify the Axis Triad labels;
Keep in mind this approach relies on several internal HOOPS implementation details (e.g. segment key name “hps_axis_triad”) which may change.