Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:28

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