Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Graphic3d_Group.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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