0030748: Visualization - Marker displayed in immediate layer ruins QT Quick view...
[occt.git] / src / OpenGl / OpenGl_Structure.hxx
index 8276945..58c3a0e 100644 (file)
 #include <Graphic3d_CStructure.hxx>
 #include <Graphic3d_SequenceOfHClipPlane.hxx>
 
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
 
 #include <OpenGl_GraphicDriver.hxx>
 #include <OpenGl_Group.hxx>
 #include <OpenGl_Workspace.hxx>
 
 #include <NCollection_List.hxx>
-#include <InterfaceGraphic_Graphic3d.hxx>
 
-class OpenGl_Structure;
 class OpenGl_GraphicDriver;
 
+DEFINE_STANDARD_HANDLE(OpenGl_Structure, Graphic3d_CStructure)
 typedef NCollection_List<const OpenGl_Structure* > OpenGl_ListOfStructure;
 
 //! Implementation of low-level graphic structure.
 class OpenGl_Structure : public Graphic3d_CStructure
 {
   friend class OpenGl_Group;
-
+  DEFINE_STANDARD_RTTIEXT(OpenGl_Structure, Graphic3d_CStructure)
 public:
 
-  //! Auxiliary wrapper to iterate OpenGl_Group sequence.
-  class GroupIterator
-  {
-
-  public:
-    GroupIterator (const Graphic3d_SequenceOfGroup& theGroups) : myIter (theGroups) {}
-    Standard_Boolean More() const     { return myIter.More(); }
-    void Next()                       { myIter.Next(); }
-    const OpenGl_Group* Value() const { return (const OpenGl_Group* )(myIter.Value().operator->()); }
-    OpenGl_Group*       ChangeValue() { return (OpenGl_Group* )(myIter.ChangeValue().operator->()); }
+  //! Auxiliary wrapper to iterate OpenGl_Structure sequence.
+  typedef SubclassStructIterator<OpenGl_Structure> StructIterator;
 
-  private:
-    Graphic3d_SequenceOfGroup::Iterator myIter;
-
-  };
+  //! Auxiliary wrapper to iterate OpenGl_Group sequence.
+  typedef SubclassGroupIterator<OpenGl_Group> GroupIterator;
 
 public:
 
@@ -70,104 +56,55 @@ public:
   Standard_EXPORT virtual void OnVisibilityChanged() Standard_OVERRIDE;
 
   //! Clear graphic data
-  Standard_EXPORT virtual void Clear();
+  Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
 
   //! Connect other structure to this one
-  Standard_EXPORT virtual void Connect    (Graphic3d_CStructure& theStructure);
+  Standard_EXPORT virtual void Connect    (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
 
   //! Disconnect other structure to this one
-  Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure);
-
-  //! Synchronize structure aspects
-  Standard_EXPORT virtual void UpdateAspects();
+  Standard_EXPORT virtual void Disconnect (Graphic3d_CStructure& theStructure) Standard_OVERRIDE;
 
   //! Synchronize structure transformation
-  Standard_EXPORT virtual void UpdateTransformation();
+  Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+
+  //! Set transformation persistence.
+  Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
+
+  //! Set z layer ID to display the structure in specified layer
+  Standard_EXPORT virtual void SetZLayer(const Graphic3d_ZLayerId theLayerIndex) Standard_OVERRIDE;
 
-  //! Highlight entire structure with color
-  Standard_EXPORT virtual void HighlightWithColor (const Graphic3d_Vec3&  theColor,
-                                                   const Standard_Boolean theToCreate);
+  //! Highlights structure according to the given style and updates corresponding class fields
+  //! (highlight status and style)
+  Standard_EXPORT virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle) Standard_OVERRIDE;
 
-  //! Highlight structure using boundary box
-  Standard_EXPORT virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct,
-                                                    const Standard_Boolean             theToCreate);
+  //! Unighlights structure and updates corresponding class fields (highlight status and style)
+  Standard_EXPORT virtual void GraphicUnhighlight() Standard_OVERRIDE;
 
   //! Create shadow link to this structure
-  Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const;
+  Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const Standard_OVERRIDE;
 
   //! Create new group within this structure
-  Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct);
+  Standard_EXPORT virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE;
 
   //! Remove group from this structure
-  Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup);
+  Standard_EXPORT virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) Standard_OVERRIDE;
 
 public:
 
-  //! @return graphic groups
-  virtual const Graphic3d_SequenceOfGroup& DrawGroups() const
-  {
-    return myGroups;
-  }
-
   //! Access graphic driver
   OpenGl_GraphicDriver* GlDriver() const
   {
     return (OpenGl_GraphicDriver* )myGraphicDriver.operator->();
   }
 
-  void SetTransformPersistence (const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers);
-
-  void SetAspectLine   (const CALL_DEF_CONTEXTLINE &theAspect);
-  void SetAspectFace   (const CALL_DEF_CONTEXTFILLAREA& theAspect);
-  void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect);
-  void SetAspectText   (const CALL_DEF_CONTEXTTEXT &theAspect);
-
-  void clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx);
-
-  void setHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
-                          const Graphic3d_Vec3&         theColor);
-
-  void clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx);
-
   Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx);
 
-  //! Renders groups of structure without applying any attributes (i.e. transform, material etc).
-  virtual void RenderGeometry  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-
   //! Renders the structure.
   virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
 
   //! Releases structure resources.
   virtual void Release (const Handle(OpenGl_Context)& theGlCtx);
 
-  //! Marks structure as not overlapping view volume (as it is by default).
-  void ResetCullingStatus() const
-  {
-    if (!IsAlwaysRendered())
-    {
-      myIsCulled = Standard_True;
-    }
-  }
-
-  //! Marks structure as overlapping the current view volume one.
-  //! The method is called during traverse of BVH tree.
-  void MarkAsNotCulled() const { myIsCulled = Standard_False; }
-
-  //! Returns Standard_False if the structure hits the current view volume, otherwise
-  //! returns Standard_True. The default value for all structures before each traverse
-  //! of BVH tree is Standard_True.
-  Standard_Boolean IsCulled() const { return myIsCulled; }
-
-  //! Checks if the structure should be included into BVH tree or not.
-  const Standard_Boolean IsAlwaysRendered() const
-  {
-    return IsInfinite
-        || IsForHighlight
-        || IsMutable
-        || Is2dText
-        || TransformPersistence.Flag != 0;
-  }
-
   //! This method releases GL resources without actual elements destruction.
   //! As result structure could be correctly destroyed layer without GL context
   //! (after last window was closed for example).
@@ -179,15 +116,6 @@ public:
   //! Returns instanced OpenGL structure.
   const OpenGl_Structure* InstancedStructure() const { return myInstancedStructure; }
 
-  //! Returns OpenGL face aspect.
-  const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
-
-  //! Returns OpenGL transformation matrix.
-  const OpenGl_Matrix* Transformation() const { return myTransformation; }
-  
-  //! Returns OpenGL persistent translation.
-  const TEL_TRANSFORM_PERSISTENCE* PersistentTranslation() const { return myTransPers; }
-
   //! Returns structure modification state (for ray-tracing).
   Standard_Size ModificationState() const { return myModificationState; }
 
@@ -197,6 +125,9 @@ public:
   //! Is the structure ray-tracable (contains ray-tracable elements)?
   Standard_Boolean IsRaytracable() const;
 
+  //! Update render transformation matrix.
+  Standard_EXPORT virtual void updateLayerTransformation() Standard_OVERRIDE;
+
 protected:
 
   Standard_EXPORT virtual ~OpenGl_Structure();
@@ -204,33 +135,25 @@ protected:
   //! Updates ray-tracable status for structure and its parents.
   void UpdateStateIfRaytracable (const Standard_Boolean toCheck = Standard_True) const;
 
-protected:
+  //! Renders groups of structure without applying any attributes (i.e. transform, material etc).
+  //! @param theWorkspace current workspace
+  //! @param theHasClosed flag will be set to TRUE if structure contains at least one group of closed primitives
+  Standard_EXPORT void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
+                                       bool&                           theHasClosed) const;
 
-  OpenGl_Matrix*             myTransformation;
-  TEL_TRANSFORM_PERSISTENCE* myTransPers;
-  OpenGl_AspectLine*         myAspectLine;
-  OpenGl_AspectFace*         myAspectFace;
-  OpenGl_AspectMarker*       myAspectMarker;
-  OpenGl_AspectText*         myAspectText;
+  //! Render the bounding box.
+  Standard_EXPORT void renderBoundingBox(const Handle(OpenGl_Workspace)& theWorkspace) const;
 
-  Handle(OpenGl_Group)       myHighlightBox;
-  TEL_COLOUR*                myHighlightColor;
+protected:
 
   OpenGl_Structure*          myInstancedStructure;
+  Graphic3d_Mat4             myRenderTrsf; //!< transformation, actually used for rendering (includes Local Origin shift)
 
   mutable Standard_Boolean   myIsRaytracable;
   mutable Standard_Size      myModificationState;
 
-  mutable Standard_Boolean   myIsCulled; //!< A status specifying is structure needs to be rendered after BVH tree traverse.
-
   Standard_Boolean           myIsMirrored; //!< Used to tell OpenGl to interpret polygons in clockwise order.
 
-public:
-
-  DEFINE_STANDARD_RTTI(OpenGl_Structure, Graphic3d_CStructure) // Type definition
-
 };
 
-DEFINE_STANDARD_HANDLE(OpenGl_Structure, Graphic3d_CStructure)
-
 #endif // OpenGl_Structure_Header