Adjusting test cases at current state of OCCT master
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.hxx
CommitLineData
42cf5bc1 1// Created on: 1997-01-28
2// Created by: CAL
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _Graphic3d_GraphicDriver_HeaderFile
18#define _Graphic3d_GraphicDriver_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Standard_Integer.hxx>
24#include <Aspect_DisplayConnection.hxx>
25#include <Standard_Boolean.hxx>
26#include <MMgt_TShared.hxx>
27#include <Graphic3d_CView.hxx>
28#include <Graphic3d_CStructure.hxx>
29#include <Aspect_GradientFillMethod.hxx>
30#include <Standard_CString.hxx>
31#include <Aspect_FillMethod.hxx>
42cf5bc1 32#include <Standard_Size.hxx>
33#include <Quantity_NameOfColor.hxx>
34#include <Standard_Real.hxx>
35#include <Aspect_TypeOfTriedronPosition.hxx>
36#include <Aspect_TypeOfTriedronEcho.hxx>
37#include <Graphic3d_GraduatedTrihedron.hxx>
38#include <Graphic3d_Vec3.hxx>
39#include <Standard_ShortReal.hxx>
40#include <Standard_Address.hxx>
41#include <Graphic3d_PtrFrameBuffer.hxx>
42#include <Image_PixMap.hxx>
43#include <Graphic3d_BufferType.hxx>
44#include <Aspect_Handle.hxx>
45#include <Aspect_PrintAlgo.hxx>
46#include <Graphic3d_ExportFormat.hxx>
47#include <Graphic3d_SortType.hxx>
48#include <Graphic3d_ZLayerId.hxx>
49#include <Graphic3d_ZLayerSettings.hxx>
50#include <Graphic3d_CLight.hxx>
51#include <TColStd_Array2OfReal.hxx>
52class Graphic3d_TransformError;
53class Graphic3d_Structure;
54class Graphic3d_StructureManager;
55class Quantity_Color;
56class TCollection_AsciiString;
57
58
59class Graphic3d_GraphicDriver;
60DEFINE_STANDARD_HANDLE(Graphic3d_GraphicDriver, MMgt_TShared)
61
62//! This class allows the definition of a graphic driver
63//! for 3d interface (currently only OpenGl driver is used).
64class Graphic3d_GraphicDriver : public MMgt_TShared
65{
66
67public:
68
69
70 //! call_togl_inquirelight
71 Standard_EXPORT virtual Standard_Integer InquireLightLimit() = 0;
72
73 //! call_togl_inquireplane
74 Standard_EXPORT virtual Standard_Integer InquirePlaneLimit() = 0;
75
76 //! call_togl_inquireview
77 Standard_EXPORT virtual Standard_Integer InquireViewLimit() = 0;
78
79 //! call_togl_displaystructure
80 Standard_EXPORT virtual void DisplayStructure (const Graphic3d_CView& theCView, const Handle(Graphic3d_Structure)& theStructure, const Standard_Integer thePriority) = 0;
81
82 //! call_togl_erasestructure
83 Standard_EXPORT virtual void EraseStructure (const Graphic3d_CView& theCView, const Handle(Graphic3d_Structure)& theStructure) = 0;
84
85 //! call_togl_removestructure
86 Standard_EXPORT virtual void RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure) = 0;
87
88 //! Creates new empty graphic structure
89 Standard_EXPORT virtual Handle(Graphic3d_CStructure) Structure (const Handle(Graphic3d_StructureManager)& theManager) = 0;
90
91 //! call_togl_activateview
92 Standard_EXPORT virtual void ActivateView (const Graphic3d_CView& ACView) = 0;
93
94 //! call_togl_antialiasing
95 Standard_EXPORT virtual void AntiAliasing (const Graphic3d_CView& ACView, const Standard_Boolean AFlag) = 0;
96
97 //! call_togl_background
98 Standard_EXPORT virtual void Background (const Graphic3d_CView& ACView) = 0;
99
100 //! call_togl_gradient_background
101 Standard_EXPORT virtual void GradientBackground (const Graphic3d_CView& ACView, const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod FillStyle) = 0;
102
103 Standard_EXPORT virtual void BackgroundImage (const Standard_CString FileName, const Graphic3d_CView& ACView, const Aspect_FillMethod FillStyle) = 0;
104
105 Standard_EXPORT virtual void SetBgImageStyle (const Graphic3d_CView& ACView, const Aspect_FillMethod FillStyle) = 0;
106
107 Standard_EXPORT virtual void SetBgGradientStyle (const Graphic3d_CView& ACView, const Aspect_GradientFillMethod FillStyle) = 0;
108
109 //! call_togl_cliplimit
110 Standard_EXPORT virtual void ClipLimit (const Graphic3d_CView& ACView, const Standard_Boolean AWait) = 0;
111
112 //! call_togl_deactivateview
113 Standard_EXPORT virtual void DeactivateView (const Graphic3d_CView& ACView) = 0;
114
115 //! call_togl_cliplimit
116 Standard_EXPORT virtual void DepthCueing (const Graphic3d_CView& ACView, const Standard_Boolean AFlag) = 0;
117
118 //! call_togl_ratio_window
119 Standard_EXPORT virtual void RatioWindow (const Graphic3d_CView& ACView) = 0;
120
121 //! Redraw content of the view
27f85086 122 Standard_EXPORT virtual void Redraw (const Graphic3d_CView& theCView, const Standard_Integer theX = 0, const Standard_Integer theY = 0, const Standard_Integer theWidth = 0, const Standard_Integer theHeight = 0) = 0;
42cf5bc1 123
124 //! Redraw layer of immediate presentations
27f85086 125 Standard_EXPORT virtual void RedrawImmediate (const Graphic3d_CView& theCView) = 0;
42cf5bc1 126
127 //! Invalidates content of the view but does not redraw it
128 Standard_EXPORT virtual void Invalidate (const Graphic3d_CView& theCView) = 0;
62e1beed 129
130 //! Returns true if cached view content has been invalidated.
131 Standard_EXPORT virtual Standard_Boolean IsInvalidated (const Graphic3d_CView& theCView) const = 0;
132
42cf5bc1 133 //! call_togl_removeview
134 Standard_EXPORT virtual void RemoveView (const Graphic3d_CView& ACView) = 0;
135
136 //! call_togl_setlight
137 Standard_EXPORT virtual void SetLight (const Graphic3d_CView& ACView) = 0;
138
139 //! Pass clip planes to the associated graphic driver view.
140 Standard_EXPORT virtual void SetClipPlanes (const Graphic3d_CView& theCView) = 0;
141
142 //! Inform graphic driver if camera assigned to view changes.
143 Standard_EXPORT virtual void SetCamera (const Graphic3d_CView& theCView) = 0;
144
145 //! call_togl_setvisualisation
146 Standard_EXPORT virtual void SetVisualisation (const Graphic3d_CView& ACView) = 0;
147
148 //! call_togl_view
149 Standard_EXPORT virtual Standard_Boolean View (Graphic3d_CView& ACView) = 0;
150
151 Standard_EXPORT virtual void Environment (const Graphic3d_CView& ACView) = 0;
152
153 //! enables/disables usage of OpenGL vertex buffer arrays while drawing primitiev arrays
154 Standard_EXPORT virtual void EnableVBO (const Standard_Boolean status) = 0;
155
156 //! Returns information about GPU memory usage.
157 Standard_EXPORT virtual Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes, TCollection_AsciiString& theInfo) const = 0;
158
159 //! call_togl_ztriedron_setup
160 Standard_EXPORT virtual void ZBufferTriedronSetup (const Graphic3d_CView& theCView, const Quantity_NameOfColor XColor = Quantity_NOC_RED, const Quantity_NameOfColor YColor = Quantity_NOC_GREEN, const Quantity_NameOfColor ZColor = Quantity_NOC_BLUE1, const Standard_Real SizeRatio = 0.8, const Standard_Real AxisDiametr = 0.05, const Standard_Integer NbFacettes = 12) = 0;
161
162 //! call_togl_triedron_display
163 Standard_EXPORT virtual void TriedronDisplay (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronPosition APosition = Aspect_TOTP_CENTER, const Quantity_NameOfColor AColor = Quantity_NOC_WHITE, const Standard_Real AScale = 0.02, const Standard_Boolean AsWireframe = Standard_True) = 0;
164
165 //! call_togl_triedron_erase
166 Standard_EXPORT virtual void TriedronErase (const Graphic3d_CView& ACView) = 0;
167
168 //! call_togl_triedron_echo
169 Standard_EXPORT virtual void TriedronEcho (const Graphic3d_CView& ACView, const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE) = 0;
170
171 //! call_togl_graduatedtrihedron_display
172 Standard_EXPORT virtual void GraduatedTrihedronDisplay (const Graphic3d_CView& theView, const Graphic3d_GraduatedTrihedron& theCubic) = 0;
173
174 //! call_togl_graduatedtrihedron_erase
175 Standard_EXPORT virtual void GraduatedTrihedronErase (const Graphic3d_CView& theView) = 0;
176
177 //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron
178 //! stored in graphic view object.
179 //! @param theView [in] current graphic view
180 //! @param theMin [in] the minimum point of scene.
181 //! @param theMax [in] the maximum point of scene.
182 Standard_EXPORT virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_CView& theView, const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) = 0;
183
184 //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
185 //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
186 //! Fast, so preferred for interactive work (used by default).
187 //! However these extra drawings will be missed in image dump since it is performed from back buffer.
188 //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
189 //! in run-time (in case of slow hardware) and/or tearing may appear.
190 //! So this is strongly recommended to draw only simple (fast) structures.
191 //! 2. FALSE. Drawing immediate mode structures to the back buffer.
192 //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync is turned on.
193 //! But it works in any case and is especially useful for view dump because the dump image is read from the back buffer.
194 //! @return previous mode.
195 Standard_EXPORT virtual Standard_Boolean SetImmediateModeDrawToFront (const Graphic3d_CView& theCView, const Standard_Boolean theDrawToFrontBuffer) = 0;
42cf5bc1 196
42cf5bc1 197 Standard_EXPORT virtual Standard_ShortReal DefaultTextHeight() const = 0;
198
199 //! call_togl_textsize2d
200 Standard_EXPORT virtual void TextSize (const Standard_CString AText, const Standard_ShortReal AHeight, Standard_ShortReal& AWidth, Standard_ShortReal& AnAscent, Standard_ShortReal& ADescent) const = 0;
201
202 //! call_togl_backfacing
203 Standard_EXPORT virtual void SetBackFacingModel (const Graphic3d_CView& aView) = 0;
204
205 //! Reads depths of shown pixels of the given
206 //! rectangle (glReadPixels with GL_DEPTH_COMPONENT)
207 Standard_EXPORT virtual void ReadDepths (const Graphic3d_CView& view, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height, const Standard_Address buffer) const = 0;
208
209 //! Generate offscreen FBO in the graphic library.
210 //! If not supported on hardware returns NULL.
211 Standard_EXPORT virtual Graphic3d_PtrFrameBuffer FBOCreate (const Graphic3d_CView& view, const Standard_Integer width, const Standard_Integer height) = 0;
212
213 //! Remove offscreen FBO from the graphic library
214 Standard_EXPORT virtual void FBORelease (const Graphic3d_CView& view, Graphic3d_PtrFrameBuffer& fboPtr) = 0;
215
216 //! Read offscreen FBO configuration.
217 Standard_EXPORT virtual void FBOGetDimensions (const Graphic3d_CView& view, const Graphic3d_PtrFrameBuffer fboPtr, Standard_Integer& width, Standard_Integer& height, Standard_Integer& widthMax, Standard_Integer& heightMax) = 0;
218
219 //! Change offscreen FBO viewport.
220 Standard_EXPORT virtual void FBOChangeViewport (const Graphic3d_CView& view, Graphic3d_PtrFrameBuffer& fboPtr, const Standard_Integer width, const Standard_Integer height) = 0;
221
222 //! Dump active rendering buffer into specified memory buffer.
223 Standard_EXPORT virtual Standard_Boolean BufferDump (const Graphic3d_CView& theCView, Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;
224
225 //! call_togl_gllight
226 Standard_EXPORT virtual void SetGLLightEnabled (const Graphic3d_CView& view, const Standard_Boolean isEnabled) const = 0;
227
228 //! call_togl_isgllight
229 Standard_EXPORT virtual Standard_Boolean IsGLLightEnabled (const Graphic3d_CView& view) const = 0;
230
231 //! print the contents of all layers of the view to the printer.
232 //! <hPrnDC> : Pass the PrinterDeviceContext (HDC),
233 //! <showBackground> : When set to FALSE then print the view without background color
234 //! (background is white)
235 //! else set to TRUE for printing with current background color.
236 //! <filename>: If != NULL, then the view will be printed to a file.
237 //! <printAlgorithm>: Select print algorithm: stretch, tile.
238 //! <theScaleFactor>: Scaling coefficient, used internally to scale the
239 //! printings accordingly to the scale factor selected in the printer
240 //! properties dialog.
241 //! Returns Standard_True if the data is passed to the printer, otherwise
242 //! Standard_False if the print operation failed due to the printer errors,
243 //! or insufficient system memory available.
27f85086 244 Standard_EXPORT virtual Standard_Boolean Print (const Graphic3d_CView& ACView, const Aspect_Handle hPrnDC, const Standard_Boolean showBackground, const Standard_CString filename, const Aspect_PrintAlgo printAlgorithm = Aspect_PA_STRETCH, const Standard_Real theScaleFactor = 1.0) const = 0;
42cf5bc1 245
246
247 //! Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
248 //! In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
249 //! Notice however that results may differ a lot and do not contain some elements.
27f85086 250 Standard_EXPORT virtual Standard_Boolean Export (const Standard_CString theFileName, const Graphic3d_ExportFormat theFormat, const Graphic3d_SortType theSortType, const Standard_Integer theWidth, const Standard_Integer theHeight, const Graphic3d_CView& theView, const Standard_Real thePrecision = 0.005, const Standard_Address theProgressBarFunc = NULL, const Standard_Address theProgressObject = NULL) = 0;
42cf5bc1 251
252
253 //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
254 Standard_EXPORT virtual void InvalidateBVHData (Graphic3d_CView& theCView, const Standard_Integer theLayerId) = 0;
255
256 //! Add a new top-level z layer with ID <theLayerId> for
257 //! the view. Z layers allow drawing structures in higher layers
258 //! in foreground of structures in lower layers. To add a structure
259 //! to desired layer on display it is necessary to set the layer
260 //! ID for the structure.
261 Standard_EXPORT virtual void AddZLayer (const Graphic3d_CView& theCView, const Graphic3d_ZLayerId theLayerId) = 0;
262
263 //! Remove Z layer from the specified view. All structures
264 //! displayed at the moment in layer will be displayed in default layer
265 //! ( the bottom-level z layer ). To unset layer ID from associated
266 //! structures use method UnsetZLayer (...).
267 Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_CView& theCView, const Graphic3d_ZLayerId theLayerId) = 0;
268
269 //! Unset Z layer ID for all structures. The structure
270 //! indexes will be set to default layer ( the bottom-level z layer
271 //! with ID = 0 ).
272 Standard_EXPORT virtual void UnsetZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
273
274 //! Change Z layer of a structure already presented in view.
275 Standard_EXPORT virtual void ChangeZLayer (const Graphic3d_CStructure& theCStructure, const Graphic3d_CView& theCView, const Graphic3d_ZLayerId theNewLayerId) = 0;
276
277 //! Sets the settings for a single Z layer of specified view.
278 Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_CView& theCView, const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
279
280 //! Changes the priority of a structure within its Z layer in the specified view.
281 Standard_EXPORT virtual void ChangePriority (const Graphic3d_CStructure& theCStructure, const Graphic3d_CView& theCView, const Standard_Integer theNewPriority) = 0;
282
283 Standard_EXPORT void PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const;
284
285 Standard_EXPORT void PrintCLight (const Graphic3d_CLight& ACLight, const Standard_Integer AField) const;
286
287 Standard_EXPORT void PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const;
288
289 Standard_EXPORT void PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const;
290
291 Standard_EXPORT void PrintFunction (const Standard_CString AFunc) const;
292
293 Standard_EXPORT void PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const;
294
295 Standard_EXPORT void PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const;
296
297 Standard_EXPORT void PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const;
298
299 Standard_EXPORT void PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const;
300
301 Standard_EXPORT void PrintString (const Standard_CString AComment, const Standard_CString AString) const;
302
303 Standard_EXPORT void SetTrace (const Standard_Integer ALevel);
304
305 Standard_EXPORT Standard_Integer Trace() const;
306
307 //! returns Handle to display connection
308 Standard_EXPORT const Handle(Aspect_DisplayConnection)& GetDisplayConnection() const;
309
310 Standard_EXPORT Standard_Boolean IsDeviceLost() const;
311
312 Standard_EXPORT void ResetDeviceLostFlag();
313
314
315
316
317 DEFINE_STANDARD_RTTI(Graphic3d_GraphicDriver,MMgt_TShared)
318
319protected:
320
321
322 //! Initialises the Driver
323 Standard_EXPORT Graphic3d_GraphicDriver(const Handle(Aspect_DisplayConnection)& theDisp);
324
325 Standard_Integer MyTraceLevel;
326 Handle(Aspect_DisplayConnection) myDisplayConnection;
327 Standard_Boolean myDeviceLostFlag;
328
329
330private:
331
332
333
334
335};
336
337
338
339
340
341
342
343#endif // _Graphic3d_GraphicDriver_HeaderFile