Selection with Mouse Click

Hi,

I want to select an edge with left mouse button.

For example,think that I have a cube and I want to select its one of edges with left mouse button click.

When I wrote this code :

BRepPrimAPI_MakeBox boxx(100.,100.,100.);
Handle(AIS_Shape)aBox=new AIS_Shape(boxx.Shape());

theSelection->SetMaterial(aBox,Graphic3d_NOM_SILVER,Standard_False);
theSelection->SetColor(aBox, Quantity_NOC_BLACK);
theSelection->SetDisplayMode(aBox,1);
theSelection->Display(aBox);

theSelection->InitSelected();
theSelection->OpenLocalContext();
theSelection->ActivateStandardMode(TopAbs_VERTEX);
theSelection->Select();

while(theSelection->MoreSelected())
{
if(theSelection->HasSelectedShape())
TopoDS_Shape vertex=theSelection->SelectedShape();

else
{
TopoDS_Shape vertex = Handle(AIS_Shape)::DownCast( theSelection->SelectedInteractive() )->Shape();
}

theSelection->NextSelected();
}

I first create a cube and then whenever I try to pick a vertex it highlights the vertex when the mouse cursor on it,but when I click it,it does not do anything.

I want to select it when I click the left mouse button.

Thank you in advance..

Sharjith Naramparambath's picture

Hi,
You probably did not write the code for selection in mouse click event. Check out the sample codes. You have to explicitly handle Select, ShiftSelect and MultiSelect in the mouse events.

Regards
N. Sharjith

DeleDivaneeh's picture

I am using QT,the latest version, in my project.

I do not exactly know the QT events,is there any example codes in QT?Can you send a piece of code that does this,then I will fill the left mouse click event block.

Sharjith Naramparambath's picture

You can check out the Qt Sample provided with the installation. There is a Qt Sample on both Windows as well as Unix/Linux distribution. Probably you may need to modify the Qt part of the code if you are using Qt4. the sample is using Qt3.

Regards
N. Sharjith

DeleDivaneeh's picture

Thank you Nair..