Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-30 09:15:18

0001 // Created on: 1998-09-30
0002 // Created by: Denis PASCAL
0003 // Copyright (c) 1998-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 _TPrsStd_AISPresentation_HeaderFile
0018 #define _TPrsStd_AISPresentation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Quantity_NameOfColor.hxx>
0024 #include <Graphic3d_NameOfMaterial.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <TDF_Attribute.hxx>
0027 #include <TDataXtd_Presentation.hxx>
0028 #include <AIS_InteractiveContext.hxx>
0029 
0030 class AIS_InteractiveObject;
0031 class Standard_GUID;
0032 class TDF_Label;
0033 class TDF_RelocationTable;
0034 class TDF_AttributeDelta;
0035 
0036 class TPrsStd_AISPresentation;
0037 DEFINE_STANDARD_HANDLE(TPrsStd_AISPresentation, TDF_Attribute)
0038 
0039 //! An attribute to associate an
0040 //! AIS_InteractiveObject to a label in an AIS viewer.
0041 //! This attribute works in collaboration with TPrsStd_AISViewer.
0042 //! Note that all the Set... and Unset... attribute
0043 //! methods as well as the query methods for
0044 //! visualization attributes and the HasOwn... test
0045 //! methods are shortcuts to the respective
0046 //! AIS_InteractiveObject settings.
0047 class TPrsStd_AISPresentation : public TDF_Attribute
0048 {
0049 
0050 public:
0051   //! Returns the GUID for TPrsStd_AISPresentation attributes.
0052   Standard_EXPORT static const Standard_GUID& GetID();
0053 
0054   //! Creates or retrieves the presentation attribute on
0055   //! the label L, and sets the GUID driver.
0056   Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set(const TDF_Label&     L,
0057                                                              const Standard_GUID& driver);
0058 
0059   //! Delete (if exist) the presentation attribute associated to the label <L>.
0060   Standard_EXPORT static void Unset(const TDF_Label& L);
0061 
0062   //! Creates or retrieves the AISPresentation
0063   //! attribute attached to master.
0064   //! The GUID of the driver will be the GUID of master.
0065   //! master is the attribute you want to display.
0066   Standard_EXPORT static Handle(TPrsStd_AISPresentation) Set(const Handle(TDF_Attribute)& master);
0067 
0068   Standard_EXPORT TPrsStd_AISPresentation();
0069 
0070   Standard_EXPORT void SetDisplayed(const Standard_Boolean B);
0071 
0072   //! Display presentation of object in AIS viewer.
0073   //! If <update> = True then AISObject is recomputed and all
0074   //! the visualization settings are applied
0075   Standard_EXPORT void Display(const Standard_Boolean update = Standard_False);
0076 
0077   //! Removes the presentation of this AIS
0078   //! presentation attribute from the TPrsStd_AISViewer.
0079   //! If remove is true, this AIS presentation attribute
0080   //! is removed from the interactive context.
0081   Standard_EXPORT void Erase(const Standard_Boolean remove = Standard_False);
0082 
0083   //! Recompute presentation of object and apply the visualization settings
0084   Standard_EXPORT void Update();
0085 
0086   Standard_EXPORT Standard_GUID GetDriverGUID() const;
0087 
0088   Standard_EXPORT void SetDriverGUID(const Standard_GUID& guid);
0089 
0090   //! Returns true if this AIS presentation attribute is displayed.
0091   Standard_EXPORT Standard_Boolean IsDisplayed() const;
0092 
0093   //! Returns AIS_InteractiveObject stored in the presentation attribute
0094   Standard_EXPORT Handle(AIS_InteractiveObject) GetAIS() const;
0095 
0096   //! Returns the material setting for this presentation attribute.
0097   Standard_EXPORT Graphic3d_NameOfMaterial Material() const;
0098 
0099   //! Sets the material aName for this presentation  attribute.
0100   Standard_EXPORT void SetMaterial(const Graphic3d_NameOfMaterial aName);
0101 
0102   //! Returns true if this presentation attribute already has a material setting.
0103   Standard_EXPORT Standard_Boolean HasOwnMaterial() const;
0104 
0105   //! Removes the material setting from this presentation attribute.
0106   Standard_EXPORT void UnsetMaterial();
0107 
0108   //! Sets the transparency value aValue for this
0109   //! presentation attribute.
0110   //! This value is 0.6 by default.
0111   Standard_EXPORT void SetTransparency(const Standard_Real aValue = 0.6);
0112 
0113   Standard_EXPORT Standard_Real Transparency() const;
0114 
0115   //! Returns true if this presentation attribute already has a transparency setting.
0116   Standard_EXPORT Standard_Boolean HasOwnTransparency() const;
0117 
0118   //! Removes the transparency setting from this presentation attribute.
0119   Standard_EXPORT void UnsetTransparency();
0120 
0121   Standard_EXPORT Quantity_NameOfColor Color() const;
0122 
0123   //! Sets the color aColor for this presentation attribute.
0124   Standard_EXPORT void SetColor(const Quantity_NameOfColor aColor);
0125 
0126   //! Returns true if this presentation attribute already has a color setting.
0127   Standard_EXPORT Standard_Boolean HasOwnColor() const;
0128 
0129   //! Removes the color setting from this presentation attribute.
0130   Standard_EXPORT void UnsetColor();
0131 
0132   Standard_EXPORT Standard_Real Width() const;
0133 
0134   //! Sets the width aWidth for this presentation attribute.
0135   Standard_EXPORT void SetWidth(const Standard_Real aWidth);
0136 
0137   //! Returns true if this presentation attribute already has a width setting.
0138   Standard_EXPORT Standard_Boolean HasOwnWidth() const;
0139 
0140   //! Removes the width setting from this presentation attribute.
0141   Standard_EXPORT void UnsetWidth();
0142 
0143   Standard_EXPORT Standard_Integer Mode() const;
0144 
0145   Standard_EXPORT void SetMode(const Standard_Integer theMode);
0146 
0147   Standard_EXPORT Standard_Boolean HasOwnMode() const;
0148 
0149   Standard_EXPORT void UnsetMode();
0150 
0151   //! Returns selection mode(s) of the attribute.
0152   //! It starts with 1 .. GetNbSelectionModes().
0153   Standard_EXPORT Standard_Integer GetNbSelectionModes() const;
0154   Standard_EXPORT Standard_Integer SelectionMode(const int index = 1) const;
0155 
0156   //! Sets selection mode.
0157   //! If "theTransaction" flag is OFF, modification of the attribute doesn't influence the
0158   //! transaction mechanism (the attribute doesn't participate in undo/redo because of this
0159   //! modification). Certainly, if any other data of the attribute is modified (display mode, color,
0160   //! ...), the attribute will be included into undo/redo.
0161   Standard_EXPORT void SetSelectionMode(const Standard_Integer theSelectionMode,
0162                                         const Standard_Boolean theTransaction = Standard_True);
0163   Standard_EXPORT void AddSelectionMode(const Standard_Integer theSelectionMode,
0164                                         const Standard_Boolean theTransaction = Standard_True);
0165 
0166   Standard_EXPORT Standard_Boolean HasOwnSelectionMode() const;
0167 
0168   //! Clears all selection modes of the attribute.
0169   Standard_EXPORT void UnsetSelectionMode();
0170 
0171   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0172 
0173   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0174 
0175   Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
0176 
0177   Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       into,
0178                              const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
0179 
0180   Standard_EXPORT virtual Handle(TDF_Attribute) BackupCopy() const Standard_OVERRIDE;
0181 
0182   Standard_EXPORT virtual void AfterAddition() Standard_OVERRIDE;
0183 
0184   Standard_EXPORT virtual void BeforeRemoval() Standard_OVERRIDE;
0185 
0186   Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE;
0187 
0188   Standard_EXPORT virtual void AfterResume() Standard_OVERRIDE;
0189 
0190   Standard_EXPORT virtual Standard_Boolean BeforeUndo(
0191     const Handle(TDF_AttributeDelta)& anAttDelta,
0192     const Standard_Boolean            forceIt = Standard_False) Standard_OVERRIDE;
0193 
0194   //! update AIS viewer according to delta
0195   Standard_EXPORT virtual Standard_Boolean AfterUndo(
0196     const Handle(TDF_AttributeDelta)& anAttDelta,
0197     const Standard_Boolean            forceIt = Standard_False) Standard_OVERRIDE;
0198 
0199   //! Dumps the content of me into the stream
0200   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0201                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0202 
0203   DEFINE_STANDARD_RTTIEXT(TPrsStd_AISPresentation, TDF_Attribute)
0204 
0205 protected:
0206   //! Returns attribute storing presentation data
0207   Standard_EXPORT virtual Handle(TDataXtd_Presentation) getData() const;
0208 
0209 private:
0210   Handle(AIS_InteractiveContext) getAISContext() const;
0211 
0212   //! Activates selection mode of the interactive object.
0213   //! It is called internally on change of selection mode and AISUpdate().
0214   void ActivateSelectionMode();
0215 
0216   //! Updates AIS_InteractiveObject stored in the attribute
0217   //! and applies the visualization settings
0218   Standard_EXPORT void AISUpdate();
0219 
0220   //! Displays AIS_InteractiveObject stored in the attribute
0221   Standard_EXPORT void AISDisplay();
0222 
0223   //! Erases AIS_InteractiveObject stored in the attribute in
0224   //! the viewer; If <remove> = True then AISObject is removed
0225   //! from AIS_InteractiveContext instead of simple erasing in the viewer
0226   Standard_EXPORT void AISErase(const Standard_Boolean remove = Standard_False);
0227 
0228 private:
0229   Handle(AIS_InteractiveObject) myAIS;
0230 };
0231 
0232 #endif // _TPrsStd_AISPresentation_HeaderFile