Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:48

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 apect 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 result
0054 //! in corruption of the group internal data.
0055 //! It is necessary to recreate such a group as a whole when some attribute should be changed.
0056 //! (for example, in terms of AIS it is necessary to re-Compute() the whole presentation each time).
0057 //! 2) Bounded group. Developers should specify the necessary group aspects with help of
0058 //! SetGroupPrimitivesAspect() and then add primitives to the group.
0059 //! Such a group have simplified organization in memory (a single block of attributes
0060 //! followed by a block of primitives) and therefore it can be modified, if it is necessary to
0061 //! change parameters of some aspect that has already been set, using methods:
0062 //! IsGroupPrimitivesAspectSet() to detect which aspect was set for primitives;
0063 //! GroupPrimitivesAspect() to read current aspect values
0064 //! and SetGroupPrimitivesAspect() to set new values.
0065 //!
0066 //! Developers are strongly recommended to take all the above into account when filling Graphic3d_Group
0067 //! with aspects and primitives and choose the group usage model beforehand out of application needs.
0068 //! Note that some Graphic3d_Group class virtual methods contain only base implementation
0069 //! that is extended by the descendant class in OpenGl package.
0070 class Graphic3d_Group : public Standard_Transient
0071 {
0072   friend class Graphic3d_Structure;
0073   DEFINE_STANDARD_RTTIEXT(Graphic3d_Group,Standard_Transient)
0074 
0075 public:
0076 
0077   //! Suppress all primitives and attributes of <me>.
0078   //! To clear group without update in Graphic3d_StructureManager
0079   //! pass Standard_False as <theUpdateStructureMgr>. This
0080   //! used on context and viewer destruction, when the pointer
0081   //! to structure manager in Graphic3d_Structure could be
0082   //! already released (pointers are used here to avoid handle
0083   //! cross-reference);
0084   Standard_EXPORT virtual void Clear (const Standard_Boolean theUpdateStructureMgr = Standard_True);
0085 
0086   //! Suppress the group <me> in the structure.
0087   Standard_EXPORT virtual ~Graphic3d_Group();
0088 
0089   //! Suppress the group <me> in the structure.
0090   //! Warning: No more graphic operations in <me> after this call.
0091   //! Modifies the current modelling transform persistence (pan, zoom or rotate)
0092   //! Get the current modelling transform persistence (pan, zoom or rotate)
0093   Standard_EXPORT void Remove();
0094 
0095 public:
0096 
0097   //! Return fill area aspect.
0098   virtual Handle(Graphic3d_Aspects) Aspects() const = 0;
0099 
0100   //! Modifies the context for all the face primitives of the group.
0101   virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
0102 
0103   //! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
0104   virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
0105 
0106   //! Update presentation aspects after their modification.
0107   virtual void SynchronizeAspects() = 0;
0108 
0109   //! Replace aspects specified in the replacement map.
0110   virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
0111 
0112   //! Adds a text for display
0113   Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
0114                                         const Standard_Boolean theToEvalMinMax = Standard_True);
0115 
0116   //! Adds an array of primitives for display
0117   Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
0118                                                   const Handle(Graphic3d_IndexBuffer)& theIndices,
0119                                                   const Handle(Graphic3d_Buffer)& theAttribs,
0120                                                   const Handle(Graphic3d_BoundBuffer)& theBounds,
0121                                                   const Standard_Boolean theToEvalMinMax = Standard_True);
0122 
0123   //! Adds an array of primitives for display
0124   Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
0125 
0126 public:
0127 
0128   //! sets the stencil test to theIsEnabled state;
0129   Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
0130 
0131   //! sets the flipping to theIsEnabled state.
0132   Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
0133 
0134   //! Return transformation persistence.
0135   const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
0136 
0137   //! Set transformation persistence.
0138   Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
0139 
0140   //! Returns Standard_True if the group <me> is deleted.
0141   //! <me> is deleted after the call Remove (me) or the
0142   //! associated structure is deleted.
0143   Standard_EXPORT Standard_Boolean IsDeleted() const;
0144 
0145   //! Returns Standard_True if the group <me> is empty.
0146   Standard_EXPORT Standard_Boolean IsEmpty() const;
0147 
0148   //! Returns the coordinates of the boundary box of the group.
0149   Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
0150                                      Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const;
0151 
0152   //! Sets the coordinates of the boundary box of the group.
0153   Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
0154                                         const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax);
0155 
0156   //! Returns boundary box of the group <me> without transformation applied,
0157   const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
0158 
0159   //! Returns non-const boundary box of the group <me> without transformation applied,
0160   Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
0161 
0162   //! Returns the structure containing the group <me>.
0163   Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
0164 
0165   //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
0166   void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; }
0167 
0168   //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
0169   bool IsClosed() const { return myIsClosed; }
0170 
0171 //! @name obsolete methods
0172 public:
0173 
0174   Standard_DEPRECATED("Deprecated method Marker(), pass Graphic3d_ArrayOfPoints to AddPrimitiveArray() instead")
0175   Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
0176 
0177   //! Creates the string <AText> at position <APoint>.
0178   //! The 3D point of attachment is projected. The text is
0179   //! written in the plane of projection.
0180   //! The attributes are given with respect to the plane of
0181   //! projection.
0182   //! AHeight : Height of text.
0183   //! (Relative to the Normalized Projection
0184   //! Coordinates (NPC) Space).
0185   //! AAngle  : Orientation of the text
0186   //! (with respect to the horizontal).
0187   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0188   Standard_EXPORT virtual void Text (const Standard_CString AText,
0189                                      const Graphic3d_Vertex& APoint,
0190                                      const Standard_Real AHeight,
0191                                      const Standard_Real AAngle,
0192                                      const Graphic3d_TextPath ATp,
0193                                      const Graphic3d_HorizontalTextAlignment AHta,
0194                                      const Graphic3d_VerticalTextAlignment AVta,
0195                                      const Standard_Boolean EvalMinMax = Standard_True);
0196 
0197   //! Creates the string <AText> at position <APoint>.
0198   //! The 3D point of attachment is projected. The text is
0199   //! written in the plane of projection.
0200   //! The attributes are given with respect to the plane of
0201   //! projection.
0202   //! AHeight : Height of text.
0203   //! (Relative to the Normalized Projection
0204   //! Coordinates (NPC) Space).
0205   //! The other attributes have the following default values:
0206   //! AAngle  : PI / 2.
0207   //! ATp     : TP_RIGHT
0208   //! AHta    : HTA_LEFT
0209   //! AVta    : VTA_BOTTOM
0210   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0211   Standard_EXPORT void Text (const Standard_CString AText,
0212                              const Graphic3d_Vertex& APoint,
0213                              const Standard_Real AHeight,
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   //! AAngle  : Orientation of the text
0225   //! (with respect to the horizontal).
0226   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0227   Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
0228                              const Graphic3d_Vertex& APoint,
0229                              const Standard_Real AHeight,
0230                              const Standard_Real AAngle,
0231                              const Graphic3d_TextPath ATp,
0232                              const Graphic3d_HorizontalTextAlignment AHta,
0233                              const Graphic3d_VerticalTextAlignment AVta,
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   //! The other attributes have the following default values:
0245   //! AAngle  : PI / 2.
0246   //! ATp     : TP_RIGHT
0247   //! AHta    : HTA_LEFT
0248   //! AVta    : VTA_BOTTOM
0249   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0250   Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
0251                              const Graphic3d_Vertex& APoint,
0252                              const Standard_Real AHeight,
0253                              const Standard_Boolean EvalMinMax = Standard_True);
0254 
0255   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
0256   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0257   Standard_EXPORT virtual void Text (const Standard_CString                  theTextUtf,
0258                                      const gp_Ax2&                           theOrientation,
0259                                      const Standard_Real                     theHeight,
0260                                      const Standard_Real                     theAngle,
0261                                      const Graphic3d_TextPath                theTp,
0262                                      const Graphic3d_HorizontalTextAlignment theHTA,
0263                                      const Graphic3d_VerticalTextAlignment   theVTA,
0264                                      const Standard_Boolean                  theToEvalMinMax = Standard_True,
0265                                      const Standard_Boolean                  theHasOwnAnchor = Standard_True);
0266 
0267   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
0268   Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
0269   Standard_EXPORT virtual void Text (const TCollection_ExtendedString&       theText,
0270                                      const gp_Ax2&                           theOrientation,
0271                                      const Standard_Real                     theHeight,
0272                                      const Standard_Real                     theAngle,
0273                                      const Graphic3d_TextPath                theTp,
0274                                      const Graphic3d_HorizontalTextAlignment theHTA,
0275                                      const Graphic3d_VerticalTextAlignment   theVTA,
0276                                      const Standard_Boolean                  theToEvalMinMax = Standard_True,
0277                                      const Standard_Boolean                  theHasOwnAnchor = Standard_True);
0278 
0279 
0280   //! Dumps the content of me into the stream
0281   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0282 
0283 protected:
0284 
0285   //! Creates a group in the structure <AStructure>.
0286   Standard_EXPORT Graphic3d_Group(const Handle(Graphic3d_Structure)& theStructure);
0287 
0288   //! Calls the Update method of the StructureManager which
0289   //! contains the associated Structure of the Group <me>.
0290   Standard_EXPORT void Update() const;
0291 
0292 protected:
0293 
0294   Handle(Graphic3d_TransformPers) myTrsfPers; //!< current transform persistence
0295   Graphic3d_Structure* myStructure;     //!< pointer to the parent structure
0296   Graphic3d_BndBox4f   myBounds;        //!< bounding box
0297   bool                 myIsClosed;      //!< flag indicating closed volume
0298 
0299 };
0300 
0301 DEFINE_STANDARD_HANDLE(Graphic3d_Group, Standard_Transient)
0302 
0303 #endif // _Graphic3d_Group_HeaderFile