AIS_Trihedron selection

I want to know that which component of the AIS_Trihedron is picked.

(Origin / X axis / Y axis / XY plane / XZ plane / YZ plane)

Kadir Canik's picture

Dear friend Kadir,

Here is the answer;

SetCursor(MY_CURSOR_HAND);
Handle(AIS_InteractiveObject)& aIO = aCTX->DetectedInteractive();
Handle(SelectMgr_EntityOwner) aDedected = aCTX->DetectedOwner();
if (aIO->Type() == AIS_KOI_Datum)
{
	if (aDedected->IsKind(STANDARD_TYPE(AIS_TrihedronOwner)))
	{
		CString tmp;
		Handle(AIS_TrihedronOwner) aThOwner = Handle(AIS_TrihedronOwner)::DownCast(aCTX->DetectedOwner());
		Prs3d_DatumParts aDatumPart = aThOwner->DatumPart();
		switch (aDatumPart)
		{
		case Prs3d_DP_Origin:	tmp = L"Origin"; break;
		case Prs3d_DP_XAxis:
		case Prs3d_DP_XArrow:	tmp = L"X Axis"; break;
		case Prs3d_DP_YAxis:
		case Prs3d_DP_YArrow:	tmp = L"Y Axis"; break;
		case Prs3d_DP_ZAxis:
		case Prs3d_DP_ZArrow:	tmp = L"Z Axis"; break;
		case Prs3d_DP_XOYAxis:	tmp = L"XY Plane"; break;
		case Prs3d_DP_YOZAxis:	tmp = L"YZ Plane"; break;
		case Prs3d_DP_XOZAxis:	tmp = L"XZ Plane"; break;
		case Prs3d_DP_None:		tmp = L"None"; break;
		}
		gp_Pnt P = aCTX->MainSelector()->PickedPoint(1);
		aMsg.Format(L"%s %s [%+10.3lf %+10.3lf %+10.3lf]",	MyDatumType[aIO->Signature()], tmp, P.X(), P.Y(), P.Z());
	}
}
Kirill Gavrilov's picture

Tip

Handle(AIS_InteractiveObject)& aIO = aCTX->DetectedInteractive();
Handle(SelectMgr_EntityOwner) aDedected = aCTX->DetectedOwner();
if (aIO->Type() == AIS_KOI_Datum)
{
	if (aDedected->IsKind(STANDARD_TYPE(AIS_TrihedronOwner)))

There is no need checking AIS_InteractiveObject::Type(), as it should be enough to cast AIS_InteractiveContext::DetectedOwner() to AIS_TrihedronOwner and check for NULL.

if (Handle(AIS_TrihedronOwner) aThOwner = Handle(AIS_TrihedronOwner)::DownCast(aCTX->DetectedOwner()))
{
  ...
}
Guillaume CHAFFAROD's picture

Thank you very much, I could achieve my goal with your help !! ;)