For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

arrow representation

Shawn Chang's picture
Forums: 

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

Betenev Andrey'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 Chang'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 Chang'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

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.