]> OCCT Git - occt.git/commitdiff
0031965: Visualization - AIS_InteractiveContext::HilightWithColor() ignores passed...
authorkgv <kgv@opencascade.com>
Mon, 30 Nov 2020 08:47:30 +0000 (11:47 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 3 Dec 2020 15:46:25 +0000 (18:46 +0300)
AIS_InteractiveContext::highlightGlobal() now passed through Style argument to highlightOwners().
Added OCC31965 command for testing AIS_InteractiveContext::Hilight() behavior.

src/AIS/AIS_InteractiveContext.hxx
src/AIS/AIS_InteractiveContext_1.cxx
src/QABugs/QABugs_11.cxx
tests/bugs/vis/bug31965 [new file with mode: 0644]

index 2e4d57b5a0c805bab6f637473d2c563e7575a7d1..64d536a927cd80c5c563f7eb8eb163bdbbb20f83 100644 (file)
@@ -1211,9 +1211,11 @@ protected: //! @name internal methods
   //! for AutoHighlight, e.g. is used for selection.
   Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
 
-  //! Helper function that highlights the owners with check
-  //! for AutoHighlight, e.g. is used for selection.
-  Standard_EXPORT void highlightOwners (const AIS_NListOfEntityOwner& theOwners);
+  //! Helper function that highlights the owners with check for AutoHighlight, e.g. is used for selection.
+  //! @param theOwners [in] list of owners to highlight
+  //! @param theStyle  [in] highlight style to apply or NULL to apply selection style
+  Standard_EXPORT void highlightOwners (const AIS_NListOfEntityOwner& theOwners,
+                                        const Handle(Prs3d_Drawer)& theStyle);
 
   //! Helper function that highlights global owner of the object given with <theStyle> with check
   //! for AutoHighlight, e.g. is used for selection.
index 7c9b44caab04557a34cd47a75593bdb8788629a4..c5bda0013927a4e75cea5d9b53ebd673a3e3c859 100644 (file)
@@ -107,7 +107,7 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn
   {
     anOwners.Append (theOwner);
   }
-  highlightOwners (anOwners);
+  highlightOwners (anOwners, Handle(Prs3d_Drawer)());
 }
 
 //=======================================================================
@@ -148,7 +148,7 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
   {
     anOwners.Append (aGlobOwner);
   }
-  highlightOwners (anOwners);
+  highlightOwners (anOwners, theStyle);
 }
 
 //=======================================================================
@@ -725,7 +725,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
   // In case of selection without using local context
   clearDynamicHighlight();
 
-  highlightOwners (mySelection->Objects());
+  highlightOwners (mySelection->Objects(), Handle(Prs3d_Drawer)());
 
   if (theToUpdateViewer)
     UpdateCurrentViewer();
@@ -735,7 +735,8 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
 //function : highlightOwners
 //purpose  :
 //=======================================================================
-void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners)
+void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners,
+                                              const Handle(Prs3d_Drawer)& theStyle)
 {
   AIS_MapOfObjSelectedOwners anObjOwnerMap;
   for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
@@ -745,7 +746,7 @@ void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theO
     if (anObj.IsNull())
       continue;
 
-    const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
+    const Handle(Prs3d_Drawer)& anObjSelStyle = !theStyle.IsNull() ? theStyle : getSelStyle (anObj, anOwner);
     Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
     if (!aStatusPtr)
     {
index ce18b49fd1d372d9dbb3042edb458082c79a619b..c8673911fa30522334d8e321ef4ac28c420d6a17 100644 (file)
@@ -139,58 +139,6 @@ static Standard_Integer  OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/
  return 0;
 }
 
-  // Remove as bad version of QAAddOrRemoveSelected from QADraw
-//static Standard_Integer OCC129 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-//{
-//  if( argc != 3) {
-//    di<<"Usage : " << argv[0] << " shape islocal\n";
-//    return 1;
-//  }
-//  //get AIS_Shape:
-//  Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
-//
-// //   ViewerTest_DoubleMapOfInteractiveAndName& aMap =
-// //                          ViewerTest::GetDataMapOfAIS ();
-//  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
-//
-//  TCollection_AsciiString aName(argv[1]);
-//  Handle(AIS_InteractiveObject) AISObj;
-//
-//  if(aMap.IsBound2(aName)) {
-//    AISObj = aMap.Find2(aName);
-//    if(AISObj.IsNull()){
-//      di<<"No interactive object \n";
-//      return 1;
-//    }
-//
-//    Standard_Integer aNum = -1;
-//
-//    if(Draw::Atoi(argv[2])) {
-//      aNum = anAISCtx->OpenLocalContext();
-//    }
-//
-//    if(anAISCtx->HasOpenedContext()){
-//      anAISCtx->InitSelected();
-//      anAISCtx->AddOrRemoveSelected(AISObj);
-//    }
-//    else {
-//      anAISCtx->InitCurrent();
-//      anAISCtx->AddOrRemoveCurrentObject(AISObj);
-//    }
-//
-//    if(aNum >= 0) {
-// //      anAISCtx->CloseLocalContext(aNum);
-//    }
-//
-//    return 0;
-//  }
-//  //select this shape:
-//  else {
-//    di<<"Use 'vdisplay' before";
-//    return 1;
-//  }
-//}
-
 static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
 {
   if(argc > 1){
@@ -3019,6 +2967,20 @@ static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, co
   return 0;
 }
 
+// Test AIS_InteractiveContext::Hilight() call.
+static Standard_Integer OCC31965 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+  if (theArgNb != 2)
+  {
+    theDI << "Syntax error: wrong number of arguments";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) aPrs = GetMapOfAIS().Find2 (theArgVec[1]);
+  ViewerTest::GetAISContext()->HilightWithColor (aPrs, ViewerTest::GetAISContext()->HighlightStyle (Prs3d_TypeOfHighlight_Dynamic), true);
+  return 0;
+}
+
 static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
   if ((argc < 9) || (((argc-3) % 3) != 0))
@@ -5014,5 +4976,7 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC31189", "OCC31189: check stream buffer interface of Message_Messenger", __FILE__, OCC31189, group);
   theCommands.Add("OCC25748", "OCC25748 [-niter val] [-matsize val] [-progr] [-parallel]\n"
                   "\t\ttest progress indicator in parallel execution", __FILE__, OCC25748, group);
+
+  theCommands.Add("OCC31965", "OCC31965 object : tests AIS_InteractiveContext::Hilight()", __FILE__, OCC31965, group);
   return;
 }
diff --git a/tests/bugs/vis/bug31965 b/tests/bugs/vis/bug31965
new file mode 100644 (file)
index 0000000..00e7dc9
--- /dev/null
@@ -0,0 +1,14 @@
+puts "============"
+puts "0031965: Visualization - AIS_InteractiveContext::HilightWithColor() ignores passed highlight style"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION QAcommands
+box b 1 2 3
+vdisplay -dispMode 1 b
+vfit
+vselprops dynHighlight -dispMode 1 -color RED
+OCC31965 b
+
+if { [vreadpixel 200 200 -rgb -name] != "RED2" } { puts "Error: wrong highlight color" }
+vdump ${imagedir}/${casename}.png