0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / Vrml / Vrml_OrthographicCamera.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <gp_Vec.hxx>
16 #include <Vrml_OrthographicCamera.hxx>
17 #include <Vrml_SFRotation.hxx>
18
19 Vrml_OrthographicCamera::Vrml_OrthographicCamera():
20   myFocalDistance(5),
21   myHeight(2)
22 {
23
24   gp_Vec tmpVec(0,0,1);
25   myPosition = tmpVec;
26
27   Vrml_SFRotation tmpSFR(0,0,1,0);
28   myOrientation = tmpSFR;
29 }
30
31 Vrml_OrthographicCamera::Vrml_OrthographicCamera( const gp_Vec&          aPosition, 
32                                                   const Vrml_SFRotation& aOrientation, 
33                                                   const Standard_Real    aFocalDistance, 
34                                                   const Standard_Real    aHeight)
35 {
36     myPosition      = aPosition;
37     myOrientation   = aOrientation;
38     myFocalDistance = aFocalDistance;
39     myHeight        = aHeight;
40 }
41
42 void Vrml_OrthographicCamera::SetPosition(const gp_Vec& aPosition)
43 {
44     myPosition = aPosition;
45 }
46
47 gp_Vec Vrml_OrthographicCamera::Position() const 
48 {
49    return  myPosition;
50 }
51
52 void Vrml_OrthographicCamera::SetOrientation(const Vrml_SFRotation& aOrientation)
53 {
54    myOrientation   = aOrientation;
55 }
56
57 Vrml_SFRotation Vrml_OrthographicCamera::Orientation() const 
58 {
59    return myOrientation; 
60 }
61
62 void Vrml_OrthographicCamera::SetFocalDistance(const Standard_Real aFocalDistance)
63 {
64    myFocalDistance = aFocalDistance;
65 }
66
67 Standard_Real Vrml_OrthographicCamera::FocalDistance() const 
68 {
69    return myFocalDistance;
70 }
71
72 void Vrml_OrthographicCamera::SetHeight(const Standard_Real aHeight)
73 {
74     myHeight = aHeight;
75 }
76
77 Standard_Real Vrml_OrthographicCamera::Height() const 
78 {
79    return myHeight;
80 }
81
82 Standard_OStream& Vrml_OrthographicCamera::Print(Standard_OStream& anOStream) const 
83 {
84  anOStream  << "OrthographicCamera {\n";
85  if ( Abs(myPosition.X() - 0) > 0.0001 || 
86       Abs(myPosition.Y() - 0) > 0.0001 || 
87       Abs(myPosition.Z() - 1) > 0.0001 )
88    {
89     anOStream  << "    position\t\t";
90     anOStream << myPosition.X() << " " << myPosition.Y() << " " << myPosition.Z() << "\n";
91    }
92
93  if ( Abs(myOrientation.RotationX() - 0) > 0.0001 || 
94      Abs(myOrientation.RotationY() - 0) > 0.0001 || 
95      Abs(myOrientation.RotationZ() - 1) > 0.0001 ||
96      Abs(myOrientation.Angle() - 0) > 0.0001 )
97    {
98     anOStream  << "    orientation\t\t";
99     anOStream << myOrientation.RotationX() << " " << myOrientation.RotationY() << " ";
100     anOStream << myOrientation.RotationZ() << " " << myOrientation.Angle() << "\n";
101    }
102
103  if ( Abs(myFocalDistance - 5) > 0.0001 )
104    {
105     anOStream  << "    focalDistance\t";
106     anOStream << myFocalDistance << "\n";
107    }
108  if ( Abs(myHeight - 2) > 0.0001 )
109    {
110     anOStream  << "    height\t\t";
111     anOStream << myHeight << "\n";
112    }
113  anOStream  << "}\n";
114  return anOStream;
115 }