aa50d5ab8c800cc5e6dfeb7bbd7127aa3f5f5448
[occt.git] / src / Visual3d / Visual3d_View.hxx
1 // Created on: 1991-09-17
2 // Created by: NW,JPB,CAL
3 // Copyright (c) 1991-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 _Visual3d_View_HeaderFile
18 #define _Visual3d_View_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Visual3d_ViewManagerPtr.hxx>
24 #include <Graphic3d_CView.hxx>
25 #include <Visual3d_ContextView.hxx>
26 #include <Graphic3d_SequenceOfStructure.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Aspect_Background.hxx>
29 #include <Aspect_GradientBackground.hxx>
30 #include <Graphic3d_MapOfStructure.hxx>
31 #include <Graphic3d_GraduatedTrihedron.hxx>
32 #include <Graphic3d_Camera.hxx>
33 #include <Standard_Real.hxx>
34 #include <Graphic3d_NMapOfTransient.hxx>
35 #include <Graphic3d_DataStructureManager.hxx>
36 #include <Standard_Integer.hxx>
37 #include <Standard_CString.hxx>
38 #include <Aspect_FillMethod.hxx>
39 #include <Aspect_GradientFillMethod.hxx>
40 #include <Visual3d_TypeOfBackfacingModel.hxx>
41 #include <Aspect_RenderingContext.hxx>
42 #include <Aspect_GraphicCallbackProc.hxx>
43 #include <Standard_Address.hxx>
44 #include <Aspect_TypeOfUpdate.hxx>
45 #include <Quantity_NameOfColor.hxx>
46 #include <Aspect_TypeOfTriedronPosition.hxx>
47 #include <Aspect_TypeOfTriedronEcho.hxx>
48 #include <Visual3d_TypeOfAnswer.hxx>
49 #include <Graphic3d_TypeOfStructure.hxx>
50 #include <Graphic3d_ZLayerId.hxx>
51 #include <Graphic3d_ZLayerSettings.hxx>
52 #include <Aspect_TypeOfHighlightMethod.hxx>
53 #include <TColStd_Array2OfReal.hxx>
54 #include <Aspect_Handle.hxx>
55 #include <Aspect_PrintAlgo.hxx>
56 #include <Graphic3d_PtrFrameBuffer.hxx>
57 #include <Image_PixMap.hxx>
58 #include <Graphic3d_BufferType.hxx>
59 #include <Graphic3d_ExportFormat.hxx>
60 #include <Graphic3d_SortType.hxx>
61 class Aspect_Window;
62 class Graphic3d_GraphicDriver;
63 class Visual3d_TransformError;
64 class Visual3d_ViewDefinitionError;
65 class Visual3d_ViewManager;
66 class Visual3d_Layer;
67 class Aspect_Background;
68 class Aspect_GradientBackground;
69 class Visual3d_ContextView;
70 class Bnd_Box;
71 class Graphic3d_Structure;
72
73
74 class Visual3d_View;
75 DEFINE_STANDARD_HANDLE(Visual3d_View, Graphic3d_DataStructureManager)
76
77 //! Creation and edition of a view in a 3D visualiser.
78 //! A 3D view is composed of an "orientation" part defined
79 //! by the position of the observer, the direction of view,
80 //! and a "mapping" part defined by the type of projection
81 //! (parallel or perspective) and by the window-viewport
82 //! couple which allows passage from the projected coordinate
83 //! space into the screen space.
84 //! Summary of 3D Viewing
85 //! To define a view, you must define:
86 //! -   The view orientation transformation
87 //! -   The view mapping transformation
88 //! -   The view representation.
89 //! To activate a view, you must define:
90 //! -   The associated window.
91 class Visual3d_View : public Graphic3d_DataStructureManager
92 {
93
94 public:
95
96   
97   //! Creates a view in the viewer <AManager> with a default
98   //! orientation and a default mapping.
99   Standard_EXPORT Visual3d_View(const Handle(Visual3d_ViewManager)& AManager);
100   
101   //! Activates the view <me>.
102   //! Map the associated window on the screen and
103   //! post the view in this window.
104   //! Category: Methods to modify the class definition
105   //! Warning: Raises ViewDefinitionError if the associated
106   //! window isn't defined.
107   Standard_EXPORT void Activate();
108   
109   //! Deactivates the view <me>.
110   //! Unmap the associated window on the screen and
111   //! unpost the view in this window.
112   //! Category: Methods to modify the class definition
113   //! Warning: Raises ViewDefinitionError if the associated
114   //! window isn't defined.
115   Standard_EXPORT void Deactivate();
116   
117   //! Deletes and erases the view <me>.
118   Standard_EXPORT virtual void Destroy() Standard_OVERRIDE;
119 ~Visual3d_View()
120 {
121   Destroy();
122 }
123   
124   //! Updates screen in all cases.
125   Standard_EXPORT void Redraw();
126   
127   //! Updates layer of immediate presentations.
128   Standard_EXPORT void RedrawImmediate();
129   
130   //! Updates screen area in all cases.
131   //! area is given by his xy min corner and size in pixel coordinates
132   Standard_EXPORT void Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height);
133   
134   //! Updates screen in all cases.
135   Standard_EXPORT void Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer);
136   
137   //! Updates layer of immediate presentations.
138   Standard_EXPORT void RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer, const Handle(Visual3d_Layer)& theOverLayer);
139   
140   //! Invalidates view content but does not redraw it.
141   Standard_EXPORT void Invalidate();
142
143   //! Returns true if cached view content has been invalidated.
144   Standard_EXPORT Standard_Boolean IsInvalidated() const;
145
146   //! Updates screen area in all cases.
147   //! area is given by his xy min corner and size in pixel coordinates
148   Standard_EXPORT void Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height);
149   
150   //! Deletes and erases the view <me>.
151   //! Warning: No more graphic operations in <me> after this call.
152   Standard_EXPORT void Remove();
153   
154   //! Updates the view <me> after the modification
155   //! of the associated window.
156   //! Category: Methods to modify the class definition
157   //! Warning: Raises ViewDefinitionError if the associated
158   //! window isn't defined.
159   Standard_EXPORT void Resized();
160   
161   //! Modifies the default window background.
162   //! Category: Methods to modify the class definition
163   //! Warning: Raises ViewDefinitionError if the associated
164   //! window isn't defined.
165   Standard_EXPORT void SetBackground (const Aspect_Background& ABack);
166   
167
168   //! Category: Methods to modify the class definition
169   //! Warning: Raises ViewDefinitionError if the associated
170   //! window isn't defined.
171   Standard_EXPORT void SetBackgroundImage (const Standard_CString FileName, const Aspect_FillMethod FillStyle, const Standard_Boolean update);
172   
173
174   //! Category: Methods to modify the class definition
175   //! Warning: Raises ViewDefinitionError if the associated
176   //! window isn't defined.
177   Standard_EXPORT void SetBgImageStyle (const Aspect_FillMethod FillStyle, const Standard_Boolean update);
178   
179   //! Modifies the gradient window background.
180   //! Category: Methods to modify the class definition
181   //! Warning: Raises ViewDefinitionError if the associated
182   //! window isn't defined.
183   Standard_EXPORT void SetGradientBackground (const Aspect_GradientBackground& ABack, const Standard_Boolean update);
184   
185
186   //! Category: Methods to modify the class definition
187   //! Warning: Raises ViewDefinitionError if the associated
188   //! window isn't defined.
189   Standard_EXPORT void SetBgGradientStyle (const Aspect_GradientFillMethod FillStyle, const Standard_Boolean update);
190   
191   //! Manages display of the back faces
192   Standard_EXPORT void SetBackFacingModel (const Visual3d_TypeOfBackfacingModel aModel);
193   
194   //! Returns current state of the back faces display
195   Standard_EXPORT Visual3d_TypeOfBackfacingModel BackFacingModel() const;
196   
197   //! Sets the context <CTX> in the view <me>.
198   Standard_EXPORT void SetContext (const Visual3d_ContextView& CTX);
199   
200   //! Saves the current mapping which will be the
201   //! reference value for the reset of the mapping
202   //! done by the ViewmappingReset method.
203   Standard_EXPORT void SetViewMappingDefault();
204   
205   //! Saves the current orientation which will be the
206   //! reference value for the reset of the orientation
207   //! done by the ViewOrientationReset method.
208   Standard_EXPORT void SetViewOrientationDefault();
209   
210   //! Associates the window <AWindow> to the view <me>.
211   //! No new association if the window is already defined.
212   //! Category: Methods to modify the class definition
213   //! Warning: Raises ViewDefinitionError if it is impossible
214   //! to associate a view and a window.
215   //! (association already done or another problem)
216   //! Modifies the viewmapping of the associated view
217   //! when it calls the SetRatio method.
218   //!
219   //! After this call, each view is mapped in an unique window.
220   //!
221   //! Programming example :
222   //!
223   //! An example when we have 1 view and 1 window
224   //! -------------------------------------------
225   //!
226   //! Handle(Aspect_DisplayConnection) aDisplayConnection;
227   //!
228   //! // Display connection initialization only needed on Linux platform
229   //! // and on Mac OS X, in cases when you use Xlib for windows drawing.
230   //! aDisplayConnection = new Aspect_DisplayConnection();
231   //!
232   //! // Graphic driver initialization
233   //! Handle(Graphic3d_GraphicDriver) aGraphicDriver =
234   //! Graphic3d::InitGraphicDriver (aDisplayConnection);
235   //!
236   //! // Define a view manager
237   //! Handle(Visual3d_ViewManager) aVisualManager = new Visual3d_ViewManager (aGraphicDriver);
238   //!
239   //! // Define a view
240   //! Handle(Visual3d_View) aView = new Visual3d_View (aVisaulManager);
241   //!
242   //! // Define a window
243   //! Handle(Xw_Window) aWindow = new Xw_Window
244   //! (aDisplayConnection, "Graphic View 1", 0.695, 0.695, 0.600, 0.600, Quantity_NOC_MATRAGRAY);
245   //!
246   //! // Associate the view and the window
247   //! aView->SetWindow (aWindow);
248   //!
249   //! // Map the window
250   //! aWindow->Map ();
251   //!
252   //! // Activate the view
253   //! aView->Activate ();
254   Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& AWindow);
255   
256   //! Associates the window <AWindow> and context <AContext>
257   //! to the view <me>.
258   //! If <AContext> is not NULL the graphic context is used
259   //! directly to draw something in this view.
260   //! Otherwise an internal context is created.
261   //! If <ADisplayCB> is not NULL then a user display CB is
262   //! call at the end of the OCC graphic traversal and just
263   //! before the swap of buffers. The <aClientData> is pass
264   //! to this call back.
265   //! No new association if the window is already defined.
266   //! Category: Methods to modify the class definition
267   //! Warning: Raises ViewDefinitionError if it is impossible
268   //! to associate a view and a window.
269   //! (association already done or another problem)
270   //! Modifies the viewmapping of the associated view
271   //! when it calls the SetRatio method.
272   //!
273   //! After this call, each view is mapped in an unique window.
274   Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& AWindow, const Aspect_RenderingContext AContext, const Aspect_GraphicCallbackProc& ADisplayCB, const Standard_Address AClientData);
275   
276   //! Updates screen in function of modifications of
277   //! the structures.
278   Standard_EXPORT void Update (const Aspect_TypeOfUpdate theUpdateMode);
279   
280   //! Updates screen in function of modifications of
281   //! the structures.
282   Standard_EXPORT void Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer);
283   
284   //! Sets the automatic z-fit mode and its parameters.
285   //! The auto z-fit has extra parameters which can controlled from application level
286   //! to ensure that the size of viewing volume will be sufficiently large to cover
287   //! the depth of unmanaged objects, for example, transformation persistent ones.
288   //! @param theScaleFactor [in] the scale factor for Z-range.
289   //! The range between Z-min, Z-max projection volume planes
290   //! evaluated by z fitting method will be scaled using this coefficient.
291   //! Program error exception is thrown if negative or zero value
292   //! is passed.
293   Standard_EXPORT void SetAutoZFitMode (const Standard_Boolean theIsOn, const Standard_Real theScaleFactor = 1.0);
294   
295   //! returns TRUE if automatic z-fit mode is turned on.
296   Standard_EXPORT Standard_Boolean AutoZFitMode() const;
297   
298   //! returns scale factor parameter of automatic z-fit mode.
299   Standard_EXPORT Standard_Real AutoZFitScaleFactor() const;
300   
301   //! If automatic z-range fitting is turned on, adjusts Z-min and Z-max
302   //! projection volume planes with call to ZFitAll.
303   Standard_EXPORT void AutoZFit();
304   
305   //! Change Z-min and Z-max planes of projection volume to match the
306   //! displayed objects.
307   Standard_EXPORT void ZFitAll (const Standard_Real theScaleFactor = 1.0);
308   
309   //! Sets the value of the mapping to be the same as
310   //! the mapping saved by the SetViewMappingDefaut method.
311   Standard_EXPORT void ViewMappingReset();
312   
313   //! Sets the value of the orientation to be the same as the
314   //! orientation saved by the SetViewOrientationDefaut method.
315   Standard_EXPORT void ViewOrientationReset();
316   
317   //! Switches computed HLR mode in the view
318   Standard_EXPORT void SetComputedMode (const Standard_Boolean aMode);
319   
320   //! Returns the computed HLR mode state
321   Standard_EXPORT Standard_Boolean ComputedMode() const;
322   
323   //! Customization of the ZBUFFER Triedron.
324   //! Initializes Colors of X Y and axis
325   //! Scale ratio defines decreasing of trihedron size when
326   //! its position is out of a View
327   Standard_EXPORT void ZBufferTriedronSetup (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);
328   
329   //! Display of the Triedron.
330   //! Initialize position, color and length of Triedron axes.
331   //! The scale is a percent of the window width.
332   //! If AsWireframe is FALSE triedron is shown in shaded mode
333   //! AColor is not considered for ZBUFFER mode
334   Standard_EXPORT void TriedronDisplay (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);
335   
336   //! Erases the Triedron.
337   Standard_EXPORT void TriedronErase();
338   
339   //! Highlights the echo zone of the Triedron.
340   Standard_EXPORT void TriedronEcho (const Aspect_TypeOfTriedronEcho AType = Aspect_TOTE_NONE);
341   
342   //! Returns data of a graduated trihedron
343   Standard_EXPORT const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() const;
344   
345   //! Displays a graduated trihedron.
346   Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrigedronData);
347   
348   //! Erases a graduated trihedron from the view.
349   Standard_EXPORT void GraduatedTrihedronErase();
350   
351   //! Returns the value of the default window background.
352   Standard_EXPORT Aspect_Background Background() const;
353   
354   //! Returns the value of the window background.
355   Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
356   
357   //! Returns Standard_True if one of the structures
358   //! displayed in the view <me> contains Polygons,
359   //! Triangles or Quadrangles.
360   Standard_EXPORT Standard_Boolean ContainsFacet() const;
361   
362   //! Returns Standard_True if one of the structures
363   //! in the set <ASet> contains Polygons, Triangles
364   //! or Quadrangles.
365   Standard_EXPORT Standard_Boolean ContainsFacet (const Graphic3d_MapOfStructure& ASet) const;
366   
367   //! Returns the current context of the view <me>.
368   Standard_EXPORT const Visual3d_ContextView& Context() const;
369   
370   //! Returns the set of structures displayed in
371   //! the view <me>.
372   Standard_EXPORT void DisplayedStructures (Graphic3d_MapOfStructure& SG) const;
373   
374   //! Returns the activity flag of the view <me>.
375   Standard_EXPORT Standard_Boolean IsActive() const;
376   
377   //! Returns True if the window associated to the view
378   //! <me> is defined.
379   Standard_EXPORT Standard_Boolean IsDefined() const;
380   
381   //! Returns Standard_True is the view <me> is deleted.
382   //! <me> is deleted after the call Remove (me).
383   Standard_EXPORT Standard_Boolean IsDeleted() const;
384   
385   //! Returns the coordinates of the boundary box of all
386   //! structures displayed in the view <me>.
387   //! If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
388   //! also includes minimum and maximum limits of graphical elements
389   //! forming parts of infinite structures.
390   Standard_EXPORT Bnd_Box MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
391   
392   //! Returns the coordinates of the boundary box of all
393   //! structures in the set <theSet>.
394   //! If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
395   //! also includes minimum and maximum limits of graphical elements
396   //! forming parts of infinite structures.
397   Standard_EXPORT Bnd_Box MinMaxValues (const Graphic3d_MapOfStructure& theSet, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
398   
399   //! Returns number of displayed structures in
400   //! the view <me>.
401   Standard_EXPORT Standard_Integer NumberOfDisplayedStructures() const;
402   
403   //! Returns the coordinates of the projection of the
404   //! 3d coordinates <AX>, <AY>, <AZ>.
405   Standard_EXPORT void Projects (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, Standard_Real& APX, Standard_Real& APY, Standard_Real& APZ) const;
406   
407   //! @return the default camera of <me>.
408   Standard_EXPORT const Handle(Graphic3d_Camera)& DefaultCamera() const;
409   
410   //! @return the camera of <me>.
411   Standard_EXPORT const Handle(Graphic3d_Camera)& Camera() const;
412   
413   //! Set camera object to provide orientation and projection matrices
414   //! for graphic driver.
415   Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
416   
417   //! Returns the window associated to the view <me>.
418   //! Warning: Raises ViewDefinitionError if the associated
419   //! window isn't defined.
420   Standard_EXPORT Handle(Aspect_Window) Window() const;
421   
422   //! Returns the MAX number of light associated to the view <me>.
423   Standard_EXPORT Standard_Integer LightLimit() const;
424   
425   //! Returns the MAX number of clipping planes
426   //! associated to the view <me>.
427   Standard_EXPORT Standard_Integer PlaneLimit() const;
428   
429   //! Returns the view manager handle which manage this view
430   Standard_EXPORT Handle(Visual3d_ViewManager) ViewManager() const;
431   
432   //! Computes the new presentation of the
433   //! structure <AStructure> displayed in <me>
434   //! with the type Graphic3d_TOS_COMPUTED.
435   Standard_EXPORT void ReCompute (const Handle(Graphic3d_Structure)& AStructure);
436
437   //! Returns the identification number of the view <me>.
438   Standard_EXPORT Standard_Integer Identification() const;
439   
440   //! Returns the c structure associated to <me>.
441   Standard_EXPORT Standard_Address CView() const;
442   
443   //! Returns the associated GraphicDriver.
444   Standard_EXPORT const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const;
445   
446   //! print the contents of all layers of the view to the printer.
447   //! <hPrnDC> : Pass the PrinterDeviceContext (HDC),
448   //! <showBackground> : When set to FALSE then print the view without background color
449   //! (background is white)
450   //! else set to TRUE for printing with current background color.
451   //! <filename>: If != NULL, then the view will be printed to a file.
452   //! <printAlgo>: Select print algorithm: stretch, tile.
453   //! <theScaleFactor>: Scaling coefficient, used internally to scale the
454   //! printings accordingly to the scale factor selected in the printer
455   //! properties dialog.
456   //! Returns Standard_True if the data is passed to the printer, otherwise
457   //! Standard_False if the print operation failed due to printer error
458   //! or insufficient memory.
459   //! Warning: Works only under Windows.
460   Standard_EXPORT Standard_Boolean Print (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, 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;
461   
462   //! print the contents of the view to printer.
463   //! <hPrnDC> : Pass the PrinterDeviceContext (HDC),
464   //! <showBackground> : When set to FALSE then print the view without background color
465   //! (background is white)
466   //! else set to TRUE for printing with current background color.
467   //! <filename>: If != NULL, then the view will be printed to a file.
468   //! <printAlgo>: Select print algorithm: stretch, tile.
469   //! <theScaleFactor>: Scaling coefficient, used internally to scale the
470   //! printings accordingly to the scale factor selected in the printer
471   //! properties dialog.
472   //! Returns Standard_True if the data is passed to the printer, otherwise
473   //! Standard_False if the print operation failed due to printer error
474   //! or insufficient memory.
475   //! Warning: Works only under Windows.
476   Standard_EXPORT Standard_Boolean Print (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;
477   
478   //! Returns the underlay of the view <me>.
479   Standard_EXPORT const Handle(Visual3d_Layer)& UnderLayer() const;
480   
481   //! Returns the underlay of the view <me>.
482   Standard_EXPORT const Handle(Visual3d_Layer)& OverLayer() const;
483   
484   //! Reads depths of shown pixels of the given rectangle
485   Standard_EXPORT void ReadDepths (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height, const Standard_Address buffer) const;
486   
487   //! Generate offscreen FBO in the graphic library
488   Standard_EXPORT Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer width, const Standard_Integer height);
489   
490   //! Remove offscreen FBO from the graphic library
491   Standard_EXPORT void FBORelease (Graphic3d_PtrFrameBuffer& fboPtr);
492   
493   //! Read offscreen FBO configuration.
494   Standard_EXPORT void FBOGetDimensions (const Graphic3d_PtrFrameBuffer fboPtr, Standard_Integer& width, Standard_Integer& height, Standard_Integer& widthMax, Standard_Integer& heightMax);
495   
496   //! Change offscreen FBO viewport.
497   Standard_EXPORT void FBOChangeViewport (Graphic3d_PtrFrameBuffer& fboPtr, const Standard_Integer width, const Standard_Integer height);
498   
499   //! Dump active rendering buffer into specified memory buffer.
500   Standard_EXPORT Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType);
501   
502   //! turns on/off opengl lighting, currently used in triedron displaying
503   Standard_EXPORT void EnableGLLight (const Standard_Boolean enable) const;
504   
505   //! returns the current state of the gl lighting
506   //! currently used in triedron displaying
507   Standard_EXPORT Standard_Boolean IsGLLightEnabled() const;
508   
509
510   //! Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
511   //! In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
512   //! Notice however that results may differ a lot and do not contain some elements.
513   Standard_EXPORT Standard_Boolean Export (const Standard_CString theFileName, const Graphic3d_ExportFormat theFormat, const Graphic3d_SortType theSortType = Graphic3d_ST_BSP_Tree, const Standard_Real thePrecision = 0.005, const Standard_Address theProgressBarFunc = NULL, const Standard_Address theProgressObject = NULL) const;
514   
515   //! Returns map of objects hidden within this specific view (not viewer-wise).
516   Standard_EXPORT const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const;
517   
518   //! Returns map of objects hidden within this specific view (not viewer-wise).
519   Standard_EXPORT Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects();
520
521   //! Returns Standard_True in case if the structure with the given <theStructId> is
522   //! in list of structures to be computed and stores computed struct to <theComputedStruct>.
523   Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
524                                                Handle(Graphic3d_Structure)& theComputedStruct) const;
525
526 friend class Visual3d_ViewManager;
527
528
529   DEFINE_STANDARD_RTTI(Visual3d_View,Graphic3d_DataStructureManager)
530
531 protected:
532
533
534
535
536 private:
537
538   
539   //! Is it possible to display the structure in the view?
540   Standard_EXPORT Visual3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
541   
542   //! Computes the new presentation of the
543   //! Structures displayed in <me> with the type
544   //! Graphic3d_TOS_COMPUTED.
545   Standard_EXPORT void Compute();
546   
547   //! Changes the display priority of the structure <AStructure>.
548   Standard_EXPORT void ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority);
549   
550   //! Sets the settings for a single Z layer of specified view.
551   Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings);
552   
553   //! Add a new top-level Z layer to the view with ID
554   //! <theLayerId>. The z layer mechanism allows to display
555   //! structures in higher layers in overlay of structures in lower layers.
556   //! The layers in a particular view should be managed centrally
557   //! by its view manager so to avoid IDs mismatching and provide correct
558   //! display of graphics in all views.
559   Standard_EXPORT void AddZLayer (const Graphic3d_ZLayerId theLayerId);
560   
561   //! Remove z layer from the view by its ID.
562   Standard_EXPORT void RemoveZLayer (const Graphic3d_ZLayerId theLayerId);
563   
564   //! Change Z layer of already displayed structure in the view.
565   Standard_EXPORT void ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure, const Graphic3d_ZLayerId theLayerId);
566   
567   //! Clears the structure <AStructure> to the view <me>.
568   Standard_EXPORT void Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction);
569   
570   //! Connects the structures <AMother> and <ADaughter>.
571   Standard_EXPORT void Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter);
572   
573   //! Disconnects the structures <AMother> and <ADaughter>.
574   Standard_EXPORT void Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter);
575   
576   //! Display the structure <AStructure> to the view <me>.
577   Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& AStructure);
578   
579   //! Display the structure <AStructure> to the view <me>.
580   Standard_EXPORT void Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode);
581   
582   //! Erases the structure <AStructure> from the view <me>.
583   Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& AStructure);
584   
585   //! Erases the structure <AStructure> from the view <me>.
586   Standard_EXPORT void Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode);
587   
588   //! Highlights the structure <AStructure> in the view <me>.
589   Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod);
590   
591   //! Transforms the structure <AStructure> in the view <me>.
592   Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf);
593   
594   //! Suppress the highlighting on the structure <AStructure>
595   //! in the view <me>.
596   Standard_EXPORT void UnHighlight (const Handle(Graphic3d_Structure)& AStructure);
597   
598   //! Returns an index != 0 if the structure <AStructure>
599   //! have another structure computed for the view <me>.
600   Standard_EXPORT Standard_Integer IsComputed (const Handle(Graphic3d_Structure)& AStructure) const;
601   
602   //! Returns true if the structure <AStructure> is
603   //! displayed in the view <me>.
604   Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const;
605   
606   //! Modifies the aspect ratio of the view <me> when the
607   //! associated window is defined or resized.
608   Standard_EXPORT void SetRatio();
609   
610   //! Updates the lights when the associated window is defined
611   //! and when the view is activated.
612   Standard_EXPORT void UpdateLights();
613   
614   //! Updates the planes when the associated window is defined
615   //! and when the view is activated.
616   Standard_EXPORT void UpdatePlanes();
617   
618   //! Updates the associated c structure before a call to the
619   //! graphic library.
620   Standard_EXPORT void UpdateView();
621   
622   //! Returns an index != 0 if the structure <AStructure>
623   //! have the same owner than another structure in the
624   //! sequence of the computed structures.
625   Standard_EXPORT Standard_Integer HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const;
626
627   Visual3d_ViewManagerPtr myViewManager;
628   Graphic3d_CView MyCView;
629   Visual3d_ContextView MyContext;
630   Handle(Aspect_Window) MyWindow;
631   Graphic3d_SequenceOfStructure myStructsToCompute;
632   Graphic3d_SequenceOfStructure myStructsComputed;
633   Standard_Boolean myIsInComputedMode;
634   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
635   Aspect_Background MyBackground;
636   Aspect_GradientBackground MyGradientBackground;
637   Graphic3d_MapOfStructure myStructsDisplayed;
638   Graphic3d_GraduatedTrihedron myGTrihedron;
639   Handle(Graphic3d_Camera) myDefaultCamera;
640   Standard_Boolean myAutoZFitIsOn;
641   Standard_Real myAutoZFitScaleFactor;
642   Standard_Boolean myStructuresUpdated;
643   Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
644
645
646 };
647
648
649
650
651
652
653
654 #endif // _Visual3d_View_HeaderFile