0025675: Visualization - Fix problems and inefficiencies with frustum culling
[occt.git] / src / OpenGl / OpenGl_PrinterContext.hxx
1 // Created on: 2011-05-20
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _OPENGL_PRINTERCONTEXT_H
17 #define _OPENGL_PRINTERCONTEXT_H
18
19 #include <Standard_DefineHandle.hxx>
20 #include <TColStd_Array2OfReal.hxx>
21 #include <Handle_Standard_Transient.hxx>
22 #include <OpenGl_Vec.hxx>
23
24 //! Class provides specific information for redrawing view to offscreen buffer
25 //! on printing. The information is: projection matrixes for tiling,
26 //! scaling factors for text/markers and layer viewport dimensions.
27 class OpenGl_PrinterContext : public Standard_Transient
28 {
29
30 public:
31
32   //! Constructor
33   OpenGl_PrinterContext();
34
35   //! Destructor
36   virtual ~OpenGl_PrinterContext();
37
38   //! Get view projection transformation matrix.
39   inline const TColStd_Array2OfReal& GetProjTransformation() const
40   {
41     return myProjTransform; 
42   }
43
44   //! Set view projection transformation matrix for printing/tiling purposes
45   //! theProjTransform parameter should be an 4x4 array.
46   bool SetProjTransformation (const TColStd_Array2OfReal& theProjTransform);
47
48   //! Returns projection matrix.
49   OpenGl_Mat4 ProjTransformation();
50
51   //! Get text/markers scale factor
52   inline void GetScale (Standard_ShortReal& theScaleX,
53                         Standard_ShortReal& theScaleY) const
54   {
55     theScaleX = myScaleX;
56     theScaleY = myScaleY;
57   }
58
59   //! Set text scale factor
60   void SetScale (const Standard_ShortReal theScaleX,
61                  const Standard_ShortReal theScaleY);
62
63   //! Get layer viewport dimensions
64   inline void GetLayerViewport (Standard_Integer& theViewportX,
65                                 Standard_Integer& theViewportY) const
66   {
67     theViewportX = myLayerViewportX;
68     theViewportY = myLayerViewportY;
69   }
70
71   //! Set layer viewport dimensions
72   void SetLayerViewport (const Standard_Integer theViewportX,
73                          const Standard_Integer theViewportY);
74
75 private:
76
77   TColStd_Array2OfReal myProjTransform;
78   Standard_ShortReal   myProjMatrixGl[16];
79   Standard_ShortReal   myScaleX;
80   Standard_ShortReal   myScaleY;
81   Standard_Integer     myLayerViewportX;
82   Standard_Integer     myLayerViewportY;
83
84 public:
85
86   DEFINE_STANDARD_RTTI(OpenGl_PrinterContext) // Type definition
87
88 };
89
90 DEFINE_STANDARD_HANDLE(OpenGl_PrinterContext, Standard_Transient)
91
92 #endif