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