Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:16:23

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   //! Initializes the ViewManager.
0052   //! Currently creating of more than 100 viewer instances
0053   //! is not supported and leads to InitializationError and
0054   //! initialization failure.
0055   //! This limitation might be addressed in some future OCCT releases.
0056   //! Warning: Raises InitialisationError if the initialization
0057   //! of the ViewManager failed.
0058   Standard_EXPORT Graphic3d_StructureManager(const Handle(Graphic3d_GraphicDriver)& theDriver);
0059 
0060   //! Deletes the manager <me>.
0061   Standard_EXPORT ~Graphic3d_StructureManager();
0062 
0063   //! Invalidates bounding box of specified ZLayerId.
0064   Standard_EXPORT virtual void Update(
0065     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(
0088     const Handle(Graphic3d_Structure)&            theStructure,
0089     const Handle(Graphic3d_DataStructureManager)& theProjector);
0090 
0091   //! Clears the structure.
0092   Standard_EXPORT virtual void Clear(Graphic3d_Structure*   theStructure,
0093                                      const Standard_Boolean theWithDestruction);
0094 
0095   //! Connects the structures.
0096   Standard_EXPORT virtual void Connect(const Graphic3d_Structure* theMother,
0097                                        const Graphic3d_Structure* theDaughter);
0098 
0099   //! Disconnects the structures.
0100   Standard_EXPORT virtual void Disconnect(const Graphic3d_Structure* theMother,
0101                                           const Graphic3d_Structure* theDaughter);
0102 
0103   //! Display the structure.
0104   Standard_EXPORT virtual void Display(const Handle(Graphic3d_Structure)& theStructure);
0105 
0106   //! Erases the structure.
0107   Standard_EXPORT virtual void Erase(const Handle(Graphic3d_Structure)& theStructure);
0108 
0109   //! Highlights the structure.
0110   Standard_EXPORT virtual void Highlight(const Handle(Graphic3d_Structure)& theStructure);
0111 
0112   //! Transforms the structure.
0113   Standard_EXPORT virtual void SetTransform(const Handle(Graphic3d_Structure)& theStructure,
0114                                             const Handle(TopLoc_Datum3D)&      theTrsf);
0115 
0116   //! Changes the display priority of the structure <AStructure>.
0117   Standard_EXPORT virtual void ChangeDisplayPriority(
0118     const Handle(Graphic3d_Structure)& theStructure,
0119     const Graphic3d_DisplayPriority    theOldPriority,
0120     const Graphic3d_DisplayPriority    theNewPriority);
0121 
0122   //! Change Z layer for structure. The Z layer mechanism allows to display structures in higher
0123   //! layers in overlay of structures in lower layers.
0124   Standard_EXPORT virtual void ChangeZLayer(const Handle(Graphic3d_Structure)& theStructure,
0125                                             const Graphic3d_ZLayerId           theLayerId);
0126 
0127   //! Returns the graphic driver of <me>.
0128   Standard_EXPORT const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const;
0129 
0130   //! Attaches the view to this structure manager and sets its identification number within the
0131   //! manager.
0132   Standard_EXPORT Standard_Integer Identification(Graphic3d_CView* theView);
0133 
0134   //! Detach the view from this structure manager and release its identification.
0135   Standard_EXPORT void UnIdentification(Graphic3d_CView* theView);
0136 
0137   //! Returns the group of views defined in the structure manager.
0138   Standard_EXPORT const Graphic3d_IndexedMapOfView& DefinedViews() const;
0139 
0140   //! Returns the theoretical maximum number of definable views in the manager.
0141   //! Warning: It's not possible to accept an infinite number of definable views because each
0142   //! view must have an identification and we have different managers.
0143   Standard_EXPORT Standard_Integer MaxNumOfViews() const;
0144 
0145   //! Returns the structure with the identification number <AId>.
0146   Standard_EXPORT virtual Handle(Graphic3d_Structure) Identification(
0147     const Standard_Integer AId) const;
0148 
0149   //! Suppress the highlighting on the structure <AStructure>.
0150   Standard_EXPORT virtual void UnHighlight(const Handle(Graphic3d_Structure)& AStructure);
0151 
0152   //! Suppresses the highlighting on all the structures in <me>.
0153   Standard_EXPORT virtual void UnHighlight();
0154 
0155   //! Recomputes all structures in the manager.
0156   //! Resets Device Lost flag.
0157   Standard_EXPORT void RecomputeStructures();
0158 
0159   //! Recomputes all structures from theStructures.
0160   Standard_EXPORT void RecomputeStructures(
0161     const NCollection_Map<Graphic3d_Structure*>& theStructures);
0162 
0163   Standard_EXPORT void RegisterObject(const Handle(Standard_Transient)&     theObject,
0164                                       const Handle(Graphic3d_ViewAffinity)& theAffinity);
0165 
0166   Standard_EXPORT void UnregisterObject(const Handle(Standard_Transient)& theObject);
0167 
0168   Standard_EXPORT const Handle(Graphic3d_ViewAffinity)& ObjectAffinity(
0169     const Handle(Standard_Transient)& theObject) const;
0170 
0171   //! Returns TRUE if Device Lost flag has been set and presentation data should be reuploaded onto
0172   //! graphics driver.
0173   Standard_Boolean IsDeviceLost() const { return myDeviceLostFlag; }
0174 
0175   //! Sets Device Lost flag.
0176   void SetDeviceLost() { myDeviceLostFlag = Standard_True; }
0177 
0178   //! Dumps the content of me into the stream
0179   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0180 
0181 protected:
0182   //! Returns the number of structures displayed in
0183   //! visualizer <me>.
0184   //! Returns the structure displayed in visualizer <me>.
0185   Standard_EXPORT Standard_Integer NumberOfDisplayedStructures() const;
0186 
0187 protected:
0188   Aspect_GenId                    myViewGenId;
0189   Graphic3d_MapOfStructure        myDisplayedStructure;
0190   Graphic3d_MapOfStructure        myHighlightedStructure;
0191   Graphic3d_MapOfObject           myRegisteredObjects;
0192   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
0193   Graphic3d_IndexedMapOfView      myDefinedViews;
0194   Standard_Boolean                myDeviceLostFlag;
0195 };
0196 
0197 DEFINE_STANDARD_HANDLE(Graphic3d_StructureManager, Standard_Transient)
0198 
0199 #endif // _Graphic3d_StructureManager_HeaderFile