0024275: Cppcheck warnings on uninitialized class members
[occt.git] / src / OpenGl / OpenGl_PrinterContext.cxx
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
a174a3c5 20#include <OpenGl_GlCore11.hxx>
7edf74fd
A
21#include <OpenGl_PrinterContext.hxx>
22
a174a3c5 23IMPLEMENT_STANDARD_HANDLE (OpenGl_PrinterContext, Standard_Transient)
24IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PrinterContext, Standard_Transient)
7edf74fd
A
25
26//=======================================================================
27//function : OpenGl_PrinterContext
a174a3c5 28//purpose :
7edf74fd 29//=======================================================================
a174a3c5 30OpenGl_PrinterContext::OpenGl_PrinterContext()
31: myProjTransform (0, 3, 0, 3),
a174a3c5 32 myScaleX (1.0f),
2f6cb3ac 33 myScaleY (1.0f),
34 myLayerViewportX (0),
35 myLayerViewportY (0)
36
7edf74fd 37{
a174a3c5 38 // identity projection matrix
7edf74fd
A
39 Standard_Real anInitValue = 0.0;
40 myProjTransform.Init (anInitValue);
a174a3c5 41 myProjTransform (0, 0) = 1.0;
42 myProjTransform (1, 1) = 1.0;
43 myProjTransform (2, 2) = 1.0;
44 myProjTransform (3, 3) = 1.0;
45 SetProjTransformation (myProjTransform);
7edf74fd
A
46}
47
a174a3c5 48// =======================================================================
49// function : ~OpenGl_PrinterContext
50// purpose :
51// =======================================================================
52OpenGl_PrinterContext::~OpenGl_PrinterContext()
7edf74fd 53{
a174a3c5 54 //
7edf74fd
A
55}
56
a174a3c5 57// =======================================================================
58// function : LoadProjTransformation
59// purpose :
60// =======================================================================
61void OpenGl_PrinterContext::LoadProjTransformation()
7edf74fd 62{
a174a3c5 63 glLoadMatrixf ((GLfloat* )myProjMatrixGl);
7edf74fd
A
64}
65
a174a3c5 66// =======================================================================
67// function : SetProjTransformation
68// purpose : Set view projection transformation matrix for printing purposes.
69// theProjTransform parameter should be an 4x4 array.
70// =======================================================================
71bool OpenGl_PrinterContext::SetProjTransformation (const TColStd_Array2OfReal& thePrj)
7edf74fd
A
72{
73 if (thePrj.RowLength () != 4 || thePrj.ColLength () != 4)
a174a3c5 74 {
7edf74fd 75 return false;
a174a3c5 76 }
7edf74fd
A
77
78 myProjTransform = thePrj;
a174a3c5 79 for (int i = 0, k = 0; i < 4; i++)
80 {
81 for (int j = 0; j < 4; j++, k++)
82 {
83 myProjMatrixGl[k] = (Standard_ShortReal )myProjTransform (i, j);
84 }
85 }
7edf74fd
A
86 return true;
87}
88
a174a3c5 89// =======================================================================
90// function : SetScale
91// purpose :
92// =======================================================================
93void OpenGl_PrinterContext::SetScale (const Standard_ShortReal theScaleX,
94 const Standard_ShortReal theScaleY)
7edf74fd 95{
a174a3c5 96 myScaleX = theScaleX;
97 myScaleY = theScaleY;
7edf74fd
A
98}
99
a174a3c5 100// =======================================================================
101// function : SetLayerViewport
102// purpose :
103// =======================================================================
104void OpenGl_PrinterContext::SetLayerViewport (const Standard_Integer theViewportX,
105 const Standard_Integer theViewportY)
7edf74fd 106{
a174a3c5 107 myLayerViewportX = theViewportX;
108 myLayerViewportY = theViewportY;
7edf74fd 109}