0024391: Erased AIS object can not be displayed in AIS_InteractiveContext after AIS_I...
[occt.git] / src / OpenGl / OpenGl_PrinterContext.hxx
1 // Created on: 2011-05-20
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 #ifndef _OPENGL_PRINTERCONTEXT_H
21 #define _OPENGL_PRINTERCONTEXT_H
22
23 #include <Standard_DefineHandle.hxx>
24 #include <TColStd_Array2OfReal.hxx>
25 #include <Handle_Standard_Transient.hxx>
26
27 //! Class provides specific information for redrawing view to offscreen buffer
28 //! on printing. The information is: projection matrixes for tiling,
29 //! scaling factors for text/markers and layer viewport dimensions.
30 class OpenGl_PrinterContext : public Standard_Transient
31 {
32
33 public:
34
35   //! Constructor
36   OpenGl_PrinterContext();
37
38   //! Destructor
39   virtual ~OpenGl_PrinterContext();
40
41   //! Get view projection transformation matrix.
42   inline const TColStd_Array2OfReal& GetProjTransformation() const
43   {
44     return myProjTransform; 
45   }
46
47   //! Set view projection transformation matrix for printing/tiling purposes
48   //! theProjTransform parameter should be an 4x4 array.
49   bool SetProjTransformation (const TColStd_Array2OfReal& theProjTransform);
50
51   //! Setup view projection transformation matrix (glLoadMatrixf).
52   void LoadProjTransformation();
53
54   //! Get text/markers scale factor
55   inline void GetScale (Standard_ShortReal& theScaleX,
56                         Standard_ShortReal& theScaleY) const
57   {
58     theScaleX = myScaleX;
59     theScaleY = myScaleY;
60   }
61
62   //! Set text scale factor
63   void SetScale (const Standard_ShortReal theScaleX,
64                  const Standard_ShortReal theScaleY);
65
66   //! Get layer viewport dimensions
67   inline void GetLayerViewport (Standard_Integer& theViewportX,
68                                 Standard_Integer& theViewportY) const
69   {
70     theViewportX = myLayerViewportX;
71     theViewportY = myLayerViewportY;
72   }
73
74   //! Set layer viewport dimensions
75   void SetLayerViewport (const Standard_Integer theViewportX,
76                          const Standard_Integer theViewportY);
77
78 private:
79
80   TColStd_Array2OfReal myProjTransform;
81   Standard_ShortReal   myProjMatrixGl[16];
82   Standard_ShortReal   myScaleX;
83   Standard_ShortReal   myScaleY;
84   Standard_Integer     myLayerViewportX;
85   Standard_Integer     myLayerViewportY;
86
87 public:
88
89   DEFINE_STANDARD_RTTI(OpenGl_PrinterContext) // Type definition
90
91 };
92
93 DEFINE_STANDARD_HANDLE(OpenGl_PrinterContext, Standard_Transient)
94
95 #endif