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 deferred class GraphicDriver from Graphic3d inherits TShared
21 ---Purpose: This class allows the definition of a graphic driver
22 -- for 3d interface (currently only OpenGl driver is used).
31 Array1OfInteger from TColStd,
32 Array1OfReal from TColStd,
33 Array2OfReal from TColStd,
35 AsciiString from TCollection,
36 ExtendedString from TCollection,
38 NameOfColor from Quantity,
41 PlaneAngle from Quantity,
46 TypeOfTriedronEcho from Aspect,
47 TypeOfTriedronPosition from Aspect,
50 PrintAlgo from Aspect,
51 DisplayConnection_Handle from Aspect,
53 ZLayerId from Graphic3d,
54 ZLayerSettings from Graphic3d,
56 AspectLine3d from Graphic3d,
57 AspectMarker3d from Graphic3d,
58 AspectText3d from Graphic3d,
59 AspectFillArea3d from Graphic3d,
60 HorizontalTextAlignment from Graphic3d,
61 CBitFields20 from Graphic3d,
63 CLight from Graphic3d,
64 CPlane from Graphic3d,
65 CStructure from Graphic3d,
66 CStructure_Handle from Graphic3d,
68 BufferType from Graphic3d,
69 Structure from Graphic3d,
70 StructureManager from Graphic3d,
71 TextPath from Graphic3d,
72 TypeOfComposition from Graphic3d,
73 TypeOfPrimitive from Graphic3d,
74 Vector from Graphic3d,
75 Array1OfVertex from Graphic3d,
76 Array2OfVertex from Graphic3d,
77 Vertex from Graphic3d,
78 VerticalTextAlignment from Graphic3d,
79 PtrFrameBuffer from Graphic3d,
80 HArray1OfByte from TColStd,
81 FillMethod from Aspect,
82 GradientFillMethod from Aspect,
83 ExportFormat from Graphic3d,
84 SortType from Graphic3d,
85 HArray1OfReal from TColStd,
86 CUserDraw from Graphic3d,
87 NListOfHAsciiString from Graphic3d,
89 GraduatedTrihedron from Graphic3d,
90 ClipPlane from Graphic3d,
96 TransformError from Graphic3d
99 Initialize (theDisp : DisplayConnection_Handle from Aspect)
100 returns GraphicDriver from Graphic3d;
102 ---Purpose: Initialises the Driver
104 ----------------------------
105 -- Category: Inquire methods
106 ----------------------------
108 InquireLightLimit ( me : mutable )
109 returns Integer from Standard
111 ---Purpose: call_togl_inquirelight
113 InquirePlaneLimit ( me : mutable )
114 returns Integer from Standard
116 ---Purpose: call_togl_inquireplane
118 InquireViewLimit ( me : mutable )
119 returns Integer from Standard
121 ---Purpose: call_togl_inquireview
123 -----------------------------------------
124 -- Category: Structure management methods
125 -----------------------------------------
127 DisplayStructure ( me : mutable;
128 theCView : CView from Graphic3d;
129 theStructure : Structure from Graphic3d;
130 thePriority : Integer from Standard )
132 ---Purpose: call_togl_displaystructure
134 EraseStructure ( me : mutable;
135 theCView : CView from Graphic3d;
136 theStructure : Structure from Graphic3d )
138 ---Purpose: call_togl_erasestructure
140 RemoveStructure ( me : mutable;
141 theCStructure : in out CStructure_Handle from Graphic3d )
143 ---Purpose: call_togl_removestructure
145 Structure (me : mutable;
146 theManager : StructureManager from Graphic3d)
147 returns CStructure_Handle from Graphic3d
149 ---Purpose: Creates new empty graphic structure
151 ------------------------------------
152 -- Category: Structured mode methods
153 ------------------------------------
155 ActivateView ( me : mutable;
156 ACView : CView from Graphic3d )
158 ---Purpose: call_togl_activateview
160 AntiAliasing ( me : mutable;
161 ACView : CView from Graphic3d;
162 AFlag : Boolean from Standard )
164 ---Purpose: call_togl_antialiasing
166 Background ( me : mutable;
167 ACView : CView from Graphic3d )
169 ---Purpose: call_togl_background
171 GradientBackground ( me : mutable;
172 ACView : CView from Graphic3d;
173 AColor1: Color from Quantity;
174 AColor2: Color from Quantity;
175 FillStyle : GradientFillMethod from Aspect
178 ---Purpose: call_togl_gradient_background
181 BackgroundImage( me : mutable;
182 FileName : CString from Standard;
183 ACView : CView from Graphic3d;
184 FillStyle : FillMethod from Aspect )
187 SetBgImageStyle( me : mutable;
188 ACView : CView from Graphic3d;
189 FillStyle : FillMethod from Aspect )
192 SetBgGradientStyle( me : mutable;
193 ACView : CView from Graphic3d;
194 FillStyle : GradientFillMethod from Aspect )
197 ClipLimit ( me : mutable;
198 ACView : CView from Graphic3d;
199 AWait : Boolean from Standard )
201 ---Purpose: call_togl_cliplimit
203 DeactivateView ( me : mutable;
204 ACView : CView from Graphic3d )
206 ---Purpose: call_togl_deactivateview
208 DepthCueing ( me : mutable;
209 ACView : CView from Graphic3d;
210 AFlag : Boolean from Standard )
212 ---Purpose: call_togl_cliplimit
214 RatioWindow ( me : mutable;
215 ACView : CView from Graphic3d )
217 ---Purpose: call_togl_ratio_window
219 Redraw ( me : mutable;
220 theCView : CView from Graphic3d;
221 theCUnderLayer : CLayer2d from Aspect;
222 theCOverLayer : CLayer2d from Aspect;
225 theWidth : Integer = 0;
226 theHeight : Integer = 0 )
228 ---Purpose: Redraw content of the view
230 RedrawImmediate ( me : mutable;
231 theCView : CView from Graphic3d;
232 theCUnderLayer : CLayer2d from Aspect;
233 theCOverLayer : CLayer2d from Aspect )
235 ---Purpose: Redraw layer of immediate presentations
237 Invalidate ( me : mutable;
238 theCView : CView from Graphic3d )
240 ---Purpose: Invalidates content of the view but does not redraw it
242 RemoveView ( me : mutable;
243 ACView : CView from Graphic3d )
245 ---Purpose: call_togl_removeview
247 SetLight ( me : mutable;
248 ACView : CView from Graphic3d )
250 ---Purpose: call_togl_setlight
252 SetClipPlanes (me : mutable; theCView : CView from Graphic3d) is deferred;
253 ---Purpose: Pass clip planes to the associated graphic driver view.
255 SetCamera (me : mutable; theCView : CView from Graphic3d)
257 ---Purpose: Inform graphic driver if camera assigned to view changes.
259 SetVisualisation ( me : mutable;
260 ACView : CView from Graphic3d )
262 ---Purpose: call_togl_setvisualisation
265 ACView : in out CView from Graphic3d )
266 returns Boolean from Standard
268 ---Purpose: call_togl_view
270 Environment ( me : mutable;
271 ACView : CView from Graphic3d )
275 ----------------------------------------
276 ---Category: Methods to create Triangle
277 -- for Purpose : see Graphic3d_Group.cdl
278 ----------------------------------------
280 EnableVBO( me : mutable;
281 status : Boolean from Standard )
283 ---Purpose: enables/disables usage of OpenGL vertex buffer arrays while drawing primitiev arrays
286 theFreeBytes : out Size from Standard;
287 theInfo : out AsciiString from TCollection) returns Boolean from Standard is deferred;
288 ---Purpose: Returns information about GPU memory usage.
290 ----------------------------------------
291 ---Category: Methods to create Triedron
292 -- for Purpose : see Graphic3d_Group.cdl
293 ----------------------------------------
295 ZBufferTriedronSetup ( me : mutable;
296 theCView : CView from Graphic3d;
297 XColor : NameOfColor from Quantity = Quantity_NOC_RED;
298 YColor : NameOfColor from Quantity = Quantity_NOC_GREEN;
299 ZColor : NameOfColor from Quantity = Quantity_NOC_BLUE1;
300 SizeRatio : Real from Standard = 0.8;
301 AxisDiametr : Real from Standard = 0.05;
302 NbFacettes : Integer from Standard = 12)
304 ---Purpose: call_togl_ztriedron_setup
306 TriedronDisplay ( me : mutable;
307 ACView : CView from Graphic3d;
308 APosition : TypeOfTriedronPosition from Aspect = Aspect_TOTP_CENTER;
309 AColor : NameOfColor from Quantity = Quantity_NOC_WHITE ;
310 AScale : Real from Standard = 0.02;
311 AsWireframe : Boolean from Standard = Standard_True )
313 ---Purpose: call_togl_triedron_display
316 TriedronErase ( me : mutable;
317 ACView : CView from Graphic3d)
319 ---Purpose: call_togl_triedron_erase
322 TriedronEcho ( me : mutable;
323 ACView : CView from Graphic3d;
324 AType : TypeOfTriedronEcho from Aspect = Aspect_TOTE_NONE )
326 ---Purpose: call_togl_triedron_echo
328 ---------------------------------
329 ---Category: Graduated trihedron
330 ---------------------------------
332 GraduatedTrihedronDisplay(me : mutable;
333 theView : CView from Graphic3d;
334 theCubic : GraduatedTrihedron from Graphic3d)
335 ---Purpose: call_togl_graduatedtrihedron_display
338 GraduatedTrihedronErase(me : mutable;
339 theView : CView from Graphic3d)
340 ---Purpose: call_togl_graduatedtrihedron_erase
343 GraduatedTrihedronMinMaxValues (me : mutable;
344 theView : CView from Graphic3d;
345 theMin : Vec3 from Graphic3d;
346 theMax : Vec3 from Graphic3d)
347 ---Purpose: Sets minimum and maximum points of scene bounding box for Graduated Trihedron
348 -- stored in graphic view object.
349 -- @param theView [in] current graphic view
350 -- @param theMin [in] the minimum point of scene.
351 -- @param theMax [in] the maximum point of scene.
355 ----------------------------------
356 -- Category: Immediate mode methods
357 ----------------------------------
359 SetImmediateModeDrawToFront (me : mutable;
360 theCView : CView from Graphic3d;
361 theDrawToFrontBuffer : Boolean from Standard)
362 returns Boolean from Standard
364 ---Purpose: @param theDrawToFrontBuffer Advanced option to modify rendering mode:
365 -- 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
366 -- Fast, so preferred for interactive work (used by default).
367 -- However these extra drawings will be missed in image dump since it is performed from back buffer.
368 -- Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
369 -- in run-time (in case of slow hardware) and/or tearing may appear.
370 -- So this is strongly recommended to draw only simple (fast) structures.
371 -- 2. FALSE. Drawing immediate mode structures to the back buffer.
372 -- The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync is turned on.
373 -- But it works in any case and is especially useful for view dump because the dump image is read from the back buffer.
374 -- @return previous mode.
376 DisplayImmediateStructure ( me : mutable;
377 theCView : CView from Graphic3d;
378 theStructure : Structure from Graphic3d )
380 ---Purpose: Display structure in immediate mode on top of general presentation
382 EraseImmediateStructure ( me : mutable;
383 theCView : CView from Graphic3d;
384 theCStructure : CStructure from Graphic3d )
386 ---Purpose: Erases immediate structure
388 -------------------------------
389 -- Category: Layer mode methods
390 -------------------------------
392 Layer ( me : mutable;
393 ACLayer : in out CLayer2d from Aspect )
395 ---Purpose: call_togl_layer2d
397 RemoveLayer ( me : mutable;
398 ACLayer : CLayer2d from Aspect )
400 ---Purpose: call_togl_removelayer2d
402 BeginLayer ( me : mutable;
403 ACLayer : CLayer2d from Aspect )
405 ---Purpose: call_togl_begin_layer2d
407 BeginPolygon2d ( me : mutable )
409 ---Purpose: call_togl_begin_polygon2d
411 BeginPolyline2d ( me : mutable )
413 ---Purpose: call_togl_begin_polyline2d
415 ClearLayer ( me : mutable;
416 ACLayer : CLayer2d from Aspect )
418 ---Purpose: call_togl_clear_layer2d
421 X : ShortReal from Standard;
422 Y : ShortReal from Standard )
424 ---Purpose: call_togl_draw2d
427 X : ShortReal from Standard;
428 Y : ShortReal from Standard )
430 ---Purpose: call_togl_edge2d
432 EndLayer ( me : mutable )
434 ---Purpose: call_togl_end_layer2d
436 EndPolygon2d ( me : mutable )
438 ---Purpose: call_togl_end_polygon2d
440 EndPolyline2d ( me : mutable )
442 ---Purpose: call_togl_end_polyline2d
445 X : ShortReal from Standard;
446 Y : ShortReal from Standard )
448 ---Purpose: call_togl_move2d
450 Rectangle ( me : mutable;
451 X, Y : ShortReal from Standard;
452 Width, Height : ShortReal from Standard )
454 ---Purpose: call_togl_rectangle2d
456 SetColor ( me : mutable;
457 R : ShortReal from Standard;
458 G : ShortReal from Standard;
459 B : ShortReal from Standard )
461 ---Purpose: call_togl_set_color
463 SetTransparency ( me : mutable;
464 ATransparency : ShortReal from Standard )
466 ---Purpose: call_togl_set_transparency
468 UnsetTransparency ( me : mutable )
470 ---Purpose: call_togl_unset_transparency
472 SetLineAttributes ( me : mutable;
473 Type : Integer from Standard;
474 Width : ShortReal from Standard )
476 ---Purpose: call_togl_set_line_attributes
479 SetTextAttributes ( me : mutable;
480 Font : CString from Standard;
481 Type : Integer from Standard;
482 R : ShortReal from Standard;
483 G : ShortReal from Standard;
484 B : ShortReal from Standard )
486 ---Purpose: Set text attributes for under-/overlayer.
487 -- <Font> argument defines the name of the font to be used,
488 -- <Type> argument defines the display type of the text,
489 -- <R> <G> <B> values define the color of decal or subtitle background.
490 -- To set the color of the text you can use the SetColor method.
493 AText : CString from Standard;
494 X, Y : ShortReal from Standard;
495 AHeight : ShortReal from Standard )
497 ---Purpose: call_togl_text2d
498 -- If AHeight < 0 default text height is used by driver (DefaultTextHeight method)
500 DefaultTextHeight( me )
501 returns ShortReal from Standard
506 AText : CString from Standard;
507 AHeight : ShortReal from Standard;
508 AWidth : in out ShortReal from Standard;
509 AnAscent : in out ShortReal from Standard;
510 ADescent : in out ShortReal from Standard )
512 ---Purpose: call_togl_textsize2d
514 SetBackFacingModel ( me : mutable;
515 aView : CView from Graphic3d )
517 ---Purpose: call_togl_backfacing
519 SetDepthTestEnabled( me; view : CView from Graphic3d;
520 isEnabled : Boolean from Standard )
522 ---Purpose: call_togl_depthtest
524 IsDepthTestEnabled( me; view : CView from Graphic3d )
525 returns Boolean from Standard is deferred;
526 ---Purpose: call_togl_isdepthtest
529 view : CView from Graphic3d;
531 width, height : Integer;
534 ---Purpose: Reads depths of shown pixels of the given
535 -- rectangle (glReadPixels with GL_DEPTH_COMPONENT)
537 FBOCreate( me : mutable;
538 view : CView from Graphic3d;
539 width, height : Integer from Standard )
540 returns PtrFrameBuffer from Graphic3d
542 ---Purpose: Generate offscreen FBO in the graphic library.
543 -- If not supported on hardware returns NULL.
545 FBORelease( me : mutable;
546 view : CView from Graphic3d;
547 fboPtr : in out PtrFrameBuffer from Graphic3d )
549 ---Purpose: Remove offscreen FBO from the graphic library
551 FBOGetDimensions( me : mutable;
552 view : CView from Graphic3d;
553 fboPtr : PtrFrameBuffer from Graphic3d;
554 width, height : out Integer from Standard;
555 widthMax, heightMax : out Integer from Standard )
557 ---Purpose: Read offscreen FBO configuration.
559 FBOChangeViewport( me : mutable;
560 view : CView from Graphic3d;
561 fboPtr : in out PtrFrameBuffer from Graphic3d;
562 width, height : Integer from Standard )
564 ---Purpose: Change offscreen FBO viewport.
566 BufferDump( me : mutable;
567 theCView : CView from Graphic3d;
568 theImage : in out PixMap from Image;
569 theBufferType : BufferType from Graphic3d )
570 returns Boolean from Standard
572 ---Purpose: Dump active rendering buffer into specified memory buffer.
574 SetGLLightEnabled( me; view : CView from Graphic3d;
575 isEnabled : Boolean from Standard )
577 ---Purpose: call_togl_gllight
579 IsGLLightEnabled( me; view : CView from Graphic3d )
580 returns Boolean from Standard is deferred;
581 ---Purpose: call_togl_isgllight
584 ACView : CView from Graphic3d;
585 ACUnderLayer : CLayer2d from Aspect;
586 ACOverLayer : CLayer2d from Aspect;
587 hPrnDC : Handle from Aspect;
588 showBackground : Boolean;
590 printAlgorithm : PrintAlgo from Aspect = Aspect_PA_STRETCH;
591 theScaleFactor : Real from Standard = 1.0 )
592 returns Boolean from Standard is deferred;
594 ---Purpose: print the contents of all layers of the view to the printer.
595 -- <hPrnDC> : Pass the PrinterDeviceContext (HDC),
596 -- <showBackground> : When set to FALSE then print the view without background color
597 -- (background is white)
598 -- else set to TRUE for printing with current background color.
599 -- <filename>: If != NULL, then the view will be printed to a file.
600 -- <printAlgorithm>: Select print algorithm: stretch, tile.
601 -- <theScaleFactor>: Scaling coefficient, used internally to scale the
602 -- printings accordingly to the scale factor selected in the printer
603 -- properties dialog.
604 -- Returns Standard_True if the data is passed to the printer, otherwise
605 -- Standard_False if the print operation failed due to the printer errors,
606 -- or insufficient system memory available.
607 ---Warning: Works only under Windows.
610 theFileName : CString from Standard;
611 theFormat : ExportFormat from Graphic3d;
612 theSortType : SortType from Graphic3d;
613 theWidth, theHeight : Integer from Standard;
614 theView : CView from Graphic3d;
615 theLayerUnder : CLayer2d from Aspect;
616 theLayerOver : CLayer2d from Aspect;
617 thePrecision : Real from Standard = 0.005;
618 theProgressBarFunc : Address from Standard = NULL;
619 theProgressObject : Address from Standard = NULL )
620 returns Boolean from Standard
623 -- Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
624 -- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
625 -- Notice however that results may differ a lot and do not contain some elements.
627 InvalidateBVHData( me : mutable;
628 theCView : out CView from Graphic3d;
629 theLayerId : Integer from Standard )
632 -- Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
634 AddZLayer( me : mutable;
635 theCView : CView from Graphic3d;
636 theLayerId : ZLayerId from Graphic3d )
638 ---Purpose: Add a new top-level z layer with ID <theLayerId> for
639 -- the view. Z layers allow drawing structures in higher layers
640 -- in foreground of structures in lower layers. To add a structure
641 -- to desired layer on display it is necessary to set the layer
642 -- ID for the structure.
644 RemoveZLayer( me : mutable;
645 theCView : CView from Graphic3d;
646 theLayerId : ZLayerId from Graphic3d )
648 ---Purpose: Remove Z layer from the specified view. All structures
649 -- displayed at the moment in layer will be displayed in default layer
650 -- ( the bottom-level z layer ). To unset layer ID from associated
651 -- structures use method UnsetZLayer (...).
653 UnsetZLayer( me : mutable;
654 theLayerId : ZLayerId from Graphic3d )
656 ---Purpose: Unset Z layer ID for all structures. The structure
657 -- indexes will be set to default layer ( the bottom-level z layer
660 ChangeZLayer( me : mutable;
661 theCStructure : CStructure from Graphic3d;
662 theCView : CView from Graphic3d;
663 theNewLayerId : ZLayerId from Graphic3d )
665 ---Purpose: Change Z layer of a structure already presented in view.
667 SetZLayerSettings( me : mutable;
668 theCView : CView from Graphic3d;
669 theLayerId : ZLayerId from Graphic3d;
670 theSettings : ZLayerSettings from Graphic3d)
672 ---Purpose: Sets the settings for a single Z layer of specified view.
674 ChangePriority( me : mutable;
675 theCStructure : CStructure from Graphic3d;
676 theCView : CView from Graphic3d;
677 theNewPriority : Integer from Standard )
679 ---Purpose: Changes the priority of a structure within its Z layer
680 -- in the specified view.
682 -----------------------------
683 -- Category: Internal methods
684 -----------------------------
687 AComment : CString from Standard;
688 AValue : Boolean from Standard );
691 ACLight : CLight from Graphic3d;
692 AField : Integer from Standard );
694 PrintCStructure ( me;
695 ACStructure : CStructure from Graphic3d;
696 AField : Integer from Standard );
699 ACView : CView from Graphic3d;
700 AField : Integer from Standard );
703 AFunc : CString from Standard );
706 AComment : CString from Standard;
707 AValue : Integer from Standard );
710 AFunc : CString from Standard;
711 AResult : Integer from Standard );
714 AComment : CString from Standard;
715 AValue : ShortReal from Standard );
718 AComment : CString from Standard;
719 AMatrix : Array2OfReal from TColStd )
720 raises TransformError from Graphic3d;
723 AComment : CString from Standard;
724 AString : CString from Standard );
726 SetTrace ( me : mutable;
727 ALevel : Integer from Standard )
731 returns Integer from Standard
734 GetDisplayConnection (me)
735 returns DisplayConnection_Handle from Aspect;
736 ---C++: return const &
738 ---Purpose: returns Handle to display connection
741 returns Boolean from Standard;
742 -- Purpose: @return Standard_True in cases when the last view has been removed but some objects still present.
744 ResetDeviceLostFlag (me: mutable);
745 -- Purpose: Resets DeviceLostFlag to default (Standard_False) state.
749 MyTraceLevel : Integer from Standard is protected;
750 myDisplayConnection: DisplayConnection_Handle from Aspect is protected;
751 myDeviceLostFlag : Boolean from Standard is protected;
753 end GraphicDriver from Graphic3d;