Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-26 08:28:43

0001 // Created on: 1991-09-06
0002 // Created by: NW,JPB,CAL
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Graphic3d_Group_HeaderFile
0018 #define _Graphic3d_Group_HeaderFile
0019 
0020 #include <Graphic3d_BndBox4f.hxx>
0021 #include <Graphic3d_AspectFillArea3d.hxx>
0022 #include <Graphic3d_MapOfAspectsToAspects.hxx>
0023 #include <Standard_CString.hxx>
0024 #include <Graphic3d_Vertex.hxx>
0025 #include <Graphic3d_TextPath.hxx>
0026 #include <Graphic3d_HorizontalTextAlignment.hxx>
0027 #include <Graphic3d_VerticalTextAlignment.hxx>
0028 #include <Graphic3d_TypeOfPrimitiveArray.hxx>
0029 #include <Graphic3d_IndexBuffer.hxx>
0030 #include <Graphic3d_Buffer.hxx>
0031 #include <Graphic3d_BoundBuffer.hxx>
0032 #include <gp_Ax2.hxx>
0033 #include <TCollection_ExtendedString.hxx>
0034 
0035 class Graphic3d_Structure;
0036 class Graphic3d_ArrayOfPrimitives;
0037 class Graphic3d_Text;
0038 class Graphic3d_TransformPers;
0039 
0040 //! This class allows the definition of groups
0041 //! of primitives inside of graphic objects (presentations).
0042 //! A group contains the primitives and attributes
0043 //! for which the range is limited to this group.
0044 //! The primitives of a group can be globally suppressed.
0045 //!
0046 //! There are two main group usage models:
0047 //!
0048 //! 1) Non-modifiable, or unbounded, group ('black box').
0049 //! Developers can repeat a sequence of
0050 //! SetPrimitivesAspect() with AddPrimitiveArray() methods arbitrary number of times
0051 //! to define arbitrary number of primitive "blocks" each having individual aspect values.
0052 //! Any modification of such a group is forbidden, as aspects and primitives are mixed
0053 //! in memory without any high-level logical structure, and any modification is very likely to
0054 //! result in corruption of the group internal data. It is necessary to recreate such a group as a
0055 //! whole when some attribute should be changed. (for example, in terms of AIS it is necessary to
0056 //! re-Compute() the whole presentation each time). 2) Bounded group. Developers should specify the
0057 //! necessary group aspects with help of SetGroupPrimitivesAspect() and then add primitives to the
0058 //! group. Such a group have simplified organization in memory (a single block of attributes
0059 //! followed by a block of primitives) and therefore it can be modified, if it is necessary to
0060 //! change parameters of some aspect that has already been set, using methods:
0061 //! IsGroupPrimitivesAspectSet() to detect which aspect was set for primitives;
0062 //! GroupPrimitivesAspect() to read current aspect values
0063 //! and SetGroupPrimitivesAspect() to set new values.
0064 //!
0065 //! Developers are strongly recommended to take all the above into account when filling
0066 //! Graphic3d_Group with aspects and primitives and choose the group usage model beforehand out of
0067 //! application needs. Note that some Graphic3d_Group class virtual methods contain only base
0068 //! implementation that is extended by the descendant class in OpenGl package.
0069 class Graphic3d_Group : public Standard_Transient
0070 {
0071   friend class Graphic3d_Structure;
0072   DEFINE_STANDARD_RTTIEXT(Graphic3d_Group, Standard_Transient)
0073 
0074 public:
0075   //! Suppress all primitives and attributes of <me>.
0076   //! To clear group without update in Graphic3d_StructureManager
0077   //! pass Standard_False as <theUpdateStructureMgr>. This
0078   //! used on context and viewer destruction, when the pointer
0079   //! to structure manager in Graphic3d_Structure could be
0080   //! already released (pointers are used here to avoid handle
0081   //! cross-reference);
0082   Standard_EXPORT virtual void Clear(const Standard_Boolean theUpdateStructureMgr = Standard_True);
0083 
0084   //! Suppress the group <me> in the structure.
0085   Standard_EXPORT virtual ~Graphic3d_Group();
0086 
0087   //! Suppress the group <me> in the structure.
0088   //! Warning: No more graphic operations in <me> after this call.
0089   //! Modifies the current modelling transform persistence (pan, zoom or rotate)
0090   //! Get the current modelling transform persistence (pan, zoom or rotate)
0091   Standard_EXPORT void Remove();
0092 
0093 public:
0094   //! Return fill area aspect.
0095   virtual Handle(Graphic3d_Aspects) Aspects() const = 0;
0096 
0097   //! Modifies the context for all the face primitives of the group.
0098   virtual void SetGroupPrimitivesAspect(const Handle(Graphic3d_Aspects)& theAspect) = 0;
0099 
0100   //! Modifies the current context of the group to give another aspect for all the primitives
0101   //! created after this call in the group.
0102   virtual void SetPrimitivesAspect(const Handle(Graphic3d_Aspects)& theAspect) = 0;
0103 
0104   //! Update presentation aspects after their modification.
0105   virtual void SynchronizeAspects() = 0;
0106 
0107   //! Replace aspects specified in the replacement map.
0108   virtual void ReplaceAspects(const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
0109 
0110   //! Adds a text for display
0111   Standard_EXPORT virtual void AddText(const Handle(Graphic3d_Text)& theTextParams,
0112                                        const Standard_Boolean theToEvalMinMax = Standard_True);
0113 
0114   //! Adds an array of primitives for display
0115   Standard_EXPORT virtual void AddPrimitiveArray(
0116     const Graphic3d_TypeOfPrimitiveArray theType,
0117     const Handle(Graphic3d_IndexBuffer)& theIndices,
0118     const Handle(Graphic3d_Buffer)&      theAttribs,
0119     const Handle(Graphic3d_BoundBuffer)& theBounds,
0120     const Standard_Boolean               theToEvalMinMax = Standard_True);
0121 
0122   //! Adds an array of primitives for display
0123   Standard_EXPORT void AddPrimitiveArray(const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
0124                                          const Standard_Boolean theToEvalMinMax = Standard_True);
0125 
0126 public:
0127   //! sets the stencil test to theIsEnabled state;
0128   Standard_EXPORT virtual void SetStencilTestOptions(const Standard_Boolean theIsEnabled) = 0;
0129 
0130   //! sets the flipping to theIsEnabled state.
0131   Standard_EXPORT virtual void SetFlippingOptions(const Standard_Boolean theIsEnabled,
0132                                                   const gp_Ax2&          theRefPlane) = 0;
0133 
0134   //! Return transformation.
0135   const gp_Trsf& Transformation() const { return myTrsf; }
0136 
0137   //! Assign transformation.
0138   virtual void SetTransformation(const gp_Trsf& theTrsf) { myTrsf = theTrsf; }
0139 
0140   //! Return transformation persistence.
0141   const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
0142 
0143   //! Set transformation persistence.
0144   Standard_EXPORT virtual void SetTransformPersistence(
0145     const Handle(Graphic3d_TransformPers)& theTrsfPers);
0146 
0147   //! Returns Standard_True if the group <me> is deleted.
0148   //! <me> is deleted after the call Remove (me) or the
0149   //! associated structure is deleted.
0150   Standard_EXPORT Standard_Boolean IsDeleted() const;
0151 
0152   //! Returns Standard_True if the group <me> is empty.
0153   Standard_EXPORT Standard_Boolean IsEmpty() const;
0154 
0155   //! Returns the coordinates of the boundary box of the group.
0156   Standard_EXPORT void MinMaxValues(Standard_Real& theXMin,
0157                                     Standard_Real& theYMin,
0158                                     Standard_Real& theZMin,
0159                                     Standard_Real& theXMax,
0160                                     Standard_Real& theYMax,
0161                                     Standard_Real& theZMax) const;
0162 
0163   //! Sets the coordinates of the boundary box of the group.
0164   Standard_EXPORT void SetMinMaxValues(const Standard_Real theXMin,
0165                                        const Standard_Real theYMin,
0166                                        const Standard_Real theZMin,
0167                                        const Standard_Real theXMax,
0168                                        const Standard_Real theYMax,
0169                                        const Standard_Real theZMax);
0170 
0171   //! Returns boundary box of the group <me> without transformation applied,
0172   const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
0173 
0174   //! Returns non-const boundary box of the group <me> without transformation applied,
0175   Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
0176 
0177   //! Returns the structure containing the group <me>.
0178   Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
0179 
0180   //! Changes property shown that primitive arrays within this group form closed volume (do no
0181   //! contain open shells).
0182   void SetClosed(const bool theIsClosed) { myIsClosed = theIsClosed; }
0183 
0184   //! Return true if primitive arrays within this graphic group form closed volume (do no contain
0185   //! open shells).
0186   bool IsClosed() const { return myIsClosed; }
0187 
0188   //! @name obsolete methods
0189 public:
0190   Standard_DEPRECATED(
0191     "Deprecated method Marker(), pass Graphic3d_ArrayOfPoints to AddPrimitiveArray() instead")
0192   Standard_EXPORT void Marker(const Graphic3d_Vertex& thePoint,
0193                               const Standard_Boolean  theToEvalMinMax = Standard_True);
0194 
0195   //! Creates the string <AText> at position <APoint>.
0196   //! The 3D point of attachment is projected. The text is
0197   //! written in the plane of projection.
0198   //! The attributes are given with respect to the plane of
0199   //! projection.
0200   //! AHeight : Height of text.
0201   //! (Relative to the Normalized Projection
0202   //! Coordinates (NPC) Space).
0203   //! AAngle  : Orientation of the text
0204   //! (with respect to the horizontal).
0205   Standard_DEPRECATED(
0206     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0207   Standard_EXPORT virtual void Text(const Standard_CString                  AText,
0208                                     const Graphic3d_Vertex&                 APoint,
0209                                     const Standard_Real                     AHeight,
0210                                     const Standard_Real                     AAngle,
0211                                     const Graphic3d_TextPath                ATp,
0212                                     const Graphic3d_HorizontalTextAlignment AHta,
0213                                     const Graphic3d_VerticalTextAlignment   AVta,
0214                                     const Standard_Boolean EvalMinMax = Standard_True);
0215 
0216   //! Creates the string <AText> at position <APoint>.
0217   //! The 3D point of attachment is projected. The text is
0218   //! written in the plane of projection.
0219   //! The attributes are given with respect to the plane of
0220   //! projection.
0221   //! AHeight : Height of text.
0222   //! (Relative to the Normalized Projection
0223   //! Coordinates (NPC) Space).
0224   //! The other attributes have the following default values:
0225   //! AAngle  : PI / 2.
0226   //! ATp     : TP_RIGHT
0227   //! AHta    : HTA_LEFT
0228   //! AVta    : VTA_BOTTOM
0229   Standard_DEPRECATED(
0230     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0231   Standard_EXPORT void Text(const Standard_CString  AText,
0232                             const Graphic3d_Vertex& APoint,
0233                             const Standard_Real     AHeight,
0234                             const Standard_Boolean  EvalMinMax = Standard_True);
0235 
0236   //! Creates the string <AText> at position <APoint>.
0237   //! The 3D point of attachment is projected. The text is
0238   //! written in the plane of projection.
0239   //! The attributes are given with respect to the plane of
0240   //! projection.
0241   //! AHeight : Height of text.
0242   //! (Relative to the Normalized Projection
0243   //! Coordinates (NPC) Space).
0244   //! AAngle  : Orientation of the text
0245   //! (with respect to the horizontal).
0246   Standard_DEPRECATED(
0247     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0248   Standard_EXPORT void Text(const TCollection_ExtendedString&       AText,
0249                             const Graphic3d_Vertex&                 APoint,
0250                             const Standard_Real                     AHeight,
0251                             const Standard_Real                     AAngle,
0252                             const Graphic3d_TextPath                ATp,
0253                             const Graphic3d_HorizontalTextAlignment AHta,
0254                             const Graphic3d_VerticalTextAlignment   AVta,
0255                             const Standard_Boolean                  EvalMinMax = Standard_True);
0256 
0257   //! Creates the string <AText> at position <APoint>.
0258   //! The 3D point of attachment is projected. The text is
0259   //! written in the plane of projection.
0260   //! The attributes are given with respect to the plane of
0261   //! projection.
0262   //! AHeight : Height of text.
0263   //! (Relative to the Normalized Projection
0264   //! Coordinates (NPC) Space).
0265   //! The other attributes have the following default values:
0266   //! AAngle  : PI / 2.
0267   //! ATp     : TP_RIGHT
0268   //! AHta    : HTA_LEFT
0269   //! AVta    : VTA_BOTTOM
0270   Standard_DEPRECATED(
0271     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0272   Standard_EXPORT void Text(const TCollection_ExtendedString& AText,
0273                             const Graphic3d_Vertex&           APoint,
0274                             const Standard_Real               AHeight,
0275                             const Standard_Boolean            EvalMinMax = Standard_True);
0276 
0277   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
0278   Standard_DEPRECATED(
0279     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0280   Standard_EXPORT virtual void Text(const Standard_CString                  theTextUtf,
0281                                     const gp_Ax2&                           theOrientation,
0282                                     const Standard_Real                     theHeight,
0283                                     const Standard_Real                     theAngle,
0284                                     const Graphic3d_TextPath                theTp,
0285                                     const Graphic3d_HorizontalTextAlignment theHTA,
0286                                     const Graphic3d_VerticalTextAlignment   theVTA,
0287                                     const Standard_Boolean theToEvalMinMax = Standard_True,
0288                                     const Standard_Boolean theHasOwnAnchor = Standard_True);
0289 
0290   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
0291   Standard_DEPRECATED(
0292     "Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0293   Standard_EXPORT virtual void Text(const TCollection_ExtendedString&       theText,
0294                                     const gp_Ax2&                           theOrientation,
0295                                     const Standard_Real                     theHeight,
0296                                     const Standard_Real                     theAngle,
0297                                     const Graphic3d_TextPath                theTp,
0298                                     const Graphic3d_HorizontalTextAlignment theHTA,
0299                                     const Graphic3d_VerticalTextAlignment   theVTA,
0300                                     const Standard_Boolean theToEvalMinMax = Standard_True,
0301                                     const Standard_Boolean theHasOwnAnchor = Standard_True);
0302 
0303   //! Dumps the content of me into the stream
0304   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0305                                         Standard_Integer  theDepth = -1) const;
0306 
0307 protected:
0308   //! Creates a group in the structure <AStructure>.
0309   Standard_EXPORT Graphic3d_Group(const Handle(Graphic3d_Structure)& theStructure);
0310 
0311   //! Calls the Update method of the StructureManager which
0312   //! contains the associated Structure of the Group <me>.
0313   Standard_EXPORT void Update() const;
0314 
0315 protected:
0316   Handle(Graphic3d_TransformPers) myTrsfPers;  //!< current transform persistence
0317   Graphic3d_Structure*            myStructure; //!< pointer to the parent structure
0318   Graphic3d_BndBox4f              myBounds;    //!< bounding box
0319   gp_Trsf                         myTrsf;      //!< group transformation
0320   bool                            myIsClosed;  //!< flag indicating closed volume
0321 };
0322 
0323 DEFINE_STANDARD_HANDLE(Graphic3d_Group, Standard_Transient)
0324 
0325 #endif // _Graphic3d_Group_HeaderFile