Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:16:56

0001 // Created on: 1997-01-28
0002 // Created by: CAL
0003 // Copyright (c) 1997-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_GraphicDriver_HeaderFile
0018 #define _Graphic3d_GraphicDriver_HeaderFile
0019 
0020 #include <Aspect_GenId.hxx>
0021 #include <Graphic3d_CStructure.hxx>
0022 #include <Graphic3d_ZLayerId.hxx>
0023 #include <Graphic3d_ZLayerSettings.hxx>
0024 #include <Graphic3d_TypeOfLimit.hxx>
0025 #include <TColStd_SequenceOfInteger.hxx>
0026 
0027 class Aspect_DisplayConnection;
0028 class Aspect_Window;
0029 class Graphic3d_CView;
0030 class Graphic3d_Layer;
0031 class Graphic3d_StructureManager;
0032 class TCollection_AsciiString;
0033 
0034 DEFINE_STANDARD_HANDLE(Graphic3d_GraphicDriver, Standard_Transient)
0035 
0036 //! This class allows the definition of a graphic driver
0037 //! for 3d interface (currently only OpenGl driver is used).
0038 class Graphic3d_GraphicDriver : public Standard_Transient
0039 {
0040   DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver, Standard_Transient)
0041 public:
0042   //! Request limit of graphic resource of specific type.
0043   virtual Standard_Integer InquireLimit(const Graphic3d_TypeOfLimit theType) const = 0;
0044 
0045   //! Request maximum number of active light sources supported by driver and hardware.
0046   Standard_Integer InquireLightLimit() const
0047   {
0048     return InquireLimit(Graphic3d_TypeOfLimit_MaxNbLights);
0049   }
0050 
0051   //! Request maximum number of active clipping planes supported by driver and hardware.
0052   Standard_Integer InquirePlaneLimit() const
0053   {
0054     return InquireLimit(Graphic3d_TypeOfLimit_MaxNbClipPlanes);
0055   }
0056 
0057   //! Request maximum number of views supported by driver.
0058   Standard_Integer InquireViewLimit() const
0059   {
0060     return InquireLimit(Graphic3d_TypeOfLimit_MaxNbViews);
0061   }
0062 
0063 public:
0064   //! Creates new empty graphic structure
0065   virtual Handle(Graphic3d_CStructure) CreateStructure(
0066     const Handle(Graphic3d_StructureManager)& theManager) = 0;
0067 
0068   //! Removes structure from graphic driver and releases its resources.
0069   virtual void RemoveStructure(Handle(Graphic3d_CStructure)& theCStructure) = 0;
0070 
0071   //! Creates new view for this graphic driver.
0072   virtual Handle(Graphic3d_CView) CreateView(const Handle(Graphic3d_StructureManager)& theMgr) = 0;
0073 
0074   //! Removes view from graphic driver and releases its resources.
0075   virtual void RemoveView(const Handle(Graphic3d_CView)& theView) = 0;
0076 
0077   //! enables/disables usage of OpenGL vertex buffer arrays while drawing primitive arrays
0078   virtual void EnableVBO(const Standard_Boolean status) = 0;
0079 
0080   //! Returns TRUE if vertical synchronization with display refresh rate (VSync) should be used;
0081   //! TRUE by default.
0082   virtual bool IsVerticalSync() const = 0;
0083 
0084   //! Set if vertical synchronization with display refresh rate (VSync) should be used.
0085   virtual void SetVerticalSync(bool theToEnable) = 0;
0086 
0087   //! Returns information about GPU memory usage.
0088   virtual Standard_Boolean MemoryInfo(Standard_Size&           theFreeBytes,
0089                                       TCollection_AsciiString& theInfo) const = 0;
0090 
0091   virtual Standard_ShortReal DefaultTextHeight() const = 0;
0092 
0093   //! Computes text width.
0094   virtual void TextSize(const Handle(Graphic3d_CView)& theView,
0095                         const Standard_CString         theText,
0096                         const Standard_ShortReal       theHeight,
0097                         Standard_ShortReal&            theWidth,
0098                         Standard_ShortReal&            theAscent,
0099                         Standard_ShortReal&            theDescent) const = 0;
0100 
0101   //! Adds a layer to all views.
0102   //! To add a structure to desired layer on display it is necessary to set the layer ID for the
0103   //! structure.
0104   //! @param[in] theNewLayerId  id of new layer, should be > 0 (negative values are reserved for
0105   //! default layers).
0106   //! @param[in] theSettings    new layer settings
0107   //! @param[in] theLayerAfter  id of layer to append new layer before
0108   Standard_EXPORT virtual void InsertLayerBefore(const Graphic3d_ZLayerId        theNewLayerId,
0109                                                  const Graphic3d_ZLayerSettings& theSettings,
0110                                                  const Graphic3d_ZLayerId        theLayerAfter) = 0;
0111 
0112   //! Adds a layer to all views.
0113   //! @param[in] theNewLayerId   id of new layer, should be > 0 (negative values are reserved for
0114   //! default layers).
0115   //! @param[in] theSettings     new layer settings
0116   //! @param[in] theLayerBefore  id of layer to append new layer after
0117   Standard_EXPORT virtual void InsertLayerAfter(const Graphic3d_ZLayerId        theNewLayerId,
0118                                                 const Graphic3d_ZLayerSettings& theSettings,
0119                                                 const Graphic3d_ZLayerId        theLayerBefore) = 0;
0120 
0121   //! Removes Z layer. All structures displayed at the moment in layer will be displayed in
0122   //! default layer (the bottom-level z layer). By default, there are always default
0123   //! bottom-level layer that can't be removed.  The passed theLayerId should be not less than 0
0124   //! (reserved for default layers that can not be removed).
0125   Standard_EXPORT virtual void RemoveZLayer(const Graphic3d_ZLayerId theLayerId) = 0;
0126 
0127   //! Returns list of Z layers defined for the graphical driver.
0128   Standard_EXPORT virtual void ZLayers(TColStd_SequenceOfInteger& theLayerSeq) const;
0129 
0130   //! Sets the settings for a single Z layer.
0131   Standard_EXPORT virtual void SetZLayerSettings(const Graphic3d_ZLayerId        theLayerId,
0132                                                  const Graphic3d_ZLayerSettings& theSettings) = 0;
0133 
0134   //! Returns the settings of a single Z layer.
0135   Standard_EXPORT virtual const Graphic3d_ZLayerSettings& ZLayerSettings(
0136     const Graphic3d_ZLayerId theLayerId) const;
0137 
0138   //! Returns view associated with the window if it is exists and is activated.
0139   //! Returns Standard_True if the view associated to the window exists.
0140   virtual Standard_Boolean ViewExists(const Handle(Aspect_Window)& theWindow,
0141                                       Handle(Graphic3d_CView)&     theView) = 0;
0142 
0143   //! returns Handle to display connection
0144   Standard_EXPORT const Handle(Aspect_DisplayConnection)& GetDisplayConnection() const;
0145 
0146   //! Returns a new identification number for a new structure.
0147   Standard_EXPORT Standard_Integer NewIdentification();
0148 
0149   //! Frees the identifier of a structure.
0150   Standard_EXPORT void RemoveIdentification(const Standard_Integer theId);
0151 
0152   //! Dumps the content of me into the stream
0153   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0154 
0155 protected:
0156   //! Initializes the Driver
0157   Standard_EXPORT Graphic3d_GraphicDriver(const Handle(Aspect_DisplayConnection)& theDisp);
0158 
0159 protected:
0160   Handle(Aspect_DisplayConnection)                                 myDisplayConnection;
0161   Aspect_GenId                                                     myStructGenId;
0162   NCollection_List<Handle(Graphic3d_Layer)>                        myLayers;
0163   NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
0164 };
0165 
0166 #endif // _Graphic3d_GraphicDriver_HeaderFile