
Fri, 06/12/2009 - 12:06
Forums:
Hello, I managed to decompose my solid (cube with a hole), on the other hand I wanted to know how I could get back the selection made with the mouse? For make out a will if the selection is a circle for example.
Thank you for your help
Fri, 06/12/2009 - 12:44
AIS_InteractiveContext: Check for methods that deal with LocalContext, Select and Current. It is up to you to decide what is useful for your specific case.
Fri, 06/12/2009 - 13:29
The purpose would have been to be able to click the circle and what it shows a pop up to modify the diameter.
Fri, 06/12/2009 - 14:38
Is the circle stored as a Wire or Face? Are you using AIS_Shape to display it? The more information you can give, the easier it is to help you.
Fri, 06/12/2009 - 15:57
Here is the function that I used to create my piece :
TopoDS_Shape
MakeBouchon()
{
//The cylinder
gp_Pnt neckLocation(gp_Pnt(30,30,30));
gp_Dir neckNormal = gp::DZ();
gp_Ax2 neckAx2(neckLocation , neckNormal);
TopoDS_Shape aHole = BRepPrimAPI_MakeCylinder(neckAx2,5,40);
//The cube
TopoDS_Shape box = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 60,60 , 60);
//Cube - Cylinder
TopoDS_Shape result = BRepAlgoAPI_Cut(box,aHole);
//Building the resulting compound
TopoDS_Compound aRes;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aRes);
aBuilder.Add (aRes, result);
return aRes;
}
Then the display :
TopoDS_Shape aTest=MakeBouchon();
Handle(AIS_Shape) AISBottle=new AIS_Shape(aTest);
getContext()->SetMaterial(AISBottle,Graphic3d_NOM_GOLD);
getContext()->Display(AISBottle, Standard_False);
getContext()->SetCurrentObject(AISBottle,Standard_False);
getContext()->SetDisplayMode(AISBottle,1,Standard_False);
getContext()->CloseAllContexts();
getContext()->OpenLocalContext();
emit selectionChanged();
fitAll();
QApplication::restoreOverrideCursor();
Fri, 06/12/2009 - 16:54
The idea is to use AIS_InteractiveContext::MoveTo when the mouse moves, AIS_InteractiveContext::Select when the user clicks, query for selection of a shape with AIS_InteractiveContext::HasSelectedShape, query the shape with AIS_InteractiveContext::SelectedShape, query the AIS_InteractiveObject with AIS_InteractiveContext::SelectedInteractive, ...
That is enough to get the selection.
Have you checked the samples provided with OpenCASCADE? All the basic stuff is covered there.
Fri, 06/12/2009 - 17:10
Thank you, I have to decompose my solid in this way:
getContext()->CloseAllContexts();
getContext()->OpenLocalContext();
getContext()->ActivateStandardMode(TopAbs_WIRE);
But when I click my circle it selects me all the same all my solid.
Mon, 06/15/2009 - 05:57
Hello,
Add the follow code, have a try, good luck!
Handle(AIS_TypeFilter) filter= new AIS_TypeFilter(AIS_KOI_Object );
Handle(AIS_TypeFilter) filter1= new AIS_TypeFilter(AIS_KOI_Datum );
Handle(AIS_TypeFilter) filter2= new AIS_TypeFilter(AIS_KOI_Shape );
Handle(AIS_TypeFilter) filter3= new AIS_TypeFilter(AIS_KOI_Relation);
Handle(AIS_TypeFilter) filter4= new AIS_TypeFilter(AIS_KOI_None );
m_hContext->AddFilter(filter);
m_hContext->AddFilter(filter1);
m_hContext->AddFilter(filter2);
m_hContext->AddFilter(filter3);
m_hContext->AddFilter(filter4);
Thanks!
Mon, 06/15/2009 - 10:34
I shall have wanted to know how to make out a will if the selection is a circle and if yes to show a popup
Thanks
Mon, 06/15/2009 - 11:20
Hi,
Firstly, you need add selection filter for the AIS_InteractiveContext, and then you can select an Edge of a Solid.
When you get the Edge Shape, the follow step is:
//m_selectShape is the Edge you select
if (m_selectShape.ShapeType() == TopAbs_Edge)
{
TopoDS_Edge edgeShape = TopoDS::Edge(m_selectShape);
Standard_Real first = 0, last = 0;
Handle_Geom_Curve curve = BRep_Tool::Curve(edgeShape,first,last);
if (curve->IsKind("Geom_Circle"))
{
MessageBox("You have selected a circle");
}
}
Mon, 06/15/2009 - 12:22
Thanks but how i convert context->Current() in shape ?
Mon, 06/15/2009 - 13:36
AIS_InteractiveContext::SelectedShape should give you what you want.
Mon, 06/15/2009 - 15:20
I've tried this code but I have many errors when i compile. Have you tried this code ?