1 // Created on: 2011-05-20
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public 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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_GlCore11.hxx>
17 #include <OpenGl_PrinterContext.hxx>
19 IMPLEMENT_STANDARD_HANDLE (OpenGl_PrinterContext, Standard_Transient)
20 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PrinterContext, Standard_Transient)
22 //=======================================================================
23 //function : OpenGl_PrinterContext
25 //=======================================================================
26 OpenGl_PrinterContext::OpenGl_PrinterContext()
27 : myProjTransform (0, 3, 0, 3),
34 // identity projection matrix
35 Standard_Real anInitValue = 0.0;
36 myProjTransform.Init (anInitValue);
37 myProjTransform (0, 0) = 1.0;
38 myProjTransform (1, 1) = 1.0;
39 myProjTransform (2, 2) = 1.0;
40 myProjTransform (3, 3) = 1.0;
41 SetProjTransformation (myProjTransform);
44 // =======================================================================
45 // function : ~OpenGl_PrinterContext
47 // =======================================================================
48 OpenGl_PrinterContext::~OpenGl_PrinterContext()
53 // =======================================================================
54 // function : LoadProjTransformation
56 // =======================================================================
57 void OpenGl_PrinterContext::LoadProjTransformation()
59 glLoadMatrixf ((GLfloat* )myProjMatrixGl);
62 // =======================================================================
63 // function : SetProjTransformation
64 // purpose : Set view projection transformation matrix for printing purposes.
65 // theProjTransform parameter should be an 4x4 array.
66 // =======================================================================
67 bool OpenGl_PrinterContext::SetProjTransformation (const TColStd_Array2OfReal& thePrj)
69 if (thePrj.RowLength () != 4 || thePrj.ColLength () != 4)
74 myProjTransform = thePrj;
75 for (int i = 0, k = 0; i < 4; i++)
77 for (int j = 0; j < 4; j++, k++)
79 myProjMatrixGl[k] = (Standard_ShortReal )myProjTransform (i, j);
85 // =======================================================================
86 // function : SetScale
88 // =======================================================================
89 void OpenGl_PrinterContext::SetScale (const Standard_ShortReal theScaleX,
90 const Standard_ShortReal theScaleY)
96 // =======================================================================
97 // function : SetLayerViewport
99 // =======================================================================
100 void OpenGl_PrinterContext::SetLayerViewport (const Standard_Integer theViewportX,
101 const Standard_Integer theViewportY)
103 myLayerViewportX = theViewportX;
104 myLayerViewportY = theViewportY;