Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

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:

  1. 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();
    		}
    	}
    }
  2. 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);
    }
  3. 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();
    }
  4. Build and launch the mfc_sandbox

  5. On the User Code tab, click on the User Code 3 button to enable the Axis Triad

  6. 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.

  • No labels