0022627: Change OCCT memory management defaults
[occt.git] / src / OpenGl / OpenGl_PrinterContext.hxx
CommitLineData
7edf74fd
A
1// File: OpenGl_PrinterContext.hxx
2// Created: 20.05.11 10:00:00
3// Author: Anton POLETAEV
4
5#ifndef _OPENGL_PRINTERCONTEXT_H
6#define _OPENGL_PRINTERCONTEXT_H
7
5f8b738e 8#include <OpenGl_GlCore11.hxx>
9
7edf74fd
A
10#include <MMgt_TShared.hxx>
11#include <Standard.hxx>
12#include <Standard_DefineHandle.hxx>
13#include <Handle_MMgt_TShared.hxx>
7edf74fd
A
14#include <NCollection_DataMap.hxx>
15#include <InterfaceGraphic_Graphic3d.hxx>
16#include <InterfaceGraphic_Visual3d.hxx>
17#include <TColStd_Array2OfReal.hxx>
18
2166f0fa
SK
19#include <OpenGl_Workspace.hxx>
20
7edf74fd
A
21class Standard_Transient;
22class Handle(Standard_Type);
23class Handle(MMgt_TShared);
24class OpenGl_PrinterContext;
25
26DEFINE_STANDARD_HANDLE(OpenGl_PrinterContext,MMgt_TShared)
27
28//! Class provides specific information for redrawing view to offscreen buffer
29//! on printing. The information is: projection matrixes for tiling,
30//! scaling factors for text/markers and layer viewport dimensions.
31//! The OpenGl_PrinterContext class allows to have only one global instance
32//! that can be accessed by GetPrinterContext() during printing operation.
33//! The class instance can be created only by call_togl_print().
34class OpenGl_PrinterContext : public MMgt_TShared
35{
36
37public:
38
39 //! Get the PrinterContext instance assigned for OpenGl context.
40 //! Return NULL, if there is no current printing operation and
41 //! there is no assigned instance for "theCtx" OpenGl context.
42 static OpenGl_PrinterContext* GetPrinterContext(GLCONTEXT theCtx);
43
44 //! Get view projection transformation matrix.
45 const TColStd_Array2OfReal& GetProjTransformation ()
46 {
47 return myProjTransform;
48 }
49
50 //! Get view projection transformation matrix.
51 void GetProjTransformation (GLfloat theMatrix[16]);
52
53 //! Get text/markers scale factor
54 void GetScale (GLfloat& theScaleX, GLfloat& theScaleY)
55 {
56 theScaleX = myScaleX;
57 theScaleY = myScaleY;
58 }
59
60 //! Get layer viewport dimensions
61 void GetLayerViewport (GLsizei& theViewportX,
62 GLsizei& theViewportY)
63 {
64 theViewportX = myLayerViewportX;
65 theViewportY = myLayerViewportY;
66 }
67
68private:
69
70 //! Constructor
71 OpenGl_PrinterContext (GLCONTEXT theCtx);
72
73 //! Destructor
74 virtual ~OpenGl_PrinterContext ();
75
76 //! Deactivate current printing context.
77 //! Useful when you need to redraw in usual mode the same OpenGl context
78 //! that you used for printing right after printing, before the
79 //! OpenGl_PrinterContext instance destroyed.
80 void Deactivate ();
81
82 //! Set view projection transformation matrix for printing/tiling purposes
83 //! theProjTransform parameter should be an 4x4 array.
84 bool SetProjTransformation (TColStd_Array2OfReal& theProjTransform);
85
86 //! Set text scale factor
87 void SetScale (GLfloat theScaleX, GLfloat theScaleY)
88 {
89 myScaleX = theScaleX;
90 myScaleY = theScaleY;
91 }
92
93 //! Set layer viewport dimensions
94 void SetLayerViewport (GLsizei theViewportX,
95 GLsizei theViewportY)
96 {
97 myLayerViewportX = theViewportX;
98 myLayerViewportY = theViewportY;
99 }
100
101private:
102
103 static OpenGl_PrinterContext* g_PrinterContext;
104 static GLCONTEXT g_ContextId;
105 TColStd_Array2OfReal myProjTransform;
106 GLfloat myScaleX;
107 GLfloat myScaleY;
108 GLsizei myLayerViewportX;
109 GLsizei myLayerViewportY;
110 GLCONTEXT myCtx;
111
112 // the printer context could be created only in method call_togl_print
2166f0fa 113 /*friend Standard_Boolean call_togl_print (CALL_DEF_VIEW *, CALL_DEF_LAYER *,
7edf74fd
A
114 CALL_DEF_LAYER *,
115 const Aspect_Drawable, const int,
2166f0fa
SK
116 const char*, const int, const float);*/
117 friend Standard_Boolean OpenGl_Workspace::Print (const Graphic3d_CView& ACView,
118 const Aspect_CLayer2d& ACUnderLayer,
119 const Aspect_CLayer2d& ACOverLayer,
120 const Aspect_Handle hPrintDC,
121 const Standard_Boolean showBackground,
122 const Standard_CString filename,
123 const Aspect_PrintAlgo printAlgorithm,
124 const Standard_Real theScaleFactor);
7edf74fd
A
125};
126
127#endif