1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0024420: Add methods to switch the type of sensitivity in AIS_Circle and AIS_Plane

Added methods to AIS_Circle and AIS_Plane for switching type of sensitivity
By default AIS_Circle and AIS_Plane have boundary sensitivity
This commit is contained in:
dbv 2013-12-05 15:43:48 +04:00 committed by bugmaster
parent b3837d74e0
commit 9e8804b6db
9 changed files with 186 additions and 37 deletions

View File

@ -45,15 +45,15 @@ is
returns mutable Circle from AIS;
---Purpose: Initializes this algorithm for constructing AIS circle
-- datums initializes the circle aCircle
Create(aCircle : Circle from Geom;
aUStart : Real from Standard;
aUEnd : Real from Standard;
aSens : Boolean from Standard = Standard_True)
Create(theCircle : Circle from Geom;
theUStart : Real from Standard;
theUEnd : Real from Standard;
theIsFilledCircleSens : Boolean from Standard = Standard_False)
returns mutable Circle from AIS;
---Purpose: Initializes this algorithm for constructing AIS circle datums.
-- Initializes the circle aCircle, the arc
-- starting point UStart, the arc ending point UEnd,
-- and the direction aSens.
---Purpose: Initializes this algorithm for constructing AIS circle datums.
-- Initializes the circle theCircle, the arc
-- starting point theUStart, the arc ending point theUEnd,
-- and the type of sensitivity theIsFilledCircleSens.
Compute(me : mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
@ -136,6 +136,15 @@ is
is redefined static;
---Purpose: Removes width settings from the solid line boundary of the circle datum.
IsFilledCircleSens (me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns the type of sensitivity for the circle;
SetFilledCircleSens (me: mutable;
theIsFilledCircleSens : Boolean from Standard);
---C++: inline
---Purpose: Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True
-- then the whole circle will be detectable, otherwise only the boundary of the circle.
ComputeCircle(me: mutable;
aPresentation : mutable Presentation from Prs3d)
@ -159,6 +168,6 @@ fields
myUStart : Real from Standard;
myUEnd : Real from Standard;
myCircleIsArc : Boolean from Standard;
mySens : Boolean from Standard;
myIsFilledCircleSens : Boolean from Standard;
end Circle ;

View File

@ -48,7 +48,8 @@ AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent(aComponent),
myUStart(0.),
myUEnd(2*M_PI),
myCircleIsArc(Standard_False)
myCircleIsArc(Standard_False),
myIsFilledCircleSens (Standard_False)
{
}
@ -56,17 +57,17 @@ myCircleIsArc(Standard_False)
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent,
const Standard_Real aUStart,
const Standard_Real aUEnd,
const Standard_Boolean aSens):
AIS_InteractiveObject(PrsMgr_TOP_AllView)
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
const Standard_Real theUStart,
const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens)
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent (theComponent),
myUStart (theUStart),
myUEnd (theUEnd),
myCircleIsArc (Standard_True),
myIsFilledCircleSens (theIsFilledCircleSens)
{
myComponent = aComponent;
myUStart = aUStart;
myUEnd = aUEnd;
mySens = aSens;
myCircleIsArc = Standard_True;
}
//=======================================================================
@ -236,8 +237,9 @@ void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
myComponent);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
myComponent,
myIsFilledCircleSens);
aSelection->Add(seg);
}
//=======================================================================
@ -250,8 +252,10 @@ void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelecti
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle(eown,
myComponent,myUStart,myUEnd);
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
myComponent,
myUStart, myUEnd,
myIsFilledCircleSens);
aSelection->Add(seg);
}

View File

@ -39,3 +39,13 @@ inline void AIS_Circle::SetFirstParam(const Standard_Real U)
{myUStart=U;myCircleIsArc = Standard_True;}
inline void AIS_Circle::SetLastParam(const Standard_Real U)
{myUEnd=U; myCircleIsArc = Standard_True;}
inline Standard_Boolean AIS_Circle::IsFilledCircleSens() const
{
return myIsFilledCircleSens;
}
inline void AIS_Circle::SetFilledCircleSens (const Standard_Boolean theIsFilledCircleSens)
{
myIsFilledCircleSens = theIsFilledCircleSens;
}

View File

@ -35,6 +35,7 @@ uses
NameOfColor from Quantity,
Color from Quantity,
Selection from SelectMgr,
TypeOfSensitivity from Select3D,
Pnt from gp,
Projector from Prs3d,
Transformation from Geom,
@ -187,6 +188,15 @@ is
SetContext(me:mutable; aCtx : InteractiveContext from AIS) is redefined;
---Purpose: connection to <aCtx> default drawer implies a recomputation of Frame values.
TypeOfSensitivity (me) returns TypeOfSensitivity from Select3D;
---C++: inline
---Purpose: Returns the type of sensitivity for the plane;
SetTypeOfSensitivity (me: mutable;
theTypeOfSensitivity: TypeOfSensitivity from Select3D);
---C++: inline
---Purpose: Sets the type of sensitivity for the plane.
-- Methods from PresentableObject
Compute(me : mutable;
@ -249,5 +259,6 @@ fields
myTypeOfPlane : TypeOfPlane from AIS;
myIsXYZPlane : Boolean from Standard;
myHasOwnSize : Boolean from Standard;
myTypeOfSensitivity: TypeOfSensitivity from Select3D;
end Plane;

View File

@ -74,7 +74,8 @@ myCenter(gp_Pnt(0.,0.,0.)),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False)
myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
}
@ -91,7 +92,8 @@ myCenter(aCenter),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False)
myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
}
@ -112,7 +114,8 @@ myPmax(aPmax),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_False),
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False)
myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
SetHilightMode(0);
@ -129,7 +132,8 @@ myAx2(aComponent),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
myTypeOfPlane(aPlaneType),
myIsXYZPlane(Standard_True)
myIsXYZPlane(Standard_True),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
ComputeFields();
@ -325,7 +329,7 @@ void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
thegoodpl->D0(-lx,-ly,arr(3));
thegoodpl->D0(-lx,ly,arr(4));
arr(5) = arr(1);
sfac = new Select3D_SensitiveFace(eown,harr,Select3D_TOS_BOUNDARY);
sfac = new Select3D_SensitiveFace(eown,harr,myTypeOfSensitivity);
}
else {
@ -336,7 +340,7 @@ void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
arr1(2) = myPmin;
arr1(3) = myPmax;
arr1(4) = myCenter;
sfac = new Select3D_SensitiveFace(eown,harr1,Select3D_TOS_BOUNDARY);
sfac = new Select3D_SensitiveFace(eown,harr1,myTypeOfSensitivity);
}
aSelection->Add(sfac);

View File

@ -49,3 +49,13 @@ inline void AIS_Plane::SetCenter(const gp_Pnt& aCenter)
{
myCenter = aCenter;
}
inline Select3D_TypeOfSensitivity AIS_Plane::TypeOfSensitivity() const
{
return myTypeOfSensitivity;
}
inline void AIS_Plane::SetTypeOfSensitivity (const Select3D_TypeOfSensitivity theTypeOfSensitivity)
{
myTypeOfSensitivity = theTypeOfSensitivity;
}

View File

@ -47,7 +47,7 @@ is
---Category: sensitive entities
enumeration TypeOfSensitivity is TOS_INTERIOR,TOS_BOUNDARY,TOS_EXTERIOR
enumeration TypeOfSensitivity is TOS_INTERIOR,TOS_BOUNDARY
end TypeOfSensitivity;
---Purpose: Provides values for type of sensitivity in 3D.
-- These are used to specify whether it is the interior,

View File

@ -893,9 +893,9 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
//==============================================================================
//function : VPlaneBuilder
//purpose : Build an AIS_Plane from selected entities or Named AIS components
//Draw arg : vplane PlaneName [AxisName] [PointName]
// [PointName] [PointName] [PointName]
// [PlaneName] [PointName]
//Draw arg : vplane PlaneName [AxisName] [PointName] [TypeOfSensitivity]
// [PointName] [PointName] [PointName] [TypeOfSensitivity]
// [PlaneName] [PointName] [TypeOfSensitivity]
//==============================================================================
static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
@ -908,12 +908,12 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
Standard_Integer aCurrentIndex;
// Verification
if (argc<2 || argc>5 )
if (argc<2 || argc>6 )
{
std::cout<<" Syntax error\n";
return 1;
}
if (argc==5 || argc==4)
if (argc == 6 || argc==5 || argc==4)
hasArg=Standard_True;
else
hasArg=Standard_False;
@ -1019,6 +1019,23 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane );
GetMapOfAIS().Bind (anAISPlane,aName );
if (argc == 6)
{
Standard_Integer aType = Draw::Atoi (argv[5]);
if (aType != 0 && aType != 1)
{
std::cout << "vplane error: wrong type of sensitivity!\n"
<< "Should be one of the following values:\n"
<< "0 - Interior\n"
<< "1 - Boundary"
<< std::endl;
return 1;
}
else
{
anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
}
}
TheAISContext()->Display(anAISPlane);
}
@ -1060,6 +1077,23 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
Handle(Geom_Plane) aGeomPlane = new Geom_Plane(B,D);
Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane,B );
GetMapOfAIS().Bind (anAISPlane,aName );
if (argc == 5)
{
Standard_Integer aType = Draw::Atoi (argv[4]);
if (aType != 0 && aType != 1)
{
std::cout << "vplane error: wrong type of sensitivity!\n"
<< "Should be one of the following values:\n"
<< "0 - Interior\n"
<< "1 - Boundary"
<< std::endl;
return 1;
}
else
{
anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
}
}
TheAISContext()->Display(anAISPlane);
}
@ -1098,6 +1132,23 @@ static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
// Construction of an AIS_Plane
Handle(AIS_Plane) anAISPlane = new AIS_Plane(aNewGeomPlane, B);
GetMapOfAIS().Bind (anAISPlane, aName);
if (argc == 5)
{
Standard_Integer aType = Draw::Atoi (argv[4]);
if (aType != 0 && aType != 1)
{
std::cout << "vplane error: wrong type of sensitivity!\n"
<< "Should be one of the following values:\n"
<< "0 - Interior\n"
<< "1 - Boundary"
<< std::endl;
return 1;
}
else
{
anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
}
}
TheAISContext()->Display(anAISPlane);
}
// Error
@ -1888,6 +1939,7 @@ void DisplayCircle (Handle (Geom_Circle) theGeomCircle,
else
{
aCircle = new AIS_Circle(theGeomCircle);
Handle(AIS_Circle)::DownCast (aCircle)->SetFilledCircleSens (Standard_False);
}
// Check if there is an object with given name
@ -4916,7 +4968,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
__FILE__,VPointBuilder,group);
theCommands.Add("vplane",
"vplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] ",
"vplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity]",
__FILE__,VPlaneBuilder,group);
theCommands.Add("vplanepara",

49
tests/bugs/vis/bug24420 Normal file
View File

@ -0,0 +1,49 @@
puts "============"
puts "CR24420"
puts "============"
puts ""
#######################################################################
# Test for type of sensitivity of AIS_Plane
#######################################################################
set aV "Driver1/Viewer1/View1"
vinit name=$aV l=32 t=32 w=400 h=400
vactivate $aV
vclear
vpoint p1 0 0 0
vpoint p2 1 0 0
vpoint p3 0 1 0
puts "Testing Select3D_TOS_INTERIOR type of sensitivity:"
vplane pl1 p1 p2 p3 0
vfit
vmoveto 200 200
checkcolor 395 200 0 1 1
if { $stat != 1 } {
puts "Error : Select3D_SensitiveFace does not work properly with type of sensitivity Select3D_TOS_INTERIOR!"
}
verase pl1
puts "Testing Select3D_TOS_BOUNDARY type of sensitivity:"
vplane pl2 p1 p2 p3 1
vfit
vmoveto 200 200
checkcolor 395 200 0.5 0.8 0.9
if { $stat != 1 } {
puts "Error : Select3D_SensitiveFace does not work properly with type of sensitivity Select3D_TOS_BOUNDARY!"
}
vmoveto 395 200
checkcolor 395 200 0 1 1
if { $stat != 1 } {
puts "Error : Select3D_SensitiveFace does not work properly with type of sensitivity Select3D_TOS_BOUNDARY!"
}