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>
20 //=======================================================================
21 //function : OpenGl_PrinterContext
23 //=======================================================================
24 OpenGl_PrinterContext::OpenGl_PrinterContext()
25 : myProjTransform (0, 3, 0, 3),
32 // identity projection matrix
33 Standard_Real anInitValue = 0.0;
34 myProjTransform.Init (anInitValue);
35 myProjTransform (0, 0) = 1.0;
36 myProjTransform (1, 1) = 1.0;
37 myProjTransform (2, 2) = 1.0;
38 myProjTransform (3, 3) = 1.0;
39 SetProjTransformation (myProjTransform);
42 // =======================================================================
43 // function : ~OpenGl_PrinterContext
45 // =======================================================================
46 OpenGl_PrinterContext::~OpenGl_PrinterContext()
51 // =======================================================================
52 // function : ProjTransformation
54 // =======================================================================
55 OpenGl_Mat4 OpenGl_PrinterContext::ProjTransformation()
57 return OpenGl_Mat4::Map (myProjMatrixGl);
60 // =======================================================================
61 // function : SetProjTransformation
62 // purpose : Set view projection transformation matrix for printing purposes.
63 // theProjTransform parameter should be an 4x4 array.
64 // =======================================================================
65 bool OpenGl_PrinterContext::SetProjTransformation (const TColStd_Array2OfReal& thePrj)
67 if (thePrj.RowLength () != 4 || thePrj.ColLength () != 4)
72 myProjTransform = thePrj;
73 for (int i = 0, k = 0; i < 4; i++)
75 for (int j = 0; j < 4; j++, k++)
77 myProjMatrixGl[k] = (Standard_ShortReal )myProjTransform (i, j);
83 // =======================================================================
84 // function : SetScale
86 // =======================================================================
87 void OpenGl_PrinterContext::SetScale (const Standard_ShortReal theScaleX,
88 const Standard_ShortReal theScaleY)
94 // =======================================================================
95 // function : SetLayerViewport
97 // =======================================================================
98 void OpenGl_PrinterContext::SetLayerViewport (const Standard_Integer theViewportX,
99 const Standard_Integer theViewportY)
101 myLayerViewportX = theViewportX;
102 myLayerViewportY = theViewportY;