How to select vertex in occt7.3.0

what is the proper way of selecting a vertex from the view ? 

i use mContext->Select(true);  in the left_mouse_down event handler

and use

mContext->Deactivate();

mContext->Activate(AIS_Shape::SelectionMode(TopAbs_VERTEX ), Standard_True);

 mContext->MoveTo(point.x, point.y, mView, true);

in mouse_move event handler

is this the proper method of doing that ? if not what should i do?!

 

 

ahmed magdy's picture

any ideas ?!

Benjamin Bihler's picture

It doesn't look completely wrong. Have you tried it? What is your problem?

Hugues Delorme's picture

Hello,

In the mouse move handler function you should only call AIS_InteractiveContext::MoveTo().

Deactivate() + Activate() should be called once elsewhere in some function when the user starts to select some vertices.

Make also sure that point.x and point.y are relative to the top-left corner of the OpenCascade rendering window (and not global coords).

ahmed magdy's picture

Hello 

yes, i tried that too.

(for activate/deactivate inside or outside the handler)  it works for edges , faces,bodies ,... but not for vertex!!!

it doesn't show vertices highlighted nor selected!!

ahmed magdy's picture

i also tried that code :

aGeom_Cartpnt = new Geom_CartesianPoint(20.0, 20.0, 20.0);

ais_pnt = new AIS_Point(aGeom_Cartpnt);

ais_pnt->SetColor(Quantity_NOC_BLACK);

mContext->Display(ais_pnt, Standard_False);

and it didn't display a point or + mark at (20,20,20) too !!

i thought i may have a problem with displaying vertices or points!

Benjamin Bihler's picture

And if you create a vertex like this?

gp_Pnt point(20.0, 20.0, 20.0);

TopoDS_Vertex vertex = BRepBuilderAPI_MakeVertex(point);

... new AIS_Shape(vertex);

ahmed magdy's picture

yes i tried it before and it didn't display it 

Benjamin Bihler's picture

I also had that once that vertices didn't appear, especially when they were quite far away from the origin. I found out, that there were displayed correctly when I performed depth panning after adding them. For that I am using this method:

void View::performDepthPanning()
{
    myView->ZFitAll();
    myView->DepthFitAll();
}

myView is of type V3d_View (code similar to the Qt Tutorial sample).

Benjamin