arrow representation

Hi all: I need a arrow to point out the direction. I don't have any ideal about it. Can anyone give me suggestion. Thanks a lot.

sincerely shawn

Andrey Betenev's picture

Hello Shawn,

A simplest way to draw an arrow is to use class AIS_Trihedron, but display only one axis. For instance:

gp_Ax2 Ax2 ( start, direction );

Handle(Geom_Axis2Placement) gAx2 = new Geom_Axis2Placement ( Ax2 );

Handle(AIS_Trihedron) aTr = new AIS_Trihedron(gAx2);

aTr->SetSize(aSize);

Handle(AIS_Drawer) aDrawer = aTr->Attributes();

if(!aDrawer->HasDatumAspect()) aDrawer->SetDatumAspect(new Prs3d_DatumAspect());

aDrawer->DatumAspect()->SetDrawFirstAndSecondAxis(Standard_False);

aTr->SetColor(Quantity_NOC_RED); aTr->SetTextColor(Quantity_NOC_BLACK); aTr->SetArrowColor( Quantity_NOC_RED );

However, this method has a few disadvantages: you have a letter 'Z' drawn at the end of an axis; and you cannot directly change size of the arrow-head. So if you find a better way, please share this experience.

Best Regards, Andrey

S. Routelous's picture

You can also create your own InteractiveObject and in the compute method call Prs3d_Arrow::Draw

Prs3d_Arrow::Draw(aPresentation,myLastPoint,dir,0.20,myFirstPoint.Distance(myLastPoint)/ArrowSizeValue);

You can also associate text with Prs3d_Text::Draw(...)

Stephane

Shawn Yang's picture

Hi Stephane:

Thank you for your response. How to get aPresentation? I have seen the description in the document. I didn't get it.

Thanks a lot.

sincerely
shawn

Sergey RUIN's picture

Hello shawn,

Just like this

Handle(AIS_InteractiveContext) aCtx;

//... Find or create InteractiveContext

Handle(Prs3d_Presentation) aPresentation = new Prs3d_Presentation (aCtx->CurrentViewer()->Viewer());

That's all

Best Regards

Sergey

Shawn Yang's picture

Hi:

Is it possible to change arrow shape? And, how to change it? Thanks a lot.

sincerely shawn

Sergey RUIN's picture

Hi shawn,

You can only change the length of an arrow head and its angle. To do this use method ArrowAspect of AIS_Drawer or directly Prs3d_Arrow::Draw(...).

Best Regards

Sergey