Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:21:36

0001 // Created on: 2009-04-06
0002 // Created by: Sergey ZARITCHNY
0003 // Copyright (c) 2009-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _TDataXtd_Presentation_HeaderFile
0017 #define _TDataXtd_Presentation_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_GUID.hxx>
0021 
0022 #include <gp_Pnt.hxx>
0023 #include <TDF_Attribute.hxx>
0024 #include <Quantity_NameOfColor.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <NCollection_List.hxx>
0027 
0028 class TDF_Label;
0029 class TDF_RelocationTable;
0030 
0031 //! Attribute containing parameters of presentation of the shape,
0032 //! e.g. the shape attached to the same label and displayed using
0033 //! TPrsStd tools (see TPrsStd_AISPresentation).
0034 class TDataXtd_Presentation : public TDF_Attribute
0035 {
0036 public:
0037   //!@name Attribute mechanics
0038 
0039   //! Empty constructor
0040   Standard_EXPORT TDataXtd_Presentation();
0041 
0042   //! Create if not found the TDataXtd_Presentation attribute and set its driver GUID
0043   Standard_EXPORT static occ::handle<TDataXtd_Presentation> Set(const TDF_Label&     theLabel,
0044                                                                 const Standard_GUID& theDriverId);
0045 
0046   //! Remove attribute of this type from the label
0047   Standard_EXPORT static void Unset(const TDF_Label& theLabel);
0048 
0049   //! Returns the ID of the attribute.
0050   Standard_EXPORT const Standard_GUID& ID() const override;
0051 
0052   //! Returns the ID of the attribute.
0053   Standard_EXPORT static const Standard_GUID& GetID();
0054 
0055   //! Restores the contents from <anAttribute> into this
0056   //! one. It is used when aborting a transaction.
0057   Standard_EXPORT void Restore(const occ::handle<TDF_Attribute>& anAttribute) override;
0058 
0059   //! Returns an new empty attribute from the good end
0060   //! type. It is used by the copy algorithm.
0061   Standard_EXPORT occ::handle<TDF_Attribute> NewEmpty() const override;
0062 
0063   //! This method is different from the "Copy" one,
0064   //! because it is used when copying an attribute from
0065   //! a source structure into a target structure. This
0066   //! method pastes the current attribute to the label
0067   //! corresponding to the insertor. The pasted
0068   //! attribute may be a brand new one or a new version
0069   //! of the previous one.
0070   Standard_EXPORT void Paste(
0071     const occ::handle<TDF_Attribute>&       intoAttribute,
0072     const occ::handle<TDF_RelocationTable>& aRelocTationable) const override;
0073 
0074   Standard_EXPORT occ::handle<TDF_Attribute> BackupCopy() const override;
0075 
0076   DEFINE_STANDARD_RTTIEXT(TDataXtd_Presentation, TDF_Attribute)
0077 
0078 public:
0079   //!@name Access to data
0080 
0081   //! Returns the GUID of the driver managing display of associated AIS object
0082   Standard_EXPORT Standard_GUID GetDriverGUID() const;
0083 
0084   //! Sets the GUID of the driver managing display of associated AIS object
0085   Standard_EXPORT void SetDriverGUID(const Standard_GUID& theGUID);
0086 
0087   Standard_EXPORT bool IsDisplayed() const;
0088 
0089   Standard_EXPORT bool HasOwnMaterial() const;
0090 
0091   Standard_EXPORT bool HasOwnTransparency() const;
0092 
0093   Standard_EXPORT bool HasOwnColor() const;
0094 
0095   Standard_EXPORT bool HasOwnWidth() const;
0096 
0097   Standard_EXPORT bool HasOwnMode() const;
0098 
0099   Standard_EXPORT bool HasOwnSelectionMode() const;
0100 
0101   Standard_EXPORT void SetDisplayed(const bool theIsDisplayed);
0102 
0103   Standard_EXPORT void SetMaterialIndex(const int theMaterialIndex);
0104 
0105   Standard_EXPORT void SetTransparency(const double theValue);
0106 
0107   Standard_EXPORT void SetColor(const Quantity_NameOfColor theColor);
0108 
0109   Standard_EXPORT void SetWidth(const double theWidth);
0110 
0111   Standard_EXPORT void SetMode(const int theMode);
0112 
0113   //! Returns the number of selection modes of the attribute.
0114   //! It starts with 1 .. GetNbSelectionModes().
0115   Standard_EXPORT int GetNbSelectionModes() const;
0116 
0117   //! Sets selection mode.
0118   //! If "theTransaction" flag is OFF, modification of the attribute doesn't influence the
0119   //! transaction mechanism (the attribute doesn't participate in undo/redo because of this
0120   //! modification). Certainly, if any other data of the attribute is modified (display mode, color,
0121   //! ...), the attribute will be included into undo/redo.
0122   Standard_EXPORT void SetSelectionMode(const int  theSelectionMode,
0123                                         const bool theTransaction = true);
0124   Standard_EXPORT void AddSelectionMode(const int  theSelectionMode,
0125                                         const bool theTransaction = true);
0126 
0127   Standard_EXPORT int MaterialIndex() const;
0128 
0129   Standard_EXPORT double Transparency() const;
0130 
0131   Standard_EXPORT Quantity_NameOfColor Color() const;
0132 
0133   Standard_EXPORT double Width() const;
0134 
0135   Standard_EXPORT int Mode() const;
0136 
0137   Standard_EXPORT int SelectionMode(const int index = 1) const;
0138 
0139   Standard_EXPORT void UnsetMaterial();
0140 
0141   Standard_EXPORT void UnsetTransparency();
0142 
0143   Standard_EXPORT void UnsetColor();
0144 
0145   Standard_EXPORT void UnsetWidth();
0146 
0147   Standard_EXPORT void UnsetMode();
0148 
0149   Standard_EXPORT void UnsetSelectionMode();
0150 
0151 public:
0152   //! Convert values of old Quantity_NameOfColor to new enumeration for reading old documents
0153   //! after #0030969 (Coding Rules - refactor Quantity_Color.cxx color table definition).
0154   Standard_EXPORT static Quantity_NameOfColor getColorNameFromOldEnum(int theOld);
0155 
0156   //! Convert Quantity_NameOfColor to old enumeration value for writing documents in compatible
0157   //! format.
0158   Standard_EXPORT static int getOldColorNameFromNewEnum(Quantity_NameOfColor theNew);
0159 
0160 private:
0161   Standard_GUID         myDriverGUID;
0162   Quantity_NameOfColor  myColor;
0163   int                   myMaterialIndex;
0164   int                   myMode;
0165   NCollection_List<int> mySelectionModes;
0166   double                myTransparency;
0167   double                myWidth;
0168   bool                  myIsDisplayed;
0169   bool                  myHasOwnColor;
0170   bool                  myHasOwnMaterial;
0171   bool                  myHasOwnTransparency;
0172   bool                  myHasOwnWidth;
0173   bool                  myHasOwnMode;
0174   bool                  myHasOwnSelectionMode;
0175 
0176   //! Checks a list of selection modes.
0177   bool HasSelectionMode(const int theSelectionMode) const;
0178 };
0179 
0180 #endif // _TDataXtd_Presentation_HeaderFile