Detected sequence in local ind interactive contexts is filled with interactive objects, not with AIS_Shape only.
---Purpose: returns the owner of the detected sensitive primitive.
InitDetected(me: mutable);
-
+ ---Purpose:
+ -- Initialization for iteration through mouse-detected objects in
+ -- interactive context or in local context if it is opened.
MoreDetected(me) returns Boolean from Standard;
+ ---Purpose:
+ -- @return true if there is more mouse-detected objects after the current one
+ -- during iteration through mouse-detected interactive objects.
NextDetected(me: mutable);
+ ---Purpose:
+ -- Gets next current object during iteration through mouse-detected
+ -- interactive objects.
DetectedCurrentShape(me) returns Shape from TopoDS;
---C++: return const &
+ ---Purpose:
+ -- @return current mouse-detected shape or empty (null) shape, if current interactive object
+ -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
DetectedCurrentObject(me) returns InteractiveObject from AIS;
+ --Purpose:
+ -- @return current mouse-detected interactive object or null object if there is no current detected.
+
---Category: SPECIFIC LOCAL CONTEXT ACTIONS.
myCurLocalIndex : Integer from Standard;
mylastmoveview : View from V3d;
- -- the detected objects.
+ -- The detected objects
+
myAISDetectedSeq : SequenceOfInteractive from AIS;
+ -- the sequence of detected interative objects.
myAISCurDetected : Integer from Standard;
- -- This variables is used by following functions:
+ -- current detected interactive object.
+ -- This variable is used by following functions:
-- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
- myZDetectionFlag: Boolean from Standard;
- -- This variables is used by SetZDetection() and ZDetection() methods
+ myZDetectionFlag: Boolean from Standard;
+ -- This variable is used by SetZDetection() and ZDetection() methods
-- abd:
myIsAutoActivateSelMode : Boolean from Standard;
}
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (!Handle(AIS_Shape)::DownCast (anObj).IsNull())
+ if (!anObj.IsNull())
{
myAISDetectedSeq.Append (anObj);
}
//=======================================================================
void AIS_InteractiveContext::InitDetected()
{
- if(HasOpenedContext())
+ if (HasOpenedContext())
{
myLocalContexts(myCurLocalIndex)->InitDetected();
return;
}
if(myAISDetectedSeq.Length() != 0)
+ {
myAISCurDetected = 1;
-
+ }
}
//=======================================================================
//=======================================================================
Standard_Boolean AIS_InteractiveContext::MoreDetected() const
{
- if(HasOpenedContext())
+ if (HasOpenedContext())
+ {
return myLocalContexts(myCurLocalIndex)->MoreDetected();
+ }
- return (myAISCurDetected>0 &&myAISCurDetected <= myAISDetectedSeq.Length()) ?
+ return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ?
Standard_True : Standard_False;
}
//function : DetectedCurrentShape
//purpose :
//=======================================================================
-
const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
{
- if(HasOpenedContext())
+ if (HasOpenedContext())
+ {
return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
+ }
- static TopoDS_Shape bidsh;
- if(myAISCurDetected > 0 &&
- myAISCurDetected <= myAISDetectedSeq.Length())
- return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape();
- return bidsh;
+ static TopoDS_Shape aDummyShape;
+
+ Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
+
+ if (aCurrentShape.IsNull())
+ {
+ return aDummyShape;
+ }
+
+ return aCurrentShape->Shape();
}
//=======================================================================
//function : DetectedCurrentObject
//purpose :
//=======================================================================
-
-Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const {
- if(HasOpenedContext())
+Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
+{
+ if (HasOpenedContext())
+ {
return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
+ }
- Handle(AIS_InteractiveObject) aBad;
-
- if(myAISCurDetected > 0 &&
- myAISCurDetected <= myAISDetectedSeq.Length())
- return myAISDetectedSeq(myAISCurDetected);
- else
- return aBad;
+ return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
}
---C++: inline
InitDetected(me: mutable);
+ ---Purpose:
+ -- Initialization for iteration through mouse-detected objects in local context.
+
MoreDetected(me) returns Boolean from Standard;
+ ---Purpose:
+ -- @return true if there is more mouse-detected objects after the current one
+ -- during iteration through mouse-detected interactive objects.
+
NextDetected(me: mutable);
+ ---Purpose:
+ -- Gets next current object during iteration through mouse-detected
+ -- interactive objects.
+
DetectedCurrentShape(me) returns Shape from TopoDS;
---C++: return const &
+ ---Purpose:
+ -- @return current mouse-detected shape or empty (null) shape, if current interactive object
+ -- is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
+
DetectedCurrentObject(me) returns InteractiveObject from AIS;
+ ---Purpose:
+ -- @return current mouse-detected interactive object or null object if there is no current detected.
HasDetectedShape(me) returns Boolean from Standard;
DetectedShape (me) returns Shape from TopoDS;
myDetectedSeq : SequenceOfInteger from TColStd;
myCurDetected : Integer from Standard;
- -- the detected objects.
+ -- The detected objects.
+
myAISDetectedSeq : SequenceOfInteractive from AIS;
+ -- the sequence of detected interative objects.
myAISCurDetected : Integer from Standard;
- -- This variables is used by following functions:
+ -- current detected interactive object.
+ -- This variable is used by following functions:
-- InitDetected(), MoreDetected(), NextDetected(), DetectedCurrentShape(), DetectedCurrentObject().
friends
continue;
}
- myDetectedSeq.Append (aDetIter); // normallly they are already arranged in correct order...
+ myDetectedSeq.Append (aDetIter); // normally they are already arranged in correct order...
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
- if (!Handle(AIS_Shape)::DownCast (anObj).IsNull())
+ if (!anObj.IsNull())
{
myAISDetectedSeq.Append (anObj);
}
//function : AIS_LocalContext::InitDetected
//purpose :
//=======================================================================
-
void AIS_LocalContext::InitDetected()
{
myAISCurDetected = myAISDetectedSeq.Length()? 1 : 0;
//function : AIS_LocalContext::MoreDetected
//purpose :
//=======================================================================
-
Standard_Boolean AIS_LocalContext::MoreDetected() const
{
return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length());
}
-
//=======================================================================
//function : AIS_LocalContext::NextDetected
//purpose :
//=======================================================================
-
void AIS_LocalContext::NextDetected()
{
- if (MoreDetected()) myAISCurDetected++;
+ myAISCurDetected++;
}
//=======================================================================
//function : DetectedCurrentShape
//purpose :
//=======================================================================
-
const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
{
- static TopoDS_Shape bidsh;
- if (MoreDetected())
- return Handle(AIS_Shape)::DownCast(myAISDetectedSeq(myAISCurDetected))->Shape();
- return bidsh;
-}
+ static TopoDS_Shape aDummyShape;
+ Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
+
+ if (aCurrentShape.IsNull())
+ {
+ return aDummyShape;
+ }
+
+ return aCurrentShape->Shape();
+}
//=======================================================================
//function : DetectedCurrentObject
//purpose :
//=======================================================================
-
Handle(AIS_InteractiveObject) AIS_LocalContext::DetectedCurrentObject() const
{
- Handle(AIS_InteractiveObject) theIObj;
- if (MoreDetected())
- theIObj = myAISDetectedSeq(myAISCurDetected);
-
- return theIObj;
+ return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
}
#endif