0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / AIS / AIS_InteractiveContext.hxx
index 95299cf..42b89bb 100644 (file)
@@ -370,6 +370,9 @@ public: //! @name mouse picking logic (detection and dynamic highlighting of ent
                                                 const Standard_Integer theMode,
                                                 const Standard_Integer theNewSensitivity);
 
+  //! Returns last active View (argument of MoveTo()/Select() methods).
+  Standard_EXPORT Handle(V3d_View) LastActiveView() const;
+
   //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
   //! This is done by the view theView passing this position to the main viewer and updating it.
   //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
@@ -454,6 +457,7 @@ public: //! @name iteration through detected entities
 public: //! @name Selection management
 
   //! Sets the graphic basic aspect to the current presentation of ALL selected objects.
+  Standard_DEPRECATED ("Deprecated method - presentation attributes should be assigned directly to object")
   Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect,
                                           const Standard_Boolean           theToUpdateViewer);
 
@@ -504,6 +508,9 @@ public: //! @name Selection management
                                                 const Handle(V3d_View)& theView,
                                                 const Standard_Boolean  theToUpdateViewer);
 
+  //! Returns bounding box of selected objects.
+  Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
+
   //! Fits the view correspondingly to the bounds of selected objects.
   //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
   Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
@@ -556,6 +563,14 @@ public: //! @name Selection management
   Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
                                             const Standard_Boolean               theToUpdateViewer);
 
+  //! Updates Selected state of specified owner without calling HilightSelected().
+  //! Has no effect if Selected state is not changed, and redirects to AddOrRemoveSelected() otherwise.
+  //! @param theOwner owner object to set selected state
+  //! @param theIsSelected new selected state
+  //! @return TRUE if Selected state has been changed
+  Standard_EXPORT Standard_Boolean SetSelectedState (const Handle(SelectMgr_EntityOwner)& theOwner,
+                                                     const Standard_Boolean               theIsSelected);
+
   //! Highlights selected objects.
   Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer);
 
@@ -815,6 +830,9 @@ public: //! @name common properties
   //! returns the number of removed  structures from the viewers.
   Standard_EXPORT Standard_Integer PurgeDisplay();
 
+  //! Return rotation gravity point.
+  Standard_EXPORT virtual gp_Pnt GravityPoint (const Handle(V3d_View)& theView) const;
+
 public: //! @name debug visualization
 
   //! Visualization of sensitives - for debugging purposes!
@@ -953,23 +971,6 @@ public: //! @name tessellation deviation properties for automatic triangulation
   Standard_EXPORT void SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
                                              const Standard_Real                  theAngle,
                                              const Standard_Boolean               theToUpdateViewer);
-  
-
-  //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
-  //! The Default value is 0.02.
-  Standard_EXPORT void SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj,
-                                                   const Standard_Real                  theCoefficient,
-                                                   const Standard_Boolean               theToUpdateViewer);
-  
-  Standard_EXPORT void SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj,
-                                             const Standard_Real                  theAngle,
-                                             const Standard_Boolean               theToUpdateViewer);
-  
-  //! Computes a HLRAngle and a HLRDeviationCoefficient by means of the angle anAngle
-  //! and sets the corresponding methods in the default drawing tool with these values.
-  Standard_EXPORT void SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj,
-                                                const Standard_Real                  theAngle,
-                                                const Standard_Boolean               theToUpdateViewer);
 
   //! Sets the deviation coefficient theCoefficient.
   //! Drawings of curves or patches are made with respect to a maximal chordal deviation.
@@ -999,40 +1000,10 @@ public: //! @name tessellation deviation properties for automatic triangulation
   //! This deviation will be: SizeOfObject * DeviationCoefficient.
   Standard_EXPORT Standard_Real DeviationCoefficient() const;
 
-  //! default 12 degrees
+  //! default 20 degrees
   Standard_EXPORT void SetDeviationAngle (const Standard_Real anAngle);
 
   Standard_EXPORT Standard_Real DeviationAngle() const;
-  
-  //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations.
-  //! The Default value is 0.02.
-  Standard_EXPORT void SetHLRDeviationCoefficient (const Standard_Real aCoefficient);
-
-  //! Returns the real number value of the hidden line removal deviation coefficient.
-  //! A Deviation coefficient is used in the shading display mode.
-  //! The shape is seen decomposed into triangles.
-  //! These are used to calculate reflection of light from the surface of the object.
-  //! The triangles are formed from chords of the curves in the shape.
-  //! The deviation coefficient give the highest value of the angle with which a chord can deviate from a tangent to a curve.
-  //! If this limit is reached, a new triangle is begun.
-  //! To find the hidden lines, hidden line display mode entails recalculation of the view at each different projector perspective.
-  //! Because hidden lines entail calculations of more than usual complexity to decompose them into these triangles,
-  //! a deviation coefficient allowing greater tolerance is used.
-  //! This increases efficiency in calculation.
-  //! The Default value is 0.02.
-  Standard_EXPORT Standard_Real HLRDeviationCoefficient() const;
-
-  //! Sets the HLR angle.
-  Standard_EXPORT void SetHLRAngle (const Standard_Real theAngle);
-
-  //! Returns the real number value of the deviation angle in hidden line removal views in this interactive context.
-  //! The default value is 20*PI/180.
-  Standard_EXPORT Standard_Real HLRAngle() const;
-
-  //! compute with theAngle a HLRAngle and a HLRDeviationCoefficient
-  //! and set them in myHLRAngle and in myHLRDeviationCoefficient of myDefaultDrawer;
-  //! theAngle is in radian; ( 1 deg < angle in deg < 20 deg)
-  Standard_EXPORT void SetHLRAngleAndDeviation (const Standard_Real theAngle);
 
 public: //! @name HLR (Hidden Line Removal) display attributes
 
@@ -1191,6 +1162,16 @@ public: //! @name sub-intensity management (deprecated)
   Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj,
                                         const Standard_Boolean               theToUpdateViewer);
 
+  //! Returns selection instance
+  const Handle(AIS_Selection)& Selection() const { return mySelection; }
+
+  //! Sets selection instance to manipulate a container of selected owners
+  //! @param theSelection an instance of the selection
+  void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
+
+  //! Dumps the content of me into the stream
+  Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
 protected: //! @name internal methods
 
   Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
@@ -1210,7 +1191,7 @@ protected: //! @name internal methods
   Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
 
   //! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
-  Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
+  Standard_EXPORT void unselectOwners (const Handle(AIS_InteractiveObject)& theObject);
 
   //! Helper function that highlights the owner given with <theStyle> without
   //! performing AutoHighlight checks, e.g. is used for dynamic highlight.
@@ -1221,12 +1202,16 @@ 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 global owner of the object given with <theStyle> with check
   //! for AutoHighlight, e.g. is used for selection.
   //! If global owner is null, it simply highlights the whole object
   Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
                                         const Handle(Prs3d_Drawer)& theStyle,
-                                        const Standard_Integer theDispMode) const;
+                                        const Standard_Integer theDispMode);
 
   //! Helper function that unhighlights all owners that are stored in current AIS_Selection.
   //! The function updates global status and selection state of owner and interactive object.
@@ -1234,9 +1219,14 @@ protected: //! @name internal methods
   //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
   Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
 
+  //! Helper function that unhighlights the owners with check
+  //! for AutoHighlight, e.g. is used for selection.
+  Standard_EXPORT void unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
+                                          const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
+
   //! Helper function that unhighlights global selection owner of given interactive.
   //! The function does not perform any updates of global or owner status
-  Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const;
+  Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj);
 
   //! Helper function that turns on sub-intensity in global status and highlights
   //! given objects with sub-intensity color
@@ -1339,19 +1329,27 @@ protected: //! @name internal methods
   //! Removes dynamic highlight draw
   void clearDynamicHighlight() const
   {
-    if (myLastinMain.IsNull())
+    if (myLastPicked.IsNull())
       return;
 
-    if (myLastinMain->IsAutoHilight())
+    if (myLastPicked->IsAutoHilight())
     {
       myMainPM->ClearImmediateDraw();
     }
     else
     {
-      myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM);
+      myLastPicked->Selectable()->ClearDynamicHighlight (myMainPM);
     }
   }
 
+  //! Bind/Unbind status to object and its children
+  //! @param theObj [in] the object to change status
+  //! @param theStatus status, if NULL, unbind object
+  Standard_EXPORT void setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj,
+                                        const AIS_DisplayStatus theStatus,
+                                        const Standard_Integer theDispyMode,
+                                        const Standard_Integer theSelectionMode);
+
 protected: //! @name internal fields
 
   AIS_DataMapOfIOStatus myObjects;
@@ -1359,9 +1357,8 @@ protected: //! @name internal fields
   Handle(PrsMgr_PresentationManager3d) myMainPM;
   Handle(V3d_Viewer) myMainVwr;
   Handle(StdSelect_ViewerSelector3d) myMainSel;
+  V3d_View* myLastActiveView;
   Handle(SelectMgr_EntityOwner) myLastPicked;
-  Handle(SelectMgr_EntityOwner) myLastinMain;
-  Standard_Boolean myWasLastMain;
   Standard_Boolean myToHilightSelected;
   Handle(AIS_Selection) mySelection;
   Handle(SelectMgr_OrFilter) myFilters;