]>
Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
973c2be1 | 5 | // This library is free software; you can redistribute it and / or modify it |
6 | // under the terms of the GNU Lesser General Public 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. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
7fd59977 | 14 | /*********************************************************************** |
15 | ||
16 | FONCTION : | |
17 | ---------- | |
18 | Classe V3d_View_3.cxx : | |
19 | ||
20 | HISTORIQUE DES MODIFICATIONS : | |
21 | -------------------------------- | |
22 | 00-09-92 : GG ; Creation. | |
23 | 24-12-97 : FMN ; Suppression de GEOMLITE | |
24 | 13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guide) | |
25 | 22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH | |
26 | IMP240100: GG -> Activates WalkThrough model. | |
27 | ||
28 | ************************************************************************/ | |
29 | ||
30 | #define IMP020300 //GG Don't use ZFitAll in during Rotation | |
31 | // for perf improvment | |
32 | ||
33 | /*----------------------------------------------------------------------*/ | |
34 | /* | |
35 | * Includes | |
36 | */ | |
37 | ||
38 | #include <V3d_View.jxx> | |
39 | #include <V3d_Static.hxx> | |
40 | ||
41 | #define Zmargin 1. | |
42 | ||
43 | /*----------------------------------------------------------------------*/ | |
44 | ||
45 | void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) { | |
46 | ||
47 | Graphic3d_Vertex Prp ; | |
48 | Graphic3d_Vector Vpn ; | |
49 | Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ; | |
50 | Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ; | |
51 | ||
52 | if( Start ) { | |
53 | MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ; | |
54 | MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ; | |
55 | MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ; | |
56 | MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ; | |
57 | if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp, | |
58 | MyXscreenAxis,MyYscreenAxis,MyZscreenAxis)) | |
6942f04a | 59 | V3d_BadValue::Raise ("V3d_View::Move, alignment of Eye,At,Up"); |
7fd59977 | 60 | } |
61 | MyXscreenAxis.Coord(XX,XY,XZ) ; | |
62 | MyYscreenAxis.Coord(YX,YY,YZ) ; | |
63 | MyZscreenAxis.Coord(ZX,ZY,ZZ) ; | |
64 | MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ; | |
65 | MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ; | |
66 | Xeye = Zrp*Xpn + Dx*XX + Dy*YX + Dz*ZX ; | |
67 | Yeye = Zrp*Ypn + Dx*XY + Dy*YY + Dz*ZY ; | |
68 | Zeye = Zrp*Zpn + Dx*XZ + Dy*YZ + Dz*ZZ ; | |
69 | Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ; | |
6942f04a | 70 | V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused"); |
302f96fb | 71 | |
7fd59977 | 72 | Prp.SetCoord(Xrp,Yrp,Zrp) ; |
73 | MyViewMapping.SetProjectionReferencePoint(Prp) ; | |
74 | Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ; | |
75 | Vpn.SetCoord(Xpn,Ypn,Zpn) ; | |
76 | MyViewOrientation.SetViewReferencePlane(Vpn) ; | |
77 | MyView->SetViewOrientation(MyViewOrientation) ; | |
78 | ||
79 | // Check ZClipping planes | |
7fd59977 | 80 | MyView->SetViewMapping(MyViewMapping) ; |
81 | SetZSize(0.); | |
7fd59977 | 82 | ImmediateUpdate(); |
83 | } | |
84 | ||
85 | void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) { | |
86 | Graphic3d_Vertex Prp ; | |
87 | Graphic3d_Vector Vpn ; | |
88 | Standard_Real Vx,Vy,Vz ; | |
89 | Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ; | |
90 | if( Start ) { | |
91 | MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ; | |
92 | MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ; | |
93 | MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ; | |
94 | } | |
95 | MyDefaultViewAxis.Coord(Vx,Vy,Vz) ; | |
96 | MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ; | |
97 | MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ; | |
98 | Xeye = Zrp*Xpn + Vx*Length ; | |
99 | Yeye = Zrp*Ypn + Vy*Length ; | |
100 | Zeye = Zrp*Zpn + Vz*Length ; | |
101 | Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ; | |
6942f04a | 102 | V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused"); |
7fd59977 | 103 | |
7fd59977 | 104 | Prp.SetCoord(Xrp,Yrp,Zrp) ; |
105 | MyViewMapping.SetProjectionReferencePoint(Prp) ; | |
106 | Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ; | |
107 | Vpn.SetCoord(Xpn,Ypn,Zpn) ; | |
108 | MyViewOrientation.SetViewReferencePlane(Vpn) ; | |
109 | MyView->SetViewOrientation(MyViewOrientation) ; | |
110 | ||
111 | #ifdef IMP020300 | |
112 | MyView->SetViewMapping(MyViewMapping) ; | |
113 | SetZSize(0.); | |
114 | #else | |
115 | // Check ZClipping planes | |
116 | Standard_Real Zmax,Xat,Yat,Zat ; | |
117 | MyViewReferencePoint.Coord(Xat,Yat,Zat) ; | |
118 | Xeye += Xat ; Yeye += Yat ; Zeye += Zat ; | |
119 | Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ; | |
120 | if( Zmax > MyViewMapping.FrontPlaneDistance() && | |
121 | MyProjModel == V3d_TPM_SCREEN ) { | |
122 | SetZSize(2.*Zmax+Zmax*Zmargin) ; | |
123 | } else { | |
124 | if( MyType == V3d_PERSPECTIVE ) { | |
125 | SetFocale(focale) ; | |
126 | } | |
127 | MyView->SetViewMapping(MyViewMapping) ; | |
128 | } | |
129 | #endif | |
130 | ImmediateUpdate(); | |
131 | } | |
132 | ||
133 | void V3d_View::Move(const V3d_TypeOfAxe Axe , const Standard_Real Length, const Standard_Boolean Start) { | |
134 | ||
135 | ||
136 | switch (Axe) { | |
137 | case V3d_X : | |
138 | Move(Length,0.,0.,Start); | |
139 | break ; | |
140 | case V3d_Y : | |
141 | Move(0.,Length,0.,Start); | |
142 | break ; | |
143 | case V3d_Z : | |
144 | Move(0.,0.,Length,Start); | |
145 | break ; | |
146 | } | |
147 | } | |
148 | ||
149 | void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) { | |
150 | ||
151 | Graphic3d_Vertex Vrp ; | |
152 | Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ; | |
153 | Standard_Real Xat,Yat,Zat ; | |
154 | if( Start ) { | |
155 | MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ; | |
156 | MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ; | |
157 | MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ; | |
158 | MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint(); | |
159 | if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp, | |
160 | MyXscreenAxis,MyYscreenAxis,MyZscreenAxis)) | |
6942f04a | 161 | V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up"); |
7fd59977 | 162 | } |
163 | MyXscreenAxis.Coord(XX,XY,XZ) ; | |
164 | MyYscreenAxis.Coord(YX,YY,YZ) ; | |
165 | MyZscreenAxis.Coord(ZX,ZY,ZZ) ; | |
166 | MyViewReferencePoint.Coord(Xat,Yat,Zat) ; | |
167 | Xat -= Dx*XX + Dy*YX + Dz*ZX ; | |
168 | Yat -= Dx*XY + Dy*YY + Dz*ZY ; | |
169 | Zat -= Dx*XZ + Dy*YZ + Dz*ZZ ; | |
170 | Vrp.SetCoord(Xat,Yat,Zat) ; | |
171 | MyViewOrientation.SetViewReferencePoint(Vrp) ; | |
172 | MyView->SetViewOrientation(MyViewOrientation) ; | |
173 | #ifdef IMP020300 | |
174 | SetZSize(0.); | |
175 | #else | |
176 | // Check ZClipping planes | |
177 | Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ; | |
178 | MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ; | |
179 | MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ; | |
180 | Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ; | |
181 | Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) , | |
182 | sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ; | |
183 | if( Zmax > MyViewMapping.FrontPlaneDistance() && | |
184 | MyProjModel == V3d_TPM_SCREEN ) { | |
185 | SetZSize(2.*Zmax+Zmax*Zmargin) ; | |
186 | } | |
187 | #endif | |
188 | ImmediateUpdate(); | |
189 | } | |
190 | ||
191 | void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,const Standard_Boolean Start) { | |
192 | ||
193 | switch (Axe) { | |
194 | case V3d_X : | |
195 | Translate(Length,0.,0., Start); | |
196 | break ; | |
197 | case V3d_Y : | |
198 | Translate(0.,Length,0., Start); | |
199 | break ; | |
200 | case V3d_Z : | |
201 | Translate(0.,0.,Length, Start); | |
202 | break ; | |
203 | } | |
204 | } | |
205 | void V3d_View::Place (const Standard_Integer ix, const Standard_Integer iy, | |
206 | const Quantity_Factor aZoomFactor) { | |
207 | Standard_Real xpos,ypos; | |
208 | Standard_Integer xc,yc; | |
209 | Center(xpos,ypos); | |
210 | Convert(xpos,ypos,xc,yc); | |
211 | Pan(xc-ix,iy-yc,aZoomFactor/Scale()); | |
212 | } | |
213 | void V3d_View::Translate(const Standard_Real Length,const Standard_Boolean Start) { | |
214 | Graphic3d_Vertex Vrp ; | |
215 | Standard_Real Xat,Yat,Zat,Vx,Vy,Vz ; | |
216 | if( Start ) { | |
217 | MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ; | |
218 | } | |
219 | MyDefaultViewAxis.Coord(Vx,Vy,Vz) ; | |
220 | MyViewReferencePoint.Coord(Xat,Yat,Zat) ; | |
221 | Xat -= Vx*Length ; Yat -= Vy*Length ; Zat -= Vz*Length ; | |
222 | Vrp.SetCoord(Xat,Yat,Zat) ; | |
223 | MyViewOrientation.SetViewReferencePoint(Vrp) ; | |
224 | MyView->SetViewOrientation(MyViewOrientation) ; | |
225 | ||
226 | #ifdef IMP020300 | |
227 | SetZSize(0.); | |
228 | #else | |
229 | // Check ZClipping planes | |
230 | Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ; | |
231 | MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ; | |
232 | MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ; | |
233 | Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ; | |
234 | Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) , | |
235 | sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ; | |
236 | if( Zmax > MyViewMapping.FrontPlaneDistance() && | |
237 | MyProjModel == V3d_TPM_SCREEN ) { | |
238 | SetZSize(2.*Zmax+Zmax*Zmargin) ; | |
239 | } | |
240 | #endif | |
241 | ImmediateUpdate(); | |
242 | } |