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 under
8 // the terms of the GNU Lesser General Public License 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 #if !defined(GL_ES_VERSION_2_0)
60 glLoadMatrixf ((GLfloat* )myProjMatrixGl);
64 // =======================================================================
65 // function : SetProjTransformation
66 // purpose : Set view projection transformation matrix for printing purposes.
67 // theProjTransform parameter should be an 4x4 array.
68 // =======================================================================
69 bool OpenGl_PrinterContext::SetProjTransformation (const TColStd_Array2OfReal& thePrj)
71 if (thePrj.RowLength () != 4 || thePrj.ColLength () != 4)
76 myProjTransform = thePrj;
77 for (int i = 0, k = 0; i < 4; i++)
79 for (int j = 0; j < 4; j++, k++)
81 myProjMatrixGl[k] = (Standard_ShortReal )myProjTransform (i, j);
87 // =======================================================================
88 // function : SetScale
90 // =======================================================================
91 void OpenGl_PrinterContext::SetScale (const Standard_ShortReal theScaleX,
92 const Standard_ShortReal theScaleY)
98 // =======================================================================
99 // function : SetLayerViewport
101 // =======================================================================
102 void OpenGl_PrinterContext::SetLayerViewport (const Standard_Integer theViewportX,
103 const Standard_Integer theViewportY)
105 myLayerViewportX = theViewportX;
106 myLayerViewportY = theViewportY;