0025034: Highlighted dimension objects are not in Detected list of AIS_InteractiveCon...
authoraba <aba@opencascade.com>
Thu, 3 Jul 2014 11:44:13 +0000 (15:44 +0400)
committerapn <apn@opencascade.com>
Thu, 3 Jul 2014 11:45:26 +0000 (15:45 +0400)
Detected sequence in local ind interactive contexts is filled with interactive objects, not with AIS_Shape only.

src/AIS/AIS_InteractiveContext.cdl
src/AIS/AIS_InteractiveContext_1.cxx
src/AIS/AIS_LocalContext.cdl
src/AIS/AIS_LocalContext_1.cxx

index bcbc176..f9bf5b1 100644 (file)
@@ -1525,12 +1525,26 @@ is
     ---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.
     
@@ -2078,13 +2092,16 @@ fields
     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;
index ed79893..c5a906e 100644 (file)
@@ -167,7 +167,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer  th
     }
 
     Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
-    if (!Handle(AIS_Shape)::DownCast (anObj).IsNull())
+    if (!anObj.IsNull())
     {
       myAISDetectedSeq.Append (anObj);
     }
@@ -1327,15 +1327,16 @@ Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V
 //=======================================================================
 void AIS_InteractiveContext::InitDetected()
 {
-  if(HasOpenedContext())
+  if (HasOpenedContext())
   {
     myLocalContexts(myCurLocalIndex)->InitDetected();
     return;
   }
 
   if(myAISDetectedSeq.Length() != 0)
+  {
     myAISCurDetected = 1;
-
+  }
 }
 
 //=======================================================================
@@ -1344,10 +1345,12 @@ void AIS_InteractiveContext::InitDetected()
 //=======================================================================
 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;
 }
 
@@ -1370,33 +1373,35 @@ void AIS_InteractiveContext::NextDetected()
 //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;
 }
index 61d4f16..7b57e5c 100644 (file)
@@ -340,11 +340,28 @@ is
     ---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;
@@ -625,10 +642,13 @@ fields
     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 
index a7e22e8..e84de81 100644 (file)
@@ -138,9 +138,9 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer  theXpix,
       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);
     }
@@ -1476,7 +1476,6 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const
 //function : AIS_LocalContext::InitDetected
 //purpose  :
 //=======================================================================
-
 void AIS_LocalContext::InitDetected()
 {
   myAISCurDetected = myAISDetectedSeq.Length()? 1 : 0;
@@ -1486,47 +1485,43 @@ void AIS_LocalContext::InitDetected()
 //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