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