Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1991-09-05
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_StructureManager_HeaderFile
0018 #define _Graphic3d_StructureManager_HeaderFile
0019 
0020 #include <Aspect_GenId.hxx>
0021 #include <Graphic3d_CView.hxx>
0022 #include <Graphic3d_MapOfObject.hxx>
0023 #include <Graphic3d_MapOfStructure.hxx>
0024 #include <Graphic3d_ViewAffinity.hxx>
0025 #include <Graphic3d_ZLayerId.hxx>
0026 #include <Graphic3d_ZLayerSettings.hxx>
0027 #include <Standard_Transient.hxx>
0028 #include <NCollection_IndexedMap.hxx>
0029 #include <Standard.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <Standard_Type.hxx>
0032 #include <TColStd_Array2OfReal.hxx>
0033 
0034 typedef NCollection_IndexedMap<Graphic3d_CView*> Graphic3d_IndexedMapOfView;
0035 
0036 class Graphic3d_GraphicDriver;
0037 class Graphic3d_Structure;
0038 class Graphic3d_DataStructureManager;
0039 
0040 //! This class allows the definition of a manager to
0041 //! which the graphic objects are associated.
0042 //! It allows them to be globally manipulated.
0043 //! It defines the global attributes.
0044 //! Keywords: Structure, Structure Manager, Update Mode,
0045 //! Destroy, Highlight, Visible
0046 class Graphic3d_StructureManager : public Standard_Transient
0047 {
0048   friend class Graphic3d_Structure;
0049   DEFINE_STANDARD_RTTIEXT(Graphic3d_StructureManager, Standard_Transient)
0050 public:
0051 
0052   //! Initializes the ViewManager.
0053   //! Currently creating of more than 100 viewer instances
0054   //! is not supported and leads to InitializationError and
0055   //! initialization failure.
0056   //! This limitation might be addressed in some future OCCT releases.
0057   //! Warning: Raises InitialisationError if the initialization
0058   //! of the ViewManager failed.
0059   Standard_EXPORT Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver);
0060 
0061   //! Deletes the manager <me>.
0062   Standard_EXPORT ~Graphic3d_StructureManager();
0063 
0064   //! Invalidates bounding box of specified ZLayerId.
0065   Standard_EXPORT virtual void Update (const Graphic3d_ZLayerId  theLayerId = Graphic3d_ZLayerId_UNKNOWN) const;
0066 
0067   //! Deletes and erases the 3D structure manager.
0068   Standard_EXPORT virtual void Remove();
0069 
0070   //! Erases all the structures.
0071   Standard_EXPORT virtual void Erase();
0072 
0073   //! Returns the set of structures displayed in
0074   //! visualiser <me>.
0075   Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& SG) const;
0076 
0077   //! Returns the set of highlighted structures
0078   //! in a visualiser <me>.
0079   Standard_EXPORT void HighlightedStructures (Graphic3d_MapOfStructure& SG) const;
0080 
0081   //! Forces a new construction of the structure.
0082   //! if <theStructure> is displayed and TOS_COMPUTED.
0083   Standard_EXPORT virtual void ReCompute (const Handle(Graphic3d_Structure)& theStructure);
0084 
0085   //! Forces a new construction of the structure.
0086   //! if <theStructure> is displayed in <theProjector> and TOS_COMPUTED.
0087   Standard_EXPORT virtual void ReCompute (const Handle(Graphic3d_Structure)& theStructure, const Handle(Graphic3d_DataStructureManager)& theProjector);
0088 
0089   //! Clears the structure.
0090   Standard_EXPORT virtual void Clear (Graphic3d_Structure* theStructure, const Standard_Boolean theWithDestruction);
0091 
0092   //! Connects the structures.
0093   Standard_EXPORT virtual void Connect (const Graphic3d_Structure* theMother,
0094                                         const Graphic3d_Structure* theDaughter);
0095 
0096   //! Disconnects the structures.
0097   Standard_EXPORT virtual void Disconnect (const Graphic3d_Structure* theMother,
0098                                            const Graphic3d_Structure* theDaughter);
0099 
0100   //! Display the structure.
0101   Standard_EXPORT virtual void Display (const Handle(Graphic3d_Structure)& theStructure);
0102 
0103   //! Erases the structure.
0104   Standard_EXPORT virtual void Erase (const Handle(Graphic3d_Structure)& theStructure);
0105 
0106   //! Highlights the structure.
0107   Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure);
0108 
0109   //! Transforms the structure.
0110   Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const Handle(TopLoc_Datum3D)& theTrsf);
0111 
0112   //! Changes the display priority of the structure <AStructure>.
0113   Standard_EXPORT virtual void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStructure,
0114                                                       const Graphic3d_DisplayPriority theOldPriority,
0115                                                       const Graphic3d_DisplayPriority theNewPriority);
0116 
0117   //! Change Z layer for structure. The Z layer mechanism allows to display structures in higher
0118   //! layers in overlay of structures in lower layers.
0119   Standard_EXPORT virtual void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, const Graphic3d_ZLayerId theLayerId);
0120 
0121   //! Returns the graphic driver of <me>.
0122   Standard_EXPORT const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const;
0123 
0124   //! Attaches the view to this structure manager and sets its identification number within the manager.
0125   Standard_EXPORT Standard_Integer Identification (Graphic3d_CView* theView);
0126 
0127   //! Detach the view from this structure manager and release its identification.
0128   Standard_EXPORT void UnIdentification (Graphic3d_CView* theView);
0129 
0130   //! Returns the group of views defined in the structure manager.
0131   Standard_EXPORT const Graphic3d_IndexedMapOfView& DefinedViews() const;
0132 
0133   //! Returns the theoretical maximum number of definable views in the manager.
0134   //! Warning: It's not possible to accept an infinite number of definable views because each
0135   //! view must have an identification and we have different managers.
0136   Standard_EXPORT Standard_Integer MaxNumOfViews() const;
0137 
0138   //! Returns the structure with the identification number <AId>.
0139   Standard_EXPORT virtual Handle(Graphic3d_Structure) Identification (const Standard_Integer AId) const;
0140 
0141   //! Suppress the highlighting on the structure <AStructure>.
0142   Standard_EXPORT virtual void UnHighlight (const Handle(Graphic3d_Structure)& AStructure);
0143 
0144   //! Suppresses the highlighting on all the structures in <me>.
0145   Standard_EXPORT virtual void UnHighlight();
0146 
0147   //! Recomputes all structures in the manager.
0148   //! Resets Device Lost flag.
0149   Standard_EXPORT void RecomputeStructures();
0150 
0151   //! Recomputes all structures from theStructures.
0152   Standard_EXPORT void RecomputeStructures (const NCollection_Map<Graphic3d_Structure*>& theStructures);
0153 
0154   Standard_EXPORT void RegisterObject (const Handle(Standard_Transient)& theObject,
0155                                        const Handle(Graphic3d_ViewAffinity)& theAffinity);
0156 
0157   Standard_EXPORT void UnregisterObject (const Handle(Standard_Transient)& theObject);
0158 
0159   Standard_EXPORT const Handle(Graphic3d_ViewAffinity)& ObjectAffinity (const Handle(Standard_Transient)& theObject) const;
0160 
0161   //! Returns TRUE if Device Lost flag has been set and presentation data should be reuploaded onto graphics driver.
0162   Standard_Boolean IsDeviceLost() const { return myDeviceLostFlag; }
0163 
0164   //! Sets Device Lost flag.
0165   void SetDeviceLost() { myDeviceLostFlag = Standard_True; }
0166   
0167   //! Dumps the content of me into the stream
0168   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0169 
0170 protected:
0171 
0172   //! Returns the number of structures displayed in
0173   //! visualizer <me>.
0174   //! Returns the structure displayed in visualizer <me>.
0175   Standard_EXPORT Standard_Integer NumberOfDisplayedStructures() const;
0176 
0177 protected:
0178 
0179   Aspect_GenId myViewGenId;
0180   Graphic3d_MapOfStructure myDisplayedStructure;
0181   Graphic3d_MapOfStructure myHighlightedStructure;
0182   Graphic3d_MapOfObject myRegisteredObjects;
0183   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
0184   Graphic3d_IndexedMapOfView myDefinedViews;
0185   Standard_Boolean myDeviceLostFlag;
0186 };
0187 
0188 DEFINE_STANDARD_HANDLE(Graphic3d_StructureManager, Standard_Transient)
0189 
0190 #endif // _Graphic3d_StructureManager_HeaderFile