1 // File: OpenGl_PrinterContext.hxx
2 // Created: 20.05.11 10:00:00
3 // Author: Anton POLETAEV
5 #ifndef _OPENGL_PRINTERCONTEXT_H
6 #define _OPENGL_PRINTERCONTEXT_H
8 #include <MMgt_TShared.hxx>
9 #include <Standard.hxx>
10 #include <Standard_DefineHandle.hxx>
11 #include <Handle_MMgt_TShared.hxx>
12 #include <OpenGl_tgl_all.hxx>
13 #include <NCollection_DataMap.hxx>
14 #include <InterfaceGraphic_Graphic3d.hxx>
15 #include <InterfaceGraphic_Visual3d.hxx>
16 #include <TColStd_Array2OfReal.hxx>
18 class Standard_Transient;
19 class Handle(Standard_Type);
20 class Handle(MMgt_TShared);
21 class OpenGl_PrinterContext;
23 DEFINE_STANDARD_HANDLE(OpenGl_PrinterContext,MMgt_TShared)
25 //! Class provides specific information for redrawing view to offscreen buffer
26 //! on printing. The information is: projection matrixes for tiling,
27 //! scaling factors for text/markers and layer viewport dimensions.
28 //! The OpenGl_PrinterContext class allows to have only one global instance
29 //! that can be accessed by GetPrinterContext() during printing operation.
30 //! The class instance can be created only by call_togl_print().
31 class OpenGl_PrinterContext : public MMgt_TShared
36 //! Get the PrinterContext instance assigned for OpenGl context.
37 //! Return NULL, if there is no current printing operation and
38 //! there is no assigned instance for "theCtx" OpenGl context.
39 static OpenGl_PrinterContext* GetPrinterContext(GLCONTEXT theCtx);
41 //! Get view projection transformation matrix.
42 const TColStd_Array2OfReal& GetProjTransformation ()
44 return myProjTransform;
47 //! Get view projection transformation matrix.
48 void GetProjTransformation (GLfloat theMatrix[16]);
50 //! Get text/markers scale factor
51 void GetScale (GLfloat& theScaleX, GLfloat& theScaleY)
57 //! Get layer viewport dimensions
58 void GetLayerViewport (GLsizei& theViewportX,
59 GLsizei& theViewportY)
61 theViewportX = myLayerViewportX;
62 theViewportY = myLayerViewportY;
68 OpenGl_PrinterContext (GLCONTEXT theCtx);
71 virtual ~OpenGl_PrinterContext ();
73 //! Deactivate current printing context.
74 //! Useful when you need to redraw in usual mode the same OpenGl context
75 //! that you used for printing right after printing, before the
76 //! OpenGl_PrinterContext instance destroyed.
79 //! Set view projection transformation matrix for printing/tiling purposes
80 //! theProjTransform parameter should be an 4x4 array.
81 bool SetProjTransformation (TColStd_Array2OfReal& theProjTransform);
83 //! Set text scale factor
84 void SetScale (GLfloat theScaleX, GLfloat theScaleY)
90 //! Set layer viewport dimensions
91 void SetLayerViewport (GLsizei theViewportX,
94 myLayerViewportX = theViewportX;
95 myLayerViewportY = theViewportY;
100 static OpenGl_PrinterContext* g_PrinterContext;
101 static GLCONTEXT g_ContextId;
102 TColStd_Array2OfReal myProjTransform;
105 GLsizei myLayerViewportX;
106 GLsizei myLayerViewportY;
109 // the printer context could be created only in method call_togl_print
110 friend Standard_Boolean call_togl_print (CALL_DEF_VIEW *, CALL_DEF_LAYER *,
112 const Aspect_Drawable, const int,
113 const char*, const int, const float);