a65fe52f2ff70d35e670aae74e8932da294801ef
[occt.git] / src / Graphic3d / Graphic3d_Texture2Dplane.cxx
1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #define IMP280200       //GG Add Plane(),ScaleT(),ScaleS() methods
23
24 #include <Graphic3d_Texture2Dplane.ixx>
25 #include <Graphic3d_TypeOfTextureMode.hxx>
26
27
28 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane(const Handle(Graphic3d_StructureManager)& SM,const Standard_CString FileName)
29 : Graphic3d_Texture2D(SM, FileName, Graphic3d_TOT_2D_MIPMAP)
30 {
31   MyCInitTexture.doModulate = 1;
32   MyCInitTexture.doRepeat = 1;
33   MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
34   MyCInitTexture.doLinear = 1;
35   MyCInitTexture.sx = 1.0F;
36   MyCInitTexture.sy = 1.0F;
37   MyCInitTexture.tx = 0.0F;
38   MyCInitTexture.ty = 0.0F;
39   MyCInitTexture.angle = 0.0F;
40   MyCInitTexture.sparams[0] = 1.0F;
41   MyCInitTexture.sparams[1] = 0.0F;
42   MyCInitTexture.sparams[2] = 0.0F;
43   MyCInitTexture.sparams[3] = 0.0F;
44   MyCInitTexture.tparams[0] = 0.0F;
45   MyCInitTexture.tparams[1] = 1.0F;
46   MyCInitTexture.tparams[2] = 0.0F;
47   MyCInitTexture.tparams[3] = 0.0F;
48   Update();
49 }
50
51
52
53 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane(const Handle(Graphic3d_StructureManager)& SM,const Graphic3d_NameOfTexture2D NOT)
54 : Graphic3d_Texture2D(SM, NOT, Graphic3d_TOT_2D_MIPMAP)
55 {
56   MyCInitTexture.doModulate = 1;
57   MyCInitTexture.doRepeat = 1;
58   MyCInitTexture.Mode = (int)Graphic3d_TOTM_OBJECT;
59   MyCInitTexture.doLinear = 1;
60   MyCInitTexture.sx = 1.0F;
61   MyCInitTexture.sy = 1.0F;
62   MyCInitTexture.tx = 0.0F;
63   MyCInitTexture.ty = 0.0F;
64   MyCInitTexture.angle = 0.0F;
65   MyCInitTexture.sparams[0] = 1.0F;
66   MyCInitTexture.sparams[1] = 0.0F;
67   MyCInitTexture.sparams[2] = 0.0F;
68   MyCInitTexture.sparams[3] = 0.0F;
69   MyCInitTexture.tparams[0] = 0.0F;
70   MyCInitTexture.tparams[1] = 1.0F;
71   MyCInitTexture.tparams[2] = 0.0F;
72   MyCInitTexture.tparams[3] = 0.0F;
73   Update();
74 }
75
76
77 void Graphic3d_Texture2Dplane::SetPlaneS(const Standard_ShortReal A,const Standard_ShortReal B,const Standard_ShortReal C,const Standard_ShortReal D) 
78 {
79   MyCInitTexture.sparams[0] = A;
80   MyCInitTexture.sparams[1] = B;
81   MyCInitTexture.sparams[2] = C;
82   MyCInitTexture.sparams[3] = D;
83 #ifdef IMP280200
84   myPlaneName = Graphic3d_NOTP_UNKNOWN;
85 #endif
86   Update();
87 }
88
89
90 void Graphic3d_Texture2Dplane::SetPlaneT(const Standard_ShortReal A,const Standard_ShortReal B,const Standard_ShortReal C,const Standard_ShortReal D)
91 {
92   MyCInitTexture.tparams[0] = A;
93   MyCInitTexture.tparams[1] = B;
94   MyCInitTexture.tparams[2] = C;
95   MyCInitTexture.tparams[3] = D;
96 #ifdef IMP280200
97   myPlaneName = Graphic3d_NOTP_UNKNOWN;
98 #endif
99   Update();
100 }
101
102
103 void Graphic3d_Texture2Dplane::SetPlane(const Graphic3d_NameOfTexturePlane APlane) 
104 {
105   switch (APlane)
106     {
107     case Graphic3d_NOTP_XY:
108       MyCInitTexture.sparams[0] = 1.0F;
109       MyCInitTexture.sparams[1] = 0.0F;
110       MyCInitTexture.sparams[2] = 0.0F;
111       MyCInitTexture.sparams[3] = 0.0F;
112       MyCInitTexture.tparams[0] = 0.0F;
113       MyCInitTexture.tparams[1] = 1.0F;
114       MyCInitTexture.tparams[2] = 0.0F;
115       MyCInitTexture.tparams[3] = 0.0F;
116       break;
117
118     case Graphic3d_NOTP_YZ:
119       MyCInitTexture.sparams[0] = 0.0F;
120       MyCInitTexture.sparams[1] = 1.0F;
121       MyCInitTexture.sparams[2] = 0.0F;
122       MyCInitTexture.sparams[3] = 0.0F;
123       MyCInitTexture.tparams[0] = 0.0F;
124       MyCInitTexture.tparams[1] = 0.0F;
125       MyCInitTexture.tparams[2] = 1.0F;
126       MyCInitTexture.tparams[3] = 0.0F;
127       break;
128
129     case Graphic3d_NOTP_ZX:
130       MyCInitTexture.sparams[0] = 0.0F;
131       MyCInitTexture.sparams[1] = 0.0F;
132       MyCInitTexture.sparams[2] = 1.0F;
133       MyCInitTexture.sparams[3] = 0.0F;
134       MyCInitTexture.tparams[0] = 1.0F;
135       MyCInitTexture.tparams[1] = 0.0F;
136       MyCInitTexture.tparams[2] = 0.0F;
137       MyCInitTexture.tparams[3] = 0.0F;
138       break;
139     default:
140       break;
141     }
142
143 #ifdef IMP280200
144     myPlaneName = APlane;
145 #endif
146
147   Update();
148 }
149
150
151 void Graphic3d_Texture2Dplane::SetScaleS(const Standard_ShortReal val) 
152 {
153   MyCInitTexture.sx = val;
154   Update();
155 }
156
157
158 void Graphic3d_Texture2Dplane::SetScaleT(const Standard_ShortReal val) 
159 {
160   MyCInitTexture.sy = val;
161   Update();
162 }
163
164
165 void Graphic3d_Texture2Dplane::SetTranslateS(const Standard_ShortReal val)
166 {
167   MyCInitTexture.tx = val;
168   Update();
169 }
170
171
172 void Graphic3d_Texture2Dplane::SetTranslateT(const Standard_ShortReal val) 
173 {
174   MyCInitTexture.ty = val;
175   Update();
176 }
177
178
179 void Graphic3d_Texture2Dplane::SetRotation(const Standard_ShortReal val) 
180 {
181   MyCInitTexture.angle = val;
182   Update();
183 }
184
185 void Graphic3d_Texture2Dplane::PlaneS(Standard_ShortReal& A,Standard_ShortReal& B,Standard_ShortReal& C,Standard_ShortReal& D) const
186 {
187   A = MyCInitTexture.sparams[0];
188   B = MyCInitTexture.sparams[1];
189   C = MyCInitTexture.sparams[2];
190   D = MyCInitTexture.sparams[3];
191 }
192
193 void Graphic3d_Texture2Dplane::PlaneT(Standard_ShortReal& A,Standard_ShortReal& B,Standard_ShortReal& C,Standard_ShortReal& D) const
194 {
195   A = MyCInitTexture.tparams[0];
196   B = MyCInitTexture.tparams[1];
197   C = MyCInitTexture.tparams[2];
198   D = MyCInitTexture.tparams[3];
199 }
200
201 void Graphic3d_Texture2Dplane::TranslateS(Standard_ShortReal& val) const
202 {
203   val = MyCInitTexture.tx;
204 }
205
206 void Graphic3d_Texture2Dplane::TranslateT(Standard_ShortReal& val) const
207 {
208   val = MyCInitTexture.ty;
209 }
210
211 void Graphic3d_Texture2Dplane::Rotation(Standard_ShortReal& val) const
212 {
213   val = MyCInitTexture.angle;
214 }
215
216 #ifdef IMP280200
217 Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const {
218
219   return myPlaneName;
220 }
221
222 void Graphic3d_Texture2Dplane::ScaleS(Standard_ShortReal& val) const
223 {
224   val = MyCInitTexture.sx;
225 }
226
227 void Graphic3d_Texture2Dplane::ScaleT(Standard_ShortReal& val) const
228 {
229   val = MyCInitTexture.sy;
230 }
231 #endif
232
233
234
235