]> OCCT Git - occt.git/commitdiff
0030806: Visualization - AIS Manipulator highlighting is not affected by the view...
authoraba <aba@opencascade.com>
Tue, 25 Jun 2019 09:30:24 +0000 (12:30 +0300)
committerapn <apn@opencascade.com>
Tue, 25 Jun 2019 16:44:07 +0000 (19:44 +0300)
- AIS_Manipalator object view affinity is now applied to presentation for highlighting.

src/AIS/AIS_Manipulator.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/v3d/manipulator/view_affinity [new file with mode: 0644]

index 780ebf3473d30f2efd63055ba917239e63d7977c..248e61d64825e48e9282a05beb28ac3115d64aa8 100644 (file)
@@ -1035,15 +1035,21 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
   {
     return;
   }
+
+  aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
+
   if (anOwner->Mode() == AIS_MM_TranslationPlane)
   {
     Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
-    aStyle->SetColor(myAxes[anOwner->Index()].Color());
-    aStyle->SetTransparency(0.5);
-    aPresentation->Highlight(aStyle);
+    aStyle->SetColor (myAxes[anOwner->Index()].Color());
+    aStyle->SetTransparency (0.5);
+    aPresentation->Highlight (aStyle);
   }
   else
-    aPresentation->Highlight(theStyle);
+  {
+    aPresentation->Highlight (theStyle);
+  }
+
   for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
        aGroupIter.More(); aGroupIter.Next())
   {
index f4801fee97707d25cb56609218073a1712427b3d..13bdca3a7a8d1c9a17f80dfa6edb144304bdbe87 100644 (file)
@@ -12280,10 +12280,10 @@ static int VManipulator (Draw_Interpretor& theDi,
                          Standard_Integer  theArgsNb,
                          const char**      theArgVec)
 {
-  Handle(V3d_View)   aView   = ViewerTest::CurrentView();
+  Handle(V3d_View)   aCurrentView   = ViewerTest::CurrentView();
   Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
   ViewerTest::GetAISContext()->MainSelector()->SetPickClosest (Standard_False);
-  if (aView.IsNull()
+  if (aCurrentView.IsNull()
    || aViewer.IsNull())
   {
     std::cerr << "No active viewer!\n";
@@ -12303,6 +12303,7 @@ static int VManipulator (Draw_Interpretor& theDi,
   aCmd.AddOption ("adjustPosition", "... {0|1} - adjust position when attaching");
   aCmd.AddOption ("adjustSize",     "... {0|1} - adjust size when attaching ");
   aCmd.AddOption ("enableModes",    "... {0|1} - enable modes when attaching ");
+  aCmd.AddOption ("view",           "... {active | [view name]} - define view in which manipulator will be displayed, 'all' by default");
   aCmd.AddOption ("detach",         "...       - detach manipulator");
 
   aCmd.AddOption ("startTransform",   "... mouse_x mouse_y - invoke start transformation");
@@ -12508,6 +12509,42 @@ static int VManipulator (Draw_Interpretor& theDi,
     }
 
     aManipulator->Attach (anObject, anOptions);
+
+    // Check view option
+    if (aCmd.HasOption ("view"))
+    {
+      if (!aCmd.HasOption ("view", 1, Standard_True))
+      {
+        return 1;
+      }
+      TCollection_AsciiString aViewString (aCmd.Arg ("view", 0).c_str());
+      Handle(V3d_View) aView;
+      if (aViewString.IsEqual ("active"))
+      {
+        aView = ViewerTest::CurrentView();
+      }
+      else // Check view name
+      {
+        ViewerTest_Names aViewNames (aViewString);
+        if (!ViewerTest_myViews.IsBound1 (aViewNames.GetViewName()))
+        {
+          std::cerr << theArgVec[0] << " error: wrong view name '" << aViewString << "'\n";
+          return 1;
+        }
+        aView = ViewerTest_myViews.Find1 (aViewNames.GetViewName());
+        if (aView.IsNull())
+        {
+          std::cerr << theArgVec[0] << " error: cannot find view with name '" << aViewString << "'\n";
+          return 1;
+        }
+      }
+      for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
+        anIter (ViewerTest_myViews); anIter.More(); anIter.Next())
+      {
+        ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), Standard_False);
+      }
+      ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aView, Standard_True);
+    }
   }
 
   // --------------------------------------
@@ -13756,6 +13793,8 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
       "\n      '-adjustPosition {0|1}'             adjust position when attaching"
       "\n      '-adjustSize     {0|1}'             adjust size when attaching"
       "\n      '-enableModes    {0|1}'             enable modes when attaching"
+      "\n      '-view  {active | [name of view]}'  display manipulator only in defined view,"
+      "\n                                          by default it is displayed in all views of the current viewer"
       "\n      '-detach'                           detach manipulator"
       "\n      '-startTransform mouse_x mouse_y' - invoke start of transformation"
       "\n      '-transform      mouse_x mouse_y' - invoke transformation"
diff --git a/tests/v3d/manipulator/view_affinity b/tests/v3d/manipulator/view_affinity
new file mode 100644 (file)
index 0000000..1c0f0de
--- /dev/null
@@ -0,0 +1,30 @@
+puts "====================================="
+puts "Display manipulator in one view only"
+puts "====================================="
+
+pload MODELING VISUALIZATION
+vclear
+vclose ALL
+vinit View1
+vinit View2
+vaxo
+
+box b 500 500 1 50 100 150
+vdisplay b -dispMode 1
+vfit
+
+vactivate View1
+vmanipulator m -attach b -view active
+vfit
+vmoveto 200 200
+vdump $imagedir/${casename}_View1_1.png
+vactivate View2
+vdump $imagedir/${casename}_View2_1.png
+vmanipulator m -detach
+
+vmanipulator m -attach b -view View2
+vmoveto 200 200
+vdump $imagedir/${casename}_View2_2.png
+vactivate View1
+vdump $imagedir/${casename}_View1_2.png
+vmanipulator m -detach