# How-To: Customize the labels of the Axis Triad

**URL:** <https://forum.techsoft3d.com/t/how-to-customize-the-labels-of-the-axis-triad/1375>\
**Category:** HOOPS Visualize Desktop\
**Tags:** code, learn, knowledge-base, how-to\
**Created:** [January 1, 2021, 5:00am UTC](https://forum.techsoft3d.com/t/how-to-customize-the-labels-of-the-axis-triad/1375 "2021-01-01T05:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.peragine](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/gabriel.peragine/32/1535_2.png) [@gabriel.peragine](https://forum.techsoft3d.com/u/gabriel.peragine)\
**Post date:** [January 1, 2021, 5:00am UTC](https://forum.techsoft3d.com/t/how-to-customize-the-labels-of-the-axis-triad/1375/1 "2021-01-01T05:00:00Z")

</div>

The [Axis Triad and Navigation Cube](https://docs.techsoft3d.com/hps/latest/prog_guide/0301_core.html#triad) assist the user with scene orientation. Both may be enabled and customized using the appropriate control;

```auto
myView.GetAxisTriadControl()
myView.GetNavigationCubeControl()

```

The [Navigation Cube](https://docs.techsoft3d.com/hps/latest/api_ref/cpp/class_h_p_s_1_1_navigation_cube_control.html) labels may be customized. However, the [Axis Triad](https://docs.techsoft3d.com/hps/latest/api_ref/cpp/class_h_p_s_1_1_axis_triad_control.html) 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;

```auto
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();
		}
	}
}

```

1. Next add the following to the User Code 3 method of the `CHPSView` class;

```auto
void CHPSView::OnUserCode3()
{
	_canvas.GetFrontView().GetAxisTriadControl().SetVisibility(true).SetLocation(HPS::AxisTriadControl::Location::BottomLeft);
	_canvas.GetFrontView().GetNavigationCubeControl().SetInteractivity(true);
}

```

1. Additionally, add the following to the User Code 4 method of the `CHPSView` class;

```auto
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();
}

```

1. Build and launch the mfc\_sandbox
2. On the User Code tab, click on the User Code 3 button to enable the Axis Triad

![image-20210203-223049](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/52163b192157060373b35828817b832cd12d3f86.png)

1. Click on the User Code 4 button to modify the Axis Triad labels;

![image-20210203-223331](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/599f482d1aecac1eaf6e88f0624f0dc76d0b489f.png)

> Keep in mind this approach relies on several internal HOOPS implementation details (e.g. segment key name “hps\_axis\_triad”) which may change.
