1 // Created on: 1997-01-28
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Graphic3d_GraphicDriver_HeaderFile
18 #define _Graphic3d_GraphicDriver_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Transient.hxx>
26 #include <Graphic3d_CView.hxx>
27 #include <Graphic3d_CStructure.hxx>
28 #include <Aspect_GradientFillMethod.hxx>
29 #include <Standard_CString.hxx>
30 #include <Aspect_FillMethod.hxx>
31 #include <Standard_Size.hxx>
32 #include <Quantity_NameOfColor.hxx>
33 #include <Standard_Real.hxx>
34 #include <Aspect_TypeOfTriedronPosition.hxx>
35 #include <Graphic3d_GraduatedTrihedron.hxx>
36 #include <Graphic3d_Vec3.hxx>
37 #include <Standard_ShortReal.hxx>
38 #include <Standard_Address.hxx>
39 #include <Image_PixMap.hxx>
40 #include <Graphic3d_BufferType.hxx>
41 #include <Aspect_GenId.hxx>
42 #include <Aspect_Handle.hxx>
43 #include <Graphic3d_ZLayerId.hxx>
44 #include <Graphic3d_ZLayerSettings.hxx>
45 #include <Graphic3d_MapOfZLayerSettings.hxx>
46 #include <Graphic3d_CLight.hxx>
47 #include <Graphic3d_TypeOfLimit.hxx>
48 #include <TColStd_Array2OfReal.hxx>
49 #include <TColStd_MapOfInteger.hxx>
50 #include <TColStd_SequenceOfInteger.hxx>
52 class Aspect_DisplayConnection;
53 class Graphic3d_CView;
54 class Graphic3d_GraphicDriver;
55 class Graphic3d_Layer;
56 class Graphic3d_TransformError;
57 class Graphic3d_Structure;
58 class Graphic3d_StructureManager;
59 class Graphic3d_ViewManager;
61 class TCollection_AsciiString;
63 DEFINE_STANDARD_HANDLE(Graphic3d_GraphicDriver, Standard_Transient)
65 //! This class allows the definition of a graphic driver
66 //! for 3d interface (currently only OpenGl driver is used).
67 class Graphic3d_GraphicDriver : public Standard_Transient
69 DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver, Standard_Transient)
72 //! Request limit of graphic resource of specific type.
73 virtual Standard_Integer InquireLimit (const Graphic3d_TypeOfLimit theType) const = 0;
75 //! Request maximum number of active light sources supported by driver and hardware.
76 Standard_Integer InquireLightLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbLights); }
78 //! Request maximum number of active clipping planes supported by driver and hardware.
79 Standard_Integer InquirePlaneLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbClipPlanes); }
81 //! Request maximum number of views supported by driver.
82 Standard_Integer InquireViewLimit() const { return InquireLimit (Graphic3d_TypeOfLimit_MaxNbViews); }
86 //! Creates new empty graphic structure
87 virtual Handle(Graphic3d_CStructure) CreateStructure (const Handle(Graphic3d_StructureManager)& theManager) = 0;
89 //! Removes structure from graphic driver and releases its resources.
90 virtual void RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure) = 0;
92 //! Creates new view for this graphic driver.
93 virtual Handle(Graphic3d_CView) CreateView (const Handle(Graphic3d_StructureManager)& theMgr) = 0;
95 //! Removes view from graphic driver and releases its resources.
96 virtual void RemoveView (const Handle(Graphic3d_CView)& theView) = 0;
98 //! enables/disables usage of OpenGL vertex buffer arrays while drawing primitiev arrays
99 virtual void EnableVBO (const Standard_Boolean status) = 0;
101 //! Returns information about GPU memory usage.
102 virtual Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes, TCollection_AsciiString& theInfo) const = 0;
104 virtual Standard_ShortReal DefaultTextHeight() const = 0;
106 //! Computes text width.
107 virtual void TextSize (const Handle(Graphic3d_CView)& theView,
108 const Standard_CString theText,
109 const Standard_ShortReal theHeight,
110 Standard_ShortReal& theWidth,
111 Standard_ShortReal& theAscent,
112 Standard_ShortReal& theDescent) const = 0;
114 //! Adds a layer to all views.
115 //! To add a structure to desired layer on display it is necessary to set the layer ID for the structure.
116 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
117 //! @param theSettings [in] new layer settings
118 //! @param theLayerAfter [in] id of layer to append new layer before
119 Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
120 const Graphic3d_ZLayerSettings& theSettings,
121 const Graphic3d_ZLayerId theLayerAfter) = 0;
123 //! Adds a layer to all views.
124 //! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
125 //! @param theSettings [in] new layer settings
126 //! @param theLayerBefore [in] id of layer to append new layer after
127 Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
128 const Graphic3d_ZLayerSettings& theSettings,
129 const Graphic3d_ZLayerId theLayerBefore) = 0;
131 //! Removes Z layer. All structures displayed at the moment in layer will be displayed in
132 //! default layer (the bottom-level z layer). By default, there are always default
133 //! bottom-level layer that can't be removed. The passed theLayerId should be not less than 0
134 //! (reserved for default layers that can not be removed).
135 Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
137 //! Returns list of Z layers defined for the graphical driver.
138 Standard_EXPORT virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const;
140 //! Sets the settings for a single Z layer.
141 Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
143 //! Returns the settings of a single Z layer.
144 Standard_EXPORT virtual const Graphic3d_ZLayerSettings& ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const;
146 //! Returns view associated with the window if it is exists and is activated.
147 //! Returns Standard_True if the view associated to the window exists.
148 virtual Standard_Boolean ViewExists (const Handle(Aspect_Window)& theWindow, Handle(Graphic3d_CView)& theView) = 0;
150 //! returns Handle to display connection
151 Standard_EXPORT const Handle(Aspect_DisplayConnection)& GetDisplayConnection() const;
153 //! Returns a new identification number for a new structure.
154 Standard_EXPORT Standard_Integer NewIdentification();
156 //! Frees the identifier of a structure.
157 Standard_EXPORT void RemoveIdentification(const Standard_Integer theId);
161 //! Initializes the Driver
162 Standard_EXPORT Graphic3d_GraphicDriver(const Handle(Aspect_DisplayConnection)& theDisp);
166 Handle(Aspect_DisplayConnection) myDisplayConnection;
167 Aspect_GenId myStructGenId;
168 NCollection_List<Handle(Graphic3d_Layer)> myLayers;
169 NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
173 #endif // _Graphic3d_GraphicDriver_HeaderFile